예제 #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");
            }
        }
예제 #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);
            }
        }
예제 #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();
            }
        }
예제 #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);
            }
        }
예제 #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)
         {
         }
     }
 }
예제 #6
0
 public void SpawnByPanel(List <Shape> shapePanel)
 {
     foreach (var item in shapePanel)
     {
         ShapeList.Add(item);
     }
 }
예제 #7
0
 public void SelectAll()
 {
     Selection = new List <Shape>(ShapeList);
     foreach (Shape item in Selection)
     {
         ShapeList.Add(item);
     }
 }
예제 #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);
     }
 }
예제 #10
0
        public void AddRandomLine()
        {
            // Random rnd = new Random();

            LineShape line = new LineShape(PointStart, PointEnd);

            line.BorderColor = ColorBorder;

            ShapeList.Add(line);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }