diff --git a/Forms/FrmServerController.Designer.cs b/Forms/FrmServerController.Designer.cs index 20ab146..bda0539 100644 --- a/Forms/FrmServerController.Designer.cs +++ b/Forms/FrmServerController.Designer.cs @@ -32,6 +32,10 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmServerController)); Pages = new Guna.UI2.WinForms.Guna2TabControl(); PageHome = new TabPage(); + lblram = new Label(); + guna2RadialGauge1 = new Guna.UI2.WinForms.Guna2RadialGauge(); + lblcpu = new Label(); + cpu = new Guna.UI2.WinForms.Guna2RadialGauge(); PageFiles = new TabPage(); PageDatabases = new TabPage(); PageBackups = new TabPage(); @@ -51,6 +55,7 @@ private void InitializeComponent() AnimateWindow = new Guna.UI2.WinForms.Guna2AnimateWindow(components); Elipse = new Guna.UI2.WinForms.Guna2Elipse(components); Pages.SuspendLayout(); + PageHome.SuspendLayout(); navbar.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pbappicon).BeginInit(); subnavbar.SuspendLayout(); @@ -95,6 +100,10 @@ private void InitializeComponent() // PageHome // PageHome.BackColor = Color.FromArgb(30, 45, 59); + PageHome.Controls.Add(lblram); + PageHome.Controls.Add(guna2RadialGauge1); + PageHome.Controls.Add(lblcpu); + PageHome.Controls.Add(cpu); PageHome.Location = new Point(184, 4); PageHome.Name = "PageHome"; PageHome.Padding = new Padding(3); @@ -102,6 +111,50 @@ private void InitializeComponent() PageHome.TabIndex = 0; PageHome.Text = "Home"; // + // lblram + // + lblram.AutoSize = true; + lblram.Font = new Font("Segoe UI", 10F, FontStyle.Bold, GraphicsUnit.Point); + lblram.ForeColor = Color.White; + lblram.Location = new Point(674, 249); + lblram.Name = "lblram"; + lblram.Size = new Size(45, 19); + lblram.TabIndex = 3; + lblram.Text = "RAM:"; + // + // guna2RadialGauge1 + // + guna2RadialGauge1.BackColor = Color.Transparent; + guna2RadialGauge1.Font = new Font("Verdana", 8.2F, FontStyle.Regular, GraphicsUnit.Point); + guna2RadialGauge1.ForeColor = Color.FromArgb(139, 152, 166); + guna2RadialGauge1.Location = new Point(571, 6); + guna2RadialGauge1.MinimumSize = new Size(30, 30); + guna2RadialGauge1.Name = "guna2RadialGauge1"; + guna2RadialGauge1.Size = new Size(240, 240); + guna2RadialGauge1.TabIndex = 2; + // + // lblcpu + // + lblcpu.AutoSize = true; + lblcpu.Font = new Font("Segoe UI", 10F, FontStyle.Bold, GraphicsUnit.Point); + lblcpu.ForeColor = Color.White; + lblcpu.Location = new Point(100, 249); + lblcpu.Name = "lblcpu"; + lblcpu.Size = new Size(41, 19); + lblcpu.TabIndex = 1; + lblcpu.Text = "CPU:"; + // + // cpu + // + cpu.BackColor = Color.Transparent; + cpu.Font = new Font("Verdana", 8.2F, FontStyle.Regular, GraphicsUnit.Point); + cpu.ForeColor = Color.FromArgb(139, 152, 166); + cpu.Location = new Point(6, 6); + cpu.MinimumSize = new Size(30, 30); + cpu.Name = "cpu"; + cpu.Size = new Size(240, 240); + cpu.TabIndex = 0; + // // PageFiles // PageFiles.Location = new Point(184, 4); @@ -264,7 +317,6 @@ private void InitializeComponent() pblblpanellogo.SizeMode = PictureBoxSizeMode.StretchImage; pblblpanellogo.TabIndex = 6; pblblpanellogo.TabStop = false; - pblblpanellogo.Click += pblblpanellogo_Click; // // DragController // @@ -296,6 +348,8 @@ private void InitializeComponent() Text = "FrmServerController"; Load += FrmServerController_Load; Pages.ResumeLayout(false); + PageHome.ResumeLayout(false); + PageHome.PerformLayout(); navbar.ResumeLayout(false); navbar.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pbappicon).EndInit(); @@ -330,5 +384,9 @@ private void InitializeComponent() private Label txtpanelname; private PictureBox pblblpanellogo; private Guna.UI2.WinForms.Guna2Separator separator; + private Guna.UI2.WinForms.Guna2RadialGauge cpu; + private Label lblcpu; + private Label lblram; + private Guna.UI2.WinForms.Guna2RadialGauge guna2RadialGauge1; } } \ No newline at end of file diff --git a/Forms/FrmServerController.cs b/Forms/FrmServerController.cs index bece9e7..94eab50 100644 --- a/Forms/FrmServerController.cs +++ b/Forms/FrmServerController.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; +using Guna.UI2.WinForms; +using Newtonsoft.Json; using PteroController.PteroConsoleHook; -using PteroController.Pterodactyl; using System.Net; namespace PteroController.Forms @@ -12,13 +12,18 @@ public FrmServerController(string serverIdentifier) { InitializeComponent(); this.serverIdentifier = serverIdentifier; - + } private async void initPteroConsole() { try { var console = new PteroConsole.NET.PteroConsole(); + console.OnServerResourceUpdated += (sender, resource) => + { + Console.WriteLine($"Stats: {resource.Uptime}, State: {resource.State}"); + //cpu.Value = resource.State; + }; console.RequestToken += pteroConsole => { Console.WriteLine("Revoking token"); @@ -33,7 +38,8 @@ private async void initPteroConsole() var raw = wc.DownloadString($"{Pterodactyl.User.Info.panel_url}/api/client/servers/{serverIdentifier}/websocket"); var data = JsonConvert.DeserializeObject(raw).Data; await console.Connect(Pterodactyl.User.Info.panel_url, data.Socket, data.Token); - } catch (Exception ex) + } + catch (Exception ex) { Console.WriteLine(ex.ToString()); Program.Alert("We are sorry but we can't launch the stats", FrmAlert.enmType.Warning); @@ -67,11 +73,6 @@ private void btnservers_Click(object sender, EventArgs e) x.Show(); this.Hide(); } - - private void pblblpanellogo_Click(object sender, EventArgs e) - { - - } } } \ No newline at end of file diff --git a/PteroController.csproj b/PteroController.csproj index b9b502d..ac01d90 100644 --- a/PteroController.csproj +++ b/PteroController.csproj @@ -1,7 +1,7 @@  - WinExe + Exe net7.0-windows enable true