1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

allow window height change when logged in

This commit is contained in:
Simon Schön
2022-06-08 18:52:17 +02:00
parent f092cba2bb
commit fa884a7e73

View File

@@ -35,6 +35,7 @@ namespace MeshCentralRouter
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
private int initialHeight;
public int currentPanel = 0; public int currentPanel = 0;
public DateTime refreshTime = DateTime.Now; public DateTime refreshTime = DateTime.Now;
public MeshCentralServer meshcentral = null; public MeshCentralServer meshcentral = null;
@@ -108,6 +109,7 @@ namespace MeshCentralRouter
} }
catch (Exception) { } catch (Exception) { }
} }
public void unHookRouter() public void unHookRouter()
{ {
try { Registry.ClassesRoot.DeleteSubKeyTree("mcrouter"); } catch (Exception) { } try { Registry.ClassesRoot.DeleteSubKeyTree("mcrouter"); } catch (Exception) { }
@@ -158,6 +160,7 @@ namespace MeshCentralRouter
return bx.CompareTo(ax); return bx.CompareTo(ax);
} }
} }
public class DeviceGroupComparer : IComparer public class DeviceGroupComparer : IComparer
{ {
public int Compare(Object a, Object b) public int Compare(Object a, Object b)
@@ -195,7 +198,6 @@ namespace MeshCentralRouter
return false; return false;
} }
public MainForm(string[] args) public MainForm(string[] args)
{ {
// Set TLS 1.2 // Set TLS 1.2
@@ -226,6 +228,7 @@ namespace MeshCentralRouter
notifyIcon.Visible = Settings.GetRegValue("NotifyIcon", false); notifyIcon.Visible = Settings.GetRegValue("NotifyIcon", false);
title = this.Text; title = this.Text;
initialHeight = this.Height;
int argflags = 0; int argflags = 0;
string update = null; string update = null;
@@ -255,7 +258,11 @@ namespace MeshCentralRouter
} }
autoLogin = (argflags == 7); autoLogin = (argflags == 7);
this.MinimizeBox = !notifyIcon.Visible; this.MinimizeBox = !notifyIcon.Visible;
//this.ShowInTaskbar = !notifyIcon.Visible; this.MinimumSize = new Size(this.Width, initialHeight);
this.MaximumSize = new Size(this.Width, 1080);
this.MaximizeBox = false;
this.ResizeEnd += MainForm_ResizeEnd;
this.devicesListView.Dock = DockStyle.Fill;
if (update != null) if (update != null)
{ {
@@ -384,7 +391,19 @@ namespace MeshCentralRouter
private void setPanel(int newPanel) private void setPanel(int newPanel)
{ {
if (currentPanel == newPanel) return; if (currentPanel == newPanel) return;
if (newPanel == 4) { updatePanel4(); } if (newPanel == 4)
{
this.Height = Settings.GetRegValue("WindowHeight", this.Height);
this.FormBorderStyle = FormBorderStyle.Sizable;
updatePanel4();
}
else
{
this.Height = initialHeight;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}
panel1.Visible = (newPanel == 1); panel1.Visible = (newPanel == 1);
panel2.Visible = (newPanel == 2); panel2.Visible = (newPanel == 2);
panel3.Visible = (newPanel == 3); panel3.Visible = (newPanel == 3);
@@ -1570,7 +1589,6 @@ namespace MeshCentralRouter
private void openToolStripMenuItem_Click(object sender, EventArgs e) private void openToolStripMenuItem_Click(object sender, EventArgs e)
{ {
this.WindowState = FormWindowState.Normal; this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
this.Visible = true; this.Visible = true;
SetForegroundWindow(this.Handle.ToInt32()); SetForegroundWindow(this.Handle.ToInt32());
this.Focus(); this.Focus();
@@ -1593,13 +1611,11 @@ namespace MeshCentralRouter
if (f.ShowSystemTray) if (f.ShowSystemTray)
{ {
notifyIcon.Visible = true; notifyIcon.Visible = true;
this.ShowInTaskbar = false;
this.MinimizeBox = false; this.MinimizeBox = false;
} }
else else
{ {
notifyIcon.Visible = false; notifyIcon.Visible = false;
this.ShowInTaskbar = true;
this.MinimizeBox = true; this.MinimizeBox = true;
} }
} }
@@ -2247,6 +2263,11 @@ namespace MeshCentralRouter
} }
} }
private void MainForm_ResizeEnd(object sender, EventArgs e)
{
Settings.SetRegValue("WindowHeight", this.Height);
}
private X509Certificate2 getClientAuthCertificate() private X509Certificate2 getClientAuthCertificate()
{ {
X509Certificate2 r = null; X509Certificate2 r = null;