예제 #1
0
 private void ExecuteRemoveItemCommand(object parameter)
 {
     if (parameter is SelectableDesignerItemViewModelBase)
     {
         SelectableDesignerItemViewModelBase item = (SelectableDesignerItemViewModelBase)parameter;
         items.Remove(item);
     }
 }
예제 #2
0
 private void ExecuteAddItemCommand(object parameter)
 {
     if (parameter is SelectableDesignerItemViewModelBase)
     {
         SelectableDesignerItemViewModelBase item = (SelectableDesignerItemViewModelBase)parameter;
         item.Parent = this;
         items.Add(item);
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
        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);
        }