Beispiel #1
0
        private void buttonOptimize_Click(object sender, EventArgs e)
        {
            bool   _overrideRegem         = checkBoxOverrideRegem.Checked;
            bool   _overrideReenchant     = checkBoxOverrideReenchant.Checked;
            int    _thoroughness          = trackBarThoroughness.Value;
            string _calculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (Control ctrl in groupBoxRequirements.Controls)
            {
                if (ctrl is Panel)
                {
                    OptimizationRequirement requirement = new OptimizationRequirement();
                    foreach (Control reqCtrl in ctrl.Controls)
                    {
                        switch (reqCtrl.Name)
                        {
                        case "comboBoxRequirementCalculation":
                            requirement.Calculation = GetCalculationStringFromComboBox(reqCtrl as ComboBox);
                            break;

                        case "comboBoxRequirementGreaterLessThan":
                            requirement.LessThan = (reqCtrl as ComboBox).SelectedIndex == 1;
                            break;

                        case "numericUpDownRequirementValue":
                            requirement.Value = (float)((reqCtrl as NumericUpDown).Value);
                            break;
                        }
                    }
                    requirements.Add(requirement);
                }
            }
            OptimizationRequirement[] _requirements = requirements.ToArray();

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

            buttonOptimize.Text              = "Optimizing...";
            buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                trackBarThoroughness.Enabled = false;
            buttonCancel.DialogResult        = DialogResult.None;

            Optimizer.OptimizationMethod = Properties.Optimizer.Default.OptimizationMethod;
            _optimizer.OptimizeCharacterAsync(_character, _calculationToOptimize, _requirements, _thoroughness, false);
        }
Beispiel #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);
        }
Beispiel #3
0
        private void SaveOptimizationParameters()
        {
            _character.CalculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize, null);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (Control ctrl in groupBoxRequirements.Controls)
            {
                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);
                }
            }
            _character.OptimizationRequirements = requirements;
        }
Beispiel #4
0
        private void FormOptimize_FormClosed(object sender, FormClosedEventArgs e)
        {
            Properties.Optimizer.Default.OverrideRegem         = checkBoxOverrideRegem.Checked;
            Properties.Optimizer.Default.OverrideReenchant     = checkBoxOverrideReenchant.Checked;
            Properties.Optimizer.Default.Thoroughness          = trackBarThoroughness.Value;
            Properties.Optimizer.Default.CalculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize);
            Properties.Optimizer.Default.Save();

            _character.CalculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (Control ctrl in groupBoxRequirements.Controls)
            {
                if (ctrl is Panel)
                {
                    OptimizationRequirement requirement = new OptimizationRequirement();
                    foreach (Control reqCtrl in ctrl.Controls)
                    {
                        switch (reqCtrl.Name)
                        {
                        case "comboBoxRequirementCalculation":
                            requirement.Calculation = GetCalculationStringFromComboBox(reqCtrl as ComboBox);
                            break;

                        case "comboBoxRequirementGreaterLessThan":
                            requirement.LessThan = (reqCtrl as ComboBox).SelectedIndex == 1;
                            break;

                        case "numericUpDownRequirementValue":
                            requirement.Value = (float)((reqCtrl as NumericUpDown).Value);
                            break;
                        }
                    }
                    requirements.Add(requirement);
                }
            }
            _character.OptimizationRequirements = requirements;
        }
Beispiel #5
0
        private List <OptimizationRequirement> GetOptimizationRequirements(out bool costRequirement)
        {
            costRequirement = false;
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (UIElement requirementGrid in RequirementsStack.Children)
            {
                Grid grid = requirementGrid as Grid;
                if (grid != null)
                {
                    OptimizationRequirement requirement = new OptimizationRequirement();
                    requirement.Calculation = GetCalculationStringFromComboBox(grid.Children[0] as ComboBox, grid.Children[1] as ComboBox);
                    requirement.LessThan    = (grid.Children[2] as ComboBox).SelectedIndex == 1;
                    requirement.Value       = (float)((grid.Children[3] as NumericUpDown).Value);
                    requirements.Add(requirement);
                    if (requirement.Calculation == "[Cost]")
                    {
                        costRequirement = true;
                    }
                }
            }
            return(requirements);
        }
Beispiel #6
0
        private void AddRequirement(OptimizationRequirement requirement)
        {
            Grid requirementGrid = new Grid();

            requirementGrid.Style = Resources["RequirementGridStyle"] as Style;
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });

            ComboBox requirementCalculationCombo = new ComboBox();

            requirementCalculationCombo.Style = Resources["RequirementComboStyle"] as Style;

            List <string> requirements = new List <string>();

            requirements.Add("Overall Rating");
            foreach (string subPoint in Calculations.SubPointNameColors.Keys)
            {
                requirements.Add(subPoint + " Rating");
            }
            requirements.AddRange(Calculations.OptimizableCalculationLabels);
            requirements.Add("Talent");
            requirements.Add("Cost");
            requirementCalculationCombo.ItemsSource = requirements;
            requirementCalculationCombo.Tag         = Calculations.SubPointNameColors.Count;
            requirementCalculationCombo.Tag         = 0;
            Grid.SetColumn(requirementCalculationCombo, 0);
            Grid.SetColumnSpan(requirementCalculationCombo, 2);
            requirementCalculationCombo.SelectionChanged += requirementCalculationCombo_SelectionChanged;
            requirementGrid.Children.Add(requirementCalculationCombo);

            ComboBox requirementTalentsCombo = new ComboBox();

            requirementTalentsCombo.Style       = Resources["RequirementComboStyle"] as Style;
            requirementTalentsCombo.ItemsSource = talentList;
            requirementTalentsCombo.Visibility  = Visibility.Collapsed;
            Grid.SetColumn(requirementTalentsCombo, 1);
            requirementGrid.Children.Add(requirementTalentsCombo);

            ComboBox requirementGreaterCombo = new ComboBox();

            requirementGreaterCombo.Style       = Resources["RequirementGreaterComboStyle"] as Style;
            requirementGreaterCombo.ItemsSource = new string[] { "≥", "≤" };
            requirementGreaterCombo.Tag         = 1;
            Grid.SetColumn(requirementGreaterCombo, 2);
            requirementGrid.Children.Add(requirementGreaterCombo);

            NumericUpDown requirementNum = new NumericUpDown();

            requirementNum.Style = Resources["RequirementNumStyle"] as Style;
            requirementNum.Tag   = 2;
            Grid.SetColumn(requirementNum, 3);
            requirementGrid.Children.Add(requirementNum);

            Button requirementRemoveButton = new Button();

            requirementRemoveButton.Style  = Resources["RequirementRemoveStyle"] as Style;
            requirementRemoveButton.Click += new RoutedEventHandler(RemoveRequirement_Click);
            Grid.SetColumn(requirementRemoveButton, 4);
            requirementGrid.Children.Add(requirementRemoveButton);

            if (requirement == null)
            {
                requirementCalculationCombo.SelectedIndex = 0;
                requirementGreaterCombo.SelectedIndex     = 0;
                requirementNum.Value = 0;
            }
            else
            {
                string calculationString = requirement.Calculation;
                if (calculationString.StartsWith("[Overall]", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedIndex = 0;
                }
                else if (calculationString.StartsWith("[SubPoint ", StringComparison.Ordinal))
                {
                    calculationString = calculationString.Substring(10).TrimEnd(']');
                    int index = int.Parse(calculationString);
                    if (index < Calculations.SubPointNameColors.Count)
                    {
                        requirementCalculationCombo.SelectedIndex = index + 1;
                    }
                }
                else if (calculationString.StartsWith("[Talent ", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedItem = "Talent";
                    string talent = calculationString.Substring(8).TrimEnd(']');
                    int    index  = int.Parse(talent);
                    if (index < talentList.Length)
                    {
                        requirementTalentsCombo.SelectedIndex = index;
                    }
                }
                else if (calculationString.StartsWith("[Cost]", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedItem = "Cost";
                }
                else
                {
                    if (Array.IndexOf(Calculations.OptimizableCalculationLabels, calculationString) >= 0)
                    {
                        requirementCalculationCombo.SelectedItem = calculationString;
                    }
                }
                requirementGreaterCombo.SelectedIndex = requirement.LessThan ? 1 : 0;
                requirementNum.Value = (double)requirement.Value;
            }

            RequirementsStack.Children.Add(requirementGrid);
        }
Beispiel #7
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);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();

            foreach (Control ctrl in groupBoxRequirements.Controls)
            {
                if (ctrl is Panel)
                {
                    OptimizationRequirement requirement = new OptimizationRequirement();
                    foreach (Control reqCtrl in ctrl.Controls)
                    {
                        switch (reqCtrl.Name)
                        {
                        case "comboBoxRequirementCalculation":
                            requirement.Calculation = GetCalculationStringFromComboBox(reqCtrl as ComboBox);
                            break;

                        case "comboBoxRequirementGreaterLessThan":
                            requirement.LessThan = (reqCtrl as ComboBox).SelectedIndex == 1;
                            break;

                        case "numericUpDownRequirementValue":
                            requirement.Value = (float)((reqCtrl as NumericUpDown).Value);
                            break;
                        }
                    }
                    requirements.Add(requirement);
                }
            }
            OptimizationRequirement[] _requirements = requirements.ToArray();

            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)
                {
                    return;
                }
            }

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

            buttonUpgrades.Text              = "Calculating...";
            buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                trackBarThoroughness.Enabled = false;
            buttonCancel.DialogResult        = DialogResult.None;

            Optimizer.OptimizationMethod = Properties.Optimizer.Default.OptimizationMethod;
            _optimizer.ComputeUpgradesAsync(_character, _calculationToOptimize, _requirements, _thoroughness);
        }
 private List<OptimizationRequirement> GetOptimizationRequirements(out bool costRequirement)
 {
     costRequirement = false;
     List<OptimizationRequirement> requirements = new List<OptimizationRequirement>();
     foreach (UIElement requirementGrid in RequirementsStack.Children)
     {
         Grid grid = requirementGrid as Grid;
         if (grid != null)
         {
             OptimizationRequirement requirement = new OptimizationRequirement();
             requirement.Calculation = GetCalculationStringFromComboBox(grid.Children[0] as ComboBox, grid.Children[1] as ComboBox);
             requirement.LessThan = (grid.Children[2] as ComboBox).SelectedIndex == 1;
             requirement.Value = (float)((grid.Children[3] as NumericUpDown).Value);
             requirements.Add(requirement);
             if (requirement.Calculation == "[Cost]")
             {
                 costRequirement = true;
             }
         }
     }
     return requirements;
 }
        private void AddRequirement(OptimizationRequirement requirement)
        {
            Grid requirementGrid = new Grid();
            requirementGrid.Style = Resources["RequirementGridStyle"] as Style;
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            requirementGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            ComboBox requirementCalculationCombo = new ComboBox();
            requirementCalculationCombo.Style = Resources["RequirementComboStyle"] as Style;

            List<string> requirements = new List<string>();
            requirements.Add("Overall Rating");
            foreach (string subPoint in Calculations.SubPointNameColors.Keys)
                requirements.Add(subPoint + " Rating");
            requirements.AddRange(Calculations.OptimizableCalculationLabels);
            requirements.Add("Talent");
            requirements.Add("Cost");
            requirementCalculationCombo.ItemsSource = requirements;
            requirementCalculationCombo.Tag = Calculations.SubPointNameColors.Count;
            requirementCalculationCombo.Tag = 0;
            Grid.SetColumn(requirementCalculationCombo, 0);
            Grid.SetColumnSpan(requirementCalculationCombo, 2);
            requirementCalculationCombo.SelectionChanged += requirementCalculationCombo_SelectionChanged;
            requirementGrid.Children.Add(requirementCalculationCombo);

            ComboBox requirementTalentsCombo = new ComboBox();
            requirementTalentsCombo.Style = Resources["RequirementComboStyle"] as Style;
            requirementTalentsCombo.ItemsSource = talentList;
            requirementTalentsCombo.Visibility = Visibility.Collapsed;
            Grid.SetColumn(requirementTalentsCombo, 1);
            requirementGrid.Children.Add(requirementTalentsCombo);

            ComboBox requirementGreaterCombo = new ComboBox();
            requirementGreaterCombo.Style = Resources["RequirementGreaterComboStyle"] as Style;
            requirementGreaterCombo.ItemsSource = new string[] { "≥", "≤" };
            requirementGreaterCombo.Tag = 1;
            Grid.SetColumn(requirementGreaterCombo, 2);
            requirementGrid.Children.Add(requirementGreaterCombo);

            NumericUpDown requirementNum = new NumericUpDown();
            requirementNum.Style = Resources["RequirementNumStyle"] as Style;
            requirementNum.Tag = 2;
            Grid.SetColumn(requirementNum, 3);
            requirementGrid.Children.Add(requirementNum);

            Button requirementRemoveButton = new Button();
            requirementRemoveButton.Style = Resources["RequirementRemoveStyle"] as Style;
            requirementRemoveButton.Click += new RoutedEventHandler(RemoveRequirement_Click);
            Grid.SetColumn(requirementRemoveButton, 4);
            requirementGrid.Children.Add(requirementRemoveButton);

            if (requirement == null)
            {
                requirementCalculationCombo.SelectedIndex = 0;
                requirementGreaterCombo.SelectedIndex = 0;
                requirementNum.Value = 0;
            }
            else
            {
                string calculationString = requirement.Calculation;
                if (calculationString.StartsWith("[Overall]", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedIndex = 0;
                }
                else if (calculationString.StartsWith("[SubPoint ", StringComparison.Ordinal))
                {
                    calculationString = calculationString.Substring(10).TrimEnd(']');
                    int index = int.Parse(calculationString);
                    if (index < Calculations.SubPointNameColors.Count)
                    {
                        requirementCalculationCombo.SelectedIndex = index + 1;
                    }
                }
                else if (calculationString.StartsWith("[Talent ", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedItem = "Talent";
                    string talent = calculationString.Substring(8).TrimEnd(']');
                    int index = int.Parse(talent);
                    if (index < talentList.Length)
                    {
                        requirementTalentsCombo.SelectedIndex = index;
                    }
                }
                else if (calculationString.StartsWith("[Cost]", StringComparison.Ordinal))
                {
                    requirementCalculationCombo.SelectedItem = "Cost";
                }
                else
                {
                    if (Array.IndexOf(Calculations.OptimizableCalculationLabels, calculationString) >= 0)
                    {
                        requirementCalculationCombo.SelectedItem = calculationString;
                    }
                }
                requirementGreaterCombo.SelectedIndex = requirement.LessThan ? 1 : 0;
                requirementNum.Value = (double)requirement.Value;
            }

            RequirementsStack.Children.Add(requirementGrid);
        }
Beispiel #10
0
        private void buttonOptimize_Click(object sender, EventArgs e)
        {
            bool   _overrideRegem         = checkBoxOverrideRegem.Checked;
            bool   _overrideReenchant     = checkBoxOverrideReenchant.Checked;
            int    _thoroughness          = trackBarThoroughness.Value;
            string _calculationToOptimize = GetCalculationStringFromComboBox(comboBoxCalculationToOptimize, null);
            List <OptimizationRequirement> requirements = new List <OptimizationRequirement>();
            bool costRequirement = false;

            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 (requirement.Calculation == "[Cost]")
                    {
                        costRequirement = true;
                    }
                }
            }

            _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, costRequirement);
            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;
                    }
                }
                prompt = _optimizer.CheckOneHandedWeaponUniqueness();
                if (prompt != null)
                {
                    if (MessageBox.Show(prompt, "Optimizer Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        EnableAllReqs(); return;
                    }
                }
                if (!_optimizer.ItemGenerator.IsCharacterValid(_character, out prompt, true))
                {
                    if (MessageBox.Show(prompt, "Optimizer Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        EnableAllReqs(); return;
                    }
                }
            }

            buttonOptimize.Text                  = "Optimizing...";
            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.OptimizeCharacterAsync(_character, _calculationToOptimize, requirements, _thoroughness, false);
        }