Esempio n. 1
0
        public override BaseShape copySelf()
        {
            LineShape copyLineShape = new LineShape();

            copyLineShape.setP1(this.getP1());
            copyLineShape.setP2(this.getP2());
            copyLineShape.penColor = this.penColor;
            copyLineShape.penWidth = this.penWidth;
            return(copyLineShape);
        }
Esempio n. 2
0
        public void AddRandomLine()
        {
            // Random rnd = new Random();

            LineShape line = new LineShape(PointStart, PointEnd);

            line.BorderColor = ColorBorder;

            ShapeList.Add(line);
        }
Esempio n. 3
0
        public void addRandomLine()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            int z = rnd.Next(100, 1000);
            int w = rnd.Next(100, 600);

            LineShape line = new LineShape(new RectangleF(x, y, z, w));

            ShapeList.Add(line);
        }
Esempio n. 4
0
        /// <summary>
        /// Добавя примитив - линия на произволно място върху клиентската област.
        /// </summary>
        public void AddRandomLine(Color borderColor)
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            LineShape line = new LineShape(new Rectangle(x, y, 150, 0));

            {
                line.FillColor   = borderColor;
                line.BorderColor = borderColor;
            }

            ShapeList.Add(line);
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var shapeListJson    = File.ReadAllText("save.json");
            var shapeListObjects = JsonConvert.DeserializeObject <List <string> >(shapeListJson);

            var shapeList = new List <Shape>();

            foreach (var shapeObject in shapeListObjects)
            {
                var parts = shapeObject.Split('|');

                var shapeType       = parts[0];
                var shapeProperties = parts[1];

                Shape currentShape = JsonConvert.DeserializeObject <Shape>(shapeProperties);
                Shape typizedShape = null;

                if (shapeType == "rectangle")
                {
                    typizedShape = new RectangleShape(currentShape.Rectangle);
                }
                else if (shapeType == "line")
                {
                    typizedShape = new LineShape(currentShape.Rectangle);
                }
                else if (shapeType == "elipse")
                {
                    typizedShape = new ElipseShape(currentShape.Rectangle);
                }

                else if (shapeType == "circle")
                {
                    typizedShape = new CirlceWithLines(currentShape.Rectangle);
                }

                // ToDo serialize Color
                typizedShape.FillColor   = this.lastSelectedFillColor;
                typizedShape.BorderColor = this.lastSelectedBorderColor;

                shapeList.Add(typizedShape);
            }

            this.dialogProcessor.ShapeList = shapeList;

            this.viewPort.Invalidate();
        }
Esempio n. 6
0
        public LineShape(PointF x, PointF y, LineShape line)//angle point 1 & 2
        {
            PointF s = new Point(Convert.ToInt32(x.X), Convert.ToInt32(x.Y));
            PointF f = new Point(Convert.ToInt32(y.X), Convert.ToInt32(y.Y));
            PointF C = new Point(10, 10);//angle point 2

            C.X = x.X;
            C.Y = y.Y - x.Y;
            PointF B = new Point(10, 10);//angle point 3

            B.X = y.X - x.X;
            B.Y = y.Y;
            float width  = B.X;
            float height = C.Y;

            line = new LineShape(new Rectangle(Convert.ToInt32(s.X), Convert.ToInt32(s.Y), Convert.ToInt32(B.X), Convert.ToInt32(C.Y)),
                                 new Rectangle(Convert.ToInt32(f.X), Convert.ToInt32(f.Y), Convert.ToInt32(B.X), Convert.ToInt32(C.Y)));
            DialogProcessor.ShapeList.Add(line);
        }
Esempio n. 7
0
        public void AddRandomLine(SizeF size)
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);
            float  x1  = 7;            //Left most x in the rectangle
            float  x2  = 7;
            // float y1 = 0;
            float y2 = 150;                  //Height

            int width = (Int32)(14);         //Width of Rect=10 pixels to the right of start
                                             //  int p1y = (Int32)(y1 - 5);
            int   height      = (Int32)(y2); //HeightOfRectangle
            float pointStartX = x1;
            float pointEndX   = x2;

            float pointStartY = 0;
            float pointEndY   = y2; //150=height-5

            float[] edges = new float[4];

            LineShape line = new LineShape(new Rectangle(x, y, width, height));

            line.edges(pointStartX, pointStartY, pointEndX, pointEndY);

            //LineShape line = new LineShape(PointStart, PointEnd);
            line.PercentY = 1;
            if (size.Height != 0)
            {
                line.IsBeingResized = true;
                line.LineSize       = size.Height;
                line.PercentY       = size.Height / line.Size.Height;
                line.Size           = new SizeF(line.Size.Width, size.Height);
            }

            ShapeList.Add(line);
            line.FillColor   = ColorFill;
            line.Rotation    = Rotation;
            line.BorderColor = ColorBorder;
        }
        public void AddLine(PointF p1, PointF p2, DashStyle dashStyle, bool temporary = false, int transparency = 255)
        {
            Shape triangle = new LineShape(p1, p2, Color.Black, Color.FromArgb(transparency, Color.White), dashStyle, temporary);

            ShapeList[CurrentTab].Add(triangle);
        }
 public LineShape(LineShape line) : base(line)
 {
 }
Esempio n. 10
0
        public void Paste()
        {
            foreach (var item in CopyData.ToList())
            {
                if (item.GetType() == typeof(RectangleShape))
                {
                    RectangleShape rect = new RectangleShape(new Rectangle((int)item.Location.X + 200, (int)item.Location.Y, 100, 200))
                    {
                        BorderColor = item.BorderColor,
                        FillColor   = item.FillColor,
                        Height      = item.Height,
                        Width       = item.Width,
                        Rotation    = item.Rotation
                    };
                    ShapeList.Add(rect);
                }

                else if (item.GetType() == typeof(EllipseShape))
                {
                    EllipseShape ellipse = new EllipseShape(new Rectangle((int)item.Location.X + 200, (int)item.Location.Y, 100, 200))
                    {
                        BorderColor = item.BorderColor,
                        FillColor   = item.FillColor,
                        Height      = item.Height,
                        Width       = item.Width,
                        Rotation    = item.Rotation
                    };
                    ShapeList.Add(ellipse);
                }

                else if (item.GetType() == typeof(TriangleShape))
                {
                    TriangleShape triangle = new TriangleShape(new Rectangle((int)item.Location.X + 200, (int)item.Location.Y, 100, 200))
                    {
                        PercentX       = item.PercentX,
                        PercentY       = item.PercentY,
                        IsBeingResized = item.IsBeingResized,
                        Point1         = item.Point1,
                        Point2         = item.Point2,

                        x1 = item.x1,
                        x2 = item.x2,
                        x3 = item.x3,
                        y1 = item.y1,
                        y2 = item.y2,
                        y3 = item.y3,

                        Polygon      = item.Polygon,
                        TriangleSize = item.TriangleSize,
                        BorderColor  = item.BorderColor,
                        FillColor    = item.FillColor,
                        Height       = item.Height,
                        Width        = item.Width,
                        Rotation     = item.Rotation
                    };
                    ShapeList.Add(triangle);
                }

                else if (item.GetType() == typeof(LineShape))
                {
                    LineShape line = new LineShape(new Rectangle((int)item.Location.X + 200, (int)item.Location.Y, 100, 200))
                    {
                        x1             = item.x2,
                        x2             = item.x2,
                        y1             = item.y1,
                        y2             = item.y2,
                        LineSize       = item.LineSize,
                        Point1         = item.Point1,
                        Point2         = item.Point2,
                        IsBeingResized = item.IsBeingResized,
                        Polygon        = item.Polygon,
                        TriangleSize   = item.TriangleSize,
                        BorderColor    = item.BorderColor,
                        FillColor      = item.FillColor,
                        Height         = item.Height,
                        Width          = item.Width,
                        Rotation       = item.Rotation
                    };
                    ShapeList.Add(line);
                }

                else if (item.GetType() == typeof(TrapezoidShape))
                {
                    TrapezoidShape trape = new TrapezoidShape(new Rectangle((int)item.Location.X + 200, (int)item.Location.Y, 100, 200))
                    {
                        LineSize     = item.LineSize,
                        Polygon      = item.Polygon,
                        TriangleSize = item.TriangleSize,
                        BorderColor  = item.BorderColor,
                        FillColor    = item.FillColor,
                        Height       = item.Height,
                        Width        = item.Width,
                        Rotation     = item.Rotation
                    };
                    ShapeList.Add(trape);
                }
            }
        }
Esempio n. 11
0
 private void lineToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ShapeToDraw       = new LineShape();
     shapeButton.Image = lineButton.Image;
 }