using DocumentFormat.OpenXml.Drawing; using HTEXLib.Helpers.ShapeHelpers; using System; using System.Collections.Generic; using System.Text; namespace HTEXLib.Models.HTEX { public class HtexConnectionShape : HtexElement { public Inner.PPTConnectionShape connectionShape { get; set; } public HtexConnectionShape(string id, double rot, double width, double height, double top, double left, bool invisible, bool animatable, int index, Inner.PPTConnectionShape connectionShape, PPTSlide slide, string partForm) { base.slide = slide; this.rot = rot; this.connectionShape = connectionShape; base.id = id; base.top = top; base.left = left; base.width = width; base.height = height; base.invisible = invisible; base.animatable = animatable; base.index = index; base.type = "CxnSp"; base.partForm = partForm; } public override List DrawElement() { //var xfrm = connectionShape.element.GetTextByPath("//p:spPr/a:xfrm"); //var flipV = xfrm.Attribute("flipV"); //var flipH = xfrm.Attribute("flipH"); Position position = new Position { x = top, y = left, cx = width, cy = height, rot =rot}; //if (flipV != null) { // position.flipV = int.Parse(flipV.Value); //} //if (flipH!= null) //{ // position.flipH = int.Parse(flipH.Value); //} position.flipV = connectionShape.element.ShapeProperties.Transform2D.VerticalFlip!=null && connectionShape.element.ShapeProperties.Transform2D.VerticalFlip.Value?1:0; position.flipH = connectionShape.element.ShapeProperties.Transform2D.HorizontalFlip!=null && connectionShape.element.ShapeProperties.Transform2D.HorizontalFlip.Value ? 1 : 0; /* 三角形-▶ 菱形◆ 圆点● ->⇱ */ var shapeTypeNode = connectionShape.element.ShapeProperties.GetFirstChild(); var shapeType= shapeTypeNode.Preset.InnerText; var otl = connectionShape.element.ShapeProperties.GetFirstChild(); var shapeBorder = PPTXHelper.DoOutline(otl, slide,type); //从ShapeProperties 获取 p:spPr //再从 ShapeStyle 获取 p:spPr if (shapeBorder.color == null|| shapeBorder.color.type==-1) { SlideColor slideColor = PPTXHelper.DoShapeStyle(connectionShape.element.ShapeStyle, slide,type); if (slideColor != null) { shapeBorder.color.solidFill = slideColor.LineColor; shapeBorder.color.type = 2; } } 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 }; return new List() { item }; } } }