Exemple #1
0
        public VendorTabViewModel()
        {
            MainWindow.Instance.vendorTabSelect.SelectionChanged += VendorTabSelect_SelectionChanged;
            MainWindow.Instance.vendorTabButtonAdd.Click         += VendorTabButtonAdd_Click;
            NPCVendor empty = new NPCVendor();

            Vendor = empty;
            UpdateTabs();

            ContextMenu cmenu2 = new ContextMenu();

            cmenu2.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(VendorItem), (result) =>
            {
                if (result is VendorItem item)
                {
                    if (item.isBuy)
                    {
                        AddItemBuy(item);
                    }
                    else
                    {
                        AddItemSell(item);
                    }
                }
            }));

            MainWindow.Instance.vendorAddItemButton.ContextMenu = cmenu2;

            ContextMenu cmenu3 = new ContextMenu();

            cmenu3.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(NPCVendor), (result) =>
            {
                if (result is NPCVendor item)
                {
                    MainWindow.CurrentProject.data.vendors.Add(item);
                    MetroTabItem tabItem = CreateTab(item);
                    MainWindow.Instance.vendorTabSelect.Items.Add(tabItem);
                    MainWindow.Instance.vendorTabSelect.SelectedIndex = MainWindow.Instance.vendorTabSelect.Items.Count - 1;
                }
            }));

            MainWindow.Instance.vendorTitleTxtBox.ContextMenu = ContextHelper.CreateContextMenu(ContextHelper.EContextOption.Group_Rich | ContextHelper.EContextOption.Group_TextEdit);
            MainWindow.Instance.vendorDescTxtBox.ContextMenu  = ContextHelper.CreateContextMenu(ContextHelper.EContextOption.Group_Rich | ContextHelper.EContextOption.Group_TextEdit);

            ContextMenu cmenu4 = new ContextMenu();

            cmenu4.Items.Add(ContextHelper.CreateSelectAssetButton(typeof(GameCurrencyAsset), (asset) =>
            {
                Currency = asset.guid.ToString("N");
                MainWindow.Instance.vendorCurrencyBox.Text = asset.guid.ToString("N");
            }, "Control_SelectAsset_Currency", MahApps.Metro.IconPacks.PackIconMaterialKind.CurrencyUsd));
            cmenu4.Items.Add(ContextHelper.CreateGenericButton(new AdvancedCommand(() =>
            {
                Currency = string.Empty;
                MainWindow.Instance.vendorCurrencyBox.Text = string.Empty;
            }, (obj) =>
            {
                return(!string.IsNullOrEmpty(Currency));
            }), "Control_Vendor_SwitchToExperience", MahApps.Metro.IconPacks.PackIconMaterialKind.Star));

            MainWindow.Instance.vendorCurrencyBox.ContextMenu = cmenu4;

            var vendorIdTxtBoxContext = new ContextMenu();

            vendorIdTxtBoxContext.Items.Add(ContextHelper.CreateFindUnusedIDButton((id) =>
            {
                this.ID = id;
                MainWindow.Instance.vendorIdTxtBox.Value = id;
            }, GameIntegration.EGameAssetCategory.NPC));

            MainWindow.Instance.vendorIdTxtBox.ContextMenu = vendorIdTxtBoxContext;
        }