Exemple #1
0
        private Wp.Inline CreateInline(A.GraphicData graphicData, Wpg.WordprocessingGroup wordprocessingGroup1)
        {
            UInt32Value inlineId = UInt32Value.FromUInt32((uint)_ooxmlId++);

            Int64Value width = OoXmlHelper.ScaleCmlToEmu(_canvasExtents.Width);
            Int64Value height = OoXmlHelper.ScaleCmlToEmu(_canvasExtents.Height);

            Wp.Inline inline1 = new Wp.Inline() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U };
            Wp.Extent extent1 = new Wp.Extent() { Cx = width, Cy = height };

            Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L };
            Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = inlineId, Name = "moleculeGroup" };

            Wpg.NonVisualGroupDrawingShapeProperties nonVisualGroupDrawingShapeProperties1 = new Wpg.NonVisualGroupDrawingShapeProperties();
            Wpg.NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties = new Wpg.NonVisualGraphicFrameProperties();
            A.GraphicFrameLocks gfl = new A.GraphicFrameLocks()
            {
                NoMove = true,
                NoSelection = true
            };

            Wpg.GroupShapeProperties groupShapeProperties1 = new Wpg.GroupShapeProperties();

            A.TransformGroup transformGroup1 = new A.TransformGroup();
            A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
            A.Extents extents1 = new A.Extents() { Cx = width, Cy = height };
            A.ChildOffset childOffset1 = new A.ChildOffset() { X = 0L, Y = 0L };
            A.ChildExtents childExtents1 = new A.ChildExtents() { Cx = width, Cy = height };

            transformGroup1.Append(offset1);
            transformGroup1.Append(extents1);
            transformGroup1.Append(childOffset1);
            transformGroup1.Append(childExtents1);

            groupShapeProperties1.Append(transformGroup1);
            wordprocessingGroup1.Append(nonVisualGroupDrawingShapeProperties1);
            wordprocessingGroup1.Append(groupShapeProperties1);

            inline1.Append(extent1);
            inline1.Append(effectExtent1);
            inline1.Append(docProperties1);
            inline1.Append(gfl);

            return inline1;
        }
Exemple #2
0
        private void DrawBox(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, string colour, int thick)
        {
            UInt32Value bondLineId   = UInt32Value.FromUInt32((uint)_ooxmlId++);
            string      bondLineName = "diag-box-" + bondLineId;

            Int64Value width1  = OoXmlHelper.ScaleCmlToEmu(extents.Width);
            Int64Value height1 = OoXmlHelper.ScaleCmlToEmu(extents.Height);
            Int64Value top1    = OoXmlHelper.ScaleCmlToEmu(extents.Top);
            Int64Value left1   = OoXmlHelper.ScaleCmlToEmu(extents.Left);

            Point pp1 = new Point(left1, top1);
            Size  ss2 = new Size(width1, height1);

            pp1.Offset(OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Left), OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Top));
            Rect boundingBox = new Rect(pp1, ss2);

            Int64Value width  = (Int64Value)boundingBox.Width;
            Int64Value height = (Int64Value)boundingBox.Height;
            Int64Value top    = (Int64Value)boundingBox.Top;
            Int64Value left   = (Int64Value)boundingBox.Left;

            Wps.WordprocessingShape        wordprocessingShape1        = new Wps.WordprocessingShape();
            Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties()
            {
                Id   = bondLineId,
                Name = bondLineName
            };
            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties();

            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties();

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset      offset2      = new A.Offset()
            {
                X = left, Y = top
            };
            A.Extents extents2 = new A.Extents()
            {
                Cx = width, Cy = height
            };

            transform2D1.Append(offset2);
            transform2D1.Append(extents2);

            A.CustomGeometry  customGeometry1  = new A.CustomGeometry();
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();
            A.Rectangle       rectangle1       = new A.Rectangle()
            {
                Left = "l", Top = "t", Right = "r", Bottom = "b"
            };

            A.PathList pathList1 = new A.PathList();

            A.Path path1 = new A.Path()
            {
                Width = width, Height = height
            };

            // Starting Point
            A.MoveTo moveTo1 = new A.MoveTo();
            A.Point  point1  = new A.Point()
            {
                X = "0", Y = "0"
            };
            moveTo1.Append(point1);

            // Mid Point
            A.LineTo lineTo1 = new A.LineTo();
            A.Point  point2  = new A.Point()
            {
                X = boundingBox.Width.ToString("0"), Y = "0"
            };
            lineTo1.Append(point2);

            // Mid Point
            A.LineTo lineTo2 = new A.LineTo();
            A.Point  point3  = new A.Point()
            {
                X = boundingBox.Width.ToString("0"), Y = boundingBox.Height.ToString("0")
            };
            lineTo2.Append(point3);

            // Last Point
            A.LineTo lineTo3 = new A.LineTo();
            A.Point  point4  = new A.Point()
            {
                X = "0", Y = boundingBox.Height.ToString("0")
            };
            lineTo3.Append(point4);

            // Back to Start Point
            A.LineTo lineTo4 = new A.LineTo();
            A.Point  point5  = new A.Point()
            {
                X = "0", Y = "0"
            };
            lineTo4.Append(point5);

            path1.Append(moveTo1);
            path1.Append(lineTo1);
            path1.Append(lineTo2);
            path1.Append(lineTo3);
            path1.Append(lineTo4);

            pathList1.Append(path1);

            customGeometry1.Append(adjustValueList1);
            customGeometry1.Append(rectangle1);
            customGeometry1.Append(pathList1);

            A.Outline outline1 = new A.Outline()
            {
                Width = thick, CapType = A.LineCapValues.Round
            };

            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex()
            {
                Val = colour
            };
            A.Alpha alpha1 = new A.Alpha()
            {
                Val = new Int32Value()
                {
                    InnerText = "100%"
                }
            };

            rgbColorModelHex1.Append(alpha1);

            solidFill1.Append(rgbColorModelHex1);

            outline1.Append(solidFill1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(customGeometry1);
            shapeProperties1.Append(outline1);

            Wps.ShapeStyle  shapeStyle1    = new Wps.ShapeStyle();
            A.LineReference lineReference1 = new A.LineReference()
            {
                Index = (UInt32Value)0U
            };
            A.FillReference fillReference1 = new A.FillReference()
            {
                Index = (UInt32Value)0U
            };
            A.EffectReference effectReference1 = new A.EffectReference()
            {
                Index = (UInt32Value)0U
            };
            A.FontReference fontReference1 = new A.FontReference()
            {
                Index = A.FontCollectionIndexValues.Minor
            };

            shapeStyle1.Append(lineReference1);
            shapeStyle1.Append(fillReference1);
            shapeStyle1.Append(effectReference1);
            shapeStyle1.Append(fontReference1);
            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties();

            wordprocessingShape1.Append(nonVisualDrawingProperties1);
            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(shapeStyle1);
            wordprocessingShape1.Append(textBodyProperties1);

            wordprocessingGroup1.Append(wordprocessingShape1);
        }
Exemple #3
0
        private void DrawShape(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, A.ShapeTypeValues shape, string colour)
        {
            UInt32Value bondLineId   = UInt32Value.FromUInt32((uint)_ooxmlId++);
            string      bondLineName = "shape" + bondLineId;

            Int64Value width1  = OoXmlHelper.ScaleCmlToEmu(extents.Width);
            Int64Value height1 = OoXmlHelper.ScaleCmlToEmu(extents.Height);
            Int64Value top1    = OoXmlHelper.ScaleCmlToEmu(extents.Top);
            Int64Value left1   = OoXmlHelper.ScaleCmlToEmu(extents.Left);

            Point pp1 = new Point(left1, top1);
            Size  ss2 = new Size(width1, height1);

            pp1.Offset(OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Left), OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Top));
            Rect boundingBox = new Rect(pp1, ss2);

            Int64Value width  = (Int64Value)boundingBox.Width;
            Int64Value height = (Int64Value)boundingBox.Height;
            Int64Value top    = (Int64Value)boundingBox.Top;
            Int64Value left   = (Int64Value)boundingBox.Left;

            A.Extents        extents2        = null;
            A.PresetGeometry presetGeometry1 = null;
            extents2 = new A.Extents()
            {
                Cx = width, Cy = height
            };
            presetGeometry1 = new A.PresetGeometry()
            {
                Preset = shape
            };

            Wps.WordprocessingShape        wordprocessingShape1        = new Wps.WordprocessingShape();
            Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties()
            {
                Id   = bondLineId,
                Name = bondLineName
            };

            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties();
            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties();

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset      offset2      = new A.Offset()
            {
                X = left, Y = top
            };

            transform2D1.Append(offset2);
            transform2D1.Append(extents2);

            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);
            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex()
            {
                Val = colour
            };
            A.Alpha alpha1 = new A.Alpha()
            {
                Val = new Int32Value()
                {
                    InnerText = "100%"
                }
            };
            solidFill1.Append(rgbColorModelHex1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(presetGeometry1);
            shapeProperties1.Append(solidFill1);

            Wps.ShapeStyle  shapeStyle1    = new Wps.ShapeStyle();
            A.LineReference lineReference1 = new A.LineReference()
            {
                Index = (UInt32Value)0U
            };
            A.FillReference fillReference1 = new A.FillReference()
            {
                Index = (UInt32Value)0U
            };
            A.EffectReference effectReference1 = new A.EffectReference()
            {
                Index = (UInt32Value)0U
            };
            A.FontReference fontReference1 = new A.FontReference()
            {
                Index = A.FontCollectionIndexValues.Minor
            };

            shapeStyle1.Append(lineReference1);
            shapeStyle1.Append(fillReference1);
            shapeStyle1.Append(effectReference1);
            shapeStyle1.Append(fontReference1);
            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties();

            wordprocessingShape1.Append(nonVisualDrawingProperties1);
            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(shapeStyle1);
            wordprocessingShape1.Append(textBodyProperties1);

            wordprocessingGroup1.Append(wordprocessingShape1);
        }
Exemple #4
0
        private void DrawLine(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, Point startPoint, Point endPoint, string colour, int thick)
        {
            UInt32Value bondLineId   = UInt32Value.FromUInt32((uint)_ooxmlId++);
            string      bondLineName = "diag-line-" + bondLineId;

            // Move Bond Line Extents and Points to have 0,0 Top Left Reference
            startPoint.Offset(-_canvasExtents.Left, -_canvasExtents.Top);
            endPoint.Offset(-_canvasExtents.Left, -_canvasExtents.Top);
            extents.Offset(-_canvasExtents.Left, -_canvasExtents.Top);

            // Move points into New Bond Line Extents
            startPoint.Offset(-extents.Left, -extents.Top);
            endPoint.Offset(-extents.Left, -extents.Top);

            Int64Value width  = OoXmlHelper.ScaleCmlToEmu(extents.Width);
            Int64Value height = OoXmlHelper.ScaleCmlToEmu(extents.Height);
            Int64Value top    = OoXmlHelper.ScaleCmlToEmu(extents.Top);
            Int64Value left   = OoXmlHelper.ScaleCmlToEmu(extents.Left);

            Wps.WordprocessingShape        wordprocessingShape1        = new Wps.WordprocessingShape();
            Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties()
            {
                Id = bondLineId, Name = bondLineName
            };
            Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties();

            Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties();

            A.Transform2D transform2D1 = new A.Transform2D();
            A.Offset      offset2      = new A.Offset()
            {
                X = left, Y = top
            };
            A.Extents extents2 = new A.Extents()
            {
                Cx = width, Cy = height
            };

            transform2D1.Append(offset2);
            transform2D1.Append(extents2);

            A.CustomGeometry  customGeometry1  = new A.CustomGeometry();
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();
            A.Rectangle       rectangle1       = new A.Rectangle()
            {
                Left = "l", Top = "t", Right = "r", Bottom = "b"
            };

            A.PathList pathList1 = new A.PathList();

            A.Path path1 = new A.Path()
            {
                Width = width, Height = height
            };

            A.MoveTo moveTo1 = new A.MoveTo();
            A.Point  point1  = new A.Point()
            {
                X = OoXmlHelper.ScaleCmlToEmu(startPoint.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(startPoint.Y).ToString()
            };
            moveTo1.Append(point1);

            A.LineTo lineTo1 = new A.LineTo();
            A.Point  point2  = new A.Point()
            {
                X = OoXmlHelper.ScaleCmlToEmu(endPoint.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(endPoint.Y).ToString()
            };
            lineTo1.Append(point2);

            path1.Append(moveTo1);
            path1.Append(lineTo1);

            pathList1.Append(path1);

            customGeometry1.Append(adjustValueList1);
            customGeometry1.Append(rectangle1);
            customGeometry1.Append(pathList1);

            A.Outline outline1 = new A.Outline()
            {
                Width = thick, CapType = A.LineCapValues.Round
            };

            A.SolidFill solidFill1 = new A.SolidFill();

            A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex()
            {
                Val = colour
            };
            A.Alpha alpha1 = new A.Alpha()
            {
                Val = new Int32Value()
                {
                    InnerText = "100%"
                }
            };

            rgbColorModelHex1.Append(alpha1);

            solidFill1.Append(rgbColorModelHex1);

            outline1.Append(solidFill1);

            shapeProperties1.Append(transform2D1);
            shapeProperties1.Append(customGeometry1);
            shapeProperties1.Append(outline1);

            Wps.ShapeStyle  shapeStyle1    = new Wps.ShapeStyle();
            A.LineReference lineReference1 = new A.LineReference()
            {
                Index = (UInt32Value)0U
            };
            A.FillReference fillReference1 = new A.FillReference()
            {
                Index = (UInt32Value)0U
            };
            A.EffectReference effectReference1 = new A.EffectReference()
            {
                Index = (UInt32Value)0U
            };
            A.FontReference fontReference1 = new A.FontReference()
            {
                Index = A.FontCollectionIndexValues.Minor
            };

            shapeStyle1.Append(lineReference1);
            shapeStyle1.Append(fillReference1);
            shapeStyle1.Append(effectReference1);
            shapeStyle1.Append(fontReference1);
            Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties();

            wordprocessingShape1.Append(nonVisualDrawingProperties1);
            wordprocessingShape1.Append(nonVisualDrawingShapeProperties1);
            wordprocessingShape1.Append(shapeProperties1);
            wordprocessingShape1.Append(shapeStyle1);
            wordprocessingShape1.Append(textBodyProperties1);

            wordprocessingGroup1.Append(wordprocessingShape1);
        }