Exemplo n.º 1
0
        public void DeleteItem(ItemVM itemVMToDelete)
        {
            bool stop = false;

            foreach (WindowItemVM windowItemVM in WindowItemVMs)
            {
                if (windowItemVM.RootItemVMs.Contains(itemVMToDelete))
                {
                    // Delete physical file/s first
                    ShortcutUtils.DeleteShortcuts(itemVMToDelete);
                    // Delete the item
                    windowItemVM.RootItemVMs.Remove(itemVMToDelete);
                    stop = true;
                    break;
                }

                foreach (ItemVM rootItemVM in windowItemVM.RootItemVMs)
                {
                    IEnumerable <ItemVM> itemVMs = rootItemVM.FlattenItemVMs();
                    foreach (ItemVM itemVM in itemVMs)
                    {
                        if (itemVM.IsGroup)
                        {
                            if (itemVM.ItemVMs.Contains(itemVMToDelete))
                            {
                                // Delete physical file/s first
                                ShortcutUtils.DeleteShortcuts(itemVMToDelete);
                                // Delete the item
                                itemVM.ItemVMs.Remove(itemVMToDelete);
                                //
                                stop = true;
                                break;
                            }
                        }

                        if (stop)
                        {
                            break;
                        }
                    }

                    if (stop)
                    {
                        break;
                    }
                }

                if (stop)
                {
                    break;
                }
            }
            SaveData.SaveShortcuts(false);
        }
Exemplo n.º 2
0
 public void DeleteAllItems(WindowItemVM windowItemVM)
 {
     // Delete physical files first
     foreach (ItemVM subItemVMToDelete in windowItemVM.RootItemVMs)
     {
         ShortcutUtils.DeleteShortcuts(subItemVMToDelete);
     }
     // Delete all items
     windowItemVM.RootItemVMs.Clear();
     SaveData.SaveShortcuts(false);
 }