From fb310e303b6d29950f4af4d207ad8a5acff71d86 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 23 Jul 2022 21:34:51 +0200 Subject: [PATCH 1/2] Formatting --- I18N Commander/UI WinForms/AppEvents.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/I18N Commander/UI WinForms/AppEvents.cs b/I18N Commander/UI WinForms/AppEvents.cs index f4ae16a..5b99d62 100644 --- a/I18N Commander/UI WinForms/AppEvents.cs +++ b/I18N Commander/UI WinForms/AppEvents.cs @@ -4,15 +4,23 @@ namespace UI_WinForms; internal static class AppEvents { + #region Event: Section was changed + // Section changed event which can be subscribed: internal static event EventHandler
WhenSectionChanged; // Method to raise the section changed event: - internal static void SectionChanged(Section section) => AppEvents.WhenSectionChanged?.Invoke(null, section); - + internal static void SectionChanged(Section section) => WhenSectionChanged?.Invoke(null, section); + + #endregion + + #region Event: Text element was changed + // Text element changed event which can be subscribed: internal static event EventHandler WhenTextElementChanged; // Method to raise the text element changed event: - internal static void TextElementChanged(TextElement textElement) => AppEvents.WhenTextElementChanged?.Invoke(null, textElement); + internal static void TextElementChanged(TextElement textElement) => WhenTextElementChanged?.Invoke(null, textElement); + + #endregion } \ No newline at end of file From 46ad1ccf38583824f71448fd97e83df10fde9d1f Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 23 Jul 2022 22:03:15 +0200 Subject: [PATCH 2/2] Fixes #31 --- I18N Commander/UI WinForms/Components/SectionTree.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/I18N Commander/UI WinForms/Components/SectionTree.cs b/I18N Commander/UI WinForms/Components/SectionTree.cs index 308a38c..f7b3db6 100644 --- a/I18N Commander/UI WinForms/Components/SectionTree.cs +++ b/I18N Commander/UI WinForms/Components/SectionTree.cs @@ -151,6 +151,9 @@ public partial class SectionTree : UserControl // Ensure, that the added node is visible and gets the focus: node.EnsureVisible(); this.treeView.SelectedNode = node; + + // Fire the click event: + this.treeView_NodeMouseClick(this, new TreeNodeMouseClickEventArgs(node, MouseButtons.Left, 1, 0, 0)); } private async void buttonRemove_Click(object sender, EventArgs e) @@ -178,6 +181,12 @@ public partial class SectionTree : UserControl // Reload the tree: this.LoadNodes(this, EventArgs.Empty); + + // Select the first root node: + this.treeView.SelectedNode = this.treeView.Nodes.Count > 0 ? this.treeView.Nodes[0] : null; + + // Fire the click event: + this.treeView_NodeMouseClick(this, new TreeNodeMouseClickEventArgs(this.treeView.SelectedNode!, MouseButtons.Left, 1, 0, 0)); } private async void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)