소스 검색

调整样式

CrazyIter 4 년 전
부모
커밋
cd320d952e

+ 1 - 2
HTEXLib/Models/Chart.cs

@@ -9,8 +9,7 @@ namespace HTEXLib
         public  List<CommonChart> charts { get; set; }
         public Shape title { get; set; }
 
-        public Fill fill { get; set; } = new Fill() { type = -1 };
-        public Border border { get; set; } = new Border();
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
 
     }
 

+ 2 - 2
HTEXLib/Models/Connector.cs

@@ -14,8 +14,8 @@ namespace HTEXLib
         public string cxnType { get; set; }
         //public string HeadEnd { get; set; }
         //public string TailEnd { get; set; }
-        public Border border { get; set; }
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
+
 
-       
     }
 }

+ 1 - 1
HTEXLib/Models/Diagram.cs

@@ -7,7 +7,7 @@ namespace HTEXLib
     public class Diagram :Item
     {
         public List<Item> shapes { get; set; }
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
 
-       
     }
 }

+ 1 - 4
HTEXLib/Models/Group.cs

@@ -8,9 +8,6 @@ namespace HTEXLib
     {
         public List<Item> shapes { get; set; }
 
-        public Fill fill { get; set; } = new Fill() { type = -1 };
-        public Border border { get; set; } = new Border();
-
-
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
     }
 }

+ 7 - 2
HTEXLib/Models/HTEX/HtexChart.cs

@@ -98,8 +98,13 @@ namespace HTEXLib.Models.HTEX
             }
             LinkedList<PPTParagraph> PPTParagraphs=  DoChartTitle(Chart.Title);
             List<Paragraph> paragraphs = DrawText(PPTParagraphs);
-            Shape shape= new Shape { type = "Shape", shapeType = "Rect", paragraph = paragraphs, fill = shapeStyle!=null? shapeStyle.fill:null, border = shapeStyle != null ? shapeStyle.border:null };
-            return new Chart { charts=charts,title=shape, fill= shapeStyleChart !=null ?shapeStyleChart.fill:null,border= shapeStyleChart !=null? shapeStyleChart.border:null};
+            Shape shape= new Shape { type = "Shape", shapeType = "Rect", paragraph = paragraphs };
+            shape.style.fill = shapeStyle != null ? shapeStyle.fill : null;
+            shape.style.border = shapeStyle != null ? shapeStyle.border : null;
+            var  chart= new Chart { charts=charts,title=shape};
+            chart.style.fill = shapeStyleChart != null ? shapeStyleChart.fill : null;
+            chart.style.border = shapeStyleChart != null ? shapeStyleChart.border : null;
+            return chart;
         }
         public LinkedList<PPTParagraph> DoChartTitle(DocumentFormat.OpenXml.Drawing.Charts.Title title)
         {

+ 4 - 2
HTEXLib/Models/HTEX/HtexConnectionShape.cs

@@ -64,8 +64,10 @@ namespace HTEXLib.Models.HTEX
                 }
             }
             Svg svg = PPTXSvg.GenShapeSvg(connectionShape.element, index, shapeType, position,   shapeBorder);
-          //  position = position ,mediaType = "image",type = type,index = index,animatable = animatable ,invisible = invisible
-            Item item= new Connector { position = position,type=type,cxnType=shapeType, invisible = invisible, animatable = animatable, index = index, id = id, svg = svg, border = shapeBorder };
+            //  position = position ,mediaType = "image",type = type,index = index,animatable = animatable ,invisible = invisible
+            Connector item = new Connector { type=type,cxnType=shapeType, invisible = invisible, animatable = animatable, index = index, id = id, svg = svg };
+            item.style.position = position;
+            item.style.border = shapeBorder;
             return new List<Item>() { item }; 
         }
     }

+ 4 - 3
HTEXLib/Models/HTEX/HtexGroupShape.cs

@@ -30,9 +30,10 @@ namespace HTEXLib.Models.HTEX
         {
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(groupShape.element.GroupShapeProperties, slide, type, partForm);
-            Group group = new Group() { position = position, type = type, index = index, animatable = animatable, invisible = invisible };
-            group.border = ShapeStyle.border;
-            group.fill = ShapeStyle.fill;
+            Group group = new Group() {  type = type, index = index, animatable = animatable, invisible = invisible };
+            group.style.border = ShapeStyle.border;
+            group.style.fill = ShapeStyle.fill;
+            group.style.position = position;
             //SlideColor slideColor = PPTXHelper.DoShapeStyle(groupShape.element.ShapeStyle, slide, type);
             HtexSlide htexSlide = new HtexSlide(slide, slide.slideIndex)
             {

+ 8 - 7
HTEXLib/Models/HTEX/HtexImage.cs

@@ -35,7 +35,8 @@ namespace HTEXLib.Models.HTEX
         { 
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(image.element.ShapeProperties, slide,type,partForm);
-            Media media = new Media() { position = position ,mediaType= "image",type=type,index=index,animatable=animatable ,invisible=invisible};
+            Media media = new Media() { mediaType= "image",type=type,index=index,animatable=animatable ,invisible=invisible};
+            media.style.position = position;
             /*
              *  cNvPicPr (非可视图片绘图属性)	§19.3.1.11
                 cNvPr (非可视绘图属性)	§19.3.1.12
@@ -84,25 +85,25 @@ namespace HTEXLib.Models.HTEX
             {
                 if (slideColor != null)
                 {
-                    media.border.color.solidFill = slideColor.LineColor;
-                    media.border.color.type = 2;
+                    media.style.border.color.solidFill = slideColor.LineColor;
+                    media.style.border.color.type = 2;
                 }
             }
             else
             {
-                media.border = ShapeStyle.border;
+                media.style.border = ShapeStyle.border;
             }
             if (ShapeStyle.fill == null || ShapeStyle.fill.type == -1)
             {
                 if (slideColor != null)
                 {
-                    media.fill.solidFill = slideColor.FillColor;
-                    media.fill.type = 2;
+                    media.style.fill.solidFill = slideColor.FillColor;
+                    media.style.fill.type = 2;
                 }
             }
             else
             {
-                media.fill = ShapeStyle.fill;
+                media.style.fill = ShapeStyle.fill;
             }
             HtexBlipFill htexBlipFill = PPTXHelper.DoBlipFill(image.element.BlipFill, slide,partForm);
             media.image = htexBlipFill;

+ 9 - 8
HTEXLib/Models/HTEX/HtexMath.cs

@@ -43,7 +43,8 @@ namespace HTEXLib.Models.HTEX
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(pptMath.element.ShapeProperties, slide, type, partForm);
             var shapeTypeNode = pptMath.element.ShapeProperties.GetFirstChild<PresetGeometry>();
-            Math math = new Math { position = position, type = type, index = index, animatable = animatable, invisible = invisible };
+            Math math = new Math {  type = type, index = index, animatable = animatable, invisible = invisible };
+            math.style.position = position;
             SlideColor slideColor = PPTXHelper.DoShapeStyle(pptMath.element.ShapeStyle, slide, type);
             //从ShapeProperties 获取 p:spPr
             //再从 ShapeStyle 获取 p:spPr
@@ -51,30 +52,30 @@ namespace HTEXLib.Models.HTEX
             {
                 if (slideColor != null)
                 {
-                    math.border.color.solidFill = slideColor.LineColor;
-                    math.border.color.type = 2;
+                    math.style.border.color.solidFill = slideColor.LineColor;
+                    math.style.border.color.type = 2;
                 }
             }
             else
             {
-                math.border = ShapeStyle.border;
+                math.style.border = ShapeStyle.border;
             }
             if (ShapeStyle.fill == null || ShapeStyle.fill.type == -1)
             {
                 if (slideColor != null)
                 {
-                    math.fill.solidFill = slideColor.FillColor;
-                    math.fill.type = 2;
+                    math.style.fill.solidFill = slideColor.FillColor;
+                    math.style.fill.type = 2;
                 }
             }
             else
             {
-                math.fill = ShapeStyle.fill;
+                math.style.fill = ShapeStyle.fill;
             }
             if (shapeTypeNode != null && shapeTypeNode.Preset != null && !string.IsNullOrEmpty(shapeTypeNode.Preset.InnerText))
             {
                 var shapeType = shapeTypeNode.Preset.InnerText;
-                Svg svg = PPTXSvg.GenShapeSvg(pptMath.element, index, shapeType, position, math.border);
+                Svg svg = PPTXSvg.GenShapeSvg(pptMath.element, index, shapeType, position, math.style.border);
                 math.svg = svg;
                 math.shapeType = shapeType;
             }

+ 12 - 13
HTEXLib/Models/HTEX/HtexShape.cs

@@ -43,13 +43,12 @@ namespace HTEXLib.Models.HTEX
                 return null;
             }
             // string style = invisible ? "DC0" : "DC1";
-            if (Shape.element.InnerText.Contains("顶")) {
-                Console.WriteLine("1");
-            }
+           
             Position position = new Position { cx= width, cy= height, x=left,y=top,rot=rot};
             var ShapeStyle =PPTXHelper.DoShapeProperties(Shape.element.ShapeProperties, slide,type,partForm);
             //position = position ,mediaType = "image",type = type,index = index,animatable = animatable ,invisible = invisible
-            Shape shape = new Shape() { paragraph = DrawText(),position=position ,type=type,index=index,animatable=animatable,invisible=invisible };
+            Shape shape = new Shape() { paragraph = DrawText() ,type=type,index=index,animatable=animatable,invisible=invisible };
+            shape.style.position = position;
             var shapeTypeNode = Shape.element.ShapeProperties.GetFirstChild<PresetGeometry>();
             var shapeTypeCustom = Shape.element.ShapeProperties.GetFirstChild<CustomGeometry>();
 
@@ -61,23 +60,23 @@ namespace HTEXLib.Models.HTEX
             {
                 if (slideColor != null)
                 {
-                    shape.border.color.solidFill = slideColor.LineColor;
-                    shape.border.color.type = 2;
+                    shape.style.border.color.solidFill = slideColor.LineColor;
+                    shape.style.border.color.type = 2;
                 }
             }
             else {
-                shape.border = ShapeStyle.border;
+                shape.style.border = ShapeStyle.border;
             }
             if (ShapeStyle.fill == null || ShapeStyle.fill.type == -1)
             {
                 if (slideColor != null)
                 {
-                    shape.fill.solidFill = slideColor.FillColor;
-                    shape.fill.type = 2;
+                    shape.style.fill.solidFill = slideColor.FillColor;
+                    shape.style.fill.type = 2;
                 }
             }
             else {
-                shape.fill = ShapeStyle.fill;
+                shape.style.fill = ShapeStyle.fill;
             }
             
             if (shape.paragraph != null) {
@@ -99,7 +98,7 @@ namespace HTEXLib.Models.HTEX
             }
             if (shapeTypeNode != null && shapeTypeNode.Preset!=null  && !string.IsNullOrEmpty(shapeTypeNode.Preset.InnerText)) {
                 var shapeType = shapeTypeNode.Preset.InnerText;
-                Svg svg = PPTXSvg.GenShapeSvg(Shape.element, index, shapeType, position, shape.border);
+                Svg svg = PPTXSvg.GenShapeSvg(Shape.element, index, shapeType, position, shape.style.border);
                 shape.svg = svg;
                 shape.shapeType = shapeType;
             }
@@ -184,8 +183,8 @@ namespace HTEXLib.Models.HTEX
                         //StrokeWidth = shapeBorder.Width + "",
                         //StrokeDasharray = shapeBorder.Stroke,
                         d=d,
-                        start=shape.border.headEnd!=null?shape.border.headEnd:null,
-                        end=shape.border.tailEnd!=null?shape.border.tailEnd:null,
+                        start=shape.style.border.headEnd!=null?shape.style.border.headEnd:null,
+                        end=shape.style.border.tailEnd!=null?shape.style.border.tailEnd:null,
                         }
                     };
                     shape.svg = new Svg { 

+ 2 - 4
HTEXLib/Models/Item.cs

@@ -7,6 +7,7 @@ namespace HTEXLib
 {
     public abstract class Item
     {
+       
         public List<IAnimation> animations { get; set; }
         public string id { get; set; }
         /// <summary>
@@ -14,10 +15,7 @@ namespace HTEXLib
         /// 元素类型
         /// </summary>
         public string type { get; set; }
-        /// <summary>
-        /// 坐标信息
-        /// </summary>
-        public Position position { get; set; }
+       
         //  public string Xml { get; set; }
         /// <summary>
         /// 层级

+ 1 - 3
HTEXLib/Models/Math.cs

@@ -10,9 +10,7 @@ namespace HTEXLib
         //https://www.compart.com/en/unicode/U+1D59C
         //https://www.fuhaozi.com/unicode/1D/1D510.html
         public MathML mathML { get; set; }
-        public Fill fill { get; set; } = new Fill() { type = -1 };
-
-        public Border border { get; set; }
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
 
         public string shapeType { get; set; }
        

+ 2 - 5
HTEXLib/Models/Media.cs

@@ -12,11 +12,8 @@ namespace HTEXLib
         public HtexBlipFill file { get; set; }
         //图片或视频音频缩略图链接
         public HtexBlipFill  image { get; set; }
-     
-        public Fill fill { get; set; }
-      
-        public Border border { get; set; }
 
-       
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
+
     }
 }

+ 1 - 4
HTEXLib/Models/Shape.cs

@@ -8,10 +8,7 @@ namespace HTEXLib
     { 
         public string shapeType;
         public List<Paragraph> paragraph { get; set; }
-        public Fill fill { get; set; } = new Fill() { type=-1};
-        public Border border { get; set; } = new Border();
-
-       
+        public HTEXLib.Models.HTEX.ShapeStyle style { get; set; } = new Models.HTEX.ShapeStyle();
 
         //public List<ShapeGuide> ShapeGuides { get; set; }
         //public List<Path> Paths { get; set; }

+ 5 - 1
HTEXLib/Models/HTEX/ShapeStyle.cs

@@ -5,7 +5,11 @@ using System.Text;
 namespace HTEXLib.Models.HTEX
 {
     public  class ShapeStyle
-    {
+    { 
+        /// <summary>
+        /// 坐标信息
+        /// </summary>
+        public Position position { get; set; }
         public Border border { get; set; }
         public Fill fill { get; set; }
     }

+ 1 - 1
HTEXLib/Models/Table.cs

@@ -6,7 +6,7 @@ namespace HTEXLib
 {
     public class Table : Item
     {
-       
+        public Position position { get; set; }
         public TbStyle style { get; set; }
         public Table() {
             tr = new List<Tr>();