Skip to content

Commit 1e098d0

Browse files
committed
Added status of VM to Tile
1 parent 9a18a58 commit 1e098d0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Panels/MainPanel.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Drawing;
4+
using System.Globalization;
35
using System.Linq;
46
using System.Threading;
57
using System.Threading.Tasks;
8+
using System.Web.UI.WebControls;
69
using System.Windows.Forms;
710
using Newtonsoft.Json;
811
using Proxmox_Desktop_Client.Classes.consoles;
912
using Proxmox_Desktop_Client.Classes.pveAPI.objects;
13+
using Label = System.Windows.Forms.Label;
1014
using Timer = System.Timers.Timer;
1115

1216
namespace Proxmox_Desktop_Client.Panels;
@@ -148,6 +152,17 @@ private void GenerateMachineTile(MachineData machineData)
148152
Properties.Resources.vm_logo,
149153
SizeMode = PictureBoxSizeMode.StretchImage
150154
};
155+
156+
// Label Status of Virtual Machine
157+
var newStatus = new Label()
158+
{
159+
Name = "Status_" + machineData.Vmid.ToString(),
160+
Location = new System.Drawing.Point(0, 110),
161+
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
162+
Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(machineData.Status.ToLower()),
163+
Font = new Font(Font.FontFamily, 7f, FontStyle.Bold),
164+
ForeColor = (machineData.Status.ToLower() == "running" ? Color.Green : Color.Red )
165+
};
151166

152167
// Generate Context Menus
153168
var mainContextMenu = new ContextMenuStrip();
@@ -228,7 +243,6 @@ private void GenerateMachineTile(MachineData machineData)
228243
}
229244
};
230245

231-
232246
// Set States for Menu Items
233247
// Remote Items
234248
remoteContextMenu.Enabled = (machineData.Status == "running");
@@ -248,7 +262,7 @@ private void GenerateMachineTile(MachineData machineData)
248262
newPbDots.ContextMenuStrip = mainContextMenu;
249263
newGroupBox.Controls.Add(newPbDots);
250264
newGroupBox.Controls.Add(newPbImg);
251-
265+
newPbImg.Controls.Add(newStatus);
252266
machinePanel.Controls.Add(newGroupBox);
253267

254268
}

0 commit comments

Comments
 (0)