controlapp/ControlApp/Other.cs
2025-02-28 11:29:02 -08:00

129 lines
3.8 KiB
C#

using System;
using System.ComponentModel;
using System.Configuration;
using System.Drawing;
using System.Windows.Forms;
namespace ControlApp;
public class Other : Form
{
private IContainer components;
private Button svncls;
private Label label1;
private TextBox textBox1;
private TextBox textBox2;
private Label label2;
public Other()
{
InitializeComponent();
}
private void svncls_Click(object sender, EventArgs e)
{
Configuration myconfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
KeyValueConfigurationCollection apps = myconfig.AppSettings.Settings;
apps.Remove("CommonUsers");
string userlist = "";
string[] lines = textBox1.Lines;
foreach (string line in lines)
{
userlist = ((!(userlist == "")) ? (userlist + ",[" + line + "]") : (userlist + "[" + line + "]"));
}
apps.Add("CommonUsers", userlist);
apps.Remove("BlackList");
string blist = "";
lines = textBox2.Lines;
foreach (string line2 in lines)
{
blist = ((!(blist == "")) ? (blist + ",[" + line2 + "]") : (blist + "[" + line2 + "]"));
}
apps.Add("BlackList", blist);
myconfig.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection(myconfig.AppSettings.SectionInformation.Name);
Close();
}
private void Other_Load(object sender, EventArgs e)
{
string userlist = ConfigurationManager.AppSettings["CommonUsers"];
string blist = ConfigurationManager.AppSettings["BlackList"];
if (userlist != null)
{
string[] users = new Utils().seperate_string(userlist);
textBox1.Lines = users;
}
if (blist != null)
{
string[] blists = new Utils().seperate_string(blist);
textBox1.Lines = blists;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.svncls = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
base.SuspendLayout();
this.svncls.Location = new System.Drawing.Point(277, 246);
this.svncls.Name = "svncls";
this.svncls.Size = new System.Drawing.Size(84, 23);
this.svncls.TabIndex = 0;
this.svncls.Text = "Save & Close";
this.svncls.UseVisualStyleBackColor = true;
this.svncls.Click += new System.EventHandler(svncls_Click);
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Common Users";
this.textBox1.Location = new System.Drawing.Point(11, 27);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(123, 189);
this.textBox1.TabIndex = 2;
this.textBox2.Location = new System.Drawing.Point(154, 27);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(123, 189);
this.textBox2.TabIndex = 4;
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(165, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(77, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Web blacklist";
base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(373, 281);
base.Controls.Add(this.textBox2);
base.Controls.Add(this.label2);
base.Controls.Add(this.textBox1);
base.Controls.Add(this.label1);
base.Controls.Add(this.svncls);
base.Name = "Other";
this.Text = "Other";
base.Load += new System.EventHandler(Other_Load);
base.ResumeLayout(false);
base.PerformLayout();
}
}