private void RemoveItemFromToolbox(ItemDataSource item) { var itemsToRemove = _service.FindItemsByDefintion(item.Definition); foreach (var toolboxItem in itemsToRemove) { toolboxItem.Parent?.RemoveItem(toolboxItem); } }
public static bool Load() { try { CustomItems = new List <ACustomItemContainer>(); XmlDocument doc = new XmlDocument(); doc.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "customitems.xml")); foreach (XmlElement xi in doc.GetElementsByTagName("CustomItem")) { string name = xi.Attributes["name"].Value; ItemDataSource source = (ItemDataSource)Enum.Parse(typeof(ItemDataSource), xi.Attributes["source"].Value); switch (source) { case ItemDataSource.LegendaryGreenSteel: LGSCrafting.LGSItemContainer lic = new LGSCrafting.LGSItemContainer { Name = name }; if (lic.FromXml(xi)) { CustomItems.Add(lic); } break; case ItemDataSource.SlaveLord: SlaveLordCrafting.SlaveLordItemContainer slic = new SlaveLordCrafting.SlaveLordItemContainer { Name = name }; if (slic.FromXml(xi)) { CustomItems.Add(slic); } break; case ItemDataSource.Custom: CustomItemContainer cic = new CustomItemContainer { Name = name, Source = source }; if (cic.FromXml(xi)) { CustomItems.Add(cic); } break; } } return(true); } catch { return(false); } }
public static List <T> GetItemsFromSource <T>(ItemDataSource ids) where T : ACustomItemContainer { List <T> list = new List <T>(); foreach (var ci in CustomItems) { if (ci.Source == ids) { list.Add((T)ci); } } return(list); }
private void RestoreSelectionState(ListSelectionState state) { ListView.SelectedItems.Clear(); ItemDataSource tempItem = null; foreach (ItemDataSource item in ListView.Items) { var index = state.SelectedItemDataSources.IndexOf(item); if (index >= 0) { state.SelectedItemDataSources.RemoveAt(index); ListView.SelectedItems.Add(item); } if (item == state.CaretItemDataSource) { tempItem = item; } } _data.CaretItem = tempItem; }
/// <summary> /// Set datasource to itemDatasource /// </summary> /// <param name="dataSource">itemDatasource</param> public void SetItemDataSource(ItemDataSource dataSource) { this.DataSource = dataSource; this.DisplayMember = "DisplayMember"; this.ValueMember = "ValueMember"; }
private int DistanceBetween(ItemsControl listView, ItemDataSource previousCaretItem, ItemDataSource item) { return(Math.Abs(listView.Items.IndexOf(previousCaretItem) - listView.Items.IndexOf(item))); }
private static void InstallItem(ItemDataSource item) { IoC.Get <IAddItemToSelectedNodeCommand>() .Execute(new DataObject(ToolboxItemDataFormats.DataSource, item.Definition)); }
public bool IsItemOnToolbox(ItemDataSource item) { return(Service.ToolboxHasItem(item.Definition)); }