diff --git a/src/MainForm.cs b/src/MainForm.cs index b103200..e9bda56 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -524,7 +524,7 @@ namespace MeshCentralRouter private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { - if ((notifyIcon.Visible == true && currentPanel == 4) && (forceExit == false)) { e.Cancel = true; Visible = false; } + if ((notifyIcon.Visible == true) && (currentPanel == 4) && (forceExit == false)) { e.Cancel = true; Visible = false; } Settings.SetRegValue("Location", Location.X + "," + Location.Y); } @@ -757,12 +757,12 @@ namespace MeshCentralRouter devicesListView.SuspendLayout(); devicesListView.Items.Clear(); + bool bGroupChanged = false; ArrayList controlsToAdd = new ArrayList(); if (meshcentral.nodes != null) { foreach (NodeClass node in meshcentral.nodes.Values) { - if (node.agentid == -1) { continue; } ListViewItem device; if (node.listitem == null) @@ -779,82 +779,39 @@ namespace MeshCentralRouter device.SubItems[1].Text = node.getStateString(); } + // Fetch the device group name if ((node.meshid != null) && meshcentral.meshes.ContainsKey(node.meshid)) { node.mesh = (MeshClass)meshcentral.meshes[node.meshid]; } string meshName = (node.mesh != null) ? node.mesh.name : Properties.Resources.IndividualDevices; - if ((showGroupNamesToolStripMenuItem.Checked) && (node.mesh != null)) - { + // Set the device name + if ((showGroupNamesToolStripMenuItem.Checked) && (node.mesh != null)) { device.SubItems[0].Text = meshName + " - " + node.name; - } - else - { + } else { device.SubItems[0].Text = node.name; } - // *** Flynn Grouping start + // See if this device can be added to an existing group bool bGroupExisting = false; for (int i = 0; i < devicesListView.Groups.Count; i++) { // if ((node.mesh != null && devicesListView.Groups[i].Header == node.mesh.name) || (node.mesh == null && devicesListView.Groups[i].Header == "")) - if (devicesListView.Groups[i].Header == meshName) + if (((string)devicesListView.Groups[i].Tag) == node.meshid) { bGroupExisting = true; node.listitem.Group = devicesListView.Groups[i]; + devicesListView.Groups[i].Header = meshName; // Set this again just in case the device group name changed break; } } - - if (!bGroupExisting) - { - ListViewGroup grp = devicesListView.Groups.Add(devicesListView.Groups.Count.ToString(), ((node.mesh == null) ? "" : 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); - } - } + // If a device group does not exist, create it if (!bGroupExisting) { ListViewGroup grp = devicesListView.Groups.Add(devicesListView.Groups.Count.ToString(), meshName); + grp.Tag = node.meshid; 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); - } - } + bGroupChanged = true; } - // *** Flynn Grouping end bool connVisible = ((showOfflineDevicesToolStripMenuItem.Checked) || ((node.conn & 1) != 0)) || (node.mtype == 3); int imageIndex = (node.icon - 1) * 2; @@ -879,6 +836,25 @@ namespace MeshCentralRouter } } + // If groups have changes update them + if (bGroupChanged) + { + 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) + { + ListViewExtended.setGrpState(lvg, ListViewGroupState.Collapsible | ListViewGroupState.Normal); + //ListViewExtended.setGrpState(lvg, ListViewGroupState.Collapsible | ListViewGroupState.Collapsed); + } + } + // Add all controls at once to make it fast. if (controlsToAdd.Count > 0) { diff --git a/src/MainForm.resx b/src/MainForm.resx index 0a32c09..658b436 100644 --- a/src/MainForm.resx +++ b/src/MainForm.resx @@ -129,13 +129,10 @@ - 13, 355 - - - 4, 4, 4, 4 + 10, 286 - 127, 28 + 95, 23 @@ -166,13 +163,10 @@ NoControl - 148, 355 - - - 4, 4, 4, 4 + 111, 286 - 127, 28 + 95, 23 104 @@ -208,13 +202,10 @@ NoControl - 321, 277 - - - 4, 0, 4, 0 + 241, 225 - 114, 17 + 88, 13 19 @@ -244,13 +235,10 @@ NoControl - 317, 217 - - - 4, 0, 4, 0 + 238, 176 - 69, 17 + 53, 13 18 @@ -277,13 +265,10 @@ NoControl - 317, 166 - - - 4, 0, 4, 0 + 238, 135 - 73, 17 + 55, 13 17 @@ -310,13 +295,10 @@ NoControl - 317, 113 - - - 4, 0, 4, 0 + 238, 92 - 50, 17 + 38, 13 16 @@ -340,16 +322,13 @@ Top, Left, Right - 321, 236 - - - 4, 4, 4, 4 + 241, 192 - 287, 22 + 214, 20 102 @@ -373,13 +352,10 @@ meshcentral.com - 321, 135 - - - 4, 4, 4, 4 + 241, 110 - 287, 24 + 214, 21 100 @@ -400,13 +376,10 @@ Top, Left, Right - 321, 186 - - - 4, 4, 4, 4 + 241, 151 - 287, 22 + 214, 20 101 @@ -430,13 +403,10 @@ NoControl - 235, 323 - - - 4, 0, 4, 0 + 174, 260 - 404, 16 + 303, 13 103 @@ -469,13 +439,10 @@ NoControl - 4, 323 - - - 4, 0, 4, 0 + 3, 260 - 47, 17 + 37, 13 11 @@ -502,13 +469,10 @@ NoControl - 499, 355 - - - 4, 4, 4, 4 + 372, 286 - 127, 28 + 95, 23 105 @@ -535,13 +499,10 @@ NoControl - 0, 345 - - - 4, 4, 4, 4 + 0, 278 - 640, 49 + 478, 40 StretchImage @@ -568,13 +529,10 @@ NoControl - 16, 11 - - - 4, 0, 4, 0 + 12, 9 - 608, 69 + 454, 56 6 @@ -601,13 +559,10 @@ NoControl - 20, 84 - - - 4, 4, 4, 4 + 15, 68 - 292, 212 + 217, 170 Zoom @@ -631,13 +586,10 @@ Fill - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 392 + 478, 316 6 @@ -655,16 +607,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 648, 400 + 484, 322 0 @@ -691,13 +640,10 @@ NoControl - 321, 272 - - - 4, 4, 4, 4 + 241, 221 - 170, 21 + 131, 17 204 @@ -724,13 +670,10 @@ NoControl - 321, 218 - - - 4, 4, 4, 4 + 241, 177 - 127, 28 + 95, 23 202 @@ -757,13 +700,10 @@ NoControl - 456, 218 - - - 4, 4, 4, 4 + 342, 177 - 127, 28 + 95, 23 203 @@ -793,13 +733,10 @@ NoControl - 317, 224 - - - 4, 0, 4, 0 + 238, 182 - 73, 17 + 55, 13 21 @@ -829,13 +766,10 @@ NoControl - 317, 166 - - - 4, 0, 4, 0 + 238, 135 - 48, 17 + 38, 13 19 @@ -859,13 +793,10 @@ Top, Left, Right - 321, 186 - - - 4, 4, 4, 4 + 241, 151 - 287, 22 + 214, 20 201 @@ -889,13 +820,10 @@ NoControl - 20, 84 - - - 4, 4, 4, 4 + 15, 68 - 292, 212 + 217, 170 Zoom @@ -922,13 +850,10 @@ NoControl - 363, 355 - - - 4, 4, 4, 4 + 270, 286 - 127, 28 + 95, 23 205 @@ -955,13 +880,10 @@ NoControl - 499, 355 - - - 4, 4, 4, 4 + 372, 286 - 127, 28 + 95, 23 206 @@ -988,13 +910,10 @@ NoControl - 0, 345 - - - 4, 4, 4, 4 + 0, 278 - 640, 49 + 478, 40 StretchImage @@ -1021,13 +940,10 @@ NoControl - 16, 11 - - - 4, 0, 4, 0 + 12, 9 - 608, 69 + 454, 56 6 @@ -1051,13 +967,10 @@ Fill - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 392 + 478, 316 7 @@ -1075,16 +988,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 648, 400 + 484, 322 1 @@ -1114,13 +1024,10 @@ NoControl - 277, 319 - - - 4, 4, 4, 4 + 208, 256 - 190, 21 + 145, 17 302 @@ -1144,10 +1051,7 @@ Top, Bottom, Left, Right - 20, 101 - - - 4, 4, 4, 4 + 15, 82 True @@ -1156,7 +1060,7 @@ Vertical - 602, 202 + 450, 162 25 @@ -1180,13 +1084,10 @@ NoControl - 19, 313 - - - 4, 4, 4, 4 + 14, 251 - 251, 28 + 188, 23 301 @@ -1216,13 +1117,10 @@ NoControl - 11, 7 - - - 4, 0, 4, 0 + 8, 6 - 627, 27 + 468, 22 23 @@ -1252,13 +1150,10 @@ NoControl - 16, 42 - - - 4, 0, 4, 0 + 12, 34 - 608, 55 + 454, 45 22 @@ -1285,13 +1180,10 @@ NoControl - 371, 362 - - - 4, 4, 4, 4 + 276, 291 - 127, 28 + 95, 23 303 @@ -1318,13 +1210,10 @@ NoControl - 507, 362 - - - 4, 4, 4, 4 + 378, 291 - 127, 28 + 95, 23 304 @@ -1351,13 +1240,10 @@ NoControl - 0, 351 - - - 4, 4, 4, 4 + 0, 282 - 648, 49 + 484, 40 StretchImage @@ -1383,11 +1269,8 @@ 0, 0 - - 4, 4, 4, 4 - - 648, 400 + 484, 322 8 @@ -1405,13 +1288,10 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 648, 400 + 484, 322 2 @@ -1441,49 +1321,49 @@ 613, 17 - 218, 26 + 185, 22 Show &Group Names - 218, 26 + 185, 22 Show &Offline Devices - 215, 6 + 182, 6 - 218, 26 + 185, 22 Sort by &Name - 218, 26 + 185, 22 Sort by G&roup - 215, 6 + 182, 6 - 218, 26 + 185, 22 S&ettings... - 218, 26 + 185, 22 &Custom Apps... - 219, 172 + 186, 148 mainContextMenuStrip @@ -1498,13 +1378,10 @@ NoControl - 608, 2 - - - 4, 0, 4, 0 + 454, 2 - 31, 31 + 25, 25 403 @@ -1528,13 +1405,10 @@ Top, Right - 411, 6 - - - 4, 4, 4, 4 + 306, 5 - 193, 22 + 146, 20 402 @@ -1570,13 +1444,10 @@ NoControl - 8, 240 - - - 4, 4, 4, 4 + 6, 191 - 224, 43 + 168, 35 405 @@ -1618,82 +1489,82 @@ Segoe UI, 9pt, style=Bold - 198, 24 + 170, 22 Add &Map... - 198, 24 + 170, 22 Add &Relay Map... - 195, 6 + 167, 6 - 204, 26 + 171, 22 Ask Consent + Bar - 204, 26 + 171, 22 Ask Consent - 204, 26 + 171, 22 Privacy Bar - 198, 24 + 170, 22 Remote Desktop... - 198, 24 + 170, 22 Remote Files... - 198, 24 + 170, 22 HTTP - 198, 24 + 170, 22 HTTPS - 198, 24 + 170, 22 RDP - 198, 24 + 170, 22 SSH - 198, 24 + 170, 22 SCP - 199, 226 + 171, 208 devicesContextMenuStrip @@ -1709,7 +1580,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADg - HQAAAk1TRnQBSQFMAgEBEAEAARABAQEQAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA + HQAAAk1TRnQBSQFMAgEBEAEAARgBAQEYAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABUAMAAQEBAAEYBgABPP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AJYAA/0D+AP3A/sD/yEAA/0D+gP5 A/wD/xgAAfoB+wH6A/4qAAP9A/8tAAP7A88D1QPbA88D1AO+A9QYAAP8A90D4APjA90D4APUA+MSAAP8 AZEBjwF9AU4BaAEhAfQB9QH0JAAD/gPRA8YD+ioAAcYCxwHPAtAB2ALZA90DywPBA68DmgP3FQAD2APd @@ -1840,13 +1711,10 @@ - 13, 5 - - - 4, 4, 4, 4 + 10, 4 - 593, 258 + 446, 210 404 @@ -1858,7 +1726,7 @@ devicesListView - MeshCentralRouter.ListViewExtended, MeshCentralRouter, Version=1.8.8190.31143, Culture=neutral, PublicKeyToken=null + MeshCentralRouter.ListViewExtended, MeshCentralRouter, Version=1.8.8219.36334, Culture=neutral, PublicKeyToken=null devicesPanel @@ -1876,13 +1744,10 @@ NoControl - 3, 108 - - - 4, 0, 4, 0 + 2, 88 - 503, 64 + 372, 52 5 @@ -1918,13 +1783,10 @@ NoControl - 3, 108 - - - 4, 0, 4, 0 + 2, 88 - 503, 64 + 372, 52 4 @@ -1950,11 +1812,8 @@ 0, 0 - - 4, 4, 4, 4 - - 628, 305 + 470, 248 50 @@ -1972,16 +1831,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 632, 315 + 470, 250 0 @@ -2008,13 +1864,10 @@ NoControl - 5, 217 - - - 4, 4, 4, 4 + 4, 182 - 224, 43 + 168, 35 55 @@ -2053,13 +1906,10 @@ NoControl - 8, 97 - - - 4, 0, 4, 0 + 6, 79 - 595, 64 + 446, 52 4 @@ -2087,11 +1937,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 625, 264 + 472, 221 49 @@ -2115,13 +1962,10 @@ Click "Add" to get started. NoControl - 1, 271 - - - 4, 4, 4, 4 + 1, 226 - 27, 25 + 20, 20 54 @@ -2145,13 +1989,10 @@ Click "Add" to get started. NoControl - 317, 271 - - - 4, 4, 4, 4 + 240, 226 - 27, 25 + 20, 20 5 @@ -2178,13 +2019,10 @@ Click "Add" to get started. NoControl - 493, 267 - - - 4, 4, 4, 4 + 372, 223 - 133, 28 + 100, 23 50 @@ -2214,13 +2052,10 @@ Click "Add" to get started. NoControl - 352, 267 - - - 4, 4, 4, 4 + 266, 223 - 133, 28 + 100, 23 52 @@ -2241,16 +2076,13 @@ Click "Add" to get started. 5 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 629, 311 + 472, 253 1 @@ -2271,13 +2103,10 @@ Click "Add" to get started. 1 - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 347 + 478, 279 401 @@ -2301,13 +2130,10 @@ Click "Add" to get started. NoControl - 13, 362 - - - 4, 4, 4, 4 + 10, 291 - 145, 28 + 109, 23 406 @@ -2337,13 +2163,10 @@ Click "Add" to get started. NoControl - 371, 362 - - - 4, 4, 4, 4 + 276, 291 - 127, 28 + 95, 23 407 @@ -2370,13 +2193,10 @@ Click "Add" to get started. NoControl - 507, 362 - - - 4, 4, 4, 4 + 378, 291 - 127, 28 + 95, 23 408 @@ -2403,13 +2223,10 @@ Click "Add" to get started. NoControl - 0, 351 - - - 4, 4, 4, 4 + 0, 282 - 648, 49 + 484, 40 StretchImage @@ -2435,11 +2252,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 648, 400 + 484, 322 8 @@ -2457,13 +2271,10 @@ Click "Add" to get started. 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 648, 400 + 484, 322 4 @@ -2493,7 +2304,7 @@ Click "Add" to get started. 0, 0, 0, 0 - 656, 432 + 492, 351 8 @@ -2517,13 +2328,10 @@ Click "Add" to get started. Fill - 0, 80 - - - 4, 4, 4, 4 + 0, 65 - 656, 432 + 492, 351 9 @@ -2549,11 +2357,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 656, 80 + 492, 65 Zoom @@ -2579,11 +2384,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 656, 512 + 492, 416 8 @@ -2613,22 +2415,22 @@ Click "Add" to get started. 418, 17 - 123, 24 + 112, 22 &Open... - 120, 6 + 109, 6 - 123, 24 + 112, 22 E&xit - 124, 58 + 113, 54 trayIconContextMenuStrip @@ -4340,34 +4142,34 @@ Click "Add" to get started. 905, 17 - 193, 24 + 168, 22 &Open Mappings... - 193, 24 + 168, 22 &Save Mappings... - 190, 6 + 165, 6 - 193, 24 + 168, 22 S&ettings... - 193, 24 + 168, 22 &Custom Apps... - 194, 106 + 169, 98 mappingsContextMenuStrip @@ -4397,10 +4199,10 @@ Click "Add" to get started. True - 8, 16 + 6, 13 - 656, 512 + 492, 416 @@ -6096,9 +5898,6 @@ Click "Add" to get started. AADAPwAAwD8AAMA/AADAPwAA - - 4, 4, 4, 4 - MeshCentral Router