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

📄 chatclient.cs

📁 进程间通信精华资料,包括好多源码,和文章,都是个人收集的.主要是vc和c#方面的
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Reflection;
using System.Net;
using System.Threading;
using System.Runtime.InteropServices;
using System.Configuration;
using ChatMediator;
[assembly:ComVisible(false)]
[assembly:CLSCompliant(true)]


namespace ChatClient
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	/// 	
	[ComVisible(true)] 
	[CLSCompliant(true)]
	public class Form1 : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;			
		private System.Windows.Forms.Label lblErrorMessage;
		private System.Windows.Forms.GroupBox grpClientChatBox;
		private System.Windows.Forms.RichTextBox txtMessage;
		private System.Windows.Forms.Label lblUserList;
		private System.Windows.Forms.StatusBar stsConnected;
		private System.Windows.Forms.Label lblUserName;
		private System.Windows.Forms.TextBox txtUserName;
		private System.Windows.Forms.ListBox lstUsers;
		private System.Windows.Forms.Button btnConnect;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.GroupBox grpAuthenticate;
		private System.Windows.Forms.TextBox txtProxyPassword;
		private System.Windows.Forms.Label lblPassword;
		private System.Windows.Forms.TextBox txtProxyUserName;
		private System.Windows.Forms.Label lblUser;

		#region MyVariables
		
		private IMediator im = null;
		private EventsClass em = null;
		private ArrayList clientList = null;
		private System.Windows.Forms.Button btnSend;
		private System.Windows.Forms.TextBox txtSendMessage;
		private System.Windows.Forms.GroupBox grpSend;
		private System.Windows.Forms.Label lblUserCount;
		private IClientImplement iciClient = null;
		private Hashtable hsPrivateWindows = new Hashtable();
		private string httpServerUrl = ConfigurationSettings.AppSettings["HttpServerURL"].ToString();
		private string tcpServerUrl = ConfigurationSettings.AppSettings["TcpServerURL"].ToString();

		#endregion		

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//			
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.lblErrorMessage = new System.Windows.Forms.Label();
			this.grpClientChatBox = new System.Windows.Forms.GroupBox();
			this.grpSend = new System.Windows.Forms.GroupBox();
			this.lblUserCount = new System.Windows.Forms.Label();
			this.btnSend = new System.Windows.Forms.Button();
			this.txtSendMessage = new System.Windows.Forms.TextBox();
			this.txtMessage = new System.Windows.Forms.RichTextBox();
			this.lblUserList = new System.Windows.Forms.Label();
			this.stsConnected = new System.Windows.Forms.StatusBar();
			this.lblUserName = new System.Windows.Forms.Label();
			this.txtUserName = new System.Windows.Forms.TextBox();
			this.lstUsers = new System.Windows.Forms.ListBox();
			this.btnConnect = new System.Windows.Forms.Button();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.grpAuthenticate = new System.Windows.Forms.GroupBox();
			this.txtProxyPassword = new System.Windows.Forms.TextBox();
			this.lblPassword = new System.Windows.Forms.Label();
			this.txtProxyUserName = new System.Windows.Forms.TextBox();
			this.lblUser = new System.Windows.Forms.Label();
			this.grpClientChatBox.SuspendLayout();
			this.grpSend.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.grpAuthenticate.SuspendLayout();
			this.SuspendLayout();
			// 
			// lblErrorMessage
			// 
			this.lblErrorMessage.ForeColor = System.Drawing.Color.Red;
			this.lblErrorMessage.Location = new System.Drawing.Point(74, -112);
			this.lblErrorMessage.Name = "lblErrorMessage";
			this.lblErrorMessage.Size = new System.Drawing.Size(408, 88);
			this.lblErrorMessage.TabIndex = 10;
			// 
			// grpClientChatBox
			// 
			this.grpClientChatBox.Controls.Add(this.grpSend);
			this.grpClientChatBox.Controls.Add(this.txtMessage);
			this.grpClientChatBox.Controls.Add(this.lblUserList);
			this.grpClientChatBox.Controls.Add(this.stsConnected);
			this.grpClientChatBox.Controls.Add(this.lblUserName);
			this.grpClientChatBox.Controls.Add(this.txtUserName);
			this.grpClientChatBox.Controls.Add(this.lstUsers);
			this.grpClientChatBox.Controls.Add(this.btnConnect);
			this.grpClientChatBox.Location = new System.Drawing.Point(8, 104);
			this.grpClientChatBox.Name = "grpClientChatBox";
			this.grpClientChatBox.Size = new System.Drawing.Size(656, 408);
			this.grpClientChatBox.TabIndex = 8;
			this.grpClientChatBox.TabStop = false;
			this.grpClientChatBox.Text = "Client";
			// 
			// grpSend
			// 
			this.grpSend.Controls.Add(this.lblUserCount);
			this.grpSend.Controls.Add(this.btnSend);
			this.grpSend.Controls.Add(this.txtSendMessage);
			this.grpSend.Enabled = false;
			this.grpSend.Location = new System.Drawing.Point(16, 200);
			this.grpSend.Name = "grpSend";
			this.grpSend.Size = new System.Drawing.Size(368, 120);
			this.grpSend.TabIndex = 11;
			this.grpSend.TabStop = false;
			this.grpSend.Text = "Send";
			// 
			// lblUserCount
			// 
			this.lblUserCount.Location = new System.Drawing.Point(16, 88);
			this.lblUserCount.Name = "lblUserCount";
			this.lblUserCount.Size = new System.Drawing.Size(344, 23);
			this.lblUserCount.TabIndex = 13;
			// 
			// btnSend
			// 
			this.btnSend.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnSend.Location = new System.Drawing.Point(284, 24);
			this.btnSend.Name = "btnSend";
			this.btnSend.Size = new System.Drawing.Size(72, 48);
			this.btnSend.TabIndex = 5;
			this.btnSend.Text = "Send";
			this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
			// 
			// txtSendMessage
			// 
			this.txtSendMessage.ForeColor = System.Drawing.Color.Maroon;
			this.txtSendMessage.Location = new System.Drawing.Point(8, 24);
			this.txtSendMessage.Multiline = true;
			this.txtSendMessage.Name = "txtSendMessage";
			this.txtSendMessage.Size = new System.Drawing.Size(272, 48);
			this.txtSendMessage.TabIndex = 4;
			this.txtSendMessage.Text = "Hi!!";
			this.txtSendMessage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSendMessage_KeyDown);
			// 
			// txtMessage
			// 
			this.txtMessage.Location = new System.Drawing.Point(16, 56);
			this.txtMessage.Name = "txtMessage";
			this.txtMessage.ReadOnly = true;
			this.txtMessage.Size = new System.Drawing.Size(360, 128);
			this.txtMessage.TabIndex = 10;
			this.txtMessage.Text = "/*********************WEL-COME TO CHAT ROOM ********************/";
			// 
			// lblUserList
			// 
			this.lblUserList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lblUserList.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblUserList.Location = new System.Drawing.Point(480, 24);
			this.lblUserList.Name = "lblUserList";
			this.lblUserList.Size = new System.Drawing.Size(80, 32);
			this.lblUserList.TabIndex = 9;
			this.lblUserList.Text = "Users list";
			this.lblUserList.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// stsConnected
			// 
			this.stsConnected.Location = new System.Drawing.Point(3, 383);
			this.stsConnected.Name = "stsConnected";
			this.stsConnected.Size = new System.Drawing.Size(650, 22);
			this.stsConnected.TabIndex = 8;
			this.stsConnected.Text = "Not connected...";
			// 
			// lblUserName
			// 
			this.lblUserName.Location = new System.Drawing.Point(16, 24);
			this.lblUserName.Name = "lblUserName";
			this.lblUserName.Size = new System.Drawing.Size(64, 16);
			this.lblUserName.TabIndex = 5;
			this.lblUserName.Text = "UserName: ";
			// 
			// txtUserName
			// 
			this.txtUserName.Location = new System.Drawing.Point(96, 24);
			this.txtUserName.Name = "txtUserName";
			this.txtUserName.Size = new System.Drawing.Size(192, 20);
			this.txtUserName.TabIndex = 2;
			this.txtUserName.Text = "User";
			// 
			// lstUsers
			// 
			this.lstUsers.Location = new System.Drawing.Point(424, 64);
			this.lstUsers.Name = "lstUsers";
			this.lstUsers.Size = new System.Drawing.Size(208, 303);
			this.lstUsers.TabIndex = 4;
			this.lstUsers.DoubleClick += new System.EventHandler(this.lstUsers_DoubleClick);
			// 
			// btnConnect
			// 
			this.btnConnect.Location = new System.Drawing.Point(304, 24);
			this.btnConnect.Name = "btnConnect";
			this.btnConnect.TabIndex = 3;
			this.btnConnect.Text = "Connect";
			this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.textBox1);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.textBox2);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Location = new System.Drawing.Point(-190, -120);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(248, 96);
			this.groupBox1.TabIndex = 9;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Proxy authentication";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(128, 56);
			this.textBox1.Name = "textBox1";
			this.textBox1.PasswordChar = '*';
			this.textBox1.TabIndex = 3;
			this.textBox1.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 56);
			this.label1.Name = "label1";
			this.label1.TabIndex = 2;
			this.label1.Text = "Password:";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(128, 24);
			this.textBox2.Name = "textBox2";
			this.textBox2.TabIndex = 1;
			this.textBox2.Text = "ProxyUser";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(16, 24);
			this.label2.Name = "label2";
			this.label2.TabIndex = 0;
			this.label2.Text = "UserName:";
			// 
			// label3
			// 
			this.label3.ForeColor = System.Drawing.Color.Red;
			this.label3.Location = new System.Drawing.Point(268, 16);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(396, 80);
			this.label3.TabIndex = 12;
			// 
			// grpAuthenticate
			// 
			this.grpAuthenticate.Controls.Add(this.txtProxyPassword);
			this.grpAuthenticate.Controls.Add(this.lblPassword);
			this.grpAuthenticate.Controls.Add(this.txtProxyUserName);
			this.grpAuthenticate.Controls.Add(this.lblUser);
			this.grpAuthenticate.Enabled = false;
			this.grpAuthenticate.Location = new System.Drawing.Point(4, 8);
			this.grpAuthenticate.Name = "grpAuthenticate";
			this.grpAuthenticate.Size = new System.Drawing.Size(248, 88);
			this.grpAuthenticate.TabIndex = 11;
			this.grpAuthenticate.TabStop = false;
			this.grpAuthenticate.Text = "Proxy authentication";
			// 
			// txtProxyPassword
			// 
			this.txtProxyPassword.Location = new System.Drawing.Point(128, 56);
			this.txtProxyPassword.Name = "txtProxyPassword";
			this.txtProxyPassword.PasswordChar = '*';
			this.txtProxyPassword.TabIndex = 1;
			this.txtProxyPassword.Text = "password";
			// 
			// lblPassword
			// 
			this.lblPassword.Location = new System.Drawing.Point(16, 56);
			this.lblPassword.Name = "lblPassword";
			this.lblPassword.TabIndex = 2;
			this.lblPassword.Text = "Password:";
			// 
			// txtProxyUserName
			// 
			this.txtProxyUserName.Location = new System.Drawing.Point(128, 24);
			this.txtProxyUserName.Name = "txtProxyUserName";
			this.txtProxyUserName.TabIndex = 0;
			this.txtProxyUserName.Text = "user";
			// 
			// lblUser
			// 
			this.lblUser.Location = new System.Drawing.Point(16, 24);
			this.lblUser.Name = "lblUser";
			this.lblUser.TabIndex = 0;
			this.lblUser.Text = "UserName:";
			// 
			// Form1
			// 
			this.AcceptButton = this.btnSend;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.ClientSize = new System.Drawing.Size(680, 525);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.grpAuthenticate);
			this.Controls.Add(this.lblErrorMessage);
			this.Controls.Add(this.grpClientChatBox);
			this.Controls.Add(this.groupBox1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "Form1";
			this.Text = "Form1";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);

⌨️ 快捷键说明

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