Ejemplo n.º 1
0
        public void AddRandomTriangle()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            TriangleShape triangle = new TriangleShape(new Rectangle(x, y, 300, 150));


            triangle.FillColor   = Color.Lime;
            triangle.BorderColor = Color.Red;
            ShapeList.Add(triangle);
        }
Ejemplo n.º 2
0
        public void AddTriangle()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            TriangleShape rect = new TriangleShape(new Rectangle(x, y, 150, 150));

            rect.FillColor = Color.White;

            ShapeList.Add(rect);
            BackList.Add(rect);
        }
Ejemplo n.º 3
0
        public void addRandomTriangle()
        {
            Random rnd = new Random();

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

            TriangleShape triangle = new TriangleShape(new RectangleF(x, y, z, w));

            ShapeList.Add(triangle);
        }
Ejemplo n.º 4
0
        public void AddRandomTriangle()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            TriangleShape tri = new TriangleShape(new Rectangle(x, y, 100, 200));

            tri.FillColor   = Color.White;
            tri.BorderColor = Color.Black;
            tri.Opacity     = 255;

            ShapeList.Add(tri);
        }
Ejemplo n.º 5
0
        public void AddTriangle(PointF p1, PointF p2, PointF p3, DashStyle dashStyle, bool temporary = false, int transparency = 255)
        {
            Shape triangle = new TriangleShape(p1, p2, p3, Color.Black, Color.FromArgb(transparency, Color.White), dashStyle, temporary);

            ShapeList[CurrentTab].Add(triangle);
        }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 7
0
        public void AddRandomTriangle(SizeF size)
        {
            Random rnd = new Random();

            int   x   = rnd.Next(100, 1000); //Generate random position for the rectangle
            int   y   = rnd.Next(100, 600);
            float p1x = 0;                   //Left most x in the rectangle
            //////    float p1y = 100;  //Manually
            //////    float p2x = 150;  //Manually
            //////    float p2y = 100;             // the top most Y edge of the rectangle
            float p2x = 150; // Changes size

            float p3x = (p2x + p1x) / 2;
            float p3y = 0;

            float p1y = (float)Math.Sqrt(p2x * p2x - (p2x / 2) * (p2x / 2));

            //////    float p2y = 100;  //Manually
            float p2y = (float)Math.Sqrt(p2x * p2x - (p2x / 2) * (p2x / 2));

            float[] edges = new float[3];

            edges[0] = p1x;
            edges[1] = p2x;
            edges[2] = p3x;

            int x1 = 10000; //leftmost x Unused
            int x2 = 0;     //rightmost x

            for (int i = 0; i < edges.Length; i++)
            {
                if (edges[i] < x1)
                {
                    x1 = (Int32)edges[i];
                }
                if (edges[i] > x2)
                {
                    x2 = (Int32)edges[i];
                }
            }

            edges[0] = p1y;
            edges[1] = p2y;
            edges[2] = p3y;

            int y1 = 10000; //top y Unused
            int y2 = 0;     //bottom y

            for (int i = 0; i < edges.Length; i++)
            {
                if (edges[i] < y1)
                {
                    y1 = (Int32)edges[i];
                }
                if (edges[i] > y2)
                {
                    y2 = (Int32)edges[i];
                }
            }
            TriangleShape triangle = new TriangleShape(new Rectangle(x, y, x2, y2));

            triangle.Edges(p1x, p1y, p2x, p2y, p3x, p3y);

            triangle.TriangleSize = p2x;
            triangle.FillColor    = ColorFill;
            triangle.Rotation     = Rotation;
            triangle.BorderColor  = ColorBorder;

            ShapeList.Add(triangle);
            if (size.Width != 0 || size.Height != 0)
            {
                triangle.Size = size;
            }
        }