Example #1
0
        TreeViewItem AddItemToTreeView(ACustomItemContainer cic)
        {
            TreeViewItem tvi = null;

            foreach (TreeViewItem i in tvItems.Items)
            {
                if ((SlotType)i.Tag == cic.GetItem().Slot)
                {
                    tvi = i;
                    break;
                }
            }
            if (tvi == null)
            {
                tvi = new TreeViewItem();
                TextBlock tb = new TextBlock {
                    Text = cic.GetItem().Slot.ToString(), FontWeight = FontWeights.Bold
                };
                tvi.Header = tb;
                tvi.Tag    = cic.GetItem().Slot;
                tvItems.Items.Add(tvi);
            }

            TreeViewItem tvii = new TreeViewItem();

            tvii.Header = cic.Name + " (" + cic.Source.ToString() + ")";
            tvii.Tag    = cic;
            tvi.Items.Add(tvii);

            return(tvii);
        }
Example #2
0
        private void ChangeSlot_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem         tvi  = tvItems.SelectedItem as TreeViewItem;
            ACustomItemContainer cic  = tvi.Tag as ACustomItemContainer;
            DDOItemData          item = cic.GetItem();
            SlotType             slot = SlotType.None;

            if (!GetSlot(item.Slot, cic.GetDisallowedSlots(), out slot))
            {
                return;
            }
            if (slot == item.Slot)
            {
                return;
            }
            tvi.IsSelected = false;
            (tvi.Parent as TreeViewItem).Items.Remove(tvi);
            if (ItemPropertiesArea.Child == CustomIP)
            {
                RemoveSlotSpecificProperties(item);
            }
            item.Slot = slot;
            if (ItemPropertiesArea.Child == CustomIP)
            {
                AddSlotSpecificProperties(item);
            }
            tvi            = AddItemToTreeView(cic);
            tvi.IsSelected = true;
            tvi.BringIntoView();
            CustomItemChangedSlot?.Invoke(item);
        }
Example #3
0
        private void DeleteCustomItem_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem         tvi = tvItems.SelectedItem as TreeViewItem;
            ACustomItemContainer cic = tvi.Tag as ACustomItemContainer;

            if (MessageBox.Show("Are you sure you want to delete " + cic.Name + "?", "Confirm deletion", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            CustomItemsManager.CustomItems.Remove(cic);
            tvi.IsSelected = false;
            (tvi.Parent as TreeViewItem).Items.Remove(tvi);
            CustomItemDeleted?.Invoke(cic.GetItem());
        }
Example #4
0
        private void RenameCustomItem_Click(object sender, RoutedEventArgs e)
        {
            ACustomItemContainer cic = (tvItems.SelectedItem as TreeViewItem).Tag as ACustomItemContainer;
            TextBoxWindow        tbw = new TextBoxWindow();

            tbw.Owner = this;
            tbw.Setup("Input name", cic.Name);
            if (tbw.ShowDialog() == true)
            {
                string name = tbw.Text.Replace('"', '\'').Replace('{', '(').Replace('}', ')').Replace('\\', '/').Replace('|', '/');
                cic.Name = name;
                cic.GetItem().Name = name;
                (tvItems.SelectedItem as TreeViewItem).Header = name + " (" + cic.Source.ToString() + ")";
            }
        }
Example #5
0
 public void SelectItem(string name, string slot)
 {
     foreach (TreeViewItem tvi in tvItems.Items)
     {
         if ((tvi.Header as TextBlock).Text == slot)
         {
             foreach (TreeViewItem tvii in tvi.Items)
             {
                 ACustomItemContainer cic = tvii.Tag as ACustomItemContainer;
                 if (cic?.Name == name)
                 {
                     tvii.BringIntoView();
                     tvii.IsSelected = true;
                     return;
                 }
             }
         }
     }
 }
Example #6
0
        private void Items_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (ItemPropertiesArea.Child == SlaveLordIP)
            {
                SlaveLordIP.SetItem(null);
            }
            else if (ItemPropertiesArea.Child == CustomIP)
            {
                CustomIP.SetItem(null);
            }
            else if (ItemPropertiesArea.Child == LGSIP)
            {
                LGSIP.SetItem(null);
            }

            if (tvItems.SelectedItem == null)
            {
                tvItems.ContextMenu = tvItems.Resources["EmptyCM"] as ContextMenu;
            }
            else
            {
                TreeViewItem tvi = tvItems.SelectedItem as TreeViewItem;
                if (tvi.Tag is SlotType)
                {
                    tvItems.ContextMenu = tvItems.Resources["SlotCM"] as ContextMenu;
                    SlotType st = (SlotType)tvi.Tag;
                    if (LGSCrafting.LGSItemContainer.DisallowedSlots.Contains(st))
                    {
                        (tvItems.ContextMenu.Items[0] as MenuItem).Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        (tvItems.ContextMenu.Items[0] as MenuItem).Visibility = Visibility.Visible;
                        (tvItems.ContextMenu.Items[0] as MenuItem).Header     = "New Legendary Green Steel " + (SlotType)tvi.Tag + " Item";
                    }
                    if (SlaveLordCrafting.SlaveLordItemContainer.DisallowedSlots.Contains(st))
                    {
                        (tvItems.ContextMenu.Items[1] as MenuItem).Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        (tvItems.ContextMenu.Items[1] as MenuItem).Visibility = Visibility.Visible;
                        (tvItems.ContextMenu.Items[1] as MenuItem).Header     = "New Slave Lord " + (SlotType)tvi.Tag + " Item";
                    }
                    (tvItems.ContextMenu.Items[2] as MenuItem).Header = "New Custom " + (SlotType)tvi.Tag + " Item";
                }
                else
                {
                    tvItems.ContextMenu = tvItems.Resources["ItemCM"] as ContextMenu;
                    ACustomItemContainer cic = tvi.Tag as ACustomItemContainer;
                    switch (cic.Source)
                    {
                    case ItemDataSource.LegendaryGreenSteel:
                        if (LGSIP == null)
                        {
                            LGSIP = new LGSItemProperties();
                        }
                        ItemPropertiesArea.Child = LGSIP;
                        LGSIP.SetItem((LGSCrafting.LGSItemContainer)cic);
                        (tvItems.ContextMenu.Items[3] as MenuItem).IsEnabled = true;
                        WikiURL = cic.WikiURL;
                        break;

                    case ItemDataSource.SlaveLord:
                        if (SlaveLordIP == null)
                        {
                            SlaveLordIP = new SlaveLordItemProperties();
                        }
                        ItemPropertiesArea.Child = SlaveLordIP;
                        SlaveLordIP.SetItem((SlaveLordCrafting.SlaveLordItemContainer)cic);
                        (tvItems.ContextMenu.Items[3] as MenuItem).IsEnabled = true;
                        WikiURL = cic.WikiURL;
                        break;

                    case ItemDataSource.Custom:
                        ItemPropertiesArea.Child = CustomIP;
                        CustomIP.SetItem(cic.GetItem());
                        (tvItems.ContextMenu.Items[3] as MenuItem).IsEnabled = false;
                        break;
                    }
                }
            }
        }