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" ////} }
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; } }
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); } }
public AddLineCommand(ObservableCollection<LineViewModel> _lines, LineViewModel _line) { lines = _lines; line = _line; }