select dialog form sorting
This commit is contained in:
parent
5ed4c2808e
commit
d2237efca0
3 changed files with 34 additions and 3 deletions
|
@ -15,9 +15,20 @@ internal class CustomTreeView : TreeView
|
|||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
private class TreeNodeSorter : IComparer
|
||||
internal class TreeNodeSorter : IComparer
|
||||
{
|
||||
public int Compare(object a, object b) => AppIdComparer.Comparer.Compare((a as TreeNode).Name, (b as TreeNode).Name);
|
||||
private readonly bool compareText;
|
||||
|
||||
internal TreeNodeSorter(bool compareText = false) : base() => this.compareText = compareText;
|
||||
|
||||
public int Compare(object a, object b)
|
||||
{
|
||||
TreeNode NodeA = a as TreeNode;
|
||||
TreeNode NodeB = b as TreeNode;
|
||||
string StringA = compareText ? NodeA.Text : NodeA.Name;
|
||||
string StringB = compareText ? NodeB.Text : NodeB.Name;
|
||||
return AppIdComparer.Comparer.Compare(StringA, StringB);
|
||||
}
|
||||
}
|
||||
|
||||
internal CustomTreeView() : base()
|
||||
|
|
18
CreamInstaller/Forms/SelectDialogForm.Designer.cs
generated
18
CreamInstaller/Forms/SelectDialogForm.Designer.cs
generated
|
@ -31,12 +31,13 @@ namespace CreamInstaller
|
|||
{
|
||||
this.acceptButton = new System.Windows.Forms.Button();
|
||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||
this.selectionTreeView = new Components.CustomTreeView();
|
||||
this.sortCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.allCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.loadButton = new System.Windows.Forms.Button();
|
||||
this.saveButton = new System.Windows.Forms.Button();
|
||||
this.selectionTreeView = new Components.CustomTreeView();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.flowLayoutPanel2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
|
@ -71,6 +72,18 @@ namespace CreamInstaller
|
|||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Choices";
|
||||
//
|
||||
// sortCheckBox
|
||||
//
|
||||
this.sortCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.sortCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.sortCheckBox.Location = new System.Drawing.Point(105, 245);
|
||||
this.sortCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.sortCheckBox.Name = "sortCheckBox";
|
||||
this.sortCheckBox.Size = new System.Drawing.Size(92, 19);
|
||||
this.sortCheckBox.TabIndex = 2;
|
||||
this.sortCheckBox.Text = "Sort By Name";
|
||||
this.sortCheckBox.CheckedChanged += new System.EventHandler(this.OnSortCheckBoxChanged);
|
||||
//
|
||||
// selectionTreeView
|
||||
//
|
||||
this.selectionTreeView.BackColor = System.Drawing.SystemColors.Control;
|
||||
|
@ -166,6 +179,7 @@ namespace CreamInstaller
|
|||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(433, 279);
|
||||
this.Controls.Add(this.sortCheckBox);
|
||||
this.Controls.Add(this.saveButton);
|
||||
this.Controls.Add(this.loadButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
|
@ -186,6 +200,7 @@ namespace CreamInstaller
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button acceptButton;
|
||||
private System.Windows.Forms.GroupBox groupBox;
|
||||
private Components.CustomTreeView selectionTreeView;
|
||||
|
@ -194,5 +209,6 @@ namespace CreamInstaller
|
|||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button loadButton;
|
||||
private System.Windows.Forms.Button saveButton;
|
||||
private System.Windows.Forms.CheckBox sortCheckBox;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ using System.Windows.Forms;
|
|||
using CreamInstaller.Components;
|
||||
using CreamInstaller.Utility;
|
||||
|
||||
using static CreamInstaller.Components.CustomTreeView;
|
||||
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal partial class SelectDialogForm : CustomForm
|
||||
|
@ -71,6 +73,8 @@ internal partial class SelectDialogForm : CustomForm
|
|||
? Program.ApplicationNameShort
|
||||
: Program.ApplicationName;
|
||||
|
||||
private void OnSortCheckBoxChanged(object sender, EventArgs e) => selectionTreeView.TreeViewNodeSorter = new TreeNodeSorter(sortCheckBox.Checked);
|
||||
|
||||
private void OnAllCheckBoxChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool shouldCheck = false;
|
||||
|
|
Loading…
Reference in a new issue