📄 ipconfig.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace 五子棋
{
/// <summary>
/// Config 的摘要说明。
/// </summary>
public class IpConfig : System.Windows.Forms.Form
{
private System.Windows.Forms.Label localhostlabel;
private System.Windows.Forms.Button scanIPbtn;
private System.Windows.Forms.TextBox ipaddtbx;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button setipbtn;
private string ip="";
public string IP
{
get{return ip;}
set{ip=value;}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public IpConfig()
{
//
// 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.localhostlabel = new System.Windows.Forms.Label();
this.scanIPbtn = new System.Windows.Forms.Button();
this.ipaddtbx = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.setipbtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// localhostlabel
//
this.localhostlabel.Location = new System.Drawing.Point(24, 16);
this.localhostlabel.Name = "localhostlabel";
this.localhostlabel.Size = new System.Drawing.Size(192, 16);
this.localhostlabel.TabIndex = 0;
this.localhostlabel.Text = "本机IP:";
//
// scanIPbtn
//
this.scanIPbtn.Location = new System.Drawing.Point(240, 8);
this.scanIPbtn.Name = "scanIPbtn";
this.scanIPbtn.Size = new System.Drawing.Size(88, 32);
this.scanIPbtn.TabIndex = 1;
this.scanIPbtn.Text = "扫描IP";
this.scanIPbtn.Click += new System.EventHandler(this.scanIPbutton_Click);
//
// ipaddtbx
//
this.ipaddtbx.Location = new System.Drawing.Point(80, 64);
this.ipaddtbx.Name = "ipaddtbx";
this.ipaddtbx.Size = new System.Drawing.Size(136, 21);
this.ipaddtbx.TabIndex = 2;
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 16);
this.label2.TabIndex = 3;
this.label2.Text = "对方IP:";
//
// setipbtn
//
this.setipbtn.Location = new System.Drawing.Point(240, 56);
this.setipbtn.Name = "setipbtn";
this.setipbtn.Size = new System.Drawing.Size(88, 32);
this.setipbtn.TabIndex = 4;
this.setipbtn.Text = "确定";
this.setipbtn.Click += new System.EventHandler(this.Linkbutton_Click);
//
// IpConfig
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(368, 102);
this.Controls.Add(this.setipbtn);
this.Controls.Add(this.label2);
this.Controls.Add(this.ipaddtbx);
this.Controls.Add(this.scanIPbtn);
this.Controls.Add(this.localhostlabel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "IpConfig";
this.Text = "配置IP地址";
this.Load += new System.EventHandler(this.Config_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void Config_Load(object sender, System.EventArgs e)
{
this.localhostlabel.Text += Connect.getIP();
}
private void scanIPbutton_Click(object sender, System.EventArgs e)
{
ScanIP scan=new ScanIP();
scan.Show();
}
private void Linkbutton_Click(object sender, System.EventArgs e)
{
ip=this.ipaddtbx.Text;
this.Hide();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -