Esempio n. 1
0
        private void Startup()
        {
            Rbt_LangDE.Checked += (sender, e) => UpdateLanguage(DizzySasquatchsBeltstatcalculator.Language.DE);
            Rbt_LangEN.Checked += (sender, e) => UpdateLanguage(DizzySasquatchsBeltstatcalculator.Language.EN);
            Rbt_LangFR.Checked += (sender, e) => UpdateLanguage(DizzySasquatchsBeltstatcalculator.Language.FR);
            CBx_BeltEnhancement.SelectionChanged += (sender, e) =>
            {
                Update();
            };

            ResourceReader res = new ResourceReader(_lang);

            foreach (ComboBox cbx in MainGrid.Children.OfType <ComboBox>())
            {
                cbx.SelectionChanged += (sender, e) => Update();

                if (cbx.Tag?.ToString() == "Petlist")
                {
                    foreach (CreatureType type in (CreatureType[])Enum.GetValues(typeof(CreatureType)))
                    {
                        string       cName = res.GetString(type.ToString());
                        ComboBoxItem cbxi  = new ComboBoxItem()
                        {
                            Content = cName, Tag = type
                        };
                        cbx.Items.Add(cbxi);
                    }
                    cbx.SelectedIndex = 0;
                }
            }
        }
Esempio n. 2
0
        private void UpdateLanguage(Language lang = 0)
        {
            if (lang == 0)
            {
                string langeName = MainGrid.Children.OfType <RadioButton>()
                                   .Where(r => r.GroupName == "Language")
                                   .First(r => r.IsChecked.Value).Name;
                if (Enum.TryParse(langeName, out Language language))
                {
                    lang = language;
                }
                else
                {
                    ResourceReader enRes = new ResourceReader(DizzySasquatchsBeltstatcalculator.Language.EN);
                    MessageBox.Show(enRes.GetString("UI_LanguageParseError"), enRes.GetString("UI_Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            _lang = lang;

            ResourceReader res = new ResourceReader(_lang);

            foreach (Label label in MainGrid.Children.OfType <Label>())
            {
                if (label.Tag?.ToString() == "IgnoreLang")
                {
                    continue;
                }
                string prefix = "UI_";
                string name   = label.Name;
                if (label.Name.StartsWith("Stat_"))
                {
                    prefix = "";
                    name   = name.Replace("Stat_", "");
                }
                label.Content = res.GetString($"{prefix}{name}");
            }

            foreach (ComboBox cbx in MainGrid.Children.OfType <ComboBox>())
            {
                if (cbx.Tag?.ToString() == "Petlist")
                {
                    int cbxSelectedIdx = cbx.SelectedIndex;
                    cbx.Items.Clear();
                    foreach (CreatureType type in (CreatureType[])Enum.GetValues(typeof(CreatureType)))
                    {
                        string       cName = res.GetString(type.ToString());
                        ComboBoxItem cbxi  = new ComboBoxItem()
                        {
                            Content = cName, Tag = type
                        };
                        cbx.Items.Add(cbxi);
                    }
                    cbx.SelectedIndex = cbxSelectedIdx;
                }
            }

            Btn_Reset.Content = res.GetString("UI_Reset");
            Btn_About.Content = res.GetString("UI_About");
        }
Esempio n. 3
0
        private void Btn_About_Click(object sender, RoutedEventArgs e)
        {
            ResourceReader res = new ResourceReader(_lang);

            MessageBox.Show(res.GetString("UI_AboutText").Replace("$n", "\n").Replace("$t", "\t").Replace("$version", VERSION), res.GetString("UI_AboutTitle"), MessageBoxButton.OK);
        }