⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winclient.cs

📁 一个即时通信 Messenger C#代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
/*

<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.IO;
using System.Threading;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Xml;

namespace TalkClient
{
	public class WinClient : System.Windows.Forms.Form
	{
		private WinCom WC = new WinCom();
		private WinAccept xWinAccept = null;
		private WinRoot xWinRoot = null;

		private Hashtable FormHash = new Hashtable();

		private Socket RootSocket = null;
		private TextWriter SocketWriter = null;

		private string clientAddr;
		private string configData;
		private string clientVersion;
		private string rootID;
		private string localID;

		private bool shutFlag = false;

		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.NotifyIcon onTrayIcon;
		private System.Windows.Forms.NotifyIcon offTrayIcon;
		private System.Windows.Forms.MainMenu mainMenu;
		private System.Windows.Forms.MenuItem actionMenu;
		private System.Windows.Forms.MenuItem configMenu;
		private System.Windows.Forms.MenuItem startMenu;
		private System.Windows.Forms.MenuItem stopMenu;
		private System.Windows.Forms.MenuItem hideMenu;
		private System.Windows.Forms.MenuItem shutMenu;
		private System.Windows.Forms.MenuItem helpMenu;
		private System.Windows.Forms.MenuItem aboutMenu;
		private System.Windows.Forms.ToolBar toolBar;
		private System.Windows.Forms.ToolBarButton configBtn;
		private System.Windows.Forms.ToolBarButton startBtn;
		private System.Windows.Forms.ToolBarButton stopBtn;
		private System.Windows.Forms.ToolBarButton hideBtn;
		private System.Windows.Forms.ToolBarButton shutBtn;
		private System.Windows.Forms.StatusBar statusBar;
		private System.Windows.Forms.StatusBarPanel mainStatus;
		private System.Windows.Forms.ListView clientList;
		private System.Windows.Forms.ColumnHeader idColumn;
		private System.Windows.Forms.ColumnHeader ipColumn;
		private System.Windows.Forms.ColumnHeader portColumn;
		private System.Windows.Forms.ListView boardList;
		private System.Windows.Forms.ColumnHeader nameColumn;
		private System.Windows.Forms.ColumnHeader typeColumn;
		private System.Windows.Forms.TextBox chatBox;
		private System.Windows.Forms.Button sendButton;
		private System.Windows.Forms.TextBox inputBox;
		private System.Windows.Forms.StatusBarPanel processStatus;

		public WinClient()
		{
			this.InitializeComponent();
			this.InitializeClient();
		}

		protected override void Dispose(bool disposing)
		{
			if (shutFlag == true)
			{
				if( disposing )
				{
					if(components != null)
					{
						components.Dispose();
					}
				}
				base.Dispose( disposing );
			}
			else
			{
				this.Visible = false;
			}
		}

        #region Windows Form Designer generated code
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(WinClient));
			this.onTrayIcon = new System.Windows.Forms.NotifyIcon(this.components);
			this.offTrayIcon = new System.Windows.Forms.NotifyIcon(this.components);
			this.mainMenu = new System.Windows.Forms.MainMenu();
			this.actionMenu = new System.Windows.Forms.MenuItem();
			this.configMenu = new System.Windows.Forms.MenuItem();
			this.startMenu = new System.Windows.Forms.MenuItem();
			this.stopMenu = new System.Windows.Forms.MenuItem();
			this.hideMenu = new System.Windows.Forms.MenuItem();
			this.shutMenu = new System.Windows.Forms.MenuItem();
			this.helpMenu = new System.Windows.Forms.MenuItem();
			this.aboutMenu = new System.Windows.Forms.MenuItem();
			this.toolBar = new System.Windows.Forms.ToolBar();
			this.configBtn = new System.Windows.Forms.ToolBarButton();
			this.startBtn = new System.Windows.Forms.ToolBarButton();
			this.stopBtn = new System.Windows.Forms.ToolBarButton();
			this.hideBtn = new System.Windows.Forms.ToolBarButton();
			this.shutBtn = new System.Windows.Forms.ToolBarButton();
			this.statusBar = new System.Windows.Forms.StatusBar();
			this.mainStatus = new System.Windows.Forms.StatusBarPanel();
			this.processStatus = new System.Windows.Forms.StatusBarPanel();
			this.clientList = new System.Windows.Forms.ListView();
			this.idColumn = new System.Windows.Forms.ColumnHeader();
			this.ipColumn = new System.Windows.Forms.ColumnHeader();
			this.portColumn = new System.Windows.Forms.ColumnHeader();
			this.boardList = new System.Windows.Forms.ListView();
			this.nameColumn = new System.Windows.Forms.ColumnHeader();
			this.typeColumn = new System.Windows.Forms.ColumnHeader();
			this.chatBox = new System.Windows.Forms.TextBox();
			this.inputBox = new System.Windows.Forms.TextBox();
			this.sendButton = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.mainStatus)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.processStatus)).BeginInit();
			this.SuspendLayout();
			// 
			// onTrayIcon
			// 
			this.onTrayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("onTrayIcon.Icon")));
			this.onTrayIcon.Text = "Connected";
			this.onTrayIcon.Visible = true;
			this.onTrayIcon.DoubleClick += new System.EventHandler(this.TrayIcon_DoubleClick);
			// 
			// offTrayIcon
			// 
			this.offTrayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("offTrayIcon.Icon")));
			this.offTrayIcon.Text = "Disconnected";
			this.offTrayIcon.DoubleClick += new System.EventHandler(this.TrayIcon_DoubleClick);
			// 
			// mainMenu
			// 
			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.actionMenu,
																					 this.helpMenu});
			// 
			// actionMenu
			// 
			this.actionMenu.Index = 0;
			this.actionMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.configMenu,
																					   this.startMenu,
																					   this.stopMenu,
																					   this.hideMenu,
																					   this.shutMenu});
			this.actionMenu.Text = "Action";
			// 
			// configMenu
			// 
			this.configMenu.Index = 0;
			this.configMenu.Text = "Config";
			this.configMenu.Click += new System.EventHandler(this.configMenu_Click);
			// 
			// startMenu
			// 
			this.startMenu.Enabled = false;
			this.startMenu.Index = 1;
			this.startMenu.Text = "Client Start";
			this.startMenu.Click += new System.EventHandler(this.startMenu_Click);
			// 
			// stopMenu
			// 
			this.stopMenu.Index = 2;
			this.stopMenu.Text = "Client Stop";
			this.stopMenu.Click += new System.EventHandler(this.stopMenu_Click);
			// 
			// hideMenu
			// 
			this.hideMenu.Index = 3;
			this.hideMenu.Text = "Hide";
			this.hideMenu.Click += new System.EventHandler(this.hideMenu_Click);
			// 
			// shutMenu
			// 
			this.shutMenu.Index = 4;
			this.shutMenu.Text = "Shut Down";
			this.shutMenu.Click += new System.EventHandler(this.shutMenu_Click);
			// 
			// helpMenu
			// 
			this.helpMenu.Index = 1;
			this.helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.aboutMenu});
			this.helpMenu.Text = "Help";
			// 
			// aboutMenu
			// 
			this.aboutMenu.Index = 0;
			this.aboutMenu.Text = "About Aicaca Client";
			this.aboutMenu.Click += new System.EventHandler(this.aboutMenu_Click);
			// 
			// toolBar
			// 
			this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.configBtn,
																					   this.startBtn,
																					   this.stopBtn,
																					   this.hideBtn,
																					   this.shutBtn});
			this.toolBar.ButtonSize = new System.Drawing.Size(80, 35);
			this.toolBar.DropDownArrows = true;
			this.toolBar.Name = "toolBar";
			this.toolBar.ShowToolTips = true;
			this.toolBar.Size = new System.Drawing.Size(600, 38);
			this.toolBar.TabIndex = 1;
			this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
			// 
			// configBtn
			// 
			this.configBtn.Text = "Config";
			// 
			// startBtn
			// 
			this.startBtn.Enabled = false;
			this.startBtn.Text = "Client Start";
			// 
			// stopBtn
			// 
			this.stopBtn.Text = "Client Stop";
			// 
			// hideBtn
			// 
			this.hideBtn.Text = "Hide";
			// 
			// shutBtn
			// 
			this.shutBtn.Text = "Shut Down";
			// 
			// statusBar
			// 
			this.statusBar.Location = new System.Drawing.Point(0, 328);
			this.statusBar.Name = "statusBar";
			this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																						 this.mainStatus,
																						 this.processStatus});
			this.statusBar.ShowPanels = true;
			this.statusBar.Size = new System.Drawing.Size(600, 22);
			this.statusBar.TabIndex = 0;
			// 
			// mainStatus
			// 
			this.mainStatus.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.mainStatus.Width = 384;
			// 
			// processStatus
			// 
			this.processStatus.Width = 200;
			// 
			// clientList
			// 
			this.clientList.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left);
			this.clientList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						 this.idColumn,
																						 this.ipColumn,
																						 this.portColumn});
			this.clientList.Location = new System.Drawing.Point(0, 40);
			this.clientList.Name = "clientList";
			this.clientList.Size = new System.Drawing.Size(254, 144);
			this.clientList.TabIndex = 2;
			this.clientList.View = System.Windows.Forms.View.Details;
			this.clientList.DoubleClick += new System.EventHandler(this.clientList_DoubleClick);
			// 
			// idColumn
			// 
			this.idColumn.Text = "User ID";
			this.idColumn.Width = 80;
			// 
			// ipColumn
			// 
			this.ipColumn.Text = "IP";
			this.ipColumn.Width = 120;
			// 
			// portColumn
			// 
			this.portColumn.Text = "Port";
			this.portColumn.Width = 50;
			// 
			// boardList
			// 
			this.boardList.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.boardList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						this.nameColumn,
																						this.typeColumn});
			this.boardList.Location = new System.Drawing.Point(0, 184);
			this.boardList.Name = "boardList";
			this.boardList.Size = new System.Drawing.Size(254, 144);
			this.boardList.TabIndex = 3;
			this.boardList.View = System.Windows.Forms.View.Details;
			this.boardList.DoubleClick += new System.EventHandler(this.boardList_DoubleClick);
			// 
			// nameColumn
			// 
			this.nameColumn.Text = "Board Name";
			this.nameColumn.Width = 150;
			// 
			// typeColumn
			// 
			this.typeColumn.Text = "Board Type";
			this.typeColumn.Width = 100;
			// 
			// chatBox
			// 
			this.chatBox.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.chatBox.Location = new System.Drawing.Point(256, 40);
			this.chatBox.MaxLength = 10000000;
			this.chatBox.Multiline = true;
			this.chatBox.Name = "chatBox";
			this.chatBox.ReadOnly = true;
			this.chatBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.chatBox.Size = new System.Drawing.Size(344, 240);
			this.chatBox.TabIndex = 0;
			this.chatBox.Text = "";
			// 
			// inputBox
			// 
			this.inputBox.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.inputBox.Location = new System.Drawing.Point(256, 280);
			this.inputBox.MaxLength = 1000;
			this.inputBox.Multiline = true;
			this.inputBox.Name = "inputBox";
			this.inputBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.inputBox.Size = new System.Drawing.Size(280, 48);
			this.inputBox.TabIndex = 4;
			this.inputBox.Text = "";
			// 
			// sendButton
			// 
			this.sendButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.sendButton.Location = new System.Drawing.Point(536, 280);
			this.sendButton.Name = "sendButton";
			this.sendButton.Size = new System.Drawing.Size(64, 48);
			this.sendButton.TabIndex = 5;
			this.sendButton.Text = "Send";
			this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
			// 
			// WinClient
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(600, 350);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.sendButton,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -