Fix changelog sorting

This commit is contained in:
pointfeev 2024-04-20 19:37:17 -04:00
parent 0b1d8e7937
commit 16dcbc6231
9 changed files with 16 additions and 18 deletions

View file

@ -12,6 +12,7 @@ Global
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C94C882-7168-435E-B9E3-B4B9222BBF68}.Debug|x64.ActiveCfg = Debug|x64 {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.ActiveCfg = Release|x64
{6C94C882-7168-435E-B9E3-B4B9222BBF68}.Release|x64.Build.0 = Release|x64 {6C94C882-7168-435E-B9E3-B4B9222BBF68}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection

View file

@ -35,9 +35,8 @@ internal sealed class CustomTreeView : TreeView
internal CustomTreeView() internal CustomTreeView()
{ {
DrawMode = TreeViewDrawMode.OwnerDrawText; DrawMode = TreeViewDrawMode.OwnerDrawAll;
DrawNode += DrawTreeNode; DrawNode += DrawTreeNode;
TreeViewNodeSorter = PlatformIdComparer.NodeName;
Disposed += OnDisposed; Disposed += OnDisposed;
} }

View file

@ -70,14 +70,12 @@ namespace CreamInstaller.Forms
selectionTreeView.BorderStyle = BorderStyle.None; selectionTreeView.BorderStyle = BorderStyle.None;
selectionTreeView.CheckBoxes = true; selectionTreeView.CheckBoxes = true;
selectionTreeView.Dock = DockStyle.Fill; selectionTreeView.Dock = DockStyle.Fill;
selectionTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll;
selectionTreeView.Location = new System.Drawing.Point(3, 19); selectionTreeView.Location = new System.Drawing.Point(3, 19);
selectionTreeView.Name = "selectionTreeView"; selectionTreeView.Name = "selectionTreeView";
selectionTreeView.ShowLines = false; selectionTreeView.ShowLines = false;
selectionTreeView.ShowPlusMinus = false; selectionTreeView.ShowPlusMinus = false;
selectionTreeView.ShowRootLines = false; selectionTreeView.ShowRootLines = false;
selectionTreeView.Size = new System.Drawing.Size(518, 203); selectionTreeView.Size = new System.Drawing.Size(518, 203);
selectionTreeView.Sorted = true;
selectionTreeView.TabIndex = 0; selectionTreeView.TabIndex = 0;
// //
// allCheckBoxFlowPanel // allCheckBoxFlowPanel

View file

@ -10,7 +10,12 @@ namespace CreamInstaller.Forms;
internal sealed partial class SelectDialogForm : CustomForm internal sealed partial class SelectDialogForm : CustomForm
{ {
private readonly List<(Platform platform, string id, string name)> selected = new(); 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, internal DialogResult QueryUser(string groupBoxText,
List<(Platform platform, string id, string name, bool alreadySelected)> potentialChoices, List<(Platform platform, string id, string name, bool alreadySelected)> potentialChoices,

View file

@ -181,13 +181,11 @@ namespace CreamInstaller.Forms
selectionTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None; selectionTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
selectionTreeView.CheckBoxes = true; selectionTreeView.CheckBoxes = true;
selectionTreeView.Dock = System.Windows.Forms.DockStyle.Fill; selectionTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
selectionTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
selectionTreeView.Enabled = false; selectionTreeView.Enabled = false;
selectionTreeView.FullRowSelect = true; selectionTreeView.FullRowSelect = true;
selectionTreeView.Location = new System.Drawing.Point(3, 19); selectionTreeView.Location = new System.Drawing.Point(3, 19);
selectionTreeView.Name = "selectionTreeView"; selectionTreeView.Name = "selectionTreeView";
selectionTreeView.Size = new System.Drawing.Size(554, 187); selectionTreeView.Size = new System.Drawing.Size(554, 187);
selectionTreeView.Sorted = true;
selectionTreeView.TabIndex = 1001; selectionTreeView.TabIndex = 1001;
// //
// allCheckBoxLayoutPanel // allCheckBoxLayoutPanel

View file

@ -36,6 +36,7 @@ internal sealed partial class SelectForm : CustomForm
private SelectForm() private SelectForm()
{ {
InitializeComponent(); InitializeComponent();
selectionTreeView.TreeViewNodeSorter = PlatformIdComparer.NodeName;
Text = Program.ApplicationName; Text = Program.ApplicationName;
} }

View file

@ -68,12 +68,10 @@ namespace CreamInstaller.Forms
// //
// changelogTreeView // changelogTreeView
// //
changelogTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll;
changelogTreeView.Location = new System.Drawing.Point(12, 70); changelogTreeView.Location = new System.Drawing.Point(12, 70);
changelogTreeView.Margin = new Padding(0, 0, 0, 12); changelogTreeView.Margin = new Padding(0, 0, 0, 12);
changelogTreeView.Name = "changelogTreeView"; changelogTreeView.Name = "changelogTreeView";
changelogTreeView.Size = new System.Drawing.Size(380, 179); changelogTreeView.Size = new System.Drawing.Size(380, 179);
changelogTreeView.Sorted = true;
changelogTreeView.TabIndex = 5; changelogTreeView.TabIndex = 5;
// //
// UpdateForm // UpdateForm

View file

@ -79,7 +79,7 @@ internal sealed partial class UpdateForm : CustomForm
updateButton.Enabled = true; updateButton.Enabled = true;
updateButton.Click += OnUpdate; updateButton.Click += OnUpdate;
changelogTreeView.Visible = true; changelogTreeView.Visible = true;
for (int r = releases!.Count - 1; r >= 0; r--) for (int r = 0; r < releases!.Count; r++)
{ {
ProgramRelease release = releases[r]; ProgramRelease release = releases[r];
#if !DEBUG #if !DEBUG
@ -88,17 +88,13 @@ internal sealed partial class UpdateForm : CustomForm
#endif #endif
TreeNode root = new(release.Name) { Name = release.Name }; TreeNode root = new(release.Name) { Name = release.Name };
changelogTreeView.Nodes.Add(root); changelogTreeView.Nodes.Add(root);
if (changelogTreeView.Nodes.Count > 0) for (int c = 0; c < release.Changes.Length; c++)
changelogTreeView.Nodes[0].EnsureVisible();
for (int i = release.Changes.Length - 1; i >= 0; i--)
Invoke(delegate Invoke(delegate
{ {
string change = release.Changes[i]; string change = release.Changes[c];
TreeNode changeNode = new() { Text = change }; TreeNode changeNode = new() { Text = change };
root.Nodes.Add(changeNode); root.Nodes.Add(changeNode);
root.Expand(); root.Expand();
if (changelogTreeView.Nodes.Count > 0)
changelogTreeView.Nodes[0].EnsureVisible();
}); });
} }
} }

View file

@ -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()) if (!filePath.FileExists())
return null; return null;
@ -212,7 +213,8 @@ internal static class SafeIO
return null; 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) while (!Program.Canceled)
try try