diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 81f007f..197abaf 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -62,12 +62,19 @@ private void InitializeComponent() this.ebutton1 = new System.Windows.Forms.Button(); this.ebutton2 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.pictureBox7 = new System.Windows.Forms.PictureBox(); + this.largeimagetext = new System.Windows.Forms.TextBox(); + this.appcache = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit(); this.SuspendLayout(); // // label1 @@ -104,16 +111,16 @@ private void InitializeComponent() // clientid // this.clientid.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.clientid.Location = new System.Drawing.Point(294, 99); + this.clientid.Location = new System.Drawing.Point(294, 91); this.clientid.Name = "clientid"; - this.clientid.Size = new System.Drawing.Size(343, 31); + this.clientid.Size = new System.Drawing.Size(251, 31); this.clientid.TabIndex = 3; this.clientid.Text = "Client ID"; // // details // this.details.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.details.Location = new System.Drawing.Point(294, 153); + this.details.Location = new System.Drawing.Point(294, 138); this.details.Name = "details"; this.details.Size = new System.Drawing.Size(343, 31); this.details.TabIndex = 4; @@ -123,7 +130,7 @@ private void InitializeComponent() // state // this.state.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.state.Location = new System.Drawing.Point(294, 207); + this.state.Location = new System.Drawing.Point(294, 186); this.state.Name = "state"; this.state.Size = new System.Drawing.Size(343, 31); this.state.TabIndex = 5; @@ -220,11 +227,10 @@ private void InitializeComponent() // this.comboBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(294, 259); + this.comboBox1.Location = new System.Drawing.Point(294, 249); this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(251, 32); + this.comboBox1.Size = new System.Drawing.Size(343, 32); this.comboBox1.TabIndex = 14; - this.comboBox1.Text = "FETCH for options"; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // button1 @@ -233,7 +239,7 @@ private void InitializeComponent() this.button1.FlatAppearance.BorderSize = 0; this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(551, 259); + this.button1.Location = new System.Drawing.Point(551, 90); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(86, 32); this.button1.TabIndex = 15; @@ -319,7 +325,7 @@ private void InitializeComponent() this.checkBox1.AutoSize = true; this.checkBox1.BackColor = System.Drawing.Color.LightSkyBlue; this.checkBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.checkBox1.Location = new System.Drawing.Point(294, 304); + this.checkBox1.Location = new System.Drawing.Point(294, 371); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(146, 28); this.checkBox1.TabIndex = 23; @@ -343,7 +349,7 @@ private void InitializeComponent() this.buttonbox1.AutoSize = true; this.buttonbox1.BackColor = System.Drawing.Color.LightSkyBlue; this.buttonbox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonbox1.Location = new System.Drawing.Point(294, 348); + this.buttonbox1.Location = new System.Drawing.Point(294, 411); this.buttonbox1.Name = "buttonbox1"; this.buttonbox1.Size = new System.Drawing.Size(15, 14); this.buttonbox1.TabIndex = 30; @@ -354,7 +360,7 @@ private void InitializeComponent() // this.textBox1.Enabled = false; this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(315, 340); + this.textBox1.Location = new System.Drawing.Point(315, 403); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(125, 31); this.textBox1.TabIndex = 31; @@ -367,7 +373,7 @@ private void InitializeComponent() this.buttonbox2.BackColor = System.Drawing.Color.LightSkyBlue; this.buttonbox2.Enabled = false; this.buttonbox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonbox2.Location = new System.Drawing.Point(294, 395); + this.buttonbox2.Location = new System.Drawing.Point(294, 455); this.buttonbox2.Name = "buttonbox2"; this.buttonbox2.Size = new System.Drawing.Size(15, 14); this.buttonbox2.TabIndex = 32; @@ -378,7 +384,7 @@ private void InitializeComponent() // this.textBox2.Enabled = false; this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox2.Location = new System.Drawing.Point(315, 387); + this.textBox2.Location = new System.Drawing.Point(315, 447); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(125, 31); this.textBox2.TabIndex = 33; @@ -389,7 +395,7 @@ private void InitializeComponent() // this.textBox3.Enabled = false; this.textBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox3.Location = new System.Drawing.Point(461, 340); + this.textBox3.Location = new System.Drawing.Point(461, 403); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(176, 31); this.textBox3.TabIndex = 34; @@ -399,7 +405,7 @@ private void InitializeComponent() // this.textBox4.Enabled = false; this.textBox4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox4.Location = new System.Drawing.Point(461, 387); + this.textBox4.Location = new System.Drawing.Point(461, 447); this.textBox4.Name = "textBox4"; this.textBox4.Size = new System.Drawing.Size(176, 31); this.textBox4.TabIndex = 35; @@ -441,7 +447,7 @@ private void InitializeComponent() this.button4.FlatAppearance.BorderSize = 0; this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button4.Location = new System.Drawing.Point(892, 465); + this.button4.Location = new System.Drawing.Point(802, 468); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(150, 31); this.button4.TabIndex = 40; @@ -449,12 +455,81 @@ private void InitializeComponent() this.button4.UseVisualStyleBackColor = false; this.button4.Click += new System.EventHandler(this.button4_Click); // + // comboBox2 + // + this.comboBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Location = new System.Drawing.Point(294, 332); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(343, 32); + this.comboBox2.TabIndex = 41; + this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.BackColor = System.Drawing.Color.LightSkyBlue; + this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(291, 228); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(94, 16); + this.label6.TabIndex = 43; + this.label6.Text = "Large Image"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.BackColor = System.Drawing.Color.LightSkyBlue; + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(291, 313); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(93, 16); + this.label7.TabIndex = 44; + this.label7.Text = "Small Image"; + // + // pictureBox7 + // + this.pictureBox7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(155)))), ((int)(((byte)(240))))); + this.pictureBox7.Location = new System.Drawing.Point(797, 292); + this.pictureBox7.Name = "pictureBox7"; + this.pictureBox7.Size = new System.Drawing.Size(17, 17); + this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox7.TabIndex = 45; + this.pictureBox7.TabStop = false; + // + // largeimagetext + // + this.largeimagetext.Location = new System.Drawing.Point(294, 287); + this.largeimagetext.Name = "largeimagetext"; + this.largeimagetext.Size = new System.Drawing.Size(343, 20); + this.largeimagetext.TabIndex = 46; + // + // appcache + // + this.appcache.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(106)))), ((int)(((byte)(185)))), ((int)(((byte)(242))))); + this.appcache.FlatAppearance.BorderSize = 0; + this.appcache.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.appcache.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.appcache.Location = new System.Drawing.Point(958, 468); + this.appcache.Name = "appcache"; + this.appcache.Size = new System.Drawing.Size(96, 31); + this.appcache.TabIndex = 47; + this.appcache.Text = "Cache"; + this.appcache.UseVisualStyleBackColor = false; + this.appcache.Click += new System.EventHandler(this.appcache_Click); + // // BretxaRichPresence // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.LightSlateGray; this.ClientSize = new System.Drawing.Size(1066, 511); + this.Controls.Add(this.appcache); + this.Controls.Add(this.largeimagetext); + this.Controls.Add(this.pictureBox7); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); + this.Controls.Add(this.comboBox2); this.Controls.Add(this.button4); this.Controls.Add(this.ebutton2); this.Controls.Add(this.ebutton1); @@ -500,6 +575,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -539,6 +615,12 @@ private void InitializeComponent() private System.Windows.Forms.Button ebutton1; private System.Windows.Forms.Button ebutton2; private System.Windows.Forms.Button button4; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.PictureBox pictureBox7; + private System.Windows.Forms.TextBox largeimagetext; + private System.Windows.Forms.Button appcache; } } diff --git a/Form1.cs b/Form1.cs index fed685d..122ae00 100644 --- a/Form1.cs +++ b/Form1.cs @@ -43,6 +43,12 @@ public BretxaRichPresence() loadprofiles(); + comboBox1.DropDownStyle = ComboBoxStyle.DropDown; + comboBox1.KeyDown += comboBox1_KeyDown; + comboBox1.Leave += comboBox1_Leave; + comboBox2.DropDownStyle = ComboBoxStyle.DropDown; + comboBox2.KeyDown += comboBox2_KeyDown; + comboBox2.Leave += comboBox2_Leave; clientid.Click += clientid_Click; details.Click += details_Click; state.Click += state_Click; @@ -50,38 +56,29 @@ public BretxaRichPresence() DiscordRpcClient client; private int imagenum = 0; - private bool clientidclick = true; - private bool detailsclick = true; - private bool stateclick = true; List buttons = new List(); private void clientid_Click(object sender, EventArgs e) { - if (clientidclick) + if (clientid.Text == "Client ID") { - // Clear the text box on the first click clientid.Text = string.Empty; - clientidclick = false; } } private void details_Click(object sender, EventArgs e) { - if (detailsclick) + if (details.Text == "Details") { - // Clear the text box on the first click details.Text = string.Empty; - detailsclick = false; } } private void state_Click(object sender, EventArgs e) { - if (stateclick) + if (state.Text == "State") { - // Clear the text box on the first click state.Text = string.Empty; - stateclick = false; } } private DateTime startTime; @@ -119,7 +116,9 @@ private void launch_Click(object sender, EventArgs e) State = state.Text, Assets = new Assets() { - LargeImageKey = (string)comboBox1.SelectedItem + LargeImageKey = (string)comboBox1.SelectedItem, + LargeImageText = largeimagetext.Text, + SmallImageKey = (string)comboBox2.SelectedItem } }; if (buttonbox1.Checked && buttonbox2.Checked) @@ -177,7 +176,9 @@ private void UpdatePresence() State = $"{elapsedTime.ToString(@"hh\:mm\:ss")} elapsed", Assets = new Assets() { - LargeImageKey = (string)comboBox1.SelectedItem + LargeImageKey = (string)comboBox1.SelectedItem, + LargeImageText = largeimagetext.Text, + SmallImageKey = (string)comboBox2.SelectedItem } }; @@ -267,6 +268,8 @@ private async void button1_Click(object sender, EventArgs e) comboBox1.Items.Clear(); comboBox1.Items.AddRange(names.ToArray()); + comboBox2.Items.Clear(); + comboBox2.Items.AddRange(names.ToArray()); } catch (Exception ex) { @@ -286,17 +289,27 @@ private void stop_Click(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { - int position = names.IndexOf((string)comboBox1.SelectedItem); - string selectedId = ids[position]; - string imageUrl = "https://cdn.discordapp.com/app-assets/" + clientid.Text + "/" + selectedId + ".png"; - string appLocation = appDataFolderPath + "/previewimage" + imagenum + ".png"; - imagenum += 1; - using (WebClient client = new WebClient()) + if (!IsValidLink((string)comboBox1.SelectedItem)) { try { - client.DownloadFile(new Uri(imageUrl), appLocation); - pictureBox5.Image = Image.FromFile(appLocation); + int position = names.IndexOf((string)comboBox1.SelectedItem); + string selectedId = ids[position]; + string imageUrl = "https://cdn.discordapp.com/app-assets/" + clientid.Text + "/" + selectedId + ".png"; + string appLocation = appDataFolderPath + "/previewimage" + imagenum + ".png"; + imagenum += 1; + using (WebClient client = new WebClient()) + { + try + { + client.DownloadFile(new Uri(imageUrl), appLocation); + pictureBox5.Image = Image.FromFile(appLocation); + } + catch (Exception ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + } + } } catch (Exception ex) { @@ -305,6 +318,30 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) } } + private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) + { + if (!IsValidLink((string)comboBox2.SelectedItem)) + { + int position = names.IndexOf((string)comboBox2.SelectedItem); + string selectedId = ids[position]; + string imageUrl = "https://cdn.discordapp.com/app-assets/" + clientid.Text + "/" + selectedId + ".png"; + string appLocation = appDataFolderPath + "/previewimage" + imagenum + ".png"; + imagenum += 1; + using (WebClient client = new WebClient()) + { + try + { + client.DownloadFile(new Uri(imageUrl), appLocation); + pictureBox7.Image = Image.FromFile(appLocation); + } + catch (Exception ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + } + } + } + } + private void details_TextChanged(object sender, EventArgs e) { detailslabel.Text = details.Text; @@ -317,6 +354,18 @@ private void state_TextChanged(object sender, EventArgs e) private void save_Click(object sender, EventArgs e) { + List comboBoxItems = new List(); + foreach (var item in comboBox1.Items) + { + comboBoxItems.Add(item.ToString()); + } + + List comboBox2Items = new List(); + foreach (var item in comboBox2.Items) + { + comboBox2Items.Add(item.ToString()); + } + var jsonObject = new { profilenametext = profilename.Text, @@ -324,6 +373,7 @@ private void save_Click(object sender, EventArgs e) detailstext = details.Text, statetext = state.Text, imageselected = (string)comboBox1.SelectedItem, + smallimageselected = (string)comboBox2.SelectedItem, chebox1 = buttonbox1.CheckState, buttontext1 = textBox1.Text, buttonurl1 = textBox3.Text, @@ -331,8 +381,9 @@ private void save_Click(object sender, EventArgs e) buttontext2 = textBox2.Text, buttonurl2 = textBox4.Text, timeelpased = checkBox1.CheckState, - - + largeimagetext1 = largeimagetext.Text, + comboBoxItems = comboBoxItems, + comboBox2Items = comboBox2Items }; string jsonString = JsonConvert.SerializeObject(jsonObject, Formatting.Indented); @@ -392,14 +443,39 @@ public void loadprofiles() clientid.Text = (string)json["clientidtext"]; details.Text = (string)json["detailstext"]; state.Text = (string)json["statetext"]; - comboBox1.SelectedItem = (string)json["imageselected"]; buttonbox1.Checked = (bool)json["chebox1"]; textBox1.Text = (string)json["buttontext1"]; textBox3.Text = (string)json["buttonurl1"]; buttonbox2.Checked = (bool)json["chebox2"]; + comboBox1.Items.Clear(); + comboBox1.Text = null; + + JArray comboBoxItems = (JArray)json["comboBoxItems"]; + if (comboBoxItems != null) + { + foreach (var item in comboBoxItems) + { + comboBox1.Items.Add(item.ToString()); + } + } + comboBox2.Items.Clear(); + comboBox2.Text = null; + + JArray comboBox2Items = (JArray)json["comboBox2Items"]; + if (comboBox2Items != null) + { + foreach (var item in comboBox2Items) + { + comboBox2.Items.Add(item.ToString()); + } + } + //button1_Click(sender, e); textBox2.Text = (string)json["buttontext2"]; textBox4.Text = (string)json["buttonurl2"]; checkBox1.Checked = (bool)json["timeelpased"]; + largeimagetext.Text = (string)json["largeimagetext1"]; + comboBox1.SelectedItem = (string)json["imageselected"]; + comboBox2.SelectedItem = (string)json["smallimageselected"]; } catch (Exception ex) { @@ -462,16 +538,6 @@ private void textBox2_TextChanged(object sender, EventArgs e) ebutton2.Text = textBox2.Text; } - private void button2_Click(object sender, EventArgs e) - { - Application.Exit(); - } - - private void button3_Click(object sender, EventArgs e) - { - this.WindowState = FormWindowState.Minimized; - } - public static string GetAppDataFolderPath(string appName) { string appDataFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), appName); @@ -507,7 +573,7 @@ protected override void OnLoad(EventArgs e) { base.OnLoad(e); - this.ShowInTaskbar = false; + this.ShowInTaskbar = true; notifyIcon = new NotifyIcon(); notifyIcon.Icon = this.Icon; @@ -531,26 +597,91 @@ private void NotifyIcon_MouseClick(object sender, MouseEventArgs e) this.WindowState = FormWindowState.Normal; this.Show(); } - //this.BringToFront(); } private void CloseMenuItem_Click(object sender, EventArgs e) { + this.ShowInTaskbar = false; this.Close(); } - protected override void OnResize(EventArgs e) + + protected override void OnFormClosing(FormClosingEventArgs e) { - base.OnResize(e); + base.OnFormClosing(e); - if (this.WindowState == FormWindowState.Minimized) + if (e.CloseReason == CloseReason.UserClosing) { - this.Hide(); + if (this.WindowState != FormWindowState.Minimized) + { + this.WindowState = FormWindowState.Minimized; + this.Hide(); + e.Cancel = true; + } } } - protected override void OnFormClosing(FormClosingEventArgs e) + + private void comboBox1_KeyDown(object sender, KeyEventArgs e) { - base.OnFormClosing(e); - notifyIcon.Dispose(); + // Handle the Enter key press event to add a link to the ComboBox + if (e.KeyCode == Keys.Enter) + { + SaveLink(); + } + } + + private void comboBox1_Leave(object sender, EventArgs e) + { + SaveLink(); + } + + private void SaveLink() + { + string text = comboBox1.Text.Trim(); + + // Check if the entered text is a valid link and not already present in the ComboBox + if (IsValidLink(text) && !comboBox1.Items.Contains(text)) + { + comboBox1.Items.Add(text); + } + } + + private void comboBox2_KeyDown(object sender, KeyEventArgs e) + { + // Handle the Enter key press event to add a link to the ComboBox + if (e.KeyCode == Keys.Enter) + { + SaveLink1(); + } + } + + private void comboBox2_Leave(object sender, EventArgs e) + { + SaveLink1(); + } + + private void SaveLink1() + { + string text = comboBox2.Text.Trim(); + + // Check if the entered text is a valid link and not already present in the ComboBox + if (IsValidLink(text) && !comboBox2.Items.Contains(text)) + { + comboBox2.Items.Add(text); + } + } + + private bool IsValidLink(string text) + { + // Validate the entered text as a link + Uri uriResult; + return Uri.TryCreate(text, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); + } + + private void appcache_Click(object sender, EventArgs e) + { + string appName = "BretxaRichPresenceDiscord"; + appDataFolderPath = GetAppDataFolderPath(appName); + Process.Start(appDataFolderPath); } } }