Ejemplo n.º 1
0
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            if (e.ColumnIndex == loadBatchCharacterColumn.Index)
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.DefaultExt  = ".xml";
                dialog.Filter      = "Rawr Xml Character Files | *.xml";
                dialog.Multiselect = false;
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    dataGridView[e.ColumnIndex, e.RowIndex].Value = RelativePath(dialog.FileName, AppDomain.CurrentDomain.BaseDirectory);
                    dataGridView.NotifyCurrentCellDirty(true); // force DataGridView to add new row
                    dataGridView.NotifyCurrentCellDirty(false);
                }
                dialog.Dispose();
            }
            else if (e.ColumnIndex == showBatchCharacterColumn.Index && e.RowIndex != dataGridView.NewRowIndex)
            {
                formMain.LoadBatchCharacter(dataGridView.Rows[e.RowIndex].DataBoundItem as BatchCharacter);
            }
            else if (e.ColumnIndex == diffBatchCharacterColumn.Index && e.RowIndex != dataGridView.NewRowIndex)
            {
                BatchCharacter     character = (BatchCharacter)dataGridView.Rows[e.RowIndex].DataBoundItem;
                Character          before    = Character.Load(character.AbsolutePath); // load clean version for comparison
                Character          after     = character.Character;
                FormOptimizeResult result    = new FormOptimizeResult(before, after);
                result.SetOptimizerScores(character.Score, character.NewScore.GetValueOrDefault(character.Score));
                if (result.ShowDialog(this) == DialogResult.No)
                {
                    // we don't want the new character, reload the old one
                    Character _character = character.Character;
                    _character.IsLoading = true;
                    _character.SetItems(before, false, false);
                    _character.ActiveBuffs = before.ActiveBuffs;
                    //_character.CurrentTalents = before.CurrentTalents; // let's not play with talents for now
                    _character.IsLoading = false;
                    _character.OnCalculationsInvalidated();
                    character.UnsavedChanges = false; // reset the dirty flag and update ui
                }
            }
        }
Ejemplo n.º 2
0
        void _optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            buttonCancel.DialogResult = DialogResult.Cancel;
            if (e.Cancelled)
            {
                labelMax.Text                        = string.Empty;
                buttonOptimize.Text                  = "Optimize";
                buttonCancel.Text                    = "Close";
                buttonOptimize.Enabled               = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                    trackBarThoroughness.Enabled     = checkBoxMixology.Enabled = checkBoxOptimizeElixir.Enabled =
                        checkBoxOptimizeFood.Enabled = checkBoxOptimizeTalents.Enabled = checkBoxMutateTalents.Enabled =
                            comboBoxCalculationToOptimize.Enabled = true;
                foreach (Control ctrl in groupBoxRequirements.Controls)
                {
                    ctrl.Enabled = true;
                }
                progressBarAlt.Value = progressBarMain.Value = 0;
            }
            else
            {
                progressBarAlt.Value = progressBarMain.Value = 100;
                Character bestCharacter = e.OptimizedCharacter;
                if (bestCharacter == null)
                {
                    labelMax.Text                        = string.Empty;
                    buttonOptimize.Text                  = "Optimize";
                    buttonCancel.Text                    = "Close";
                    buttonOptimize.Enabled               = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                        trackBarThoroughness.Enabled     = checkBoxMixology.Enabled = checkBoxOptimizeElixir.Enabled =
                            checkBoxOptimizeFood.Enabled = checkBoxOptimizeTalents.Enabled = checkBoxMutateTalents.Enabled =
                                comboBoxCalculationToOptimize.Enabled = true;
                    foreach (Control ctrl in groupBoxRequirements.Controls)
                    {
                        ctrl.Enabled = true;
                    }
                    progressBarAlt.Value = progressBarMain.Value = 0;
                    MessageBox.Show(this, "Sorry, Rawr was unable to find a gearset to meet your requirements.", "Rawr Optimizer Results");
                }

                if (_character != null)
                {
                    FormOptimizeResult result = new FormOptimizeResult(_character, bestCharacter);
                    result.SetOptimizerScores(e.CurrentCharacterValue, e.OptimizedCharacterValue);
                    result.ShowDialog(this);
//                    OptimizerResults results = new OptimizerResults(_character, bestCharacter, checkBoxOptimizeTalents.Checked);
//                    string msg = e.OptimizedCharacterValue >= 0 ?
//                        string.Format("The Optimizer found a gearset with a score of {0}. (Your currently equipped gear has a score of {1}) Would you like to equip the optimized gear?",
//                            e.OptimizedCharacterValue, e.CurrentCharacterValue) :
//                        "The Optimizer was not able to meet all the requirements. Would you like to equip the gear that is closest to meeting them?";
                    if (result.DialogResult == DialogResult.Yes)
                    {
                        //Loading new items while IsLoading==true causes properties to be reset to their previously cached values,
                        //so load all the items beforehand, then put them into the character all at once.
                        _character.IsLoading = true;
                        _character.SetItems(bestCharacter, false, false);
                        _character.ActiveBuffs = bestCharacter.ActiveBuffs;
                        if (checkBoxOptimizeTalents.Checked || checkBoxMutateTalents.Checked)
                        {
                            _character.CurrentTalents = bestCharacter.CurrentTalents;
                        }
                        _character.IsLoading = false;
                        _character.OnCalculationsInvalidated();
                        if (checkBoxOptimizeTalents.Checked || checkBoxMutateTalents.Checked)
                        {
                            FormMain.Instance.TalentPicker.Talents = _character.CurrentTalents;
                        }
                        Close();
                        return;
                    }
                    result.Dispose();
                }
                labelMax.Text                        = string.Empty;
                buttonOptimize.Text                  = "Optimize";
                buttonCancel.Text                    = "Close";
                buttonOptimize.Enabled               = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                    trackBarThoroughness.Enabled     = checkBoxMixology.Enabled = checkBoxOptimizeElixir.Enabled =
                        checkBoxOptimizeFood.Enabled = checkBoxOptimizeTalents.Enabled = checkBoxMutateTalents.Enabled =
                            comboBoxCalculationToOptimize.Enabled = true;
                foreach (Control ctrl in groupBoxRequirements.Controls)
                {
                    ctrl.Enabled = true;
                }
                progressBarAlt.Value = progressBarMain.Value = 0;
            }
        }