Example #1
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            pictureBox1.Invalidate();
            if (stripChoice == ToolStripChoice.DrawFigure)
            {
                if (e.IsStartPoint(collection))
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.MoveVertice)
            {
                if (isMoving)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        Figure fig = collection.GetFigure(clickedPoint);
                        fig.MovePoint(clickedPoint, new Vertice(e.X, e.Y));
                    }
                }

                if (e.IsPoint(collection))
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.MoveEdge)
            {
                Edge edge = collection.GetEdgeFromPoint(new Vertice(e.X, e.Y));
                if (edge != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }

                if (isMoving && clickedEdge != null)
                {
                    Figure figure = collection.GetFigure(clickedEdge);
                    int    X      = e.X - clickedPointOnEdge.x;
                    int    Y      = e.Y - clickedPointOnEdge.y;
                    clickedPointOnEdge.x = e.X;
                    clickedPointOnEdge.y = e.Y;
                    figure.MoveEdge(clickedEdge, X, Y);
                }
            }

            if (stripChoice == ToolStripChoice.MoveFigure)
            {
                Figure figure = collection.GetFigureFromClickOnBorder(new Vertice(e.X, e.Y));
                if (figure != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Cross;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }

                if (isMoving && clickedFigure != null)
                {
                    int X = e.X - clickedPointOnFigure.x;
                    int Y = e.Y - clickedPointOnFigure.y;
                    clickedPointOnFigure.x = e.X;
                    clickedPointOnFigure.y = e.Y;
                    clickedFigure.MoveFigure(X, Y);
                }
            }

            if (stripChoice == ToolStripChoice.RemoveFigure)
            {
                Figure figure = collection.GetFigureFromClickOnBorder(new Vertice(e.X, e.Y));
                if (figure != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Cross;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.AddPoint)
            {
                Edge edge = collection.GetEdgeFromPoint(new Vertice(e.X, e.Y));
                if (edge != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.RemovePoint)
            {
                if (e.IsPoint(collection))
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.AddRelation)
            {
                Edge edge = collection.GetEdgeFromPoint(new Vertice(e.X, e.Y));
                if (edge != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }

            if (stripChoice == ToolStripChoice.RemoveRelation)
            {
                Edge edge = collection.GetEdgeFromPoint(new Vertice(e.X, e.Y));
                if (edge != null)
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                }
            }
        }