Ejemplo n.º 1
0
        private void UpdateSavedSpecs()
        {
            SavedPetTalentSpecList savedSpecs = SavedPetTalentSpec.SpecsFor(CalculationOptionsHunter.PetFamilyToPetFamilyTree(CalcOpts.PetFamily));
            SavedPetTalentSpec     current    = null;

            updating = true;
            foreach (SavedPetTalentSpec sts in savedSpecs)
            {
                if (sts.Equals(CalcOpts.PetTalents))
                {
                    current = sts;
                    break;
                }
            }

            if (current != null)
            {
                HasCustomSpec            = false;
                SavedCombo.ItemsSource   = savedSpecs;
                SavedCombo.SelectedItem  = current;
                SaveDeleteButton.Content = "Delete";
            }
            else
            {
                PetFamilyTree ftree   = CalculationOptionsHunter.PetFamilyToPetFamilyTree(CalcOpts.PetFamily);
                int           treepts = (ftree == PetFamilyTree.Cunning  ? Tree1.Points() :
                                         (ftree == PetFamilyTree.Ferocity ? Tree2.Points() :
                                          (ftree == PetFamilyTree.Tenacity ? Tree3.Points() :
                                           Tree1.Points() + Tree2.Points() + Tree3.Points())));
                HasCustomSpec = true;
                current       = new SavedPetTalentSpec("Custom", CalcOpts.PetTalents, ftree, treepts);
                SavedPetTalentSpecList currentList = new SavedPetTalentSpecList();
                currentList.AddRange(savedSpecs);
                currentList.Add(current);
                SavedCombo.ItemsSource   = null;
                SavedCombo.ItemsSource   = currentList;
                SavedCombo.SelectedItem  = current;
                SaveDeleteButton.Content = "Save";
            }
            updating = false;
        }
Ejemplo n.º 2
0
        private void SaveDelete_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SavedPetTalentSpec currentSpec = SavedCombo.SelectedItem as SavedPetTalentSpec;

            if (HasCustomSpec)
            {
                PetFamilyTree ftree   = CalculationOptionsHunter.PetFamilyToPetFamilyTree(CalcOpts.PetFamily);
                int           treepts = (ftree == PetFamilyTree.Cunning ? Tree1.Points() :
                                         (ftree == PetFamilyTree.Ferocity ? Tree2.Points() :
                                          (ftree == PetFamilyTree.Tenacity ? Tree3.Points() :
                                           Tree1.Points() + Tree2.Points() + Tree3.Points())));
                FormSavePetTalentSpec dialog = new FormSavePetTalentSpec(CalcOpts.PetTalents, ftree, treepts);
                dialog.Closed += new EventHandler(dialog_Closed);
                dialog.Show();
            }
            else
            {
                SavedPetTalentSpec.AllSpecs.Remove(currentSpec);
                UpdateSavedSpecs();
            }
        }