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
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

View file

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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

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

View file

@ -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

View file

@ -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();
});
}
}

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())
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