From 16dcbc6231486089655504f319894facbfac0691 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sat, 20 Apr 2024 19:37:17 -0400 Subject: [PATCH] Fix changelog sorting --- CreamInstaller.sln | 1 + CreamInstaller/Components/CustomTreeView.cs | 3 +-- CreamInstaller/Forms/SelectDialogForm.Designer.cs | 2 -- CreamInstaller/Forms/SelectDialogForm.cs | 7 ++++++- CreamInstaller/Forms/SelectForm.Designer.cs | 2 -- CreamInstaller/Forms/SelectForm.cs | 1 + CreamInstaller/Forms/UpdateForm.Designer.cs | 2 -- CreamInstaller/Forms/UpdateForm.cs | 10 +++------- CreamInstaller/Utility/SafeIO.cs | 6 ++++-- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/CreamInstaller.sln b/CreamInstaller.sln index 08d4ef8..667db83 100644 --- a/CreamInstaller.sln +++ b/CreamInstaller.sln @@ -12,6 +12,7 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6C94C882-7168-435E-B9E3-B4B9222BBF68}.Debug|x64.ActiveCfg = Debug|x64 + {6C94C882-7168-435E-B9E3-B4B9222BBF68}.Debug|x64.Build.0 = Debug|x64 {6C94C882-7168-435E-B9E3-B4B9222BBF68}.Release|x64.ActiveCfg = Release|x64 {6C94C882-7168-435E-B9E3-B4B9222BBF68}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/CreamInstaller/Components/CustomTreeView.cs b/CreamInstaller/Components/CustomTreeView.cs index 301d117..bf2de45 100644 --- a/CreamInstaller/Components/CustomTreeView.cs +++ b/CreamInstaller/Components/CustomTreeView.cs @@ -35,9 +35,8 @@ internal sealed class CustomTreeView : TreeView internal CustomTreeView() { - DrawMode = TreeViewDrawMode.OwnerDrawText; + DrawMode = TreeViewDrawMode.OwnerDrawAll; DrawNode += DrawTreeNode; - TreeViewNodeSorter = PlatformIdComparer.NodeName; Disposed += OnDisposed; } diff --git a/CreamInstaller/Forms/SelectDialogForm.Designer.cs b/CreamInstaller/Forms/SelectDialogForm.Designer.cs index be170aa..1bfeee8 100644 --- a/CreamInstaller/Forms/SelectDialogForm.Designer.cs +++ b/CreamInstaller/Forms/SelectDialogForm.Designer.cs @@ -70,14 +70,12 @@ namespace CreamInstaller.Forms selectionTreeView.BorderStyle = BorderStyle.None; selectionTreeView.CheckBoxes = true; selectionTreeView.Dock = DockStyle.Fill; - selectionTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll; selectionTreeView.Location = new System.Drawing.Point(3, 19); selectionTreeView.Name = "selectionTreeView"; selectionTreeView.ShowLines = false; selectionTreeView.ShowPlusMinus = false; selectionTreeView.ShowRootLines = false; selectionTreeView.Size = new System.Drawing.Size(518, 203); - selectionTreeView.Sorted = true; selectionTreeView.TabIndex = 0; // // allCheckBoxFlowPanel diff --git a/CreamInstaller/Forms/SelectDialogForm.cs b/CreamInstaller/Forms/SelectDialogForm.cs index f763d89..bd058b8 100644 --- a/CreamInstaller/Forms/SelectDialogForm.cs +++ b/CreamInstaller/Forms/SelectDialogForm.cs @@ -10,7 +10,12 @@ namespace CreamInstaller.Forms; internal sealed partial class SelectDialogForm : CustomForm { private readonly List<(Platform platform, string id, string name)> selected = new(); - internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent(); + + internal SelectDialogForm(IWin32Window owner) : base(owner) + { + InitializeComponent(); + selectionTreeView.TreeViewNodeSorter = PlatformIdComparer.NodeName; + } internal DialogResult QueryUser(string groupBoxText, List<(Platform platform, string id, string name, bool alreadySelected)> potentialChoices, diff --git a/CreamInstaller/Forms/SelectForm.Designer.cs b/CreamInstaller/Forms/SelectForm.Designer.cs index 61ca4af..3fc7c08 100644 --- a/CreamInstaller/Forms/SelectForm.Designer.cs +++ b/CreamInstaller/Forms/SelectForm.Designer.cs @@ -181,13 +181,11 @@ namespace CreamInstaller.Forms selectionTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None; selectionTreeView.CheckBoxes = true; selectionTreeView.Dock = System.Windows.Forms.DockStyle.Fill; - selectionTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll; selectionTreeView.Enabled = false; selectionTreeView.FullRowSelect = true; selectionTreeView.Location = new System.Drawing.Point(3, 19); selectionTreeView.Name = "selectionTreeView"; selectionTreeView.Size = new System.Drawing.Size(554, 187); - selectionTreeView.Sorted = true; selectionTreeView.TabIndex = 1001; // // allCheckBoxLayoutPanel diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 8ec420b..4b12ded 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -36,6 +36,7 @@ internal sealed partial class SelectForm : CustomForm private SelectForm() { InitializeComponent(); + selectionTreeView.TreeViewNodeSorter = PlatformIdComparer.NodeName; Text = Program.ApplicationName; } diff --git a/CreamInstaller/Forms/UpdateForm.Designer.cs b/CreamInstaller/Forms/UpdateForm.Designer.cs index ca2a190..351057c 100644 --- a/CreamInstaller/Forms/UpdateForm.Designer.cs +++ b/CreamInstaller/Forms/UpdateForm.Designer.cs @@ -68,12 +68,10 @@ namespace CreamInstaller.Forms // // changelogTreeView // - changelogTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll; changelogTreeView.Location = new System.Drawing.Point(12, 70); changelogTreeView.Margin = new Padding(0, 0, 0, 12); changelogTreeView.Name = "changelogTreeView"; changelogTreeView.Size = new System.Drawing.Size(380, 179); - changelogTreeView.Sorted = true; changelogTreeView.TabIndex = 5; // // UpdateForm diff --git a/CreamInstaller/Forms/UpdateForm.cs b/CreamInstaller/Forms/UpdateForm.cs index 8b8eef7..37dc804 100644 --- a/CreamInstaller/Forms/UpdateForm.cs +++ b/CreamInstaller/Forms/UpdateForm.cs @@ -79,7 +79,7 @@ internal sealed partial class UpdateForm : CustomForm updateButton.Enabled = true; updateButton.Click += OnUpdate; changelogTreeView.Visible = true; - for (int r = releases!.Count - 1; r >= 0; r--) + for (int r = 0; r < releases!.Count; r++) { ProgramRelease release = releases[r]; #if !DEBUG @@ -88,17 +88,13 @@ internal sealed partial class UpdateForm : CustomForm #endif TreeNode root = new(release.Name) { Name = release.Name }; changelogTreeView.Nodes.Add(root); - if (changelogTreeView.Nodes.Count > 0) - changelogTreeView.Nodes[0].EnsureVisible(); - for (int i = release.Changes.Length - 1; i >= 0; i--) + for (int c = 0; c < release.Changes.Length; c++) Invoke(delegate { - string change = release.Changes[i]; + string change = release.Changes[c]; TreeNode changeNode = new() { Text = change }; root.Nodes.Add(changeNode); root.Expand(); - if (changelogTreeView.Nodes.Count > 0) - changelogTreeView.Nodes[0].EnsureVisible(); }); } } diff --git a/CreamInstaller/Utility/SafeIO.cs b/CreamInstaller/Utility/SafeIO.cs index e3035c3..2334b80 100644 --- a/CreamInstaller/Utility/SafeIO.cs +++ b/CreamInstaller/Utility/SafeIO.cs @@ -174,7 +174,8 @@ internal static class SafeIO } } - internal static string ReadFile(this string filePath, bool crucial = false, Form form = null, Encoding encoding = null) + internal static string ReadFile(this string filePath, bool crucial = false, Form form = null, + Encoding encoding = null) { if (!filePath.FileExists()) return null; @@ -212,7 +213,8 @@ internal static class SafeIO return null; } - internal static void WriteFile(this string filePath, string text, bool crucial = false, Form form = null, Encoding encoding = null) + internal static void WriteFile(this string filePath, string text, bool crucial = false, Form form = null, + Encoding encoding = null) { while (!Program.Canceled) try