12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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, string timingId)
- {
- base.sid = timingId;
- 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<Item> 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;
-
- /*
- <xsd:enumeration value="none"/> 无
- <xsd:enumeration value="triangle"/> 三角形-▶
- <xsd:enumeration value="stealth"/> →
- <xsd:enumeration value="diamond"/> 菱形◆
- <xsd:enumeration value="oval"/> 圆点●
- <xsd:enumeration value="arrow"/> ->⇱
- */
- var shapeTypeNode = connectionShape.element.ShapeProperties.GetFirstChild<PresetGeometry>();
- var shapeType= shapeTypeNode.Preset.InnerText;
- var otl = connectionShape.element.ShapeProperties.GetFirstChild<Outline>();
- var shapeBorder = PPTXHelper.DoOutline(otl, slide,type);
- //从ShapeProperties 获取 p:spPr
- //再从 ShapeStyle 获取 p:spPr
- if (shapeBorder.color == null|| shapeBorder.color.type == 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
- Connector item = new Connector { sid =sid, type =type,cxnType=shapeType, invisible = invisible, animatable = animatable, index = index, id = id, svg = svg };
- item.style.position = position;
- item.style.border = shapeBorder;
- item.uid = connectionShape.suid;
- return new List<Item>() { item };
- }
- }
- }
|