Example #1
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");
        }
Example #2
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);
        }