public void UpdateGroupChecked(string group) { isLoading = true; bool someChecked = false; bool allChecked = true; foreach (UIElement element in templateItems[group].Children) { GemmingTemplateItem item = element as GemmingTemplateItem; someChecked = item.template.Enabled || someChecked; allChecked = item.template.Enabled && allChecked; } if (allChecked) { templateGroupChecks[group].IsChecked = true; } else if (someChecked) { templateGroupChecks[group].IsChecked = null; } else { templateGroupChecks[group].IsChecked = false; } isLoading = false; }
public void RemoveTemplate(GemmingTemplateItem item) { if (item.isCustom) { CustomStack.Children.Remove(item); character.CustomGemmingTemplates.Remove(item.template); UpdateGroupChecked(item.template.Group); } }
public GemmingTemplates(Character c) { isLoading = true; character = c; InitializeComponent(); GemmingsShownNum.Value = Properties.GeneralSettings.Default.CountGemmingsShown; ComparisonGemList.Slot = CharacterSlot.Gems; ComparisonGemList.Character = c; ComparisonGemList.SelectedItemChanged += new EventHandler(ComparisonGemList_SelectedItemChanged); ComparisonMetaList.Slot = CharacterSlot.Metas; ComparisonMetaList.Character = c; ComparisonMetaList.SelectedItemChanged += new EventHandler(ComparisonMetaList_SelectedItemChanged); templateItems = new Dictionary <string, StackPanel>(); templateItems["Custom"] = CustomStack; templateGroupChecks = new Dictionary <string, CheckBox>(); templateGroupChecks["Custom"] = CustomCheck; foreach (GemmingTemplate template in character.CurrentGemmingTemplates) { GemmingTemplateItem templateItem = new GemmingTemplateItem(this, template); if (!templateItems.ContainsKey(template.Group)) { Expander groupExpander = new Expander(); CheckBox groupCheckBox = new CheckBox(); groupCheckBox.Content = template.Group; groupCheckBox.Checked += new RoutedEventHandler(groupCheckBox_Checked); groupCheckBox.Indeterminate += new RoutedEventHandler(groupCheckBox_Checked); groupCheckBox.Unchecked += new RoutedEventHandler(groupCheckBox_Checked); templateGroupChecks[template.Group] = groupCheckBox; groupExpander.Header = groupCheckBox; GroupStack.Children.Add(groupExpander); StackPanel stack = new StackPanel(); groupExpander.Content = stack; templateItems[template.Group] = stack; } templateItems[template.Group].Children.Add(templateItem); } foreach (GemmingTemplate template in character.CustomGemmingTemplates) { GemmingTemplateItem templateItem = new GemmingTemplateItem(this, template); templateItems[template.Group].Children.Add(templateItem); } isLoading = false; foreach (string group in templateGroupChecks.Keys) { UpdateGroupChecked(group); } }
private void groupCheckBox_Checked(object sender, RoutedEventArgs e) { if (!isLoading) { CheckBox check = sender as CheckBox; bool enabled = check.IsChecked.GetValueOrDefault(); foreach (UIElement element in templateItems[check.Content.ToString()].Children) { GemmingTemplateItem item = element as GemmingTemplateItem; item.template.Enabled = enabled; } } }
private void AddTemplate(object sender, RoutedEventArgs e) { GemmingTemplate newTemplate = new GemmingTemplate() { Group = "Custom", Enabled = true, Model = Calculations.Instance.Name }; character.CustomGemmingTemplates.Add(newTemplate); GemmingTemplateItem newItem = new GemmingTemplateItem(this, newTemplate); CustomStack.Children.Add(newItem); UpdateGroupChecked(newTemplate.Group); }
public GemmingTemplates(Character c) { isLoading = true; character = c; InitializeComponent(); #if !SILVERLIGHT this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; this.WindowState = System.Windows.WindowState.Normal; #endif GemmingsShownNum.Value = Properties.GeneralSettings.Default.CountGemmingsShown; ComparisonGemList.GemSlot = CharacterSlot.Gems; ComparisonGemList.GemIndex = 0; ComparisonGemList.Character = c; ComparisonGemList.SelectedItemChanged += new EventHandler(ComparisonGemList_SelectedItemChanged); ComparisonCogwheelList.GemSlot = CharacterSlot.Cogwheels; ComparisonCogwheelList.GemIndex = 0; ComparisonCogwheelList.Character = c; ComparisonCogwheelList.SelectedItemChanged += new EventHandler(ComparisonCogwheelList_SelectedItemChanged); ComparisonHydraulicList.GemSlot = CharacterSlot.Hydraulics; ComparisonHydraulicList.GemIndex = 0; ComparisonHydraulicList.Character = c; ComparisonHydraulicList.SelectedItemChanged += new EventHandler(ComparisonHydraulicList_SelectedItemChanged); ComparisonMetaList.GemSlot = CharacterSlot.Metas; ComparisonMetaList.GemIndex = 0; ComparisonMetaList.Character = c; ComparisonMetaList.SelectedItemChanged += new EventHandler(ComparisonMetaList_SelectedItemChanged); templateItems = new Dictionary<string, StackPanel>(); templateItems["Custom"] = CustomStack; templateGroupChecks = new Dictionary<string, CheckBox>(); templateGroupChecks["Custom"] = CustomCheck; foreach (GemmingTemplate template in character.CurrentGemmingTemplates) { GemmingTemplateItem templateItem = new GemmingTemplateItem(this, template); if (!templateItems.ContainsKey(template.Group)) { Expander groupExpander = new Expander(); CheckBox groupCheckBox = new CheckBox(); groupCheckBox.Content = template.Group; groupCheckBox.Checked += new RoutedEventHandler(groupCheckBox_Checked); groupCheckBox.Indeterminate += new RoutedEventHandler(groupCheckBox_Checked); groupCheckBox.Unchecked += new RoutedEventHandler(groupCheckBox_Checked); templateGroupChecks[template.Group] = groupCheckBox; groupExpander.Header = groupCheckBox; GroupStack.Children.Add(groupExpander); StackPanel stack = new StackPanel(); groupExpander.Content = stack; templateItems[template.Group] = stack; } templateItems[template.Group].Children.Add(templateItem); } foreach (GemmingTemplate template in character.CustomGemmingTemplates) { GemmingTemplateItem templateItem = new GemmingTemplateItem(this, template); templateItems[template.Group].Children.Add(templateItem); } isLoading = false; foreach (string group in templateGroupChecks.Keys) UpdateGroupChecked(group); }