示例#1
0
        private void UpgradesButton_Click(object sender, RoutedEventArgs e)
        {
            bool overrideRegem     = CK_Override_Regem.IsChecked.GetValueOrDefault();
            bool overrideReenchant = CK_Override_Reenchant.IsChecked.GetValueOrDefault();
            bool overrideReforge   = CK_Override_Reforge.IsChecked.GetValueOrDefault();
            int  thoroughness      = (int)Math.Ceiling((float)ThoroughnessSlider.Value / 10f);

            if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                thoroughness *= 10;                                                   //Allow super high thoroughness using Ctrl-Click on Optimize
            }
            string calculationToOptimize = GetCalculationStringFromComboBox(CalculationToOptimizeCombo, null);
            List <OptimizationRequirement> requirements = GetOptimizationRequirements();

            if ((overrideReenchant || overrideRegem || thoroughness > 100) && OptimizerSettings.Default.WarningsEnabled)
            {
                if (MessageBox.Show("The upgrade evaluations perform an optimization for each relevant item. With your settings this might take a long time. Consider using lower thoroughness and no overriding of regem and reenchant options." + Environment.NewLine + Environment.NewLine + "Do you want to continue with upgrade evaluations?", "Optimizer Warning", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            optimizer.OptimizationMethod       = OptimizerSettings.Default.OptimizationMethod;
            optimizer.GreedyOptimizationMethod = OptimizerSettings.Default.GreedyOptimizationMethod;

            optimizer.InitializeItemCache(character, character.AvailableItems, overrideRegem, overrideReenchant, overrideReforge,
                                          OptimizerSettings.Default.TemplateGemsEnabled, Calculations.Instance,
                                          CK_Food.IsChecked.GetValueOrDefault(), CK_ElixirsFlasks.IsChecked.GetValueOrDefault(),
                                          CK_Mixology.IsChecked.GetValueOrDefault(), GetOptimizeTalentSpecs(), false, false);
            if (OptimizerSettings.Default.WarningsEnabled)
            {
                string prompt = optimizer.GetWarningPromptIfNeeded();
                if (prompt != null)
                {
                    if (MessageBox.Show(prompt, "Optimizer Warning", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                    {
                        ControlsEnabled(true); return;
                    }
                }
            }

            lastOperation = Operation.UpgradeList;
            ControlsEnabled(false);
            PauseButton.Visibility = Visibility.Visible;

            if (doSlot)
            {
                optimizer.ComputeUpgradesAsync(character, calculationToOptimize, requirements, thoroughness, Character.GetCharacterSlotByItemSlot(itemToEvaluate.Item.Slot));
            }
            else
            {
                optimizer.ComputeUpgradesAsync(character, calculationToOptimize, requirements, thoroughness, itemToEvaluate);
            }
        }
示例#2
0
        private void buttonUpgrades_Click(object sender, EventArgs e)
        {
            bool   _overrideRegem         = checkBoxOverrideRegem.Checked;
            bool   _overrideReenchant     = checkBoxOverrideReenchant.Checked;
            int    _thoroughness          = (int)Math.Ceiling((float)trackBarThoroughness.Value / 10f);
            string _calculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize, null);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (Control ctrl in groupBoxRequirements.Controls)
            {
                ctrl.Enabled = false;
                Panel panel = ctrl as Panel;
                if (panel != null)
                {
                    OptimizationRequirement requirement = new OptimizationRequirement();
                    requirement.Calculation = GetCalculationStringFromComboBox(panel.Controls["comboBoxRequirementCalculation"] as ComboBox, panel.Controls["comboBoxRequirementTalent"] as ComboBox);
                    requirement.LessThan    = (panel.Controls["comboBoxRequirementGreaterLessThan"] as ComboBox).SelectedIndex == 1;
                    requirement.Value       = (float)((panel.Controls["numericUpDownRequirementValue"] as NumericUpDown).Value);
                    requirements.Add(requirement);
                }
            }

            if ((_overrideReenchant || _overrideRegem || _thoroughness > 100) && Properties.Optimizer.Default.WarningsEnabled)
            {
                if (MessageBox.Show("The upgrade evaluations perform an optimization for each relevant item. With your settings this might take a long time. Consider using lower thoroughness and no overriding of regem and reenchant options." + Environment.NewLine + Environment.NewLine + "Do you want to continue with upgrade evaluations?", "Optimizer Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    EnableAllReqs(); return;
                }
            }

            _optimizer.OptimizationMethod       = Properties.Optimizer.Default.OptimizationMethod;
            _optimizer.GreedyOptimizationMethod = Properties.Optimizer.Default.GreedyOptimizationMethod;

            _optimizer.InitializeItemCache(_character, _character.AvailableItems, _overrideRegem, _overrideReenchant, Properties.Optimizer.Default.TemplateGemsEnabled, Calculations.Instance, checkBoxOptimizeFood.Checked, checkBoxOptimizeElixir.Checked, checkBoxMixology.Checked, GetOptimizeTalentSpecs(), checkBoxMutateTalents.Checked);
            if (Properties.Optimizer.Default.WarningsEnabled)
            {
                string prompt = _optimizer.GetWarningPromptIfNeeded();
                if (prompt != null)
                {
                    if (MessageBox.Show(prompt, "Optimizer Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        EnableAllReqs(); return;
                    }
                }
            }

            buttonUpgrades.Text                  = "Calculating...";
            buttonCancel.Text                    = "Cancel";
            buttonOptimize.Enabled               = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                trackBarThoroughness.Enabled     = checkBoxMixology.Enabled = checkBoxOptimizeElixir.Enabled =
                    checkBoxOptimizeFood.Enabled = checkBoxOptimizeTalents.Enabled = checkBoxMutateTalents.Enabled =
                        comboBoxCalculationToOptimize.Enabled = false;
            buttonCancel.DialogResult = DialogResult.None;

            _optimizer.ComputeUpgradesAsync(_character, _calculationToOptimize, requirements, _thoroughness, _itemToEvaluate);
        }
示例#3
0
        private void UpgradesButton_Click(object sender, RoutedEventArgs e)
        {
            bool   overrideRegem         = OverrideRegemCheck.IsChecked.GetValueOrDefault();
            bool   overrideReenchant     = OverrideReenchantCheck.IsChecked.GetValueOrDefault();
            int    thoroughness          = (int)Math.Ceiling((float)ThoroughnessSlider.Value / 10f);
            string calculationToOptimize = GetCalculationStringFromComboBox(CalculationToOptimizeCombo, null);
            List <OptimizationRequirement> requirements = GetOptimizationRequirements();

            if ((overrideReenchant || overrideRegem || thoroughness > 100) && OptimizerSettings.Default.WarningsEnabled)
            {
                if (MessageBox.Show("The upgrade evaluations perform an optimization for each relevant item. With your settings this might take a long time. Consider using lower thoroughness and no overriding of regem and reenchant options." + Environment.NewLine + Environment.NewLine + "Do you want to continue with upgrade evaluations?", "Optimizer Warning", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            optimizer.OptimizationMethod       = OptimizerSettings.Default.OptimizationMethod;
            optimizer.GreedyOptimizationMethod = OptimizerSettings.Default.GreedyOptimizationMethod;

            optimizer.InitializeItemCache(character, character.AvailableItems, overrideRegem, overrideReenchant,
                                          OptimizerSettings.Default.TemplateGemsEnabled, Calculations.Instance,
                                          FoodCheck.IsChecked.GetValueOrDefault(), ElixirsFlasksCheck.IsChecked.GetValueOrDefault(),
                                          MixologyCheck.IsChecked.GetValueOrDefault(), GetOptimizeTalentSpecs(), false);
            if (OptimizerSettings.Default.WarningsEnabled)
            {
                string prompt = optimizer.GetWarningPromptIfNeeded();
                if (prompt != null)
                {
                    if (MessageBox.Show(prompt, "Optimizer Warning", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                    {
                        ControlsEnabled(true); return;
                    }
                }
            }

            ControlsEnabled(false);

            optimizer.ComputeUpgradesAsync(character, calculationToOptimize, requirements, thoroughness, itemToEvaluate);
        }