Ejemplo n.º 1
0
        private void ComputeUpgradesCurrentBatchCharacter()
        {
            int  _thoroughness      = trackBarThoroughness.Value;
            bool _overrideRegem     = checkBoxOverrideRegem.Checked;
            bool _overrideReenchant = checkBoxOverrideReenchant.Checked;

            _optimizer.InitializeItemCache(CurrentBatchCharacter.Character.AvailableItems, _overrideRegem, _overrideReenchant, CurrentBatchCharacter.Model);
            _optimizer.ComputeUpgradesAsync(CurrentBatchCharacter.Character, CurrentBatchCharacter.Character.CalculationToOptimize, CurrentBatchCharacter.Character.OptimizationRequirements.ToArray(), _thoroughness);
        }
Ejemplo n.º 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);
            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);
        }