public override void BeginEdit() { base.BeginEdit(); PartLinks.BeginEdit(); PartConnector.BeginEdit(); }
public CollectionPartConnectorViewModel(PartConnectorViewModel partConnector) { PartConnector = partConnector; AddCmd = new AsyncCommand(OnAdd, CanAdd, true); RemoveCmd = new RelayCommand(Remove, CanRemove); PartConnector.PartLinks.ForEach(pl => AddPartLink(partConnector, pl)); SelectedPartLink = PartLinks.FirstOrDefault(); }
private SinglePartConnectorPartViewModel AddPartLink(PartConnectorViewModel partConnector, PartLinkViewModel partLink) { var link = new SinglePartConnectorPartViewModel(partConnector, partLink) { DialogManager = DialogManager, PartDialogsFactory = PartDialogsFactory }; PartLinks.Add(link); return(link); }
public override void CancelEdit() { // Remove newly created part links PartLinks.RemoveRange(_newLinks); _newLinks.Clear(); // Add removed again PartLinks.AddRange(_removedLinks); _removedLinks.Clear(); // Cancel on existent PartLinks.CancelEdit(); PartConnector.CancelEdit(); base.CancelEdit(); }
public override void EndEdit() { // End on part links PartLinks.ForEach(p => p.EndEdit()); // Add new links var newLinks = _newLinks.Select(n => n.PartLink); PartConnector.PartLinks.AddRange(newLinks); _newLinks.Clear(); // Remove removed links from connector PartConnector.PartLinks.RemoveRange(_removedLinks.Select(l => l.PartLink)); _removedLinks.Clear(); base.EndEdit(); }
private void Remove(object obj) { var idx = PartLinks.IndexOf(SelectedPartLink); // If is not new, add to list of removed part links if (!_newLinks.Contains(SelectedPartLink)) { _removedLinks.Add(SelectedPartLink); } else { _newLinks.Remove(SelectedPartLink); } PartLinks.Remove(SelectedPartLink); if (idx >= PartLinks.Count) { idx = PartLinks.Count - 1; } SelectedPartLink = idx >= 0 ? PartLinks[idx] : null; }
public override void BeginEdit() { base.BeginEdit(); PartLinks.ForEach(p => p.BeginEdit()); }