Example #1
0
        private void RemoveItemFromToolbox(ItemDataSource item)
        {
            var itemsToRemove = _service.FindItemsByDefintion(item.Definition);

            foreach (var toolboxItem in itemsToRemove)
            {
                toolboxItem.Parent?.RemoveItem(toolboxItem);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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;
        }
Example #5
0
 /// <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";
 }
Example #6
0
 private int DistanceBetween(ItemsControl listView, ItemDataSource previousCaretItem, ItemDataSource item)
 {
     return(Math.Abs(listView.Items.IndexOf(previousCaretItem) - listView.Items.IndexOf(item)));
 }
Example #7
0
 private static void InstallItem(ItemDataSource item)
 {
     IoC.Get <IAddItemToSelectedNodeCommand>()
     .Execute(new DataObject(ToolboxItemDataFormats.DataSource, item.Definition));
 }
Example #8
0
 public bool IsItemOnToolbox(ItemDataSource item)
 {
     return(Service.ToolboxHasItem(item.Definition));
 }