📄 frmaddrange.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ShootSearch.Helper;
namespace ShootSearch
{
/// <summary>
/// AddRange 的摘要说明。
/// </summary>
public class frmAddRange : System.Windows.Forms.Form
{
private static frmMain m_frmMain;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TabPage tabPageIP;
private System.Windows.Forms.TabPage tabPageURL;
private System.Windows.Forms.Button button_Add;
private System.Windows.Forms.ListBox listBoxURLs;
private System.Windows.Forms.TextBox textBox_URL;
private System.Windows.Forms.Button button_Delelt;
private System.Windows.Forms.Button button_Cancel;
private System.Windows.Forms.Button button_Save;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmAddRange()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.button_Add = new System.Windows.Forms.Button();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPageURL = new System.Windows.Forms.TabPage();
this.textBox_URL = new System.Windows.Forms.TextBox();
this.tabPageIP = new System.Windows.Forms.TabPage();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button_Delelt = new System.Windows.Forms.Button();
this.listBoxURLs = new System.Windows.Forms.ListBox();
this.button_Cancel = new System.Windows.Forms.Button();
this.button_Save = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPageURL.SuspendLayout();
this.tabPageIP.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button_Add);
this.groupBox1.Controls.Add(this.tabControl1);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(320, 136);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "选择类型:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(232, 88);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 10;
this.button2.Text = "帮助";
//
// button_Add
//
this.button_Add.Location = new System.Drawing.Point(232, 56);
this.button_Add.Name = "button_Add";
this.button_Add.Size = new System.Drawing.Size(80, 24);
this.button_Add.TabIndex = 6;
this.button_Add.Text = "添加";
this.button_Add.Click += new System.EventHandler(this.button_Add_Click);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPageURL);
this.tabControl1.Controls.Add(this.tabPageIP);
this.tabControl1.Location = new System.Drawing.Point(8, 32);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(216, 88);
this.tabControl1.TabIndex = 5;
//
// tabPageURL
//
this.tabPageURL.Controls.Add(this.textBox_URL);
this.tabPageURL.Location = new System.Drawing.Point(4, 21);
this.tabPageURL.Name = "tabPageURL";
this.tabPageURL.Size = new System.Drawing.Size(208, 63);
this.tabPageURL.TabIndex = 1;
this.tabPageURL.Text = "网址";
this.tabPageURL.Visible = false;
//
// textBox_URL
//
this.textBox_URL.Location = new System.Drawing.Point(8, 8);
this.textBox_URL.Multiline = true;
this.textBox_URL.Name = "textBox_URL";
this.textBox_URL.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox_URL.Size = new System.Drawing.Size(176, 48);
this.textBox_URL.TabIndex = 0;
this.textBox_URL.Text = "http://";
//
// tabPageIP
//
this.tabPageIP.Controls.Add(this.label3);
this.tabPageIP.Controls.Add(this.label2);
this.tabPageIP.Controls.Add(this.textBox2);
this.tabPageIP.Controls.Add(this.textBox1);
this.tabPageIP.Location = new System.Drawing.Point(4, 21);
this.tabPageIP.Name = "tabPageIP";
this.tabPageIP.Size = new System.Drawing.Size(208, 63);
this.tabPageIP.TabIndex = 0;
this.tabPageIP.Text = "IP地址";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 5;
this.label3.Text = "终点网段";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 4;
this.label2.Text = "起点网段";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(72, 32);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(112, 21);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 8);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(112, 21);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "222.222.222.222";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button_Delelt);
this.groupBox2.Controls.Add(this.listBoxURLs);
this.groupBox2.Location = new System.Drawing.Point(8, 152);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(320, 248);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "已经添加的地址:";
//
// button_Delelt
//
this.button_Delelt.Location = new System.Drawing.Point(208, 216);
this.button_Delelt.Name = "button_Delelt";
this.button_Delelt.Size = new System.Drawing.Size(88, 24);
this.button_Delelt.TabIndex = 10;
this.button_Delelt.Text = "删除";
this.button_Delelt.Click += new System.EventHandler(this.button_Delelt_Click);
//
// listBoxURLs
//
this.listBoxURLs.ItemHeight = 12;
this.listBoxURLs.Location = new System.Drawing.Point(8, 24);
this.listBoxURLs.Name = "listBoxURLs";
this.listBoxURLs.Size = new System.Drawing.Size(296, 184);
this.listBoxURLs.TabIndex = 9;
this.listBoxURLs.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listBoxURLs_MouseDown);
this.listBoxURLs.SelectedIndexChanged += new System.EventHandler(this.listBoxURLs_SelectedIndexChanged);
//
// button_Cancel
//
this.button_Cancel.Location = new System.Drawing.Point(264, 416);
this.button_Cancel.Name = "button_Cancel";
this.button_Cancel.Size = new System.Drawing.Size(64, 24);
this.button_Cancel.TabIndex = 9;
this.button_Cancel.Text = "取消";
this.button_Cancel.Click += new System.EventHandler(this.button_Cancel_Click);
//
// button_Save
//
this.button_Save.Location = new System.Drawing.Point(184, 416);
this.button_Save.Name = "button_Save";
this.button_Save.Size = new System.Drawing.Size(72, 24);
this.button_Save.TabIndex = 10;
this.button_Save.Text = "确定";
this.button_Save.Click += new System.EventHandler(this.button_Save_Click);
//
// frmAddRange
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(336, 453);
this.Controls.Add(this.button_Save);
this.Controls.Add(this.button_Cancel);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmAddRange";
this.Text = "设置范围";
this.Closing += new System.ComponentModel.CancelEventHandler(this.frmAddRange_Closing);
this.Load += new System.EventHandler(this.frmAddRange_Load);
this.groupBox1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPageURL.ResumeLayout(false);
this.tabPageIP.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 添加URL
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Add_Click(object sender, System.EventArgs e)
{
//Console.WriteLine(textBox_URL.Text.Substring(textBox_URL.Text.Length-1));
if(textBox_URL.Text.Substring(textBox_URL.Text.Length-1) == "/")
{
this.listBoxURLs.Items.Add(textBox_URL.Text);
}
else
{
this.listBoxURLs.Items.Add(textBox_URL.Text + "/");
}
}
/// <summary>
/// 删除URL
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Delelt_Click(object sender, System.EventArgs e)
{
if(this.listBoxURLs.SelectedIndex != -1)
listBoxURLs.Items.RemoveAt(listBoxURLs.SelectedIndex) ;
}
/// <summary>
/// 关闭窗体
/// </summary>
private void form_Exit()
{
m_frmMain.Enabled = true ;
Dispose(true);
}
private void frmAddRange_Load(object sender, System.EventArgs e)
{
}
public void Load_JobList(frmMain p_frmMain)
{
this.Show();
m_frmMain=p_frmMain;
m_frmMain.Enabled = false;
//
Config.Load_Config();
//
for(int i = 0 ; i < Config.JobList.Count ; i++)
{
this.listBoxURLs.Items.Add(Config.JobList[i].ToString());
}
}
public void Save_JobList()
{
Config.JobList = new ArrayList();
for(int i = 0 ; i < listBoxURLs.Items.Count ; i++)
{
Config.JobList.Add(listBoxURLs.Items[i].ToString());
}
Config.Save_Config();
form_Exit();
}
/// <summary>
/// 点击X关闭窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmAddRange_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Config.Load_Config();
form_Exit();
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Save_Click(object sender, System.EventArgs e)
{
Save_JobList();
form_Exit();
}
/// <summary>
/// 取消按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Cancel_Click(object sender, System.EventArgs e)
{
Config.Load_Config();
form_Exit();
}
private void listBoxURLs_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
}
private void listBoxURLs_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.listBoxURLs.SelectedIndex>=0)
{
this.textBox_URL.Text = this.listBoxURLs.SelectedItem.ToString();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -