Example #1
0
        public static OpenXmlCompositeElement BuildRectangle(MainDocumentPart docPart, uint id, string text, double width, double height, double left, double top, List <string> props, List <string> textProperties)
        {
            RectangleShape rectangle = new RectangleShape()
            {
                Id = id,
                ShapeProperties = CustomShapeProperties.Create(props),
                TextProperties  = textProperties
            };

            rectangle.ShapeProperties.InnerText    = text;
            rectangle.ShapeProperties.Height       = height;
            rectangle.ShapeProperties.Width        = width;
            rectangle.ShapeProperties.PositionTop  = top;
            rectangle.ShapeProperties.PositionLeft = left;

            rectangle.AddRequiredNamespaces(docPart);
            return(rectangle.Build());
        }
Example #2
0
        public static CustomShapeProperties Create(List <string> Props)
        {
            CustomShapeProperties cProps = new CustomShapeProperties();

            if (Props != null)
            {
                foreach (var item in Props)
                {
                    string[] itemSplit = item.Split(VALUE_SEPARATOR);
                    if (itemSplit.Length == 2)
                    {
                        string itemKey   = itemSplit[0].ToLower();
                        string itemValue = itemSplit[1];
                        switch (itemKey)
                        {
                        case "strokewidth":
                            cProps.StrokeWidth = Double.Parse(itemValue);
                            break;

                        case "color":
                            cProps.StrokeColor = itemValue;
                            break;

                        case "fillcolor":
                            cProps.FillColor = itemValue;
                            break;

                        case "horizontalalignment":
                            cProps.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), itemValue, true);
                            break;

                        case "verticalalignment":
                            cProps.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), itemValue, true);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            return(cProps);
        }