Skip to content

Commit 1b075c5

Browse files
committed
Added System Tray Icon to allow minimize hiding of Machine Panel
1 parent 1d3c5c1 commit 1b075c5

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

Panels/ClientLogin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Proxmox_Desktop_Client.Panels
88
{
99
public partial class ClientLogin : Form
1010
{
11+
1112
public ClientLogin()
1213
{
1314
// Init ClientForm

Panels/MainPanel.Designer.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Panels/MainPanel.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ namespace Proxmox_Desktop_Client.Panels;
1414
public partial class MainPanel : Form
1515
{
1616
private Timer refreshTimer;
17+
private NotifyIcon notifyIcon;
18+
private ContextMenuStrip contextMenu;
19+
1720
public MainPanel()
1821
{
1922
Load += RefreshContent;
2023
InitializeComponent();
21-
24+
InitializeNotifyIcon();
25+
Resize += ClientLogin_Resize;
26+
2227
// Initialize and configure the timer
2328
refreshTimer = new Timer(30000); // 30 seconds
2429
refreshTimer.Elapsed += RefreshContent;
@@ -303,6 +308,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
303308
{
304309
refreshTimer.Stop();
305310
refreshTimer.Dispose();
311+
notifyIcon.Dispose();
306312
var theWindow = (ClientLogin)Program._Panels["ClientLogin"];
307313
theWindow.Show();
308314
base.OnFormClosing(e);
@@ -338,4 +344,30 @@ private void WebClient(MachineData machineData, string remoteType)
338344
webClient.Show(); // Show the form as a non-blocking window
339345
}
340346

347+
private void InitializeNotifyIcon()
348+
{
349+
notifyIcon = new NotifyIcon();
350+
notifyIcon.Icon = Properties.Resources.icon_proxmox; // Set your desired icon here
351+
notifyIcon.Visible = true;
352+
353+
contextMenu = new ContextMenuStrip();
354+
contextMenu.Items.Add("Restore", null, Restore_Click);
355+
contextMenu.Items.Add("Exit", null, ActionExitApplication);
356+
notifyIcon.ContextMenuStrip = contextMenu;
357+
}
358+
359+
private void ClientLogin_Resize(object sender, EventArgs e)
360+
{
361+
if (WindowState == FormWindowState.Minimized)
362+
{
363+
Hide();
364+
}
365+
}
366+
367+
private void Restore_Click(object sender, EventArgs e)
368+
{
369+
Show();
370+
WindowState = FormWindowState.Normal;
371+
}
372+
341373
}

Properties/Resources.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@
6868
<data name="icons_dots" type="System.Resources.ResXFileRef, System.Windows.Forms">
6969
<value>..\Resources\icons_dots.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
7070
</data>
71+
<data name="icon_proxmox" type="System.Resources.ResXFileRef, System.Windows.Forms">
72+
<value>..\Resources\Icons\default-icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
73+
</data>
7174
</root>

0 commit comments

Comments
 (0)