private void On_Mouse_Move(Object sender, MouseEventArgs e)
        {
            VertexView v_on_over = VertexHitTest(new Point(e.X, e.Y));
            EdgeView   e_on_over = EdgeHitTest(new Point(e.X, e.Y));

            foreach (VertexView v in Views.OfType <VertexView>())
            {
                if (v_on_over != null && v == v_on_over)
                {
                    v_on_over.Raise_MouseEnter();
                    v_on_over.Raise_MouseMove();
                }
                else
                {
                    v.Raise_MouseLeave();
                }
            }

            foreach (EdgeView v in Views.OfType <EdgeView>())
            {
                if (e_on_over != null && v == e_on_over)
                {
                    e_on_over.Raise_MouseEnter();
                }
                else
                {
                    v.Raise_MouseLeave();
                }
            }



            Refresh();
        }
        public void On_EdgeRemoved(Graph sender, Edge edge)
        {
            EdgeView e = canvasView1.FindViewByEdge(edge);

            if (e != null)
            {
                canvasView1.Views.Remove(e);
            }
            canvasView1.Refresh();
        }
        public void On_EdgeAdded(Graph sender, Edge edge)
        {
            EdgeView e = new EdgeView();

            e.Edge   = edge;
            e.Point1 = canvasView1.FindViewByVertex(edge.Vertex1).Location;
            e.Point2 = canvasView1.FindViewByVertex(edge.Vertex2).Location;
            canvasView1.Views.Add(e);
            e.MouseClick += On_MouseClick;
            canvasView1.Refresh();
        }
 void On_MouseClick(IView sender)
 {
     SelectedEdge          = sender as EdgeView;
     EdgeEdit.Top          = (int)(sender as EdgeView).valR.Top + canvasView1.Top;
     EdgeEdit.Left         = (int)(sender as EdgeView).valR.Left + canvasView1.Left;
     EdgeEdit.Text         = (sender as EdgeView).Val;
     EdgeEdit.Visible      = true;
     btnRemoveEdge.Top     = EdgeEdit.Top;
     btnRemoveEdge.Left    = EdgeEdit.Left - EdgeEdit.Height;
     btnRemoveEdge.Width   = EdgeEdit.Height;
     btnRemoveEdge.Height  = EdgeEdit.Height;
     btnRemoveEdge.Visible = true;
     EdgeEdit.BringToFront();
     EdgeEdit.Focus();
     EdgeEdit.SelectAll();
 }
        private void On_Mouse_Down(Object sender, MouseEventArgs e)
        {
            foreach (VertexView v in Views.OfType <VertexView>())
            {
                v.IsSelected = false;
            }
            VertexView on_down = VertexHitTest(new Point(e.X, e.Y));

            if (on_down != null)
            {
                on_down.Raise_MouseDown();
            }

            EdgeView on_click = EdgeHitTest(new Point(e.X, e.Y));

            if (on_click != null)
            {
                on_click.Raise_MouseClick();
            }

            Refresh();
        }