Example #1
0
 public static bool NegativeMotion(this CurveType type) => type.HasFlag(CurveType.NegativeMotion);
Example #2
0
        VoidMethod SetVoidMethod()
        {
            Enum.TryParse(cmbGradient.SelectedItem + "", true, out MnM.GWS.Gradient grad);
            IFillStyle fStyle;

            if (lstColors.Items.Count > 0)
            {
                object[] all = new object[lstColors.Items.Count];
                lstColors.Items.CopyTo(all, 0);
                fStyle = Factory.newFillStyle(grad, all.Select(x => ((System.Drawing.Color)x).ToArgb()).ToArray());
            }
            else
            {
                fStyle = Factory.newFillStyle(grad, MnM.GWS.Colour.Silver);
            }

            Renderer.ReadContext = fStyle;

            VoidMethod gwsMethod = null;
            var        stroke    = (float)numStroke.Value;

            Renderer.CopySettings(pse, stroke, StrokeMode.Middle, chkAA.Checked ? LineDraw.AA : LineDraw.NonAA);

            mnmCanvas.ApplyBackground(MnM.GWS.Colour.White);

            if (rotate1.Valid)
            {
                Renderer.RotateTransform(Entity.Buffer, rotate1);
            }
            else
            {
                Renderer.ResetTransform(Entity.Buffer);
            }

            curveType = 0;
            foreach (var item in lstCurveOption.CheckedItems)
            {
                curveType |= (CurveType)item;
            }
            IDrawStyle ds = new DrawStyle();

            ds.Angle = rotate;
            var font = gwsFont ?? Factory.SystemFont;

            ds.LineHeight = (font?.Info?.LineHeight ?? 0).Ceiling();

            switch (cmbShape.Text)
            {
            case "Line":
                if (drawPoints == null || drawPoints.Length < 4)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 2 coordinates to create a line by clicking 2 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawLines(true, rotate, drawPoints);
                break;

            case "Trapezium":
                if (drawPoints == null || drawPoints.Length < 4)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 2 coordinates to create a line by clicking 2 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawTrapezium(
                    new float[] { drawPoints[0], drawPoints[1], drawPoints[2], drawPoints[3],
                                  (float)numSize.Value, (float)numSizeDiff.Value }, rotate);
                break;

            case "Circle":
                if (drawPoints?.Length >= 4)
                {
                    gwsMethod = () => mnmCanvas.DrawCircle(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                           new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), rotate);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(x, y, w, w, rotate);
                }

                break;

            case "Ellipse":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                            new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(x, y, w, h, rotate);
                }
                break;

            case "Arc":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawArc(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                        new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType | CurveType.Arc);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawArc(x, y, w, h, startA, endA, rotate, curveType | CurveType.Arc);
                }
                break;

            case "Pie":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawPie(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                        new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType | CurveType.Pie);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawPie(x, y, w, h, startA, endA, rotate, curveType | CurveType.Pie);
                }
                break;

            case "BezierArc":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawBezierArc(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                              new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawBezierArc(x, y, w, h, startA, endA, rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                break;

            case "BezierPie":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawBezierPie(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                              new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawBezierPie(x, y, w, h, startA, endA, rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                break;

            case "Square":
                gwsMethod = () => mnmCanvas.DrawRhombus(x, y, w, w, rotate);
                break;

            case "Rectangle":
                gwsMethod = () => mnmCanvas.DrawRectangle(x, y, w, h, rotate);
                break;

            case "RoundedArea":
                gwsMethod = () => mnmCanvas.DrawRoundedBox(x, y, w, h, (float)numCornerRadius.Value, rotate);
                break;

            case "Rhombus":
                gwsMethod = () => mnmCanvas.DrawRhombus(x, y, w, h, rotate);

                break;

            case "Triangle":
                if (drawPoints == null || drawPoints.Length < 6)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 3 coordinates to create a triangle by clicking 3 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawTriangle(drawPoints[0], drawPoints[1],
                                                         drawPoints[2], drawPoints[3], drawPoints[4], drawPoints[5], rotate);
                break;

            case "Polygon":
                if (drawPoints == null)
                {
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawPolygon(rotate, drawPoints.Select(p => p + 0f).ToArray());
                break;

            case "Bezier":
                var type = cmbBezier.SelectedIndex != -1 ?
                           ((KeyValuePair <string, BezierType>)cmbBezier.SelectedItem).Value : BezierType.Cubic;
                if (type.HasFlag(BezierType.Multiple))
                {
                    if (drawPoints == null || drawPoints.Length < 6)
                    {
                        return(null);
                    }
                    gwsMethod = () => mnmCanvas.DrawBezier(type, rotate, drawPoints.Select(p => (float)p).ToArray());
                }
                else
                {
                    if (drawPoints == null || drawPoints.Length < 3)
                    {
                        System.Windows.Forms.MessageBox.Show("Please provide at least 3 coordinates to create a bezier by clicking 3 points on GWS picture box!");
                        return(null);
                    }
                    gwsMethod = () => mnmCanvas.DrawBezier(type, rotate, drawPoints.Select(p => (float)p).ToArray());
                }
                break;

            case "Glyphs":
                gwsMethod = () => mnmCanvas.DrawText(font, 130, 130 + font.Size, txtPts.Text, ds);
                break;
            }
            return(gwsMethod);
        }
Example #3
0
 public static bool IsPie(this CurveType type) => type.HasFlag(CurveType.Pie);
Example #4
0
 public static bool IsClosedArc(this CurveType type) => type.HasFlag(CurveType.ClosedArc);
Example #5
0
 public static bool IsArc(this CurveType type) => type.HasFlag(CurveType.Arc);
Example #6
0
 public static bool SweepAngle(this CurveType type) => !type.HasFlag(CurveType.NoSweepAngle);
Example #7
0
 public static bool CrossStroke(this CurveType type) => type.HasFlag(CurveType.CrossStroke);