예제 #1
0
        private void GridNetwork_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDragging == true)
            {
                Debug.WriteLine("Moving mouse on network canvas");
                Debug.WriteLine("MAKING connection");
                var currentPosition = e.GetPosition(net_canvas);
                Debug.WriteLine("Current position: " + currentPosition.X.ToString() + "," + currentPosition.Y.ToString());
                secondPosition = currentPosition;
                var currentLine = new Line {
                    From = new Point(firstPosition.X, firstPosition.Y), To = new Point(secondPosition.X, secondPosition.Y), Stroke = Brushes.Green, StrokeThickness = 10
                };
                if (indexCurrentLine >= 1)
                {
                    Debug.WriteLine(indexCurrentLine);
                    CurrentConnection.RemoveAt(indexCurrentLine - 1);
                }
                CurrentConnection.Add(currentLine);
            }
            else
            {
                if (Nodes.Count() != 0)
                {
                    //CurrentConnection.Add(new Line
                    //{
                    //    From = new Point(firstPosition.X, firstPosition.Y),
                    //    To = new Point(Nodes[0].X, Nodes[0].Y),
                    //    Stroke = Brushes.BlueViolet,
                    //    StrokeThickness = 3
                    //});

                    //var currentLine = new Line { From = new Point(Nodes[0].X, Nodes[0].Y + Nodes[0].ActualHeight/ 2),
                    //    To = new Point(secondPosition.X, secondPosition.Y),
                    //    Stroke = Brushes.BlueViolet, StrokeThickness = 3 };
                    //if (indexCurrentLine >= 1)
                    //{
                    //    Debug.WriteLine(indexCurrentLine);
                    //    CurrentConnection.RemoveAt(indexCurrentLine - 1);
                    //}
                    //CurrentConnection.Add(currentLine);
                    //for (int i = 0; i < Connections.Count(); i++)
                    //{
                    //    var currentLine = new Line
                    //    {
                    //        From = new Point(Nodes[0].X, Nodes[0].Y + Nodes[0].ActualHeight / 2),
                    //        To = new Point(secondPosition.X, secondPosition.Y),
                    //        Stroke = Brushes.BlueViolet,
                    //        StrokeThickness = 3
                    //    };
                    //    Connections.Add(currentLine);
                    //}
                }
            }
            indexCurrentLine = CurrentConnection.Count() - 1;
        }