示例#1
0
 public AddLineCommand(ObservableCollection<LineViewModel> _lines, LineViewModel _line, NodeViewModel _fromNode, NodeViewModel _toNode)
 {
     lines = _lines;
     line = _line;
     fromNode = _fromNode;
     toNode = _toNode;
 }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     NodeViewModel = new NodeViewModel(LineViewModel);
     LineViewModel = new LineViewModel(NodeViewModel);
     ////if (IsInDesignMode)
     ////{
     ////    // Code runs in Blend --> create design time data.
     ////}
     ////else
     ////{
     ////    // Code runs "for real"
     ////}
 }
示例#3
0
 public void addNeighbourAndLineAndUpdatePosition(NodeViewModel n1, NodeViewModel n2)
 {
     n1.addNeighbour(n2);
     LineViewModel temp = new LineViewModel(new Line()) { From = n1, To = n2 };
     Lines.Add(temp);
     addedLinesAutoBalance.Add(temp);
     if(int.Parse(n1.TxtOne) > int.Parse(n2.TxtOne))
     {
         n1.X = n2.X + X_OFFSET;
         n1.Y = n2.Y + Y_OFFSET;
     }
     else
     {
         n1.X = n2.X - X_OFFSET;
         n1.Y = n2.Y + Y_OFFSET;
     }
 }
示例#4
0
        public void Execute()
        {
            clearSelectedNodes();
            foreach (NodeViewModel n in copiedNodes)
            {
                NodeViewModel node = n.newNodeViewModel();
                node.X += 30;
                node.Y += 30;
                Nodes.Add(node);
                addToSelectedNodes(node);
                mostRecentPastedNodes.Add(node);
            }

            foreach (LineViewModel l in copiedLines)
            {
                LineViewModel line = new LineViewModel(new Line() { From = l.From.Node, To = l.To.Node }) { From = l.From, To = l.To };
                foreach (NodeViewModel n in mostRecentPastedNodes)
                {

                    if (line.To.X + 30 == n.X && line.To.Y + 30 == n.Y)
                    {
                        line.To = n;

                    }
                    if (line.From.X + 30 == n.X && line.From.Y + 30 == n.Y)
                    {
                        line.From = n;

                    }
                }
                Lines.Add(line);
                line.From.addNeighbour(line.To);
                mostRecentPastedLines.Add(line);

            }
        }
示例#5
0
 public AddLineCommand(ObservableCollection<LineViewModel> _lines, LineViewModel _line)
 {
     lines = _lines;
     line = _line;
 }