コード例 #1
0
ファイル: OptimizeWindow.xaml.cs プロジェクト: rakot/rawr
        private void optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                MaxScoreLabel.Text = string.Empty;
                ControlsEnabled(true);
                AltProgress.Value = MainProgress.Value = 0;
            }
            else
            {
                AltProgress.Value = MainProgress.Value = 100;
                Character bestCharacter = e.OptimizedCharacter;
                if (bestCharacter == null)
                {
                    ControlsEnabled(true);
                    MessageBox.Show("Sorry, Rawr was unable to find a gearset to meet your requirements.", "Rawr Optimizer Results", MessageBoxButton.OK);
                }

                if (character != null)
                {
                    OptimizerResults results = new OptimizerResults(character, bestCharacter, false);
                    results.Closed += new EventHandler(results_Closed);
                    results.Show();
                }
                else
                {
                    ControlsEnabled(true);
                }
            }
        }
コード例 #2
0
        void _optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            buttonCancel.DialogResult = DialogResult.Cancel;
            if (e.Cancelled)
            {
                labelMax.Text                    = string.Empty;
                buttonOptimize.Text              = "Optimize";
                buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                    trackBarThoroughness.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";
                    buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                        trackBarThoroughness.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 || MessageBox.Show(this, 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),
                                                          "Rawr Optimizer Results", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    _character.Back             = bestCharacter.Back == null ? null : ItemCache.FindItemById(bestCharacter.Back.GemmedId);
                    _character.Chest            = bestCharacter.Chest == null ? null : ItemCache.FindItemById(bestCharacter.Chest.GemmedId);
                    _character.Feet             = bestCharacter.Feet == null ? null : ItemCache.FindItemById(bestCharacter.Feet.GemmedId);
                    _character.Finger1          = bestCharacter.Finger1 == null ? null : ItemCache.FindItemById(bestCharacter.Finger1.GemmedId);
                    _character.Finger2          = bestCharacter.Finger2 == null ? null : ItemCache.FindItemById(bestCharacter.Finger2.GemmedId);
                    _character.Hands            = bestCharacter.Hands == null ? null : ItemCache.FindItemById(bestCharacter.Hands.GemmedId);
                    _character.Head             = bestCharacter.Head == null ? null : ItemCache.FindItemById(bestCharacter.Head.GemmedId);
                    _character.Legs             = bestCharacter.Legs == null ? null : ItemCache.FindItemById(bestCharacter.Legs.GemmedId);
                    _character.MainHand         = bestCharacter.MainHand == null ? null : ItemCache.FindItemById(bestCharacter.MainHand.GemmedId);
                    _character.Neck             = bestCharacter.Neck == null ? null : ItemCache.FindItemById(bestCharacter.Neck.GemmedId);
                    _character.OffHand          = bestCharacter.OffHand == null ? null : ItemCache.FindItemById(bestCharacter.OffHand.GemmedId);
                    _character.Projectile       = bestCharacter.Projectile == null ? null : ItemCache.FindItemById(bestCharacter.Projectile.GemmedId);
                    _character.ProjectileBag    = bestCharacter.ProjectileBag == null ? null : ItemCache.FindItemById(bestCharacter.ProjectileBag.GemmedId);
                    _character.Ranged           = bestCharacter.Ranged == null ? null : ItemCache.FindItemById(bestCharacter.Ranged.GemmedId);
                    _character.Shoulders        = bestCharacter.Shoulders == null ? null : ItemCache.FindItemById(bestCharacter.Shoulders.GemmedId);
                    _character.Trinket1         = bestCharacter.Trinket1 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket1.GemmedId);
                    _character.Trinket2         = bestCharacter.Trinket2 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket2.GemmedId);
                    _character.Waist            = bestCharacter.Waist == null ? null : ItemCache.FindItemById(bestCharacter.Waist.GemmedId);
                    _character.Wrist            = bestCharacter.Wrist == null ? null : ItemCache.FindItemById(bestCharacter.Wrist.GemmedId);
                    _character.BackEnchant      = bestCharacter.BackEnchant;
                    _character.ChestEnchant     = bestCharacter.ChestEnchant;
                    _character.FeetEnchant      = bestCharacter.FeetEnchant;
                    _character.Finger1Enchant   = bestCharacter.Finger1Enchant;
                    _character.Finger2Enchant   = bestCharacter.Finger2Enchant;
                    _character.HandsEnchant     = bestCharacter.HandsEnchant;
                    _character.HeadEnchant      = bestCharacter.HeadEnchant;
                    _character.LegsEnchant      = bestCharacter.LegsEnchant;
                    _character.MainHandEnchant  = bestCharacter.MainHandEnchant;
                    _character.OffHandEnchant   = bestCharacter.OffHandEnchant;
                    _character.RangedEnchant    = bestCharacter.RangedEnchant;
                    _character.ShouldersEnchant = bestCharacter.ShouldersEnchant;
                    _character.WristEnchant     = bestCharacter.WristEnchant;
                    _character.OnItemsChanged();
                    Close();
                }
                else
                {
                    labelMax.Text                    = string.Empty;
                    buttonOptimize.Text              = "Optimize";
                    buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
                        trackBarThoroughness.Enabled = true;
                    progressBarAlt.Value             = progressBarMain.Value = 0;
                }
            }
        }
コード例 #3
0
ファイル: BatchTools.cs プロジェクト: LucasPeacecraft/rawr
        void _optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            int maxRounds = MaxRounds;

            switch (currentOperation)
            {
                case AsyncOperation.Optimize:
                    {
                        if (e.Cancelled || e.Error != null)
                        {
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }
                            break;
                        }
                        if (e.OptimizedCharacterValue > e.CurrentCharacterValue + 0.00001f)
                        {
                            Character _character = CurrentBatchCharacter.Character;
                            Character bestCharacter = e.OptimizedCharacter;
                            _character.SetItems(bestCharacter);

                            //CurrentBatchCharacter.UnsavedChanges = true;
                            //CurrentBatchCharacter.NewScore = e.OptimizedCharacterValue;
                            //CurrentBatchCharacter.NewScore = ItemInstanceOptimizer.GetOptimizationValue(_character, CurrentBatchCharacter.Model); // on item change always evaluate with equipped gear first (needed by mage module to store incremental data)

                            optimizerRound = 0;
                        }
                        else if (Math.Abs(e.OptimizedCharacterValue - e.CurrentCharacterValue) < 0.00001f && !e.CurrentCharacterInjected)
                        {
                            optimizerRound = maxRounds;
                        }
                        else
                        {
                            optimizerRound++;
                        }
                        if (optimizerRound >= maxRounds)
                        {
                            do
                            {
                                batchIndex++;
                            } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                            optimizerRound = 0;
                        }

                        if (batchIndex < BatchCharacterList.Count)
                        {
                            OptimizeCurrentBatchCharacter();
                        }
                        else
                        {
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }
                        }
                    }
                    break;
                case AsyncOperation.ProgressiveOptimize:
                    {
                        if (e.Cancelled || e.Error != null)
                        {
                            bestRoundCharacter = null;
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }
                            break;
                        }
                        // try to find at least same value, although sometimes it's possible it doesn't exist
                        // anymore due to restrictions
                        if (e.OptimizedCharacterValue > bestRoundValue + 0.00001f)
                        {
                            bestRoundCharacter = e.OptimizedCharacter;
                            bestRoundValue = e.OptimizedCharacterValue;
                        }

                        if (e.OptimizedCharacterValue > e.CurrentCharacterValue + 0.00001f)
                        {
                            Character _character = CurrentBatchCharacter.Character;
                            Character bestCharacter = e.OptimizedCharacter;
                            _character.SetItems(bestCharacter);

                            optimizerRound = 0;
                        }
                        else if (Math.Abs(e.OptimizedCharacterValue - e.CurrentCharacterValue) < 0.00001f && !e.CurrentCharacterInjected)
                        {
                            optimizerRound = maxRounds;
                        }
                        else
                        {
                            optimizerRound++;
                        }
                        if (optimizerRound >= maxRounds)
                        {
                            // we have to use the best one we get, even if it's lower value than what we had before
                            Character _character = CurrentBatchCharacter.Character;
                            // verify if it's actually different so we don't make it dirty when not necessary
                            bool dirty = false;
                            for (int slot = 0; slot < Character.OptimizableSlotCount; slot++)
                            {
                                if (slot != (int)CharacterSlot.OffHand || bestRoundCharacter.CurrentCalculations.IncludeOffHandInCalculations(bestRoundCharacter))
                                {
                                    if (slot == (int)CharacterSlot.Finger1 || slot == (int)CharacterSlot.Trinket1)
                                    {
                                        // ignore if we have 1/2 swap
                                        if (!((_character._item[slot] == bestRoundCharacter._item[slot] && _character._item[slot + 1] == bestRoundCharacter._item[slot + 1]) ||
                                            (_character._item[slot] == bestRoundCharacter._item[slot + 1] && _character._item[slot + 1] == bestRoundCharacter._item[slot])))
                                        {
                                            dirty = true;
                                            break;
                                        }
                                        slot++;
                                    }
                                    else
                                    {
                                        if (_character._item[slot] != bestRoundCharacter._item[slot])
                                        {
                                            dirty = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (dirty)
                            {
                                _character.SetItems(bestRoundCharacter);
                            }
                            // we have to perform item restrictions on the active item generator
                            // so that we don't regem/reenchant already used items
                            itemGenerator.AddItemRestrictions(bestRoundCharacter);
                            // move to next batch character
                            do
                            {
                                batchIndex++;
                            } while (batchIndex < BatchCharacterList.Count && (CurrentBatchCharacter.Character == null || CurrentBatchCharacter.Locked));
                            bestRoundCharacter = null;
                            bestRoundValue = float.NegativeInfinity;
                            optimizerRound = 0;
                        }

                        if (batchIndex < BatchCharacterList.Count)
                        {
                            int _thoroughness = Thoroughness;
                            Character character = CurrentBatchCharacter.Character.Clone();
                            // regularize character with current item restrictions
                            itemGenerator.RegularizeCharacter(character);
                            optimizer.InitializeItemCache(character, CurrentBatchCharacter.Model, itemGenerator);
                            optimizer.OptimizeCharacterAsync(character, _thoroughness, true);
                        }
                        else
                        {
                            bestRoundCharacter = null;
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }
                        }
                    }
                    break;
                case AsyncOperation.BuildProgressiveUpgradeList:
                    {
                        if (e.Cancelled || e.Error != null)
                        {
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }
                            break;
                        }
                        // we optimized the character with new item restrictions
                        // update the working character and start upgrade evaluation
                        workingCharacter = e.OptimizedCharacter;
                        int _thoroughness = Thoroughness;
                        // evaluate what we get by using the optimized item
                        optimizer.EvaluateUpgradeAsync(workingCharacter, _thoroughness, optimizedItemInstance);
                    }
                    break;
            }
        }
コード例 #4
0
        private void optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                MaxScoreLabel.Text = string.Empty;
                ControlsEnabled(true);
                AltProgress.Value = MainProgress.Value = 0;
            }
            else
            {
                AltProgress.Value = MainProgress.Value = 100;
                Character bestCharacter = e.OptimizedCharacter;
                if (bestCharacter == null)
                {
                    ControlsEnabled(true);
                    MessageBox.Show("Sorry, Rawr was unable to find a gearset to meet your requirements.", "Rawr Optimizer Results", MessageBoxButton.OK);
                }

                if (character != null)
                {
                    OptimizerResults results = new OptimizerResults(character, bestCharacter, false);
                    results.Closed += new EventHandler(results_Closed);
                    results.Show();
                }
                else ControlsEnabled(true);
            }
        }
コード例 #5
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;
            }
        }
コード例 #6
0
        void _optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            int maxRounds = trackBarMaxRounds.Value;

            switch (currentOperation)
            {
            case AsyncOperation.Optimize:
                if (e.Cancelled || e.Error != null)
                {
                    currentOperation        = AsyncOperation.None;
                    buttonCancel.Enabled    = false;
                    statusLabel.Text        = "";
                    statusProgressBar.Value = 0;
                    break;
                }
                if (e.OptimizedCharacterValue > e.CurrentCharacterValue + 0.00001f)
                {
                    Character _character    = CurrentBatchCharacter.Character;
                    Character bestCharacter = e.OptimizedCharacter;

                    _character.Back             = bestCharacter.Back == null ? null : ItemCache.FindItemById(bestCharacter.Back.GemmedId);
                    _character.Chest            = bestCharacter.Chest == null ? null : ItemCache.FindItemById(bestCharacter.Chest.GemmedId);
                    _character.Feet             = bestCharacter.Feet == null ? null : ItemCache.FindItemById(bestCharacter.Feet.GemmedId);
                    _character.Finger1          = bestCharacter.Finger1 == null ? null : ItemCache.FindItemById(bestCharacter.Finger1.GemmedId);
                    _character.Finger2          = bestCharacter.Finger2 == null ? null : ItemCache.FindItemById(bestCharacter.Finger2.GemmedId);
                    _character.Hands            = bestCharacter.Hands == null ? null : ItemCache.FindItemById(bestCharacter.Hands.GemmedId);
                    _character.Head             = bestCharacter.Head == null ? null : ItemCache.FindItemById(bestCharacter.Head.GemmedId);
                    _character.Legs             = bestCharacter.Legs == null ? null : ItemCache.FindItemById(bestCharacter.Legs.GemmedId);
                    _character.MainHand         = bestCharacter.MainHand == null ? null : ItemCache.FindItemById(bestCharacter.MainHand.GemmedId);
                    _character.Neck             = bestCharacter.Neck == null ? null : ItemCache.FindItemById(bestCharacter.Neck.GemmedId);
                    _character.OffHand          = bestCharacter.OffHand == null ? null : ItemCache.FindItemById(bestCharacter.OffHand.GemmedId);
                    _character.Projectile       = bestCharacter.Projectile == null ? null : ItemCache.FindItemById(bestCharacter.Projectile.GemmedId);
                    _character.ProjectileBag    = bestCharacter.ProjectileBag == null ? null : ItemCache.FindItemById(bestCharacter.ProjectileBag.GemmedId);
                    _character.Ranged           = bestCharacter.Ranged == null ? null : ItemCache.FindItemById(bestCharacter.Ranged.GemmedId);
                    _character.Shoulders        = bestCharacter.Shoulders == null ? null : ItemCache.FindItemById(bestCharacter.Shoulders.GemmedId);
                    _character.Trinket1         = bestCharacter.Trinket1 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket1.GemmedId);
                    _character.Trinket2         = bestCharacter.Trinket2 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket2.GemmedId);
                    _character.Waist            = bestCharacter.Waist == null ? null : ItemCache.FindItemById(bestCharacter.Waist.GemmedId);
                    _character.Wrist            = bestCharacter.Wrist == null ? null : ItemCache.FindItemById(bestCharacter.Wrist.GemmedId);
                    _character.BackEnchant      = bestCharacter.BackEnchant;
                    _character.ChestEnchant     = bestCharacter.ChestEnchant;
                    _character.FeetEnchant      = bestCharacter.FeetEnchant;
                    _character.Finger1Enchant   = bestCharacter.Finger1Enchant;
                    _character.Finger2Enchant   = bestCharacter.Finger2Enchant;
                    _character.HandsEnchant     = bestCharacter.HandsEnchant;
                    _character.HeadEnchant      = bestCharacter.HeadEnchant;
                    _character.LegsEnchant      = bestCharacter.LegsEnchant;
                    _character.MainHandEnchant  = bestCharacter.MainHandEnchant;
                    _character.OffHandEnchant   = bestCharacter.OffHandEnchant;
                    _character.RangedEnchant    = bestCharacter.RangedEnchant;
                    _character.ShouldersEnchant = bestCharacter.ShouldersEnchant;
                    _character.WristEnchant     = bestCharacter.WristEnchant;
                    _character.OnItemsChanged();

                    CurrentBatchCharacter.UnsavedChanges = true;
                    //CurrentBatchCharacter.NewScore = e.OptimizedCharacterValue;
                    CurrentBatchCharacter.NewScore = Optimizer.GetOptimizationValue(_character, CurrentBatchCharacter.Model);     // on item change always evaluate with equipped gear first (needed by mage module to store incremental data)

                    optimizerRound = 0;
                }
                else if (Math.Abs(e.OptimizedCharacterValue - e.CurrentCharacterValue) < 0.00001f && !e.CurrentCharacterInjected)
                {
                    optimizerRound = maxRounds;
                }
                else
                {
                    optimizerRound++;
                }
                if (optimizerRound >= maxRounds)
                {
                    do
                    {
                        batchIndex++;
                    } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                    optimizerRound = 0;
                }

                if (batchIndex < BatchCharacterList.Count)
                {
                    OptimizeCurrentBatchCharacter();
                }
                else
                {
                    currentOperation        = AsyncOperation.None;
                    buttonCancel.Enabled    = false;
                    statusLabel.Text        = "";
                    statusProgressBar.Value = 0;
                }
                break;
            }
        }