From 95acdcb63755dbef3730a862a12bf6eb6aa98f4a Mon Sep 17 00:00:00 2001 From: Olivier Rogier Date: Sat, 4 Dec 2021 22:25:15 +0100 Subject: [PATCH 1/2] Refactor --- Project/Source/Common/Core/WinControls/ComboBoxEx.cs | 3 +++ .../Common/Core/WinControls/ComboBoxNavigator.cs | 10 ++++++---- Project/Source/Forms/MainForm/MainForm.Initialize.cs | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Project/Source/Common/Core/WinControls/ComboBoxEx.cs b/Project/Source/Common/Core/WinControls/ComboBoxEx.cs index 6227b7bd..f456911f 100644 --- a/Project/Source/Common/Core/WinControls/ComboBoxEx.cs +++ b/Project/Source/Common/Core/WinControls/ComboBoxEx.cs @@ -28,6 +28,9 @@ public ComboBoxEx() SelectedIndexPrevious = SelectedIndexLast; } + /// + /// Disallows the selection of separator item. + /// protected override void OnSelectedIndexChanged(EventArgs e) { if ( Mutex ) return; diff --git a/Project/Source/Common/Core/WinControls/ComboBoxNavigator.cs b/Project/Source/Common/Core/WinControls/ComboBoxNavigator.cs index 0eaccf3c..118ab122 100644 --- a/Project/Source/Common/Core/WinControls/ComboBoxNavigator.cs +++ b/Project/Source/Common/Core/WinControls/ComboBoxNavigator.cs @@ -19,6 +19,8 @@ partial class ComboBoxNavigator : UserControl private bool Mutex; + public bool KeepFocus { get; set; } = true; + public ComboBox ComboBox { get => _ComboBox; @@ -129,28 +131,28 @@ private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) private void ActionFirst_Click(object sender, EventArgs e) { _ComboBox.SelectedIndex = 0; - ActiveControl = ActionNext; + if ( KeepFocus ) ActiveControl = ActionNext; Navigated?.Invoke(sender, e); } private void ActionPrevious_Click(object sender, EventArgs e) { if ( _ComboBox.SelectedIndex > 0 ) _ComboBox.SelectedIndex--; - if ( _ComboBox.SelectedIndex == 0 ) ActiveControl = ActionNext; + if ( _ComboBox.SelectedIndex == 0 && KeepFocus ) ActiveControl = ActionNext; Navigated?.Invoke(sender, e); } private void ActionNext_Click(object sender, EventArgs e) { if ( _ComboBox.SelectedIndex < _ComboBox.Items.Count - 1 ) _ComboBox.SelectedIndex++; - if ( _ComboBox.SelectedIndex == _ComboBox.Items.Count - 1 ) ActiveControl = ActionPrevious; + if ( _ComboBox.SelectedIndex == _ComboBox.Items.Count - 1 && KeepFocus ) ActiveControl = ActionPrevious; Navigated?.Invoke(sender, e); } private void ActionLast_Click(object sender, EventArgs e) { _ComboBox.SelectedIndex = _ComboBox.Items.Count - 1; - ActiveControl = ActionPrevious; + if ( KeepFocus ) ActiveControl = ActionPrevious; Navigated?.Invoke(sender, e); } diff --git a/Project/Source/Forms/MainForm/MainForm.Initialize.cs b/Project/Source/Forms/MainForm/MainForm.Initialize.cs index a60a3b41..c97b88bf 100644 --- a/Project/Source/Forms/MainForm/MainForm.Initialize.cs +++ b/Project/Source/Forms/MainForm/MainForm.Initialize.cs @@ -154,6 +154,7 @@ private void DoFormShown(object sender, EventArgs e) ProcessNewsAndCommandLine(); if ( Globals.IsDebugExecutable ) // TODO remove when ready ActionViewNotebook.Visible = true; + this.ForceBringToFront(); } /// From 7ee91623ed2f7898a65b503f7f3d71999c3f93c4 Mon Sep 17 00:00:00 2001 From: Olivier Rogier Date: Sat, 4 Dec 2021 23:17:19 +0100 Subject: [PATCH 2/2] Improve code --- .../Core/Globalization/SysTranslations.Processing.cs | 8 +++++++- Project/Source/Forms/MainForm/MainForm.SetView.cs | 6 ++++++ Project/Source/Forms/MainForm/MainForm.cs | 7 ------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Project/Source/Common/Core/Globalization/SysTranslations.Processing.cs b/Project/Source/Common/Core/Globalization/SysTranslations.Processing.cs index 018749f6..4960af82 100644 --- a/Project/Source/Common/Core/Globalization/SysTranslations.Processing.cs +++ b/Project/Source/Common/Core/Globalization/SysTranslations.Processing.cs @@ -11,7 +11,7 @@ /// You may add additional accurate notices of copyright ownership. /// /// 2016-04 -/// 2021-02 +/// 2021-12 namespace Ordisoftware.Core; /// @@ -44,6 +44,12 @@ static partial class SysTranslations [Language.FR] = "Chargement des données..." }; + static public readonly TranslationsDictionary BindingData = new() + { + [Language.EN] = "Binding data...", + [Language.FR] = "Liaison des données..." + }; + static public readonly TranslationsDictionary CreatingData = new() { [Language.EN] = "Creating data...", diff --git a/Project/Source/Forms/MainForm/MainForm.SetView.cs b/Project/Source/Forms/MainForm/MainForm.SetView.cs index da4f119f..5d783eb9 100644 --- a/Project/Source/Forms/MainForm/MainForm.SetView.cs +++ b/Project/Source/Forms/MainForm/MainForm.SetView.cs @@ -46,6 +46,7 @@ private sealed class ViewConnector private int SavedSelectionStart; private int SavedSelectionLength; + private bool ViewNotebookFirstTime = true; /// /// Sets the view panel. @@ -122,6 +123,11 @@ public void SetView(ViewMode view, bool first) SavedSelectionLength = EditWord.TextBox.SelectionLength; } LabelCurrentView.Text = AppTranslations.CurrentViewText[view].GetLang(); + if ( view == ViewMode.Notebook && ViewNotebookFirstTime ) + { + ViewNotebookFirstTime = false; + ActionNotebookClearLetter.PerformClick(); + } } } diff --git a/Project/Source/Forms/MainForm/MainForm.cs b/Project/Source/Forms/MainForm/MainForm.cs index a0fa2fa6..b9c1e5b6 100644 --- a/Project/Source/Forms/MainForm/MainForm.cs +++ b/Project/Source/Forms/MainForm/MainForm.cs @@ -431,16 +431,9 @@ private void ActionViewLetters_Click(object sender, EventArgs e) SetView(ViewMode.Letters); } - private bool ViewNotebookFirstTime = true; - private void ActionViewNotebook_Click(object sender, EventArgs e) { SetView(ViewMode.Notebook); - if ( ViewNotebookFirstTime ) - { - ViewNotebookFirstTime = false; - ActionNotebookClearLetter.PerformClick(); - } } ///