資源簡介
《計算機網絡系統實踐》課設成果。winform版聯機五子棋,分客戶端和服務端,修正了一些bug。帶聊天功能,仿QQ界面,可以發小的圖片和聲音,但不適合發送幾十兆以上的大數據包,會有內存溢出的問題

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Drawing;
using?System.Data;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.IO;
using?System.Resources;
namespace?Client
{
????public?partial?class?ChatPanel?:?UserControl
????{
????????string?path?=?string.Empty;
????????public?static?string?myHead?=?“http://pics.sc.chinaz.com/Files/pic/icons128/7066/b5.png“;
????????public?static?string?yourHead?=?“http://pics.sc.chinaz.com/Files/pic/icons128/7066/b5.png“;
????????StringBuilder?sb;
????????public?ChatPanel()
????????{
????????????InitializeComponent();
????????????//自定義控件Load事件里的代碼不執行,故在構造函數中寫
????????????webKitBrowser_Load(null?null);
????????}
????????private?void?webKitBrowser_Load(object?sender?EventArgs?e)
????????{
????????????//兩個客戶端同時啟動時,防止文件讀寫沖突,隨機給文件命名
????????????//這樣會在MsgReceived文件夾里產生很多文件
????????????path?=?string.Format(“{0}\\MsgReceived\\{1}.html“?Application.StartupPath?Guid.NewGuid().ToString());
????????????if?(webBrowser1.Version.Major?>=?10)
????????????{
????????????????//IE10以上默認開啟特效
????????????????File.Copy(Application.StartupPath?+?“\\MsgReceived\\index.html“?path);
????????????}
????????????else
????????????{
????????????????File.Copy(Application.StartupPath?+?“\\MsgReceived\\indexnostyle.html“?path);
????????????}
????????????webBrowser1.Navigate(path);
????????????sb?=?new?StringBuilder(File.ReadAllText(path));
????????}
????????public?void?AppendMsg(string?msg?string?name?bool?isMyWords?=?true)
????????{
????????????string?str?=?string.Empty;
????????????if?(isMyWords)
????????????{
????????????????str?=?@“
????????![]()
????????“?+?name?+?@“
????????“?+?msg?+?@“
????
“;
????????????}
????????????else
????????????{
????????????????str?=?@“
????????![]()
????????“?+?name?+?@“
????????“?+?msg?+?@“
????
“;
????????????}
????????????sb?=?sb.Replace(““?““).Append(str);
????????????//File.CreateText(path).Write(sb.ToString());
????????????using?(FileStream?fs?=?new?FileStream(path?FileMode.Create))
????????????{
????????????????byte[]?buffer?=?Encoding.UTF8.GetBytes(sb.ToString());
????????????????fs.Write(buffer?0?buffer.Length);
????????????}
????????????webBrowser1.Navigate(“file://“?+?path);
????????}
????????public?void?Clear(bool?flag)
????????{
????????????//File.Delete(path);
????????????ReLoad(flag);
????????}
????????public?void?AppendSysMsg(string?msg?string?name)
????????{
????????????string?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????4586496??2018-10-14?13:47??可執行文件\Client.exe
?????文件?????102912??2018-10-14?13:46??可執行文件\Server.exe
????..A..H.????100864??2018-10-15?17:48??源程序\.vs\FiveChess\v14\.suo
?????文件????????184??2018-10-14?17:14??源程序\Client\App.config
?????文件??????90746??2018-10-13?00:35??源程序\Client\bin\Debug\background\1.png
?????文件?????309071??2018-10-13?00:30??源程序\Client\bin\Debug\background\2.png
?????文件?????317647??2018-10-13?00:32??源程序\Client\bin\Debug\background\3.png
?????文件?????165426??2018-10-13?00:34??源程序\Client\bin\Debug\background\4.png
?????文件??????22688??2018-10-15?17:44??源程序\Client\bin\Debug\Client.vshost.exe
?????文件????????184??2018-10-14?17:14??源程序\Client\bin\Debug\Client.vshost.exe.config
?????文件????????490??2017-03-19?05:00??源程序\Client\bin\Debug\Client.vshost.exe.manifest
?????文件??????18349??2018-09-04?13:30??源程序\Client\bin\Debug\image\2507a718972bd407ddd95c3573899e510eb309fb.jpg
?????文件??????15983??2018-09-04?13:28??源程序\Client\bin\Debug\image\6f3561224f4a20a43ddc890f98529822700ed0df.jpg
?????文件???????5750??2018-09-04?13:29??源程序\Client\bin\Debug\image\873b9b2bd40735fac4f0fa7196510fb30e24089c.jpg
?????文件??????16138??2018-09-04?13:29??源程序\Client\bin\Debug\image\882c47fbfbedab643772f908ff36afc378311e9c.jpg
?????文件??????12729??2018-09-04?13:29??源程序\Client\bin\Debug\image\9d163ffa828ba61e59ef7ce74934970a314e599c.jpg
?????文件??????17010??2018-09-04?13:29??源程序\Client\bin\Debug\image\9f3f8b01a18b87d61c6605d70f0828381e30fdf1.jpg
?????文件??????29440??2018-09-04?13:30??源程序\Client\bin\Debug\image\a07798eef01f3a295bc101009125bc315d607c92.jpg
?????文件??????14978??2018-09-04?13:29??源程序\Client\bin\Debug\image\bd009bdda144ad34f77d324fd8a20cf433ad85df.jpg
?????文件??????24824??2018-09-04?13:29??源程序\Client\bin\Debug\image\f81c8b94a4c27d1ec0268f0c13d5ad6edcc4389c.jpg
?????文件???????2730??2018-10-15?12:33??源程序\Client\bin\Debug\MsgReceived\048e25dd-68f8-4253-8250-b5389659456b.html
?????文件???????1540??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\4ffb5abd-2f67-4801-a943-03d10282d2da.html
?????文件???????2912??2018-10-15?12:33??源程序\Client\bin\Debug\MsgReceived\8b39f110-37fa-41b4-8da1-d03d4bb7e8f9.html
?????文件???????2792??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\css\content.css
?????文件??????14485??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\css\default.css
?????文件????????484??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\css\jquery.classyleaves.css
?????文件????????380??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\css\jquery.classyleaves.min.css
?????文件???????1825??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\css\normalize.css
?????文件???????1540??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\fonts\icomoon.eot
?????文件???????1866??2018-10-15?10:03??源程序\Client\bin\Debug\MsgReceived\fonts\icomoon.svg
............此處省略147個文件信息
評論
共有 條評論