C# 聊天室的框架设计实现源码
来源:互联网 发布:淘宝卖的最奇葩的东西 编辑:程序博客网 时间:2024/05/01 19:45
C#代码
要想QQ一样有聊天室,C#里是个可是编程的软件,呵呵,text和label可以拖就可以了,呵呵。和容易。可是怎样显示字符和怎样获得字符是个事情。嗯,我花了差不多一个是完成了,可是完成之后,好简单的,嗯。与java的差不多,代码如下:
C#代码
- namespace TcpIp通信
- {
- partial class Form1
- {
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- /// <param name="disposing">如果应释放托管资源,为 true;否则为
- false。</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.richTextBox2 = new System.Windows.Forms.RichTextBox();
- this.button1 = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- //
- // richTextBox1
- //
- this.richTextBox1.Location = new System.Drawing.Point(26,
- 28);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(395, 241);
- this.richTextBox1.TabIndex = 7;
- this.richTextBox1.Text = "";
- //
- // richTextBox2
- //
- this.richTextBox2.Location = new System.Drawing.Point(40,
- 299);
- this.richTextBox2.Name = "richTextBox2";
- this.richTextBox2.Size = new System.Drawing.Size(381, 133);
- this.richTextBox2.TabIndex = 2;
- this.richTextBox2.Text = "";
- this.richTextBox2.TextChanged += new System.EventHandler
- (this.seMsg);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(346, 438);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 3;
- this.button1.Text = "send";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler
- (this.button1_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(183, 281);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(53, 12);
- this.label1.TabIndex = 5;
- this.label1.Text = "发送信息";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(185, 13);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(53, 12);
- this.label3.TabIndex = 6;
- this.label3.Text = "接受信息";
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
- 12F);
- this.AutoScaleMode =
- System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(447, 466);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.richTextBox2);
- this.Controls.Add(this.richTextBox1);
- this.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
- this.Name = "Form1";
- this.Text = "Form1";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private System.Windows.Forms.RichTextBox richTextBox1;
- private System.Windows.Forms.RichTextBox richTextBox2;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label3;
- }
- }
- namespace TcpIp通信
- {
- partial class Form1
- {
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- /// <param name="disposing">如果应释放托管资源,为 true;否则为
- false。</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.richTextBox2 = new System.Windows.Forms.RichTextBox();
- this.button1 = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- //
- // richTextBox1
- //
- this.richTextBox1.Location = new System.Drawing.Point(26,
- 28);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(395, 241);
- this.richTextBox1.TabIndex = 7;
- this.richTextBox1.Text = "";
- //
- // richTextBox2
- //
- this.richTextBox2.Location = new System.Drawing.Point(40,
- 299);
- this.richTextBox2.Name = "richTextBox2";
- this.richTextBox2.Size = new System.Drawing.Size(381, 133);
- this.richTextBox2.TabIndex = 2;
- this.richTextBox2.Text = "";
- this.richTextBox2.TextChanged += new System.EventHandler
- (this.seMsg);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(346, 438);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 3;
- this.button1.Text = "send";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler
- (this.button1_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(183, 281);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(53, 12);
- this.label1.TabIndex = 5;
- this.label1.Text = "发送信息";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(185, 13);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(53, 12);
- this.label3.TabIndex = 6;
- this.label3.Text = "接受信息";
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
- 12F);
- this.AutoScaleMode =
- System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(447, 466);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.richTextBox2);
- this.Controls.Add(this.richTextBox1);
- this.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
- this.Name = "Form1";
- this.Text = "Form1";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private System.Windows.Forms.RichTextBox richTextBox1;
- private System.Windows.Forms.RichTextBox richTextBox2;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label3;
- }
- }
- C#代码
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.Net.Sockets;
- namespace TcpIp通信
- {
- public partial class Form1 : Form
- {
- string semsg;
- string name;
- public Form1()
- {
- InitializeComponent();
- ChatServer();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- name = ((Button)sender).Name;
- if (name.Equals("button1"))
- {
- this.richTextBox1.AppendText("服务器说:\n");
- this.richTextBox1.AppendText(semsg+"\n");
- this.richTextBox2.Text="";
- Console.WriteLine("打印成功" + semsg);
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void seMsg(object sender, EventArgs e)
- {
- semsg = ((RichTextBox)sender).Text;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.Net.Sockets;
- namespace TcpIp通信
- {
- public partial class Form1 : Form
- {
- string semsg;
- string name;
- public Form1()
- {
- InitializeComponent();
- ChatServer();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- name = ((Button)sender).Name;
- if (name.Equals("button1"))
- {
- this.richTextBox1.AppendText("服务器说:\n");
- this.richTextBox1.AppendText(semsg+"\n");
- this.richTextBox2.Text="";
- Console.WriteLine("打印成功" + semsg);
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void seMsg(object sender, EventArgs e)
- {
- semsg = ((RichTextBox)sender).Text;
- }
- }
- }
- C# 聊天室的框架设计实现源码
- C# Asp.Net Ajax简单聊天室源码和设计文档
- 关于蓝牙聊天室的设计与实现
- JAVA网络聊天室的设计与实现
- 基于ZeroMQ的聊天室设计实现
- 实现一个简单的语音聊天室(源码)
- Node.js+Socket.IO实现的WebSocket群聊天室源码
- 简单的php+mysql聊天室实现方法(附源码)
- 聊天室的设计
- ajax+struts实现简单的聊天室(利用prototype框架)
- java聊天室设计及实现
- linux下用线程实现的聊天室 设计申明书
- 基于linux的TCP网络聊天室设计与实现
- C#简易版Socket聊天室 附源码
- 简单聊天室的实现
- Java实现的聊天室
- WebSocket聊天室的实现
- 简单的聊天室程序源码
- Maven使用之Windows下Maven安装、配置、与Eclipse集成(一) | (待完善)
- C语言中struct数组乱序赋值
- 动态的加载动态链接库
- C#解压或压缩文件夹
- 如何学习JDK里的设计模式
- C# 聊天室的框架设计实现源码
- Nebula level10
- 【移动GIS】MBTiles离线地图设置
- 开发者需知的10类工具
- iOS设计模式:观察者
- redhat下ssh,telnet,ftp服务的配置
- <s:hidden name="id" value="id"></s:hidden>
- 安卓中文SDK连载(1)
- easyui datagrid 改变行值