diff --git a/ConsoleManager.cs b/ConsoleManager.cs index 993e085..4bae4bd 100644 --- a/ConsoleManager.cs +++ b/ConsoleManager.cs @@ -1,15 +1,59 @@ -namespace PteroController.ConsoleManager; +using System.IO.Compression; + +namespace PteroController.ConsoleManager; public class ConsoleManager { - public static void CheckInstall() + public static async void CheckInstall() { - if (!File.Exists(Application.StartupPath+ @"\PteroConsole.exe")) + if (!File.Exists(Application.StartupPath + @"\PteroConsole.exe")) { - - } else + await Download(); + await Unzip(); + } + else { } } + public static Task Unzip() + { + try + { + ZipArchive archive = ZipFile.OpenRead("PteroConsole.zip"); + foreach (ZipArchiveEntry entry in archive.Entries) + { + entry.ExtractToFile(Application.StartupPath, overwrite: true); + } + archive.Dispose(); + return Task.CompletedTask; + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + return Task.FromException(ex); + } + } + + public static async Task Download() + { + string releaseURL = "https://github.com/MythicalLTD/PteroConsole/releases/latest/download/PteroConsole.zip"; + HttpClient client = new HttpClient(); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, releaseURL); + HttpResponseMessage response = await client.SendAsync(request); + if (response.IsSuccessStatusCode) + { + Stream contentStream = await response.Content.ReadAsStreamAsync(); + FileStream fileStream = new FileStream("PteroConsole.zip", FileMode.Create); + await contentStream.CopyToAsync(fileStream); + fileStream.Close(); + contentStream.Close(); + client.Dispose(); + Console.WriteLine("PteroConsole has been downloaded successfully!"); + } + else + { + Console.WriteLine("Failed to download PteroConsole: {0}", response.StatusCode); + } + } } diff --git a/FrmLogin.cs b/FrmLogin.cs index 1dc44b4..a74091b 100644 --- a/FrmLogin.cs +++ b/FrmLogin.cs @@ -15,6 +15,7 @@ public partial class FrmLogin : Form public static string? panel_first_name; public static string? panel_last_name; public static string? panel_admin; + public static string? panel_avatar; public static string panel_language = "en"; @@ -24,23 +25,31 @@ public FrmLogin() } private async Task Login(string apiKey, Uri panelUri) { - using (HttpClient client = new HttpClient()) + try { - client.BaseAddress = panelUri; - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - - try + using (HttpClient client = new HttpClient()) { - HttpResponseMessage response = await client.GetAsync("/api/client/account"); + client.BaseAddress = panelUri; + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - return response.IsSuccessStatusCode; - } - catch (HttpRequestException) - { - return false; + try + { + HttpResponseMessage response = await client.GetAsync("/api/client/account"); + + return response.IsSuccessStatusCode; + } + catch (HttpRequestException) + { + return false; + } } } + catch (Exception ex) + { + Console.WriteLine("Login Error: " + ex.Message); + return false; + } } private void Form1_Load(object sender, EventArgs e) @@ -74,6 +83,7 @@ private void CheckSession() } catch (Exception ex) { + Console.WriteLine("Session Error: " + ex.Message); Program.Alert("Failed to get session", FrmAlert.enmType.Error); } } @@ -144,6 +154,7 @@ private async void btnlogin_Click(object sender, EventArgs e) panel_first_name = attributes["first_name"].ToString(); panel_last_name = attributes["last_name"].ToString(); panel_language = attributes["language"].ToString(); + } else { diff --git a/FrmServerController.Designer.cs b/FrmServerController.Designer.cs index b8bd601..84072fb 100644 --- a/FrmServerController.Designer.cs +++ b/FrmServerController.Designer.cs @@ -41,12 +41,22 @@ private void InitializeComponent() lblexit = new Label(); pbappicon = new PictureBox(); subnavbar = new Panel(); + txtpanelname = new Label(); + btnservers = new PictureBox(); + btnlogout = new PictureBox(); + pbavatar = new PictureBox(); DragController = new Guna.UI2.WinForms.Guna2DragControl(components); AnimateWindow = new Guna.UI2.WinForms.Guna2AnimateWindow(components); Elipse = new Guna.UI2.WinForms.Guna2Elipse(components); + pblblpanellogo = new PictureBox(); Pages.SuspendLayout(); navbar.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pbappicon).BeginInit(); + subnavbar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)btnservers).BeginInit(); + ((System.ComponentModel.ISupportInitialize)btnlogout).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pbavatar).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pblblpanellogo).BeginInit(); SuspendLayout(); // // Pages @@ -181,12 +191,58 @@ private void InitializeComponent() // subnavbar // subnavbar.BackColor = Color.FromArgb(33, 42, 57); + subnavbar.Controls.Add(pblblpanellogo); + subnavbar.Controls.Add(txtpanelname); + subnavbar.Controls.Add(btnservers); + subnavbar.Controls.Add(btnlogout); + subnavbar.Controls.Add(pbavatar); subnavbar.Dock = DockStyle.Bottom; subnavbar.Location = new Point(0, 24); subnavbar.Name = "subnavbar"; subnavbar.Size = new Size(1018, 38); subnavbar.TabIndex = 0; // + // txtpanelname + // + txtpanelname.AutoSize = true; + txtpanelname.Font = new Font("Segoe UI", 15F, FontStyle.Bold, GraphicsUnit.Point); + txtpanelname.ForeColor = Color.WhiteSmoke; + txtpanelname.Location = new Point(46, 3); + txtpanelname.Name = "txtpanelname"; + txtpanelname.Size = new Size(179, 28); + txtpanelname.TabIndex = 5; + txtpanelname.Text = "Pterodactyl Panel"; + // + // btnservers + // + btnservers.Image = (Image)resources.GetObject("btnservers.Image"); + btnservers.Location = new Point(898, 4); + btnservers.Name = "btnservers"; + btnservers.Size = new Size(32, 32); + btnservers.SizeMode = PictureBoxSizeMode.StretchImage; + btnservers.TabIndex = 2; + btnservers.TabStop = false; + // + // btnlogout + // + btnlogout.Image = (Image)resources.GetObject("btnlogout.Image"); + btnlogout.Location = new Point(974, 4); + btnlogout.Name = "btnlogout"; + btnlogout.Size = new Size(32, 32); + btnlogout.SizeMode = PictureBoxSizeMode.StretchImage; + btnlogout.TabIndex = 1; + btnlogout.TabStop = false; + // + // pbavatar + // + pbavatar.Image = Properties.Resources.test; + pbavatar.Location = new Point(936, 4); + pbavatar.Name = "pbavatar"; + pbavatar.Size = new Size(32, 32); + pbavatar.SizeMode = PictureBoxSizeMode.StretchImage; + pbavatar.TabIndex = 0; + pbavatar.TabStop = false; + // // DragController // DragController.DockIndicatorTransparencyValue = 0.6D; @@ -203,6 +259,16 @@ private void InitializeComponent() Elipse.BorderRadius = 20; Elipse.TargetControl = this; // + // pblblpanellogo + // + pblblpanellogo.Image = Properties.Resources.pterry1; + pblblpanellogo.Location = new Point(8, 3); + pblblpanellogo.Name = "pblblpanellogo"; + pblblpanellogo.Size = new Size(32, 32); + pblblpanellogo.SizeMode = PictureBoxSizeMode.StretchImage; + pblblpanellogo.TabIndex = 6; + pblblpanellogo.TabStop = false; + // // FrmServerController // AutoScaleDimensions = new SizeF(7F, 15F); @@ -220,6 +286,12 @@ private void InitializeComponent() navbar.ResumeLayout(false); navbar.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pbappicon).EndInit(); + subnavbar.ResumeLayout(false); + subnavbar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)btnservers).EndInit(); + ((System.ComponentModel.ISupportInitialize)btnlogout).EndInit(); + ((System.ComponentModel.ISupportInitialize)pbavatar).EndInit(); + ((System.ComponentModel.ISupportInitialize)pblblpanellogo).EndInit(); ResumeLayout(false); } @@ -239,5 +311,10 @@ private void InitializeComponent() private TabPage PageBackups; private Guna.UI2.WinForms.Guna2AnimateWindow AnimateWindow; private Guna.UI2.WinForms.Guna2Elipse Elipse; + private PictureBox pbavatar; + private PictureBox btnlogout; + private PictureBox btnservers; + private Label txtpanelname; + private PictureBox pblblpanellogo; } } \ No newline at end of file diff --git a/FrmServerController.cs b/FrmServerController.cs index 9b0767e..5301ab7 100644 --- a/FrmServerController.cs +++ b/FrmServerController.cs @@ -13,12 +13,15 @@ public FrmServerController(string serverIdentifier) private void FrmServerController_Load(object sender, EventArgs e) { ConsoleManager.ConsoleManager.CheckInstall(); - - } - - private void updateAppTitle() - { - + if (FrmLoader.unstableMode == true) + { + lblappname.Text = $"PteroController ({Program.AppVersion} DEV)"; + } + else + { + lblappname.Text = $"PteroController ({Program.AppVersion})"; + + } } private void lblminimize_Click(object sender, EventArgs e) diff --git a/FrmServerController.resx b/FrmServerController.resx index 94b1709..dbf25fb 100644 --- a/FrmServerController.resx +++ b/FrmServerController.resx @@ -117,6 +117,45 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAYAAADjVADoAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + EAAACxABrSO9dQAAAzdJREFUeF7tm02IjVEcxu/MhBoLWRhlwoKUlAWasJgy2RiRj0lShs3MRpGS2FBE + 1EQWForNYImVDQ0pdmPnY8dGSigWvvJxPf/zf+ad933dxft5nXM6v3o259z/c57/ae69877nvY1AIBAI + BNpHs9nsgrZDV6FH0GQb9QC6BPUzzv8BAdZAzyEbkE1ZzGjtA4sOQF8kgUW8hZYxYv1gsR7og6xsIc+g + mYxaL1hI3pc2c4BR6wOLzIA+muXsZZJx6wOL9OtaVvMHmsfI9YAFzpil7GcbI9cDFniq61jPBUauHpjP + h+TPzgXq+5yA+bCu4QS/oDmMXi0wvmmWcIdNjF4dMO2E3hl7dzjL+NUB0z71dorHjF8dMD2h3k7xA+pm + C9UAwyfG2j02sIXywGwu9NPYusdJtlEemO1STyeZYBvlgdk19XSSr1D5y3KYdEBvxNFh1rOd4sBkpXo5 + zTG2UxyYHFUvp7nLdooDkwn1cprPUBdbyg+KZ0PfxckDVrGt/KB4q3p4wWG2lR8UX1YPL7jNtvKD4lfq + 4QXvoU62lh0UrTblftHH9rKDor1am2AI2uiIJGuaYbaXHRSNau00nHIGxo4zyqnsSJHWTsMpK0Ccbug8 + dB86xOEEGE/j5UaMaaqI3ZyK4HgcLzfioaaKGONUBMfjeLkRRzSVQc5a/rkTpVMJvNwIuT0g32wXoQEO + J8B4Gv82IguMHafQRrT6Hj4OyQa5IMmaZojtZQdFSyFXzjmzIL0sYXv5QOEdY+EHt9hWflB8XT28YJxt + 5QOFvZCcKPuC9LKA7WUHRYOmPMlOq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U+aA6T2gOAR783QvDIbYXlemD3b4XxfLkYWk9Of+jdxdAdtUqsQv25HP4N + fBahi9A4DyXwePffELGA90GoH7fEtgPf/twUhYfcFp+AZEGUq0jZSm8ujCzzgzksSgwgvhlSqzws84M5 + LKZZVhnxUKs8LPMDGTy/Hl9nDD8Q4qVmceE5Y/iBEL3/icxhqInfBf4L+ZFU7TWmCAhyJUVqlyW27wYI + dB36kaI1i/S4xrbdAsHOQI+hJt4SX6FH0ALbdReEHIPmJGwhidcY7YMgCIIgCIL6DAa/AAOc7ejs57x3 + AAAAAElFTkSuQmCC + + 17, 17 @@ -126,7 +165,6 @@ 51 - AAABAAgAEBAAAAEAIABoBAAAhgAAABgYAAABACAAiAkAAO4EAAAgIAAAAQAgAKgQAAB2DgAAMDAAAAEA diff --git a/Program.cs b/Program.cs index 1255734..9ae6138 100644 --- a/Program.cs +++ b/Program.cs @@ -7,6 +7,7 @@ internal static class Program /// public static string AppSettings = Application.StartupPath + @"\settings.ini"; public static string AppAccountInfo = Application.StartupPath + @"\account.ini"; + public static string AppVersion = "1.0.0"; [STAThread] public static void Main() { diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index c8bd1d1..72593e6 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -110,6 +110,16 @@ internal static System.Drawing.Bitmap pterry1 { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap test { + get { + object obj = ResourceManager.GetObject("test", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index c9f4257..be7b603 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -118,15 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\pterry.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\happycloud.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\info.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -136,4 +127,16 @@ ..\Resources\warning.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pterry.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\happycloud.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\test.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/test.jpg b/Resources/test.jpg new file mode 100644 index 0000000..3f741ed Binary files /dev/null and b/Resources/test.jpg differ