Exemplo n.º 1
0
        private bool InternalSaveAs()
        {
            var inputWindow = new TextInputWindow("Save loadout", "Enter loadout unique name:", currentLoadoutName, true);

            if (inputWindow.ShowDialog() != true)
            {
                return(false);
            }

            Dictionary <string, SkillLoadoutItemConfigurationV3> loadoutConfig = GlobalData.Instance.Configuration.SkillLoadouts;

            if (loadoutConfig.ContainsKey(inputWindow.Text))
            {
                MessageBoxResult dlgResult = MessageBox.Show($"The loadout '{inputWindow.Text}' already exist. Do you want to overwrite it ?", "Overwrite loadout ?", MessageBoxButton.YesNo);
                if (dlgResult == MessageBoxResult.No)
                {
                    return(false);
                }
            }

            loadoutConfig[inputWindow.Text] = new SkillLoadoutItemConfigurationV3
            {
                WeaponSlots = rootViewModel.InParameters.Slots.Where(x => x.Value > 0).Select(x => x.Value).ToArray(),
                Skills      = CreateSelectedSkillsArray()
            };

            GlobalData.Instance.Configuration.LastOpenedLoadout = inputWindow.Text;

            CurrentLoadoutName = inputWindow.Text;
            IsModified         = false;

            ConfigurationManager.Save(GlobalData.Instance.Configuration);

            return(true);
        }
Exemplo n.º 2
0
        public static bool Show(InputOptions inputOptions, out string newInput)
        {
            if (inputOptions == null)
            {
                throw new ArgumentNullException(nameof(inputOptions));
            }

            newInput = null;

            var inputWindow = new TextInputWindow(
                inputOptions.WindowTitle ?? "Input",
                inputOptions.WindowPrompt ?? "New input:",
                inputOptions.WindowDefaultValue,
                inputOptions.IsInputMandatory
                );

            if (inputWindow.ShowDialog() != true)
            {
                return(false);
            }

            if (inputWindow.Text == inputOptions.WindowDefaultValue)
            {
                return(false);
            }

            if (inputOptions.IsValid != null && inputOptions.IsValid(inputWindow.Text) == false)
            {
                MessageBox.Show($"Invalid input '{inputWindow.Text}'.", "Invalid input", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            newInput = inputWindow.Text;

            return(true);
        }