public ConfigForm(GncFileWrapper wrapper) : base(Program.Settings.ConfigFormSettings) { _wrapper = wrapper; InitializeComponent(); translate(); _languageHelper = new LanguageHelperWinForms <Translation>( "AccountsWeb", "AccountsWeb", true, Program.Settings.TranslationFormSettings, Icon, () => Program.Settings.Language); _languageHelper.TranslationChanged += translationChanged; tabsMain.SelectedIndex = _activeTab; SettingsToGui(); }
public static string GetPlayerName(FormType type, string defaultValue, LanguageHelperWinForms <Translation> translationHelper = null) { using (var dlg = new ChoosePlayerNameForm(type, defaultValue)) { if (translationHelper != null) { translationHelper.TranslationChanged += dlg.translationChanged; translationHelper.MakeLanguageComboBox(dlg.cmbLanguage); } var result = dlg.ShowDialog(); if (translationHelper != null) { translationHelper.TranslationChanged -= dlg.translationChanged; } if (result == DialogResult.Cancel) { return(null); } return(dlg.txtPlayerName.Text); } }
/// <summary> /// Constructor. Constructs the main form for the application. /// </summary> public Mainform() : base(Program.Settings.MainFormSettings) { InitializeComponent(); mnuMain.Renderer = new NativeToolStripRenderer(); mnuContext.Renderer = new NativeToolStripRenderer(); #if DEBUG // Auto-generate the translation classes for automated form translation using (var generator = new Lingo.TranslationFileGenerator(@"..\..\main\ExpSok\Translation.g.cs")) { using (var form = new AboutBox(false)) generator.TranslateControl(form, Program.Tr.AboutBox); using (var form = new HighscoresForm(false)) generator.TranslateControl(form, Program.Tr.Highscores); using (var form = new ChoosePlayerNameForm(false)) generator.TranslateControl(form, Program.Tr.ChoosePlayerName); generator.TranslateControl(this, Program.Tr.Mainform); generator.TranslateControl(mnuContext, Program.Tr.Context); } #else Lingo.TranslateControl(this, Program.Tr.Mainform); Lingo.TranslateControl(mnuContext, Program.Tr.Context); #endif _translationHelper = new LanguageHelperWinForms <Translation>("Expert Sokoban", "ExpSok", Program.TranslationEnabled, Program.Settings.TranslationFormSettings, Icon, () => Program.Tr.Language); _translationHelper.TranslationChanged += translationChanged; _translationHelper.MakeLanguageMenu(mnuOptionsChangeLanguage); // Restore saved settings mnuOptionsPlayingToolbar.Checked = Program.Settings.DisplayPlayingToolbar; mnuOptionsFileToolbars.Checked = Program.Settings.DisplayFileToolbars; mnuOptionsEditLevelToolbar.Checked = Program.Settings.DisplayEditLevelToolbar; ctStatusBar.Visible = mnuOptionsStatusBar.Checked = Program.Settings.DisplayStatusBar; grpMovePathOptions.SetValue(Program.Settings.MoveDrawMode); grpPushPathOptions.SetValue(Program.Settings.PushDrawMode); grpEditTool.SetValue(Program.Settings.LastUsedTool); mnuOptionsEndPos.Checked = ctMainArea.ShowEndPos = Program.Settings.ShowEndPos; mnuOptionsAreaSokoban.Checked = ctMainArea.ShowAreaSokoban = Program.Settings.ShowAreaSokoban; mnuOptionsAreaPiece.Checked = ctMainArea.ShowAreaPiece = Program.Settings.ShowAreaPiece; mnuOptionsSound.Checked = ctMainArea.SoundEnabled = Program.Settings.SoundEnabled; mnuOptionsAnimation.Checked = ctMainArea.AnimationEnabled = Program.Settings.AnimationEnabled; mnuOptionsLetterControl.Checked = ctMainArea.LetteringEnabled = Program.Settings.LetteringEnabled; if (string.IsNullOrWhiteSpace(Program.Settings.PlayerName)) { Program.Settings.PlayerName = ChoosePlayerNameForm.GetPlayerName(ChoosePlayerNameForm.FormType.FirstRun, "", _translationHelper); } // Restore the last used level file try { lstLevels.LoadLevelPack(Program.Settings.LevelFilename); } catch { lstLevels.NewList(); lstLevels.AddLevelListItem(SokobanLevel.TestLevel); lstLevels.Modified = false; } showLevelList(Program.Settings.DisplayLevelList); lstLevels.PlayFirstUnsolved(); updateControls(); // ManagedForm sets the form's Font in the Load event. This potentially changes the width of the level list, which in turn causes its Resize event, which in turn updates Program.Settings.LevelListWidth. // To work around this, remember the width from the settings file and defer setting the level list's width until the Load event. int levelListWidth = Program.Settings.LevelListWidth < 50 ? 50 : Program.Settings.LevelListWidth; Load += (s, e) => pnlLevelList.Width = levelListWidth; }