public Dialogue_Message(NPC.NPCMessage message)
        {
            InitializeComponent();
            Message = message;

            ContextMenu pbmenu = new ContextMenu();

            pbmenu.Items.Add(ContextHelper.CreateSelectAssetButton(typeof(GameDialogueAsset), (asset) =>
            {
                Prev          = asset.id;
                prevBox.Value = asset.id;
            }, "Control_SelectAsset_Dialogue", MahApps.Metro.IconPacks.PackIconMaterialKind.Chat));

            prevBox.ContextMenu = pbmenu;

            if (Configuration.AppConfig.Instance.useOldStyleMoveUpDown)
            {
                dragRectGrid.Visibility = Visibility.Collapsed;
            }
            else
            {
                dragRect.MouseLeftButtonDown += DragControl_LMB_Down;
                dragRect.MouseLeftButtonUp   += DragControl_LMB_Up;
                dragRect.MouseMove           += DragControl_MouseMove;

                UpButton.Visibility   = Visibility.Collapsed;
                DownButton.Visibility = Visibility.Collapsed;
            }

            DataContext = this;

            resizeRect.MouseLeftButtonDown += ResizeRect_MouseLeftButtonDown;
            resizeRect.MouseLeftButtonUp   += ResizeRect_MouseLeftButtonUp;
            resizeRect.MouseMove           += ResizeRect_MouseMove;
        }
        public Dialogue_Message(NPC.NPCMessage message)
        {
            InitializeComponent();
            Message = message;

            ContextMenu pbmenu = new ContextMenu();

            pbmenu.Items.Add(ContextHelper.CreateSelectAssetButton(typeof(GameDialogueAsset), (asset) =>
            {
                Prev          = asset.id;
                prevBox.Value = asset.id;
            }, "Control_SelectAsset_Dialogue", MahApps.Metro.IconPacks.PackIconMaterialKind.Chat));

            prevBox.ContextMenu = pbmenu;

            DataContext = this;
        }
Example #3
0
        public CharacterTabViewModel()
        {
            MainWindow.Instance.characterTabSelect.SelectionChanged += CharacterTabSelect_SelectionChanged;
            MainWindow.Instance.characterTabButtonAdd.Click         += CharacterTabButtonAdd_Click;
            NPCCharacter empty = new NPCCharacter();

            Character = empty;
            UpdateColorPicker();
            UpdateTabs();

            ContextMenu cmenu3 = new ContextMenu();

            cmenu3.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(NPCCharacter), (result) =>
            {
                if (result is NPCCharacter npcc)
                {
                    MainWindow.CurrentProject.data.characters.Add(npcc);
                    MetroTabItem tabItem = CreateTab(npcc);
                    MainWindow.Instance.characterTabSelect.Items.Add(tabItem);
                    MainWindow.Instance.characterTabSelect.SelectedIndex = MainWindow.Instance.characterTabSelect.Items.Count - 1;
                }
            }));

            MainWindow.Instance.characterTabButtonAdd.ContextMenu = cmenu3;

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

            #region Clothing Init
            #region Default
            ContextMenu cidDefault_hat = new ContextMenu();
            cidDefault_hat.Items.Add(ContextHelper.CreateSelectHatButton((asset) =>
            {
                this.DefaultClothing.Hat = asset.id;
                MainWindow.Instance.controlClothingDefaultHat.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultHat.ContextMenu   = cidDefault_hat;
            MainWindow.Instance.controlClothingDefaultHat.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_glasses = new ContextMenu();
            cidDefault_glasses.Items.Add(ContextHelper.CreateSelectGlassesButton((asset) =>
            {
                this.DefaultClothing.Glasses = asset.id;
                MainWindow.Instance.controlClothingDefaultGlasses.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultGlasses.ContextMenu   = cidDefault_glasses;
            MainWindow.Instance.controlClothingDefaultGlasses.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_backpack = new ContextMenu();
            cidDefault_backpack.Items.Add(ContextHelper.CreateSelectBackpackButton((asset) =>
            {
                this.DefaultClothing.Backpack = asset.id;
                MainWindow.Instance.controlClothingDefaultBackpack.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultBackpack.ContextMenu   = cidDefault_backpack;
            MainWindow.Instance.controlClothingDefaultBackpack.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_shirt = new ContextMenu();
            cidDefault_shirt.Items.Add(ContextHelper.CreateSelectShirtButton((asset) =>
            {
                this.DefaultClothing.Shirt = asset.id;
                MainWindow.Instance.controlClothingDefaultShirt.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultShirt.ContextMenu   = cidDefault_shirt;
            MainWindow.Instance.controlClothingDefaultShirt.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_pants = new ContextMenu();
            cidDefault_pants.Items.Add(ContextHelper.CreateSelectPantsButton((asset) =>
            {
                this.DefaultClothing.Pants = asset.id;
                MainWindow.Instance.controlClothingDefaultPants.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultPants.ContextMenu   = cidDefault_pants;
            MainWindow.Instance.controlClothingDefaultPants.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_mask = new ContextMenu();
            cidDefault_mask.Items.Add(ContextHelper.CreateSelectMaskButton((asset) =>
            {
                this.DefaultClothing.Mask = asset.id;
                MainWindow.Instance.controlClothingDefaultMask.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultMask.ContextMenu   = cidDefault_mask;
            MainWindow.Instance.controlClothingDefaultMask.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidDefault_vest = new ContextMenu();
            cidDefault_vest.Items.Add(ContextHelper.CreateSelectVestButton((asset) =>
            {
                this.DefaultClothing.Vest = asset.id;
                MainWindow.Instance.controlClothingDefaultVest.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingDefaultVest.ContextMenu   = cidDefault_vest;
            MainWindow.Instance.controlClothingDefaultVest.ValueChanged += (sender, e) => UpdateClothing();
            #endregion
            #region Halloween
            ContextMenu cidHalloween_hat = new ContextMenu();
            cidHalloween_hat.Items.Add(ContextHelper.CreateSelectHatButton((asset) =>
            {
                this.HalloweenClothing.Hat = asset.id;
                MainWindow.Instance.controlClothingHalloweenHat.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenHat.ContextMenu   = cidHalloween_hat;
            MainWindow.Instance.controlClothingHalloweenHat.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_glasses = new ContextMenu();
            cidHalloween_glasses.Items.Add(ContextHelper.CreateSelectGlassesButton((asset) =>
            {
                this.HalloweenClothing.Glasses = asset.id;
                MainWindow.Instance.controlClothingHalloweenGlasses.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenGlasses.ContextMenu   = cidHalloween_glasses;
            MainWindow.Instance.controlClothingHalloweenGlasses.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_backpack = new ContextMenu();
            cidHalloween_backpack.Items.Add(ContextHelper.CreateSelectBackpackButton((asset) =>
            {
                this.HalloweenClothing.Backpack = asset.id;
                MainWindow.Instance.controlClothingHalloweenBackpack.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenBackpack.ContextMenu   = cidHalloween_backpack;
            MainWindow.Instance.controlClothingHalloweenBackpack.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_shirt = new ContextMenu();
            cidHalloween_shirt.Items.Add(ContextHelper.CreateSelectShirtButton((asset) =>
            {
                this.HalloweenClothing.Shirt = asset.id;
                MainWindow.Instance.controlClothingHalloweenShirt.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenShirt.ContextMenu   = cidHalloween_shirt;
            MainWindow.Instance.controlClothingHalloweenShirt.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_pants = new ContextMenu();
            cidHalloween_pants.Items.Add(ContextHelper.CreateSelectPantsButton((asset) =>
            {
                this.HalloweenClothing.Pants = asset.id;
                MainWindow.Instance.controlClothingHalloweenPants.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenPants.ContextMenu   = cidHalloween_pants;
            MainWindow.Instance.controlClothingHalloweenPants.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_mask = new ContextMenu();
            cidHalloween_mask.Items.Add(ContextHelper.CreateSelectMaskButton((asset) =>
            {
                this.HalloweenClothing.Mask = asset.id;
                MainWindow.Instance.controlClothingHalloweenMask.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenMask.ContextMenu   = cidHalloween_mask;
            MainWindow.Instance.controlClothingHalloweenMask.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidHalloween_vest = new ContextMenu();
            cidHalloween_vest.Items.Add(ContextHelper.CreateSelectVestButton((asset) =>
            {
                this.HalloweenClothing.Vest = asset.id;
                MainWindow.Instance.controlClothingHalloweenVest.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingHalloweenVest.ContextMenu   = cidHalloween_vest;
            MainWindow.Instance.controlClothingHalloweenVest.ValueChanged += (sender, e) => UpdateClothing();
            #endregion
            #region Christmas
            ContextMenu cidChristmas_hat = new ContextMenu();
            cidChristmas_hat.Items.Add(ContextHelper.CreateSelectHatButton((asset) =>
            {
                this.ChristmasClothing.Hat = asset.id;
                MainWindow.Instance.controlClothingChristmasHat.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasHat.ContextMenu   = cidChristmas_hat;
            MainWindow.Instance.controlClothingChristmasHat.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_glasses = new ContextMenu();
            cidChristmas_glasses.Items.Add(ContextHelper.CreateSelectGlassesButton((asset) =>
            {
                this.ChristmasClothing.Glasses = asset.id;
                MainWindow.Instance.controlClothingChristmasGlasses.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasGlasses.ContextMenu   = cidChristmas_glasses;
            MainWindow.Instance.controlClothingChristmasGlasses.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_backpack = new ContextMenu();
            cidChristmas_backpack.Items.Add(ContextHelper.CreateSelectBackpackButton((asset) =>
            {
                this.ChristmasClothing.Backpack = asset.id;
                MainWindow.Instance.controlClothingChristmasBackpack.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasBackpack.ContextMenu   = cidChristmas_backpack;
            MainWindow.Instance.controlClothingChristmasBackpack.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_shirt = new ContextMenu();
            cidChristmas_shirt.Items.Add(ContextHelper.CreateSelectShirtButton((asset) =>
            {
                this.ChristmasClothing.Shirt = asset.id;
                MainWindow.Instance.controlClothingChristmasShirt.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasShirt.ContextMenu   = cidChristmas_shirt;
            MainWindow.Instance.controlClothingChristmasShirt.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_pants = new ContextMenu();
            cidChristmas_pants.Items.Add(ContextHelper.CreateSelectPantsButton((asset) =>
            {
                this.ChristmasClothing.Pants = asset.id;
                MainWindow.Instance.controlClothingChristmasPants.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasPants.ContextMenu   = cidChristmas_pants;
            MainWindow.Instance.controlClothingChristmasPants.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_mask = new ContextMenu();
            cidChristmas_mask.Items.Add(ContextHelper.CreateSelectMaskButton((asset) =>
            {
                this.ChristmasClothing.Mask = asset.id;
                MainWindow.Instance.controlClothingChristmasMask.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasMask.ContextMenu   = cidChristmas_mask;
            MainWindow.Instance.controlClothingChristmasMask.ValueChanged += (sender, e) => UpdateClothing();

            ContextMenu cidChristmas_vest = new ContextMenu();
            cidChristmas_vest.Items.Add(ContextHelper.CreateSelectVestButton((asset) =>
            {
                this.ChristmasClothing.Vest = asset.id;
                MainWindow.Instance.controlClothingChristmasVest.Value = asset.id;
            }));
            MainWindow.Instance.controlClothingChristmasVest.ContextMenu   = cidChristmas_vest;
            MainWindow.Instance.controlClothingChristmasVest.ValueChanged += (sender, e) => UpdateClothing();
            #endregion
            #endregion
            MainWindow.Instance.clothingTabControl.SelectionChanged += (sender, e) => UpdateClothing();
            #region Equipment Init
            ContextMenu cid_primary = new ContextMenu();
            cid_primary.Items.Add(ContextHelper.CreateSelectItemButton((asset) =>
            {
                EquipmentPrimary = asset.id;
                MainWindow.Instance.primaryIdBox.Value = asset.id;
            }, new AssetFilter_Equippable("Interface", "AssetPicker_Filter_Equippable", Equip_Type.Primary)));
            MainWindow.Instance.primaryIdBox.ContextMenu   = cid_primary;
            MainWindow.Instance.primaryIdBox.ValueChanged += (sender, e) => UpdateEquipment();

            ContextMenu cid_secondary = new ContextMenu();
            cid_secondary.Items.Add(ContextHelper.CreateSelectItemButton((asset) =>
            {
                EquipmentSecondary = asset.id;
                MainWindow.Instance.secondaryIdBox.Value = asset.id;
            }, new AssetFilter_Equippable("Interface", "AssetPicker_Filter_Equippable", Equip_Type.Secondary)));
            MainWindow.Instance.secondaryIdBox.ContextMenu   = cid_secondary;
            MainWindow.Instance.secondaryIdBox.ValueChanged += (sender, e) => UpdateEquipment();

            ContextMenu cid_tertiary = new ContextMenu();
            cid_tertiary.Items.Add(ContextHelper.CreateSelectItemButton((asset) =>
            {
                EquipmentTertiary = asset.id;
                MainWindow.Instance.tertiaryIdBox.Value = asset.id;
            }, new AssetFilter_Equippable("Interface", "AssetPicker_Filter_Equippable", Equip_Type.Tertiary)));
            MainWindow.Instance.tertiaryIdBox.ContextMenu   = cid_tertiary;
            MainWindow.Instance.tertiaryIdBox.ValueChanged += (sender, e) => UpdateEquipment();
            #endregion

            var txtIDContext = new ContextMenu();

            txtIDContext.Items.Add(ContextHelper.CreateFindUnusedIDButton((id) =>
            {
                this.ID = id;
                MainWindow.Instance.txtID.Value = id;
            }, GameIntegration.EGameAssetCategory.OBJECT));

            MainWindow.Instance.txtID.ContextMenu = txtIDContext;

            var dialogueIDContext = new ContextMenu();

            dialogueIDContext.Items.Add(ContextHelper.CreateSelectAssetButton(typeof(GameDialogueAsset), (asset) =>
            {
                this.DialogueID = asset.id;
                MainWindow.Instance.txtStartDialogueID.Value = asset.id;
            }, "Control_SelectAsset_Dialogue", MahApps.Metro.IconPacks.PackIconMaterialKind.Chat));

            MainWindow.Instance.txtStartDialogueID.ContextMenu = dialogueIDContext;
        }
Example #4
0
        public Universal_VendorItemEditor(VendorItem startItem = null)
        {
            InitializeComponent();

            ignoreAnimation = true;

            double scale = AppConfig.Instance.scale;

            gridScale.ScaleX      = scale;
            gridScale.ScaleY      = scale;
            Width                *= scale;
            Height               *= scale;
            typeBox.SelectedIndex = 0;
            sellBox.SelectedIndex = 0;
            Result                = startItem ?? new VendorItem()
            {
                isBuy = !isSellSelected, type = lastType
            };
            txtBoxCost.Value      = Result.cost;
            txtBoxID.Value        = Result.id;
            txtBoxSpawnpoint.Text = Result.spawnPointID;

            foreach (ComboBoxItem cbi in typeBox.Items)
            {
                ItemType it = (ItemType)cbi.Tag;
                if (it == Result.type)
                {
                    typeBox.SelectedItem = cbi;
                    break;
                }
            }
            foreach (ComboBoxItem cbi in sellBox.Items)
            {
                if ((cbi.Tag.ToString() == "BUY" && Result.isBuy) || (cbi.Tag.ToString() == "SELL" && !Result.isBuy))
                {
                    sellBox.SelectedItem = cbi;
                    break;
                }
            }

            ContextMenu cmenu      = new ContextMenu();
            MenuItem    selectItem = ContextHelper.CreateSelectAssetButton(typeof(GameItemAsset), (asset) =>
            {
                txtBoxID.Value = asset.id;
            }, "Control_SelectAsset_Item", MahApps.Metro.IconPacks.PackIconMaterialKind.Archive);
            MenuItem selectVehicle = ContextHelper.CreateSelectAssetButton(typeof(GameVehicleAsset), (asset) =>
            {
                txtBoxID.Value = asset.id;
            }, "Control_SelectAsset_Vehicle", MahApps.Metro.IconPacks.PackIconMaterialKind.Car);

            selectItem.Command = new AdvancedCommand(() => { }, (obj) =>
            {
                return(Selected_ItemType == ItemType.ITEM);
            });
            selectVehicle.Command = new AdvancedCommand(() => { }, (obj) =>
            {
                return(Selected_ItemType == ItemType.VEHICLE);
            });

            cmenu.Items.Add(selectItem);
            cmenu.Items.Add(selectVehicle);

            txtBoxID.ContextMenu = cmenu;
        }
Example #5
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;
        }
        public IEnumerable <FrameworkElement> GetControls()
        {
            PropertyInfo[] props = GetType().GetProperties();
            foreach (PropertyInfo prop in props)
            {
                if (!prop.CanWrite || !prop.CanRead)
                {
                    continue;
                }

                string propName = prop.Name;
                Type   propType = prop.PropertyType;
                // string localizedName = LocalizationManager.Current.Condition[$"{Type}_{propName}"];
                string localizedName;

                string key1 = $"{Type}_{propName}";
                string key2 = $"Shared_{propName}";

                if (LocalizationManager.Current.Condition.ContainsKey(key1))
                {
                    localizedName = LocalizationManager.Current.Condition.Translate(key1);
                }
                else if (LocalizationManager.Current.Condition.ContainsKey(key2))
                {
                    localizedName = LocalizationManager.Current.Condition.Translate(key2);
                }
                else
                {
                    localizedName = key1;
                }

                Grid  borderContents = new Grid();
                Label l = new Label
                {
                    Content = localizedName
                };
                TooltipAttribute conditionTooltip = prop.GetCustomAttribute <TooltipAttribute>();
                if (conditionTooltip != null)
                {
                    l.ToolTip = conditionTooltip.Text;
                }
                else if (LocalizationManager.Current.Condition.ContainsKey($"{key1}_Tooltip"))
                {
                    l.ToolTip = LocalizationManager.Current.Condition[$"{key1}_Tooltip"];
                }
                else if (LocalizationManager.Current.Condition.ContainsKey($"{key2}_Tooltip"))
                {
                    l.ToolTip = LocalizationManager.Current.Condition[$"{key2}_Tooltip"];
                }

                borderContents.Children.Add(l);
                RangeAttribute       rangeAttribute       = prop.GetCustomAttribute <RangeAttribute>();
                AssetPickerAttribute assetPickerAttribute = prop.GetCustomAttribute <AssetPickerAttribute>();
                FrameworkElement     valueControl         = null;
                if (propType == typeof(ushort))
                {
                    ushort newMax, newMin;
                    if (rangeAttribute != null && rangeAttribute.Maximum is ushort rMax && rangeAttribute.Minimum is ushort rMin)
                    {
                        newMax = rMax;
                        newMin = rMin;
                    }
                    else
                    {
                        newMax = ushort.MaxValue;
                        newMin = ushort.MinValue;
                    }
                    valueControl = new MahApps.Metro.Controls.NumericUpDown()
                    {
                        Maximum            = newMax,
                        Minimum            = newMin,
                        ParsingNumberStyle = System.Globalization.NumberStyles.Integer,
                        HideUpDownButtons  = true
                    };
                    (valueControl as MahApps.Metro.Controls.NumericUpDown).SetBinding(MahApps.Metro.Controls.NumericUpDown.ValueProperty, propName);

                    if (assetPickerAttribute != null)
                    {
                        var vcMenu = new ContextMenu();
                        vcMenu.Items.Add(ContextHelper.CreateSelectAssetButton(assetPickerAttribute.AssetType, (asset) =>
                        {
                            (valueControl as MahApps.Metro.Controls.NumericUpDown).Value = asset.id;
                        }, assetPickerAttribute.Key, assetPickerAttribute.Icon));
                        (valueControl as MahApps.Metro.Controls.NumericUpDown).ContextMenu = vcMenu;
                    }
                }