Example #1
0
        private void DrawLine(IPsDocument doc, int x1, int y1, int x2, int y2, string name)
        {
            List <IPsSubPathInfo> lineSubPaths = new List <IPsSubPathInfo>();
            IPsPathItem           line;

            IPsPathPointInfo endPoint1 = app.CreatePathPointInfo();

            endPoint1.Kind           = EPsPointKind.psCornerPoint;
            endPoint1.Anchor         = new PointF((float)x1 / 300 * 72, (float)y1 / 300 * 72);
            endPoint1.LeftDirection  = endPoint1.Anchor;
            endPoint1.RightDirection = endPoint1.Anchor;

            IPsPathPointInfo endPoint2 = app.CreatePathPointInfo();

            endPoint2.Kind           = EPsPointKind.psCornerPoint;
            endPoint2.Anchor         = new PointF((float)x2 / 300 * 72, (float)y2 / 300 * 72);
            endPoint2.LeftDirection  = endPoint2.Anchor;
            endPoint2.RightDirection = endPoint2.Anchor;

            IPsSubPathInfo subPath = app.CreateSubPathInfo();

            subPath.Operation = EPsShapeOperation.psShapeXOR;
            subPath.Closed    = false;
            subPath.AddPathPointInfo(endPoint1);
            subPath.AddPathPointInfo(endPoint2);
            lineSubPaths.Add(subPath);

            line = doc.PathItems.Add(name, lineSubPaths);
            line.StrokePath(EPsToolType.psPencil, false);
        }
Example #2
0
        private IPsPathItem DrawFilledRectangle(IPsDocument doc, int x1, int y1, int x2, int y2, string name)
        {
            List <IPsSubPathInfo> lineSubPaths = new List <IPsSubPathInfo>();
            IPsPathItem           rectangle;

            app.ForegroundColor = app.CreateSolidColor(53, 24, 31);

            IPsPathPointInfo endPoint1 = app.CreatePathPointInfo();

            endPoint1.Kind = EPsPointKind.psCornerPoint;
            //endPoint1.Anchor = new PointF(0, 0);
            endPoint1.Anchor         = new PointF((float)x1 / 300 * 72, (float)y1 / 300 * 72);
            endPoint1.LeftDirection  = endPoint1.Anchor;
            endPoint1.RightDirection = endPoint1.Anchor;

            IPsPathPointInfo endPoint2 = app.CreatePathPointInfo();

            endPoint2.Kind = EPsPointKind.psCornerPoint;
            //endPoint2.Anchor = new PointF(100, 0);
            endPoint2.Anchor         = new PointF((float)x2 / 300 * 72, (float)y1 / 300 * 72);
            endPoint2.LeftDirection  = endPoint2.Anchor;
            endPoint2.RightDirection = endPoint2.Anchor;

            IPsPathPointInfo endPoint3 = app.CreatePathPointInfo();

            endPoint3.Kind = EPsPointKind.psCornerPoint;
            //endPoint3.Anchor = new PointF(100, 200);
            endPoint3.Anchor         = new PointF((float)x2 / 300 * 72, (float)y2 / 300 * 72);
            endPoint3.LeftDirection  = endPoint3.Anchor;
            endPoint3.RightDirection = endPoint3.Anchor;

            IPsPathPointInfo endPoint4 = app.CreatePathPointInfo();

            endPoint4.Kind = EPsPointKind.psCornerPoint;
            //endPoint4.Anchor = new PointF(0, 200);
            endPoint4.Anchor         = new PointF((float)x1 / 300 * 72, (float)y2 / 300 * 72);
            endPoint4.LeftDirection  = endPoint4.Anchor;
            endPoint4.RightDirection = endPoint4.Anchor;

            IPsSubPathInfo subPath = app.CreateSubPathInfo();

            subPath.Operation = EPsShapeOperation.psShapeXOR;
            subPath.Closed    = true;

            subPath.AddPathPointInfo(endPoint1);
            subPath.AddPathPointInfo(endPoint2);
            subPath.AddPathPointInfo(endPoint3);
            subPath.AddPathPointInfo(endPoint4);
            lineSubPaths.Add(subPath);

            IPsSolidColor fillColor = app.CreateSolidColor(53, 24, 31);

            app.ActiveDocument = doc;
            rectangle          = doc.PathItems.Add(name, lineSubPaths);
            //line.StrokePath(EPsToolType.psBrush, false);
            rectangle.FillPath(fillColor, EPsBlendMode.psOverlay, 100, false, 0, false, true);

            return(rectangle);
        }