Пример #1
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            Rectangle rect = new Rectangle(Location.X - helper.AreaBounds.X,
                                           Location.Y - helper.AreaBounds.Y,
                                           Size.Width, Size.Height);
            string str =

                helper.GeneratePaintToolInit(this) +

                generatePointArray(rect) +
                generateTypeArray() +


                "ScalePoints(ref " + this.Name + "Points, (float)shapeBoundsNew.Width / shapeBoundsOld.Width,\r\n" +
                "(float)shapeBoundsNew.Height / shapeBoundsOld.Height);\r\n//\r\n" +
                "//Create the path\r\npath = new GraphicsPath(" + this.Name + "Points," + this.Name + "Types);\r\n" +
                "path.CloseAllFigures();\r\n";

            if (painter.PaintFill)
            {
                str += graphicsName + ".FillPath(" + this.Name + "Brush, path);\r\n";
            }
            if (painter.PaintBorder)
            {
                str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";
            }

            str += helper.GeneratePaintToolCleanup(this);
            helper.GenerateScalePoints();
            return(str);
        }
Пример #2
0
        private string generatePointArray(GDIGenerationTool helper)
        {
            StringBuilder sb = new StringBuilder(points.Count * 25);

            int   intCount = points.Count - 1;
            int   intRem   = 0;
            short i        = 0;

            for (i = 0; i < intCount; i++)
            {
                Math.DivRem(i, 4, out intRem);
                if (intRem == 0)
                {
                    sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
                              (points[i].Y - helper.AreaBounds.Y) + "f),\r\n");
                }
                else
                {
                    sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
                              (points[i].Y - helper.AreaBounds.Y) + "f), ");
                }
            }
            sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
                      (points[i].Y - helper.AreaBounds.Y) + "f)\r\n};\r\n");

            string str = "//Create the point array\r\nPointF[] " +
                         this.Name + "Points = {" + sb.ToString() + "\r\n" +
                         "ScalePoints(ref " + this.Name + "Points, shapeBoundsOld, shapeBoundsNew);\r\n";

            sb = null;
            return(str);
        }
Пример #3
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            Rectangle rect = new Rectangle(Location.X - helper.AreaBounds.X,
                        Location.Y - helper.AreaBounds.Y,
                        Size.Width, Size.Height);
            string str =

            helper.GeneratePaintToolInit(this) +

            generatePointArray(rect) +
            generateTypeArray() +

            "ScalePoints(ref " + this.Name + "Points, (float)shapeBoundsNew.Width / shapeBoundsOld.Width,\r\n" +
                    "(float)shapeBoundsNew.Height / shapeBoundsOld.Height);\r\n//\r\n" +
            "//Create the path\r\npath = new GraphicsPath(" + this.Name + "Points," + this.Name + "Types);\r\n" +
            "path.CloseAllFigures();\r\n";

             if (painter.PaintFill)
                 str += graphicsName + ".FillPath(" + this.Name + "Brush, path);\r\n";
             if (painter.PaintBorder)
                 str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";

             str += helper.GeneratePaintToolCleanup(this);
             helper.GenerateScalePoints();
             return str;
        }
Пример #4
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Polygon: " + this.Name + "\r\n" +
                         helper.GeneratePaintToolInit(this) +

                         generatePointArray(helper) +
                         generateTypeArray() +

                         "//Create the path\r\npath = new GraphicsPath(" + this.Name + "Points," + this.Name + "Types);\r\n" +
                         "path.CloseAllFigures();\r\n" +

                         "//Paint the shape\r\n";

            if (painter.PaintFill)
            {
                str += graphicsName + ".FillPath(" + this.Name + "Brush, path );\r\n";
            }
            if (painter.PaintBorder)
            {
                str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";
            }

            str += helper.GeneratePaintToolCleanup(this);
            return(str);
        }
Пример #5
0
        public string generatePointArray(GDIGenerationTool helper)
        {
            return("PointF[] " + this.Name + "Points = { " +
                   "new PointF(" + (points[0].X - helper.AreaBounds.X) + "f," +
                   (points[0].Y - helper.AreaBounds.Y) + "f)," +
                   "new PointF(" + (points[1].X - helper.AreaBounds.X) + "f," +
                   (points[1].Y - helper.AreaBounds.Y) + "f)," +
                   "new PointF(" + (points[2].X - helper.AreaBounds.X) + "f," +
                   (points[2].Y - helper.AreaBounds.Y) + "f)," +
                   "new PointF(" + (points[3].X - helper.AreaBounds.X) + "f," +
                   (points[3].Y - helper.AreaBounds.Y) + "f)\r\n};\r\n" +

                   "ScalePoints(ref " + this.Name + "Points, shapeBoundsOld, shapeBoundsNew);\r\n");
        }
Пример #6
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Line: " + this.Name + "\r\n" +
                         helper.GeneratePaintToolInit(this) +

                         generatePointArray(helper) +

                         "//Paint the shape\r\n";

            str += graphicsName + ".DrawCurve(" + this.Name + "Pen," + this.Name + "Points);\r\n";

            str += helper.GeneratePaintToolCleanup(this);
            return(str);
        }
Пример #7
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Circle: " + this.Name + "\r\n" +
                helper.GeneratePaintToolInit(this) +

            "//Paint the shape\r\n";
            if (painter.PaintFill)
                str += graphicsName + ".FillEllipse("+this.Name+"Brush, shapeBoundsNew);\r\n";
            if (painter.PaintBorder)
                str += graphicsName + ".DrawEllipse("+this.Name+"Pen, Rectangle.Round(shapeBoundsNew));\r\n";

            str += helper.GeneratePaintToolCleanup(this);
            return str;
        }
Пример #8
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Circle: " + this.Name + "\r\n" +
                         helper.GeneratePaintToolInit(this) +

                         "//Paint the shape\r\n";

            if (painter.PaintFill)
            {
                str += graphicsName + ".FillEllipse(" + this.Name + "Brush, shapeBoundsNew);\r\n";
            }
            if (painter.PaintBorder)
            {
                str += graphicsName + ".DrawEllipse(" + this.Name + "Pen, Rectangle.Round(shapeBoundsNew));\r\n";
            }

            str += helper.GeneratePaintToolCleanup(this);
            return(str);
        }
Пример #9
0
 public abstract string EmitGDICode(string graphicsName, GDIGenerationTool helper);
Пример #10
0
        private string generatePointArray(GDIGenerationTool helper)
        {
            StringBuilder sb = new StringBuilder(points.Count * 25);

            int intCount = points.Count-1;
            int intRem = 0;
            short i = 0;
            for (i =0;i<intCount;i++)
            {
                Math.DivRem(i, 4, out intRem);
                if (intRem == 0)
                    sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
                              (points[i].Y - helper.AreaBounds.Y) + "f),\r\n");
                else
                    sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
              (points[i].Y - helper.AreaBounds.Y) + "f), ");
            }
            sb.Append("new PointF(" + (points[i].X - helper.AreaBounds.X) + "f," +
                      (points[i].Y  - helper.AreaBounds.Y) + "f)\r\n};\r\n");

            string str = "//Create the point array\r\nPointF[] " +
                this.Name + "Points = {" + sb.ToString() + "\r\n" +
                "ScalePoints(ref " + this.Name + "Points, shapeBoundsOld, shapeBoundsNew);\r\n";
            sb = null;
            return str;
        }
Пример #11
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Polygon: " + this.Name + "\r\n" +
               helper.GeneratePaintToolInit(this) +

               generatePointArray(helper)+
               generateTypeArray() +

               "//Create the path\r\npath = new GraphicsPath("+this.Name + "Points,"+this.Name + "Types);\r\n"+
               "path.CloseAllFigures();\r\n"+

               "//Paint the shape\r\n";
            if (painter.PaintFill)
                str += graphicsName + ".FillPath(" + this.Name + "Brush, path );\r\n";
            if (painter.PaintBorder)
                str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";

            str += helper.GeneratePaintToolCleanup(this);
            return str;
        }
Пример #12
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            bool blnScaleText = (bool)GdiProperties.GetValue(SCALE_TEXT);
            bool blnEditText  = (bool)GdiProperties.GetValue(EDIT_TEXT);


            string strText = blnEditText ?
                             "dText[eShapeText." + this.Name + "]"
                : helper.FormatText(text);
            string strBounds = blnScaleText ?
                               "shapeBoundsOld" : "shapeBoundsNew";

            string str = "//Text: " + this.Name + "\r\n";

            if (painter.PaintWithPath)
            {
                str += helper.SetShapeBounds(this);
            }
            else
            {
                str += helper.GeneratePaintToolInit(this);
            }

            str += "Font " + this.Name + "Font = new Font(\"" + font.FontFamily.Name + "\", " +
                   font.Size.ToString() + "f * (" + Size.Width + "f / (float)shapeBoundsOld.Width), (FontStyle)" + (int)font.Style + ");\r\n" +
                   "StringFormat " + this.Name + "Format = new StringFormat();\r\n" +
                   this.Name + "Format.Alignment = (StringAlignment)" + (int)format.Alignment + ";\r\n";

            if (blnScaleText)
            {
                str += "//Will apply the scaling factors to the graphics object\r\n" +
                       graphicsName + ".ScaleTransform(scale.Width, scale.Height);\r\n";
            }

            if (painter.PaintWithPath)
            {
                str += "path = new GraphicsPath();\r\n" +
                       "path.AddString(" + strText + ", " + this.Name +
                       "Font.FontFamily ,(int)" + this.Name + "Font.Style," +
                       this.Name + "Font.Size,\r\n" + strBounds + "," +
                       this.Name + "Format);\r\n" +

                       helper.GeneratePaintToolInit(this, "path.GetBounds()", false) +

                       "//Paint the text\r\n";
                if (painter.PaintFill)
                {
                    str += graphicsName + ".FillPath(" + this.Name + "Brush, path);\r\n";
                }
                if (painter.PaintBorder)
                {
                    str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";
                }
            }
            else
            {
                str += graphicsName + ".DrawString(" + strText + ", " +
                       this.Name + "Font, " + this.Name + "Brush, " + strBounds + ", "
                       + this.Name + "Format);\r\n";
            }
            if (blnScaleText)
            {
                str += graphicsName + ".ResetTransform();\r\n";
            }

            str += "//Cleanup Text objects\r\n" +
                   this.Name + "Font.Dispose();\r\n" +
                   this.Name + "Format.Dispose();\r\n" +
                   helper.GeneratePaintToolCleanup(this);
            return(str);
        }
Пример #13
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            bool blnScaleText = (bool)GdiProperties.GetValue(SCALE_TEXT);
            bool blnEditText = (bool)GdiProperties.GetValue(EDIT_TEXT);

            string strText = blnEditText ?
                "dText[eShapeText." + this.Name + "]"
                : helper.FormatText(text);
            string strBounds = blnScaleText ?
                    "shapeBoundsOld" : "shapeBoundsNew";

            string str = "//Text: " + this.Name + "\r\n";

            if (painter.PaintWithPath)
               str += helper.SetShapeBounds(this);
            else
               str += helper.GeneratePaintToolInit(this);

             str += "Font " + this.Name + "Font = new Font(\"" + font.FontFamily.Name + "\", " +
                 font.Size.ToString() + "f * (" + Size.Width + "f / (float)shapeBoundsOld.Width), (FontStyle)" + (int)font.Style + ");\r\n" +
             "StringFormat " + this.Name + "Format = new StringFormat();\r\n" +
             this.Name + "Format.Alignment = (StringAlignment)" + (int)format.Alignment + ";\r\n";

            if (blnScaleText)
                str += "//Will apply the scaling factors to the graphics object\r\n"+
                 graphicsName + ".ScaleTransform(scale.Width, scale.Height);\r\n";

            if (painter.PaintWithPath)
            {
                str += "path = new GraphicsPath();\r\n" +
                "path.AddString(" +strText + ", " + this.Name +
                            "Font.FontFamily ,(int)" + this.Name + "Font.Style," +
                           this.Name + "Font.Size,\r\n" + strBounds+ "," +
                           this.Name + "Format);\r\n" +

                 helper.GeneratePaintToolInit(this, "path.GetBounds()",false) +

                 "//Paint the text\r\n";
                if (painter.PaintFill)
                    str += graphicsName + ".FillPath(" + this.Name + "Brush, path);\r\n";
                if (painter.PaintBorder)
                    str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n";
            }
            else
            {
                str += graphicsName + ".DrawString("+ strText +", " +
                    this.Name + "Font, " + this.Name + "Brush, "+ strBounds +", "
                    + this.Name + "Format);\r\n";
            }
            if (blnScaleText)
                str += graphicsName + ".ResetTransform();\r\n";

            str += "//Cleanup Text objects\r\n"+
                   this.Name + "Font.Dispose();\r\n"+
                   this.Name +"Format.Dispose();\r\n"+
                helper.GeneratePaintToolCleanup(this);
            return str;
        }
Пример #14
0
 public abstract string EmitGDICode(string graphicsName, GDIGenerationTool helper);
Пример #15
0
        public override string EmitGDICode(string graphicsName, GDIGenerationTool helper)
        {
            string str = "//Line: " + this.Name + "\r\n" +
            helper.GeneratePaintToolInit(this) +

            generatePointArray(helper) +

            "//Paint the shape\r\n";
                str += graphicsName + ".DrawCurve(" + this.Name + "Pen," + this.Name + "Points);\r\n";

            str += helper.GeneratePaintToolCleanup(this);
            return str;
        }
Пример #16
0
        public string generatePointArray(GDIGenerationTool helper)
        {
            return "PointF[] " + this.Name + "Points = { " +
               "new PointF(" + (points[0].X - helper.AreaBounds.X) + "f," +
                   (points[0].Y - helper.AreaBounds.Y) + "f)," +
               "new PointF(" + (points[1].X - helper.AreaBounds.X) + "f," +
                   (points[1].Y - helper.AreaBounds.Y) + "f)," +
               "new PointF(" + (points[2].X - helper.AreaBounds.X) + "f," +
                   (points[2].Y - helper.AreaBounds.Y) + "f)," +
               "new PointF(" + (points[3].X - helper.AreaBounds.X) + "f," +
                   (points[3].Y - helper.AreaBounds.Y) + "f)\r\n};\r\n" +

               "ScalePoints(ref " + this.Name + "Points, shapeBoundsOld, shapeBoundsNew);\r\n";
        }