Beispiel #1
0
        private void GridNetwork_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Debug.WriteLine("BEFORE");
            Debug.WriteLine("Number of CurrentConnection: " + CurrentConnection.Count().ToString());
            Debug.WriteLine("Number of Connections: " + Connections.Count().ToString());
            Debug.WriteLine("Number of Nodes: " + Nodes.Count().ToString());
            foreach (var iNode in Nodes)
            {
                Debug.WriteLine("---------------------------------------------------------------");
                Debug.WriteLine(String.Format("NODE GRAPH     : {0}", iNode.LayerType.ToString()));
                Debug.WriteLine(String.Format("       ID      : {0}", iNode.ID));
                Debug.WriteLine(String.Format("       location: ({0},{1})", iNode.X, iNode.Y));
                Debug.WriteLine(String.Format("       seq_id  : {0}", iNode.seq_id.ToString()));
                Debug.WriteLine(String.Format("       name    : {0}", iNode.NameLayer.ToString()));
            }
            Connections.Clear();
            CurrentConnection.Clear();
            //Nodes.Clear();
            Debug.WriteLine("AFTER");
            Debug.WriteLine("Number of CurrentConnection: " + CurrentConnection.Count().ToString());
            Debug.WriteLine("Number of Connections: " + Connections.Count().ToString());
            Debug.WriteLine("Number of Nodes: " + Nodes.Count().ToString());
            indexCurrentLine = CurrentConnection.Count() - 1;

            //net_canvas.Children.Clear();
        }
Beispiel #2
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;
        }