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

📄 winboard.cs

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

			if (boardType == "Notice") this.writeButton.Enabled = false;
			if (boardType == "Common") this.adminButton.Enabled = false;

			xDataTable.Columns.Add("recordID");
			xDataTable.Columns.Add("step");
			xDataTable.Columns.Add("title");
			xDataTable.Columns.Add("writer");
			xDataTable.Columns.Add("email");
			xDataTable.Columns.Add("upload");
			xDataTable.Columns.Add("hit");
			xDataTable.Columns.Add("createdDate");

			this.xGridDelegate = new GridDelegate(this.SetGrid);
		}

		private void SetGrid()
		{
			this.mainGrid.DataSource = this.xDataTable;
		}

		private void SetForm()
		{
			this.countBox.Text = "Waiting...";
			this.Update();
			this.searchKeyword = "";
			this.mainGrid.DataSource = null;
			this.xDataTable.Rows.Clear();
		}

		private void ListProcess()
		{
            this.SetForm();

			string sendStr = WC.MakeXML("ms", "ILOVEAICACABLI") + localID + rootID + WC.MakeXML("xs", boardID);
			xWinClient.SendRootMsg(sendStr);
		}

		private void MsgProcess(string str)
		{
			string sendStr = WC.MakeXML("ms", "ILOVEAICACABME") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xi", str);
			xWinClient.SendRootMsg(sendStr);
		}

		private void WriteProcess(string titleStr, string writerStr, string emailStr, string msgStr, string pwdStr, string ipStr, string fileStr)
		{
			this.SetForm();

			string sendStr = "";
            string fileProtocol = "";
			int len = 0;
			int fileLen = 0;
            byte[] sendStream = null;
			byte[] fileStream = null;

			if (fileStr.Length > 0)
			{
				FileStream fs = new FileStream(fileStr, FileMode.Open);
				fileLen = Convert.ToInt32(fs.Length);

				fileStream = new byte[fileLen];
				fs.Read(fileStream,0,fileLen);
				fs.Close();

				fileProtocol = WC.MakeXML("xf", fileStr) + WC.MakeXML("xn", fileLen.ToString());
			}

			MemoryStream stream = new MemoryStream();
			XmlTextWriter xw = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

			xw.WriteStartElement("record");
			xw.WriteElementString("title", titleStr);
			xw.WriteElementString("writer", writerStr);
			xw.WriteElementString("email", emailStr);
			xw.WriteElementString("msg", msgStr);
			xw.WriteElementString("pwd", pwdStr);
			xw.WriteElementString("remoteIP", ipStr);
			xw.WriteEndElement();
			xw.Flush();
			xw.Close();

			sendStream = stream.ToArray();
			len = sendStream.Length;
			sendStr = WC.MakeXML("ms", "ILOVEAICACABSA") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xl", len.ToString()) + fileProtocol;
			
			xWinClient.SendRootMsg(sendStr);
			xWinClient.SendRootStream(sendStream);
			if (fileStream != null) xWinClient.SendRootStream(fileStream);

			this.titleBox.Text = "";
			this.writerBox.Text = "";
			this.emailBox.Text = "";
			this.msgBox.Text = "";
			this.pwdBox.Text = "";
			this.uploadBox.Text = "";

			this.listPanel.Visible = true;
			this.inputPanel.Visible = false;
		}

		private void ReplyProcess(string titleStr, string writerStr, string emailStr, string msgStr, string pwdStr, string ipStr, string fileStr)
		{
			this.SetForm();

			string sendStr = "";
            string fileProtocol = "";
			int len = 0;
            int fileLen = 0;
			byte[] sendStream = null;
			byte[] fileStream = null;

			if (fileStr.Length > 0)
			{
				FileStream fs = new FileStream(fileStr, FileMode.Open);
				fileLen = Convert.ToInt32(fs.Length);

				fileStream = new byte[fileLen];
				fs.Read(fileStream,0,fileLen);
				fs.Close();

				fileProtocol = WC.MakeXML("xf", fileStr) + WC.MakeXML("xn", fileLen.ToString());
			}

			MemoryStream stream = new MemoryStream();
			XmlTextWriter xw = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

			xw.WriteStartElement("record");
			xw.WriteElementString("title", titleStr);
			xw.WriteElementString("writer", writerStr);
			xw.WriteElementString("email", emailStr);
			xw.WriteElementString("msg", msgStr);
			xw.WriteElementString("pwd", pwdStr);
			xw.WriteElementString("remoteIP", ipStr);
			xw.WriteEndElement();
			xw.Flush();
			xw.Close();

			sendStream = stream.ToArray();
			len = sendStream.Length;
			sendStr = WC.MakeXML("ms", "ILOVEAICACABRE") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xl", len.ToString()) + WC.MakeXML("xi", msgID) + fileProtocol;
			
			xWinClient.SendRootMsg(sendStr);
			xWinClient.SendRootStream(sendStream);
			if (fileStream != null) xWinClient.SendRootStream(fileStream);

			this.titleBox.Text = "";
			this.writerBox.Text = "";
			this.emailBox.Text = "";
			this.msgBox.Text = "";
			this.pwdBox.Text = "";
			this.uploadBox.Text = "";

			this.listPanel.Visible = true;
			this.inputPanel.Visible = false;
		}

		private void ModifyProcess(string titleStr, string writerStr, string emailStr, string msgStr, string pwdStr, string ipStr)
		{
			this.SetForm();

			string sendStr = "";
			int len = 0;
			byte[] sendStream = null;

			MemoryStream stream = new MemoryStream();
			XmlTextWriter xw = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

			xw.WriteStartElement("record");
			xw.WriteElementString("title", titleStr);
			xw.WriteElementString("writer", writerStr);
			xw.WriteElementString("email", emailStr);
			xw.WriteElementString("msg", msgStr);
			xw.WriteElementString("pwd", pwdStr);
			xw.WriteElementString("remoteIP", ipStr);
			xw.WriteEndElement();
			xw.Flush();
			xw.Close();

			sendStream = stream.ToArray();
			len = sendStream.Length;
			sendStr = WC.MakeXML("ms", "ILOVEAICACABMO") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xl", len.ToString()) + WC.MakeXML("xi", msgID);
			
			xWinClient.SendRootMsg(sendStr);
			xWinClient.SendRootStream(sendStream);

			this.titleBox.Text = "";
			this.writerBox.Text = "";
			this.emailBox.Text = "";
			this.msgBox.Text = "";
			this.pwdBox.Text = "";
			this.uploadBox.Text = "";

			this.listPanel.Visible = true;
			this.inputPanel.Visible = false;
		}

		private void DeleteProcess()
		{
			this.SetForm();

			string sendStr = WC.MakeXML("ms", "ILOVEAICACABDE") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xi", msgID);
			xWinClient.SendRootMsg(sendStr);
		}

		private void SearchProcess()
		{
			this.countBox.Text = "Waiting...";
			this.Update();
            this.mainGrid.DataSource = null;
			this.xDataTable.Rows.Clear();

			string sendStr = WC.MakeXML("ms", "ILOVEAICACABSE") + localID + rootID + WC.MakeXML("xs", boardID) + WC.MakeXML("xt", searchType) + WC.MakeXML("xk", searchKeyword);
			xWinClient.SendRootMsg(sendStr);
		}

		public void CheckPassword(string str)
		{
			if (str == this.boardPassword)
			{
				this.boardType = "Common";
				this.writeButton.Enabled = true;
			}
		}

		public void OnILOVEAICACAXLI(string sort, byte[] getStream)
		{
			if (getStream != null)
			{
				XmlDocument xd = new XmlDocument();
				xd.Load(new MemoryStream(getStream));

				XmlTextReader xr = new XmlTextReader(new StringReader(xd.OuterXml));
				XmlDataDocument dd = new XmlDataDocument();
				dd.DataSet.ReadXml(xr, XmlReadMode.InferSchema);
				DataTable dt = dd.DataSet.Tables[0];

				int rowCount = dt.Rows.Count;
				int step = 1;
				string prefix = "";
				string upload = "";

				for (int i=0 ; i < rowCount ; i++)
				{
					DataRow dr = this.xDataTable.NewRow();

					dr["recordID"] = dt.Rows[i]["recordID"];
					dr["writer"] = dt.Rows[i]["writer"];
					dr["email"] = dt.Rows[i]["email"];
					dr["hit"] = dt.Rows[i]["hit"];
					dr["createdDate"] = dt.Rows[i]["createdDate"];

					prefix = "";
					step = Convert.ToInt32(dt.Rows[i]["step"]);
					if (step > 1)
					{
						for (int j=1 ; j < step ; j++) prefix += "  ";
						prefix += "[RE]";
					}
					dr["step"] = step.ToString();
					dr["title"] = prefix + dt.Rows[i]["title"];

					upload = dt.Rows[i]["upload"].ToString();
					if (upload == "N/A") upload = "";
					dr["upload"] = upload;

					xDataTable.Rows.Add(dr);
				}

				try
				{
					this.countBox.Text = rowCount.ToString();
					this.Invoke(this.xGridDelegate);
				}
				catch (Exception e)
				{
					MessageBox.Show(e.ToString());
				}
			}
			else
			{
				this.countBox.Text = "No Results";
			}
		}

		public void OnILOVEAICACAXME(string sort, byte[] getStream)
		{
			XmlDocument dd = new XmlDocument();
			dd.Load(new MemoryStream(getStream));

			this.msgID = dd.SelectSingleNode("record/recordID").InnerText;
			this.msgPassword = dd.SelectSingleNode("record/pwd").InnerText;

			this.titleBox.Text = dd.SelectSingleNode("record/title").InnerText;
			this.writerBox.Text = dd.SelectSingleNode("record/writer").InnerText;
			this.emailBox.Text = dd.SelectSingleNode("record/email").InnerText;
			this.pwdBox.Text = "";

            string msgStr = dd.SelectSingleNode("record/msg").InnerText;
			string uploadStr = dd.SelectSingleNode("record/upload").InnerText;
            
			if (searchKeyword.Length > 0 && searchType == "msg")
			{
				string msgUpper = msgStr.ToUpper();
				int firstPos = 0;
				int secondPos = -1;

				while ((secondPos = msgUpper.IndexOf(searchKeyword.ToUpper(), secondPos+1)) != -1)
				{
					string str = msgStr.Substring(firstPos, secondPos-firstPos);
					this.msgBox.AppendText(str);
					this.msgBox.SelectionColor = Color.Red;
					this.msgBox.SelectionFont = new Font("Arial", 9, FontStyle.Bold);
                    string key = msgStr.Substring(secondPos, searchKeyword.Length);
					this.msgBox.AppendText(key);
					this.msgBox.SelectionColor = Color.Black;
					this.msgBox.SelectionFont = new Font("Arial", 9);

					firstPos = secondPos + searchKeyword.Length;
				}

				this.msgBox.AppendText(msgStr.Substring(firstPos, msgStr.Length-firstPos));
			}
			else
			{
				this.msgBox.AppendText(msgStr);
			}


			if (uploadStr == "N/A")
			{
				uploadStr = "";
				this.uploadButton.Enabled = false;
				this.uploadButton.Text = "Save File";
                this.uploadBox.Text = uploadStr;
			}
			else
			{
				this.uploadButton.Enabled = true;
				this.uploadButton.Text = "Save File";
                this.uploadBox.Text = uploadStr;
			}
		}
	}
}

⌨️ 快捷键说明

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