Exemplo n.º 1
0
 private Shape(XElementData data, int id, DrawPosition from, DrawPosition to, Drawings drawings)
 {
     this.data     = data;
     this.drawings = drawings;
     SetPositions(from, to);
     WriteContents(id, from, to);
 }
Exemplo n.º 2
0
        public IShape DrawShape(DrawPosition from, DrawPosition to)
        {
            var shape = Shape.New(data.Add("xdr", "twoCellAnchor"), map.Count == 0 ? 2 : map.Keys.Max() + 1, from, to, this);

            map.Add(shape.Id, shape);
            return(shape);
        }
Exemplo n.º 3
0
        private void SetPosition(string name, DrawPosition pos)
        {
            var posData = data.Add(name);

            posData.SetElementValue("col", pos.ColumnIndex);
            posData.SetElementValue("colOff", pos.ColumnOffset);
            posData.SetElementValue("row", pos.RowIndex - 1);
            posData.SetElementValue("rowOff", pos.RowOffset);
        }
Exemplo n.º 4
0
        private void WriteContents(int id, DrawPosition from, DrawPosition to)
        {
            var shape = data.Add("sp");

            shape["macro"]    = "";
            shape["textlink"] = "";

            // non visual shape properties
            var nonVisualProperties = shape.Add("nvSpPr");
            var drawingProperties   = nonVisualProperties.Add("cNvPr");

            drawingProperties.SetAttributeValue("id", id);
            drawingProperties["name"] = "TextBox " + id;
            nonVisualProperties.Add("cNvSpPr")["txBox"] = "1";

            // shape properties
            var shapePropertiesData = shape.Add("spPr");

            ShapeProperties = ShapeProperties.New(shapePropertiesData, from, to);

            // style
            var style         = shape.Add("style");
            var lineReference = style.Add("a", "lnRef");

            lineReference["idx"] = "0";
            RgbColorModel.SetPercentageColor(lineReference, 0, 0, 0);
            var fillReference = style.Add("a", "fillRef");

            fillReference["idx"] = "0";
            RgbColorModel.SetPercentageColor(fillReference, 0, 0, 0);
            var effectReference = style.Add("a", "effectRef");

            effectReference["idx"] = "0";
            RgbColorModel.SetPercentageColor(effectReference, 0, 0, 0);
            var fontReference = style.Add("a", "fontRef");

            fontReference["idx"] = "minor";
            fontReference.Add("schemeClr")["val"] = "dk1";

            // text body
            var textBody = shape.Add("txBody");

            textBody.Add("a", "bodyPr").SetAttributeValues("vertOverflow=clip horzOverflow=clip vert=horz lIns=63500 tIns=25400 rIns=63500 rtlCol=0 anchor=t");
            textBody.Add("a", "lstStyle");
            var run           = textBody.Add("a", "p").Add("r");
            var runProperties = run.Add("rPr");

            runProperties.SetAttributeValues("lang=en-US sz=1000");
            RgbColorModel.SetHexColor(runProperties.Add("solidFill"), 0, 0, 0);
            runProperties.Add("latin")["typeface"] = "Arial";
            run.Add("t").Value = "";

            data.Add("clientData");
        }
Exemplo n.º 5
0
        private DrawPosition CalculatePosition(int columnIndex, double columnOffset, int rowIndex, double rowOffset)
        {
            var pos = new DrawPosition()
            {
                ColumnIndex  = columnIndex,
                ColumnOffset = (int)(columnOffset * EmuFactor),
                RowIndex     = rowIndex,
                RowOffset    = (int)(rowOffset * EmuFactor),
            };

            //pos.X = ((int)(sheetColumns.GetXPosition(pos.ColumnIndex) * EmuFactor)) + pos.ColumnOffset;
            //pos.Y = ((int)(sheetData.GetYPosition(pos.RowIndex) * EmuFactor)) + pos.RowOffset;
            return(pos);
        }
        private void WriteContents(DrawPosition from, DrawPosition to)
        {
            // transform
            //var transform = data.Add("a", "xfrm");
            //var offset = transform.Add("off");
            //offset.SetAttributeValue("x", from.X); // absolute coordinate
            //offset.SetAttributeValue("y", from.Y); // absolute coordinate
            //var extension = transform.Add("ext");
            //extension.SetAttributeValue("cx", to.X - from.X); // absolute width
            //extension.SetAttributeValue("cy", to.Y - from.Y); // absolute height
            // preset geometry
            var presetGeometry = data.Add("a", "prstGeom");

            presetGeometry["prst"] = "rect";
            presetGeometry.Add("avLst");
            // solid fill
            RgbColorModel.SetHexColor(data.Add("a", "solidFill"), 255, 255, 255);//TODO: set color
            // outline
            var outline = data.Add("a", "ln");

            outline["w"]    = "9525"; // line width
            outline["cmpd"] = "sng";  // compound type (default: sng)
            RgbColorModel.SetHexColor(outline.Add("solidFill"), 0, 0, 0);
        }
 public static ShapeProperties New(XElementData data, DrawPosition from, DrawPosition to)
 {
     return(new ShapeProperties(data, from, to));
 }
 private ShapeProperties(XElementData data, DrawPosition from, DrawPosition to)
 {
     this.data = data;
     WriteContents(from, to);
 }
Exemplo n.º 9
0
 public void SetPositions(DrawPosition from, DrawPosition to)
 {
     SetPosition("from", from);
     SetPosition("to", to);
 }
Exemplo n.º 10
0
 public static Shape New(XElementData data, int id, DrawPosition from, DrawPosition to, Drawings drawings)
 {
     return(new Shape(data, id, from, to, drawings));
 }