📄 config.cs
字号:
this.txtLeft.TabIndex = 31;
//
// txtForward
//
this.txtForward.Location = new System.Drawing.Point(108, 36);
this.txtForward.Name = "txtForward";
this.txtForward.Size = new System.Drawing.Size(93, 21);
this.txtForward.TabIndex = 30;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(145, 112);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(17, 12);
this.label6.TabIndex = 29;
this.label6.Text = "后";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(276, 66);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(17, 12);
this.label5.TabIndex = 28;
this.label5.Text = "右";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(17, 66);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(17, 12);
this.label4.TabIndex = 27;
this.label4.Text = "左";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(145, 21);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(17, 12);
this.label3.TabIndex = 26;
this.label3.Text = "前";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.ControlURL);
this.groupBox2.Controls.Add(this.VideoURL);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.txtPort);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(16, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(604, 86);
this.groupBox2.TabIndex = 27;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "WIFI参数设置";
//
// ControlURL
//
this.ControlURL.Location = new System.Drawing.Point(70, 55);
this.ControlURL.Name = "ControlURL";
this.ControlURL.Size = new System.Drawing.Size(344, 21);
this.ControlURL.TabIndex = 39;
//
// VideoURL
//
this.VideoURL.Location = new System.Drawing.Point(70, 24);
this.VideoURL.Name = "VideoURL";
this.VideoURL.Size = new System.Drawing.Size(344, 21);
this.VideoURL.TabIndex = 38;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(438, 27);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(29, 12);
this.label11.TabIndex = 37;
this.label11.Text = "端口";
//
// txtPort
//
this.txtPort.Location = new System.Drawing.Point(482, 24);
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(93, 21);
this.txtPort.TabIndex = 36;
//
// label2
//
this.label2.Location = new System.Drawing.Point(17, 58);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 20);
this.label2.TabIndex = 8;
this.label2.Text = "控制地址";
//
// label1
//
this.label1.Location = new System.Drawing.Point(17, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(398, 20);
this.label1.TabIndex = 6;
this.label1.Text = "视频地址";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(328, 99);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(29, 12);
this.label12.TabIndex = 49;
this.label12.Text = "鸣笛";
//
// txtSpeaker
//
this.txtSpeaker.Location = new System.Drawing.Point(363, 92);
this.txtSpeaker.Name = "txtSpeaker";
this.txtSpeaker.Size = new System.Drawing.Size(93, 21);
this.txtSpeaker.TabIndex = 48;
//
// Config
//
this.AcceptButton = this.okButton;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(631, 308);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Config";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "设置";
this.Load += new System.EventHandler(this.URLForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void okButton_Click(object sender, System.EventArgs e)
{
SaveSetting();
MessageBox.Show("参数修改成功!请重启程序以使设置生效。");
}
private void SaveSetting()
{
//WIFI
WriteIni("VideoUrl", "videourl", this.VideoURL.Text);
WriteIni("ControlUrl", "controlurl", this.ControlURL.Text);
WriteIni("Port", "port", this.txtPort.Text);
//Command
WriteIni("Forward", "forward", this.txtForward.Text);
WriteIni("Left", "left", this.txtLeft.Text);
WriteIni("Right", "right", this.txtRight.Text);
WriteIni("Backward", "backward", this.txtBackward.Text);
WriteIni("Stop", "stop", this.txtStop.Text);
WriteIni("Speaker", "speaker", this.txtSpeaker.Text);
WriteIni("TurnOnLight", "turnOnLight", this.txtTurnOnLight.Text);
WriteIni("TurnOffLight", "turnOffLight", this.txtTurnOffLight.Text);
}
//写INI文件
public void WriteIni(string Section, string Ident, string Value)
{
if (!WritePrivateProfileString(Section, Ident, Value, FileName))
{
throw (new ApplicationException("写入配置文件出错"));
}
}
//读取INI文件指定
public string ReadIni(string Section, string Ident, string Default)
{
Byte[] Buffer = new Byte[65535];
int bufLen = GetPrivateProfileString(Section, Ident, Default, Buffer, Buffer.GetUpperBound(0), FileName);
//必须设定0(系统默认的代码页)的编码方式,否则无法支持中文
string s = Encoding.GetEncoding(0).GetString(Buffer);
s = s.Substring(0, bufLen);
return s.Trim();
}
private void URLForm_Load(object sender, EventArgs e)
{
FileName = Application.StartupPath + "\\Config.ini";
GetIni();
}
private void cancelButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void GetIni()
{
this.VideoURL.Text = ReadIni("VideoUrl", "videourl", "");
this.txtPort.Text = ReadIni("Port", "port", "");
this.ControlURL.Text = ReadIni("ControlUrl", "controlurl", "");
this.txtForward.Text = ReadIni("Forward", "forward", "");
this.txtBackward.Text = ReadIni("Backward", "backward", "");
this.txtLeft.Text = ReadIni("Left", "left", "");
this.txtRight.Text = ReadIni("Right", "right", "");
this.txtStop.Text = ReadIni("Stop", "stop", "");
this.txtSpeaker.Text = ReadIni("Speaker", "speaker", "");
this.txtTurnOnLight.Text = ReadIni("TurnOnLight", "turnOnLight", "");
this.txtTurnOffLight.Text = ReadIni("TurnOffLight", "turnOffLight", "");
}
private void groupBox3_Enter(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -