📄 winconfig.cs
字号:
/*
<Aicaca Community Messenger Client>
Copyright (c) Aicaca.com, All rights reserved.
Writer : Byung-ku, Cho (Aicaca)
E-mail : aicaca@hanmail.net
Personal Homepage URL : http://www.aicaca.com
Last Updated Date : Feb. 27th, 2002
Programming Language : C#
Editor & Compiler : VisualStudio.NET
*/
using System;
using System.Threading;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
namespace TalkClient
{
public class WinConfig : System.Windows.Forms.Form
{
private WinCom WC = new WinCom();
private WinClient xWinClient;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.TextBox idTextBox;
private System.Windows.Forms.TextBox portTextBox;
private System.Windows.Forms.TextBox ipTextBox;
private System.Windows.Forms.Label idLabel;
private System.Windows.Forms.Label portLabel;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage mainTap;
private System.Windows.Forms.Label ipLabel;
public WinConfig(WinClient tWinClient)
{
xWinClient = tWinClient;
InitializeComponent();
ReadConfig();
this.ShowDialog();
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.idTextBox = new System.Windows.Forms.TextBox();
this.portTextBox = new System.Windows.Forms.TextBox();
this.ipTextBox = new System.Windows.Forms.TextBox();
this.idLabel = new System.Windows.Forms.Label();
this.portLabel = new System.Windows.Forms.Label();
this.ipLabel = new System.Windows.Forms.Label();
this.cancelButton = new System.Windows.Forms.Button();
this.saveButton = new System.Windows.Forms.Button();
this.tabControl = new System.Windows.Forms.TabControl();
this.mainTap = new System.Windows.Forms.TabPage();
this.tabControl.SuspendLayout();
this.mainTap.SuspendLayout();
this.SuspendLayout();
//
// idTextBox
//
this.idTextBox.Location = new System.Drawing.Point(96, 80);
this.idTextBox.MaxLength = 20;
this.idTextBox.Name = "idTextBox";
this.idTextBox.Size = new System.Drawing.Size(120, 21);
this.idTextBox.TabIndex = 3;
this.idTextBox.Text = "";
//
// portTextBox
//
this.portTextBox.Location = new System.Drawing.Point(96, 48);
this.portTextBox.MaxLength = 10;
this.portTextBox.Name = "portTextBox";
this.portTextBox.Size = new System.Drawing.Size(120, 21);
this.portTextBox.TabIndex = 2;
this.portTextBox.Text = "";
//
// ipTextBox
//
this.ipTextBox.Location = new System.Drawing.Point(96, 16);
this.ipTextBox.MaxLength = 100;
this.ipTextBox.Name = "ipTextBox";
this.ipTextBox.Size = new System.Drawing.Size(120, 21);
this.ipTextBox.TabIndex = 1;
this.ipTextBox.Text = "";
//
// idLabel
//
this.idLabel.Location = new System.Drawing.Point(8, 80);
this.idLabel.Name = "idLabel";
this.idLabel.Size = new System.Drawing.Size(80, 23);
this.idLabel.TabIndex = 0;
this.idLabel.Text = "User ID";
this.idLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// portLabel
//
this.portLabel.Location = new System.Drawing.Point(8, 48);
this.portLabel.Name = "portLabel";
this.portLabel.Size = new System.Drawing.Size(80, 23);
this.portLabel.TabIndex = 0;
this.portLabel.Text = "Server Port";
this.portLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ipLabel
//
this.ipLabel.Location = new System.Drawing.Point(8, 16);
this.ipLabel.Name = "ipLabel";
this.ipLabel.Size = new System.Drawing.Size(80, 23);
this.ipLabel.TabIndex = 0;
this.ipLabel.Text = "Server IP";
this.ipLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(160, 152);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(88, 24);
this.cancelButton.TabIndex = 5;
this.cancelButton.Text = "Cancel";
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// saveButton
//
this.saveButton.Location = new System.Drawing.Point(64, 152);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(88, 24);
this.saveButton.TabIndex = 4;
this.saveButton.Text = "Save";
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// tabControl
//
this.tabControl.Controls.AddRange(new System.Windows.Forms.Control[] {
this.mainTap});
this.tabControl.Location = new System.Drawing.Point(8, 8);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(240, 136);
this.tabControl.TabIndex = 6;
//
// mainTap
//
this.mainTap.Controls.AddRange(new System.Windows.Forms.Control[] {
this.ipLabel,
this.portLabel,
this.idLabel,
this.ipTextBox,
this.portTextBox,
this.idTextBox});
this.mainTap.Location = new System.Drawing.Point(4, 21);
this.mainTap.Name = "mainTap";
this.mainTap.Size = new System.Drawing.Size(232, 111);
this.mainTap.TabIndex = 0;
this.mainTap.Text = "Main";
//
// WinConfig
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(256, 181);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabControl,
this.saveButton,
this.cancelButton});
this.MaximizeBox = false;
this.Name = "WinConfig";
this.Text = "Aicaca WinConfig";
this.tabControl.ResumeLayout(false);
this.mainTap.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void cancelButton_Click (object sender, System.EventArgs e)
{
this.Close();
}
private void saveButton_Click (object sender, System.EventArgs e)
{
this.SaveConfig();
}
private void SaveConfig()
{
string ipStr = this.ipTextBox.Text;
string portStr = this.portTextBox.Text;
string idStr = this.idTextBox.Text;
if (ipStr != null && portStr != null && idStr != null)
{
XmlDocument xd = new XmlDocument();
xd.Load(WC.varStr1 + "ClientConfig.xml");
XmlElement rootIP = xd.CreateElement("RootIP");
XmlText rootIP_t = xd.CreateTextNode(ipStr);
rootIP.AppendChild(rootIP_t);
XmlElement rootPort = xd.CreateElement("RootPort");
XmlText rootPort_t = xd.CreateTextNode(portStr);
rootPort.AppendChild(rootPort_t);
XmlElement localName = xd.CreateElement("LocalName");
XmlText localName_t = xd.CreateTextNode(idStr);
localName.AppendChild(localName_t);
XmlNode ipNode = xd.SelectSingleNode("Config/RootID/RootIP");
XmlNode portNode = xd.SelectSingleNode("Config/RootID/RootPort");
XmlNode idNode = xd.SelectSingleNode("Config/LocalID/LocalName");
ipNode.ParentNode.ReplaceChild(rootIP, ipNode);
portNode.ParentNode.ReplaceChild(rootPort, portNode);
idNode.ParentNode.ReplaceChild(localName, idNode);
xd.Save(WC.varStr1 + "ClientConfig.xml");
xWinClient.StopAll();
xWinClient.StartAll();
this.Close();
}
else
{
MessageBox.Show(this, WC.lineStr9);
}
}
private void ReadConfig()
{
XmlDocument xd = new XmlDocument();
xd.Load(WC.varStr1 + "ClientConfig.xml");
ipTextBox.Text = xd.SelectSingleNode("Config/RootID/RootIP").InnerText;
portTextBox.Text = xd.SelectSingleNode("Config/RootID/RootPort").InnerText;
idTextBox.Text = xd.SelectSingleNode("Config/LocalID/LocalName").InnerText;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -