Exemplo n.º 1
0
        internal void Paste()
        {
            BinaryFormatter bf = new BinaryFormatter();

            ms.Position = 0;
            List <Shape> pastedShapeList = new List <Shape>();

            try
            {
                pastedShapeList = (List <Shape>)bf.Deserialize(ms);
                foreach (var item in pastedShapeList)
                {
                    ShapeList.Add(item);
                }
                Clipboard.SetData("My Format", ms);
            }
            catch (IOException e)
            {
                MessageBox.Show("something happened");
            }
            catch (SerializationException e)
            {
                MessageBox.Show("copy something so you can paste it");
            }
        }
Exemplo n.º 2
0
        internal void Copy()
        {
            Shape shape = new Shape();

            if (selection != null)
            {
                shape = selection;
                if (shape.ShapeType == "Rectangle")
                {
                    shape = new RectangleShape(new Rectangle((int)shape.Location.X, (int)shape.Location.Y,
                                                             (int)shape.Width, (int)shape.Height));

                    CopyHelp(shape);
                }
                if (shape.ShapeType == "Ellipse")
                {
                    shape = new EllipseShape(new Rectangle((int)shape.Location.X, (int)shape.Location.Y,
                                                           (int)shape.Width, (int)shape.Height));
                    CopyHelp(shape);
                }


                ShapeList.Add(shape);
            }
        }
Exemplo n.º 3
0
        public void GroupRemoveSelection()
        {
            if (Selection.Count < 1)
            {
                return;
            }


            try
            {
                foreach (Shape item in group.SubItems)
                {
                    //ShapeList.Remove(item);
                    //item.Selected = false;

                    ShapeList.Remove(group);
                    ShapeList.Add(item);
                }
                group.SubItems = new List <Shape>();
                Selection      = new List <Shape>();
            }
            catch (NullReferenceException ex)
            {
                RemoveSelection();
                ex.Message.ToString();
            }
        }
Exemplo n.º 4
0
        public void CoppyShape()
        {
            if (Selection != null)
            {
                Node CopyItem = new Node(new RectangleF(0, 0, 0, 0), "");
                foreach (Shape item in Selection)
                {
                    switch (item.ShapeType())
                    {
                    case "node":
                        String weight = item.getWeight();
                        CopyItem = new Node(new Rectangle(Convert.ToInt32(item.Location.X + 4),
                                                          Convert.ToInt32(item.Location.Y + 4), Convert.ToInt32(item.Width), Convert.ToInt32(item.Height)), weight);
                        CopyItem.SetOpacity(item.OpacityLvl);
                        CopyItem.FillColor = item.FillColor;
                        String MyNodeName = "Copy of " + item.MyName;
                        CopyItem.SetName(MyNodeName);
                        MainForm.MyGraph.addNodeToMap(MyNodeName, CopyItem);
                        break;

                    default: break;
                    }
                }
                ShapeList.Add(CopyItem);
            }
        }
Exemplo n.º 5
0
 internal void Paste()
 {
     if (Current != null)
     {
         try
         {
             if (isGroupActive && !isMultigroupActive)
             {
                 GroupShape gs = (GroupShape)DeSerialize();
                 PointF     p  = gs.Location;
                 TranslateTo(p);
                 ShapeList.Add(gs);
             }
             else
             {
                 Shape  s = (Shape)DeSerialize();
                 PointF p = s.Location;
                 s.Location = Current;
                 TranslateTo(p);
                 ShapeList.Add(s);
             }
         }
         catch (Exception e)
         {
         }
     }
 }
Exemplo n.º 6
0
 public void SpawnByPanel(List <Shape> shapePanel)
 {
     foreach (var item in shapePanel)
     {
         ShapeList.Add(item);
     }
 }
Exemplo n.º 7
0
 public void SelectAll()
 {
     Selection = new List <Shape>(ShapeList);
     foreach (Shape item in Selection)
     {
         ShapeList.Add(item);
     }
 }
Exemplo n.º 8
0
        public void AddCustomRectangle(int x, int y, Color col)
        {
            RectangleShape rect = new RectangleShape(new Rectangle(211, 100, x, y));

            rect.FillColor   = col;
            rect.BorderColor = Pens.Black;
            rect.ShapeType   = "Rectangle";

            ShapeList.Add(rect);
        }
 internal void PasteItems(PointF mouseLocation)
 {
     foreach (var s in shapeCopies)
     {
         Shape copy = (Shape)s.Clone();
         copy.Location    = mouseLocation;
         copy.BorderColor = Color.Black;
         ShapeList.Add(copy);
     }
 }
Exemplo n.º 10
0
        public void AddRandomLine()
        {
            // Random rnd = new Random();

            LineShape line = new LineShape(PointStart, PointEnd);

            line.BorderColor = ColorBorder;

            ShapeList.Add(line);
        }
Exemplo n.º 11
0
        public void addModelShape()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            ModelShape shape = new ModelShape(new RectangleF(x, y, 100, 100));

            ShapeList.Add(shape);
        }
Exemplo n.º 12
0
        public void AddCustomEllipse(int x, int y, Color col)
        {
            EllipseShape elipse = new EllipseShape(new Rectangle(211, 100, x, y));

            elipse.FillColor   = col;
            elipse.BorderColor = Pens.Black;
            elipse.ShapeType   = "Ellipse";

            ShapeList.Add(elipse);
        }
Exemplo n.º 13
0
        public void addRandomDot()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            DotShape dot = new DotShape(new RectangleF(x, y, 20, 20));

            ShapeList.Add(dot);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Добавя примитив - правоъгълник на произволно място върху клиентската област.
        /// </summary>
        public void AddRandomRectangle()
        {
            Random         rnd  = new Random();
            int            x    = rnd.Next(100, 1000);
            int            y    = rnd.Next(100, 600);
            RectangleShape rect = new RectangleShape(new Rectangle(x, y, 100, 200));

            rect.FillColor = Color.White;
            ShapeList.Add(rect);
        }
Exemplo n.º 15
0
        public void AddElipse()
        {
            Random      rnd   = new Random();
            int         x     = rnd.Next(100, 1000);
            int         y     = rnd.Next(100, 600);
            ElipseShape shape = new ElipseShape(new Rectangle(x, y, 100, 100));

            shape.FillColor = Color.White;
            ShapeList.Add(shape);
        }
Exemplo n.º 16
0
 //------------------------------------------
 // Select or Create
 //------------------------------------------
 private void OnPanelMousePressed(object sender, MouseEventArgs e)
 {
     if (_drawing)
     {
         SearchForFigure(e.Location);
         _tl = e.Location;
         var figure = ShapeFactory.Create(_shapeName, _tl, _tl);
         if (figure != null)
         {
             _shapes.Add(figure);
         }
         _pressed = true;
     }
     else if (_shapes.Count() > 0)
     {
         Point point = e.Location;
         SearchForFigure(point);
     }
 }
Exemplo n.º 17
0
        public void addRandomSquare()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            SquareShape square = new SquareShape(new RectangleF(x, y, 50, 50));

            ShapeList.Add(square);
        }
Exemplo n.º 18
0
        public void AddRandomFilledRectangle(Color fillColor)
        {
            GetRandomDimensions(out var location, out var size);
            var rect = new RectangleShape(location, size)
            {
                FillColor   = fillColor,
                BorderColor = Color.Transparent,
            };

            ShapeList.Add(rect);
        }
Exemplo n.º 19
0
        public void AddRandomFilledPolygon(Color fillColor, int points)
        {
            GetRandomDimensions(out var location, out var size);
            var triangle = new PolygonShape(location, size.Width, points)
            {
                FillColor   = fillColor,
                BorderColor = Color.Transparent,
            };

            ShapeList.Add(triangle);
        }
Exemplo n.º 20
0
        public void AddRandomFilledElipse(Color fillColor)
        {
            GetRandomDimensions(out var location, out var size);
            var ellipse = new EllipseShape(location, size)
            {
                FillColor   = fillColor,
                BorderColor = Color.Transparent,
            };

            ShapeList.Add(ellipse);
        }
Exemplo n.º 21
0
        public void AddRandomCircle()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            CircleShape circle = new CircleShape(new Rectangle(x, y, 200, 200));

            circle.FillColor   = Color.DarkCyan;
            circle.BorderColor = Color.LimeGreen;
            ShapeList.Add(circle);
        }
Exemplo n.º 22
0
        // added from me


        public void AddRandomSquare()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            SquareShape square = new SquareShape(new Rectangle(x, y, 200, 200));

            square.FillColor   = Color.Yellow;
            square.BorderColor = Color.Red;
            ShapeList.Add(square);
        }
Exemplo n.º 23
0
        public void AddRandomCircle()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            CircleShape elipse = new CircleShape(new Rectangle(x, y, 100, 100));

            elipse.FillColor = Color.White;

            ShapeList.Add(elipse);
        }
Exemplo n.º 24
0
        public void AddRandomSquare()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            SquareShape square = new SquareShape(new Rectangle(x, y, 100, 100));

            square.FillColor = Color.White;

            ShapeList.Add(square);
        }
Exemplo n.º 25
0
        public void AddRandomElipse()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            ElipseShape elip = new ElipseShape(new Rectangle(x, y, 200, 100));

            elip.FillColor   = Color.White;
            elip.BorderColor = Color.Blue;
            ShapeList.Add(elip);
        }
Exemplo n.º 26
0
        public void AddLine(PointF pt1, PointF pt2)
        {
            Line line = new Line(pt1, pt2);

            line.Outline   = new RectangleF(line.path.GetBounds().X, line.path.GetBounds().Y, line.Width, line.Height);
            line.Opacity   = 255;
            line.FillColor = Color.FromArgb(line.Opacity, 45, 134, 89);
            ShapeList.Add(line);
            Selection = line;

            updateSelected();
        }
Exemplo n.º 27
0
        public void AddRandomEllipse()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 500);
            int    y   = rnd.Next(100, 300);

            EllipseShape rect = new EllipseShape(new Rectangle(x, y, 50, 100));

            rect.FillColor = Color.White;

            ShapeList.Add(rect);
        }
Exemplo n.º 28
0
        public void AddRandomX()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            XShape xShape = new XShape(new Rectangle(x, y, 200, 100));

            xShape.BorderColor = Color.Black;

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

            RectangleShape rectangle = new RectangleShape(new Rectangle(x, y, 100, 200));

            rectangle.FillColor   = Color.DeepSkyBlue;
            rectangle.BorderColor = Color.Green;
            ShapeList.Add(rectangle);
        }
Exemplo n.º 30
0
        public void AddCircle(PointF pt1, PointF pt2)
        {
            Circle circle = new Circle(pt1, pt2);

            circle.Outline   = new RectangleF(circle.path.GetBounds().X, circle.path.GetBounds().Y, circle.Width, circle.Height);
            circle.Opacity   = 255;
            circle.FillColor = Color.FromArgb(circle.Opacity, 45, 134, 89);
            ShapeList.Add(circle);
            Selection = circle;

            updateSelected();
        }