/// <summary> /// Invoked by "Level => Show highscores". Displays the highscores for the /// currently selected level. /// </summary> private void showHighscores(object sender, EventArgs e) { if (lstLevels.SelectedLevel != null) { string level = lstLevels.SelectedLevel.ToString(); if (!Program.Settings.Highscores.ContainsKey(level)) { DlgMessage.Show(Program.Tr.Mainform_NoHighscores, Program.Tr.Mainform_NoHighscores_Title, DlgType.Info, Program.Tr.Dialogs_btnOK); } else { HighscoresForm hsf = new HighscoresForm(); hsf.SetContents(Program.Settings.Highscores[level], lstLevels.SelectedLevel); hsf.ShowDialog(); } } }
/// <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; }