private void ExecuteRemoveItemCommand(object parameter) { if (parameter is SelectableDesignerItemViewModelBase) { SelectableDesignerItemViewModelBase item = (SelectableDesignerItemViewModelBase)parameter; items.Remove(item); } }
private void ExecuteAddItemCommand(object parameter) { if (parameter is SelectableDesignerItemViewModelBase) { SelectableDesignerItemViewModelBase item = (SelectableDesignerItemViewModelBase)parameter; item.Parent = this; items.Add(item); } }
private void DeleteFromDatabase(DiagramItem wholeDiagramToAdjust, SelectableDesignerItemViewModelBase itemToDelete) { if (itemToDelete is ConnectorViewModel) { wholeDiagramToAdjust.ConnectionIds.Remove(itemToDelete.Id); storageService.DeleteConnection(itemToDelete.Id); } else { //DiagramItemData diagramItemToRemoveFromParent = wholeDiagramToAdjust.DesignerItems.Where(x => x.ItemId == itemToDelete.Id && x.ItemType == typeof(SettingsDesignerItem)).Single(); var diagramItemToRemoveFromParent = wholeDiagramToAdjust.DesignerItems.Where(x => x.ItemId == itemToDelete.Id).Single(); wholeDiagramToAdjust.DesignerItems.Remove(diagramItemToRemoveFromParent); } storageService.SaveDiagram(wholeDiagramToAdjust); }
private void DeleteFromDatabase(DiagramItem wholeDiagramToAdjust, SelectableDesignerItemViewModelBase itemToDelete) { //make sure the item is removes from Diagram as well as removing them as individual items from database if (itemToDelete is PersistDesignerItemViewModel) { DiagramItemData diagramItemToRemoveFromParent = wholeDiagramToAdjust.DesignerItems.Where(x => x.ItemId == itemToDelete.Id && x.ItemType == typeof(PersistDesignerItem)).Single(); wholeDiagramToAdjust.DesignerItems.Remove(diagramItemToRemoveFromParent); databaseAccessService.DeletePersistDesignerItem(itemToDelete.Id); } if (itemToDelete is SettingsDesignerItemViewModel) { DiagramItemData diagramItemToRemoveFromParent = wholeDiagramToAdjust.DesignerItems.Where(x => x.ItemId == itemToDelete.Id && x.ItemType == typeof(SettingsDesignerItem)).Single(); wholeDiagramToAdjust.DesignerItems.Remove(diagramItemToRemoveFromParent); databaseAccessService.DeleteSettingDesignerItem(itemToDelete.Id); } if (itemToDelete is ConnectorViewModel) { wholeDiagramToAdjust.ConnectionIds.Remove(itemToDelete.Id); databaseAccessService.DeleteConnection(itemToDelete.Id); } databaseAccessService.SaveDiagram(wholeDiagramToAdjust); }