/// <summary> /// Deletes a KmlItem from this nodes lists. /// Result will be false if item was not in the lists or couldn't be deleted /// because of restrictions. /// </summary> /// <param name="item">The KmlItem to delete</param> /// <returns>True if item was deleted, false otherwise</returns> public virtual bool Delete(KmlItem item) { if (!item.CanBeDeleted) { return(false); } // Call itme's Delete to call it's BeforeDelete() // But there would usually be called this method, // to avoid loop we set parent to null. // We also ignore result, will be false in that case RemapParent(item, null); item.Delete(); if (!AllItems.Remove(item)) { // It wasn't in the list, nothing to do return(false); } if (item is KmlAttrib) { bool result = Attribs.Remove((KmlAttrib)item); InvokeAttribChanged(); return(result); } else if (item is KmlNode) { bool result = Children.Remove((KmlNode)item); InvokeChildrenChanged(); return(result); } else { return(Unknown.Remove(item)); } }
private void OpenSettings_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Opening Settings File..."); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Console.WriteLine(" " + openFileDialog.FileName); SettingsFile = Settings.LoadFromFile(openFileDialog.FileName); AllItems.Clear(); foreach (Item item in SettingsFile.BasicAugments.Concat(SettingsFile.CoreAugs).Concat(SettingsFile.PrimaryWeapons).Concat(SettingsFile.Prototypes)) { AllItems.Add(item); } List <Item> removeItems = AllItems.Where((item) => item.Name == String.Empty || item.Lockable == false).ToList(); foreach (Item item in removeItems) { AllItems.Remove(item); // <-- remove placeholders and non-lockable items } SettingsPathToUse = openFileDialog.FileName; Console.WriteLine(" File Opened."); } }
private void RemoveItem(FileViewModel file) { file.OnOpened -= OnItemOpened; file.OnDeleted -= OnItemDeleted; Files.Remove(file); AllItems.Remove(file); }
private void RemoveItem(FolderViewModel folder) { folder.OnOpened -= OnItemOpened; folder.OnDeleted -= OnItemDeleted; SubDirectories.Remove(folder); AllItems.Remove(folder); }
/// <summary> /// Used to remove a connector item from the 'AllItem' list. /// </summary> /// <param name="item"></param> public void RemoveConnectorItem(GlobalItem item) { if (item.GetType() == typeof(StationAreaItem)) { AllItems.Remove(item); routeItems.Remove(item); } }
public void Delete() { MainWindow.ActiveWindow.itemStackPanel.Children.Remove(this); AllItems.Remove(this); LedItem.RefreshSyncableItems(); //display no led message if this was the last led if (LedItem.AllItems.Count != 0) { //select the next item if this item was selected if (MainWindow.ActiveWindow.SelectedLedItem == this) { MainWindow.ActiveWindow.SelectedLedItem = AllItems[0]; } bool foundport = false; foreach (LedItem item in LedItem.AllItems) { if (item.ComPortName == ComPortName) { foundport = true; } } if (!foundport) { try { arduino.ActiveSerialPort.Close(); } catch { } Arduino.AllArduinos.Remove(arduino); } } else { MainWindow.ActiveWindow.SelectedLedItem = null; } //If this led was the syncparent of any other led, remove that sync foreach (LedItem item in LedItem.AllItems) { if (item.SyncedLedItem == this.ItemName) { item.SyncedLedItem = "DONTSYNC"; item.CurrentMode = "Static"; if (item == MainWindow.ActiveWindow.SelectedLedItem) { MainWindow.ActiveWindow.SelectedMode = "Static"; } } } }
private void SaveModGUI_Loaded(object sender, RoutedEventArgs e) { ItemGrid.Columns.Remove(ItemGrid.Columns.First((col) => col.Header.ToString() == "HexValue")); // Remove the HexValue column ItemGrid.Columns.Remove(ItemGrid.Columns.First((col) => col.Header.ToString() == "Lockable")); // Remove the HexValue column List <Item> removeItems = AllItems.Where((item) => item.Name == String.Empty || item.Lockable == false).ToList(); foreach (Item item in removeItems) { AllItems.Remove(item); // <-- remove placeholders and non-lockable items } }
/// <summary> /// Delete existent note /// </summary> private void DeleteItem(string entity) { var response = MessageBox.Show("Delete file [" + CurrentItem.Name + "] ?", "Question", MessageBoxButton.YesNo); if (response == MessageBoxResult.Yes) { File.Delete(BasePath + CurrentItem.Name); FileItems.Remove(CurrentItem); AllItems.Remove(CurrentItem); } }
/// <summary> /// Removes the CdmObject from the CdmCollection /// </summary> public bool Remove(T currObject) { bool wasRemoved = AllItems.Remove(currObject); if (wasRemoved) { currObject.Owner = null; MakeDocumentDirty(); } return(wasRemoved); }
private void Add() { AccessoryViewModel accessory = new AccessoryViewModel(); accessory.AccessoryType = new AccessoryTypeViewModel(AllItemsSelectedItem); accessory.Code = ""; accessory.Quantity = 1; SelectedItems.Add(accessory); AllItems.Remove(AllItemsSelectedItem); AllItemsSelectedItem = null; SelectedItemsSelectedItem = accessory; }
/// <summary> /// Used to remove an item from all list of items: AllItems, RouteItems /// </summary> /// <param name="item">the item to remove</param> public void RemoveItem(GlobalItem item) { if (item.GetType() == typeof(StationItem)) { foreach (var point in ((StationItem)item).stationArea) { RemoveConnectorItem(point); } ((StationItem)item).stationArea.Clear(); } AllItems.Remove(item); routeItems.Remove(item); toSave = true; }
public static void RemoveItem(string key) { string schemaKey = GetSchemaForItem(key); List <string> itemList; // Remove from the Item list by schema if (ItemListBySchema.TryGetValue(schemaKey, out itemList)) { itemList.Remove(key); } AllItems.Remove(key); ItemsNeedSave = true; }
//删除Item public void RemoveTodoItem(string id) { //DIY //set selectedItem to null after remove //this.selectedItem = null; if (this.selectedItem != null) { AllItems.Remove(selectedItem); TileService.UpdateTileItem(); Debug.WriteLine(selectedItem.id); App.db.deleteItem(selectedItem); this.selectedItem = null; TileService.UpdateTileItem(); //更新磁贴 } }
private void UpDataAllItems(SelectedItemWithIndexModel item) { if (item == null) { return; } bool needtodelect = false; foreach (var i in AllItems) { if (i.Key == item.Index) { needtodelect = true; break; } } if (needtodelect) { AllItems.Remove(item.Index); } AllItems.Add(item.Index, new Tuple <string, BitmapSource>(item.SelectedItem.ToString(), WPFPictureHelper.CreateBitmapFromFile(item.SelectedItem.ToString()))); UpdateImage(); }
private Task <bool> OnDeleteAsync(IEnumerable <EditFooTree> items) { items.ToList().ForEach(i => AllItems.Remove(i)); return(Task.FromResult(true)); }
protected virtual void OnModelDeletedToRepository(object sender, ModelDeletedEventArgs e) { AllItems.Remove(AllItems.FirstOrDefault <ItemsViewModel>(item => item.IsSelected)); }