mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-18 01:03:16 +00:00
Listview Grouping
This commit is contained in:
47
MainForm.cs
47
MainForm.cs
@@ -649,7 +649,15 @@ namespace MeshCentralRouter
|
||||
if ((fullRefresh == true) && (mappingsToSetup != null)) { setupMappings(); }
|
||||
}
|
||||
|
||||
private void updateDeviceList()
|
||||
class GroupComparer : IComparer
|
||||
{
|
||||
public int Compare(object objA, object objB)
|
||||
{
|
||||
return ((ListViewGroup)objA).Header.CompareTo(((ListViewGroup)objB).Header);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDeviceList()
|
||||
{
|
||||
string search = searchTextBox.Text.ToLower();
|
||||
if (deviceListViewMode)
|
||||
@@ -683,7 +691,42 @@ namespace MeshCentralRouter
|
||||
device.SubItems[0].Text = node.name;
|
||||
}
|
||||
|
||||
bool connVisible = ((showOfflineDevicesToolStripMenuItem.Checked) || ((node.conn & 1) != 0)) || (node.mtype == 3);
|
||||
// *** Flynn Grouping start
|
||||
bool bGroupExisting = false;
|
||||
for(int i = 0; i < devicesListView.Groups.Count; i++)
|
||||
if(devicesListView.Groups[i].Header == node.mesh.name)
|
||||
{
|
||||
bGroupExisting = true;
|
||||
node.listitem.Group = devicesListView.Groups[i];
|
||||
break;
|
||||
}
|
||||
if(!bGroupExisting)
|
||||
{
|
||||
ListViewGroup grp = devicesListView.Groups.Add(devicesListView.Groups.Count.ToString(), node.mesh.name);
|
||||
node.listitem.Group = grp;
|
||||
|
||||
ListViewGroup[] groups = new ListViewGroup[this.devicesListView.Groups.Count];
|
||||
|
||||
this.devicesListView.Groups.CopyTo(groups, 0);
|
||||
|
||||
Array.Sort(groups, new GroupComparer());
|
||||
|
||||
this.devicesListView.BeginUpdate();
|
||||
this.devicesListView.Groups.Clear();
|
||||
this.devicesListView.Groups.AddRange(groups);
|
||||
this.devicesListView.EndUpdate();
|
||||
|
||||
foreach(ListViewGroup lvg in devicesListView.Groups)
|
||||
{
|
||||
if(lvg.Header == "Repos")
|
||||
ListViewExtended.setGrpState(lvg, ListViewGroupState.Collapsible | ListViewGroupState.Normal);
|
||||
else
|
||||
ListViewExtended.setGrpState(lvg, ListViewGroupState.Collapsible | ListViewGroupState.Collapsed);
|
||||
}
|
||||
}
|
||||
// *** Flynn Groupng end
|
||||
|
||||
bool connVisible = ((showOfflineDevicesToolStripMenuItem.Checked) || ((node.conn & 1) != 0)) || (node.mtype == 3);
|
||||
int imageIndex = (node.icon - 1) * 2;
|
||||
if (((node.conn & 1) == 0) && (node.mtype != 3)) { imageIndex++; }
|
||||
device.ImageIndex = imageIndex;
|
||||
|
||||
Reference in New Issue
Block a user