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

📄 winboard.cs

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

		private void this_Load(object sender, System.EventArgs e)
		{
			this.ListProcess();
		}

		private void this_Closed(object sender, System.EventArgs e)
		{
			xWinClient.RemoveThread(WC.MakeXML("WinBoard", boardID));
		}

		private void adminButton_Click(object sender, System.EventArgs e)
		{
			new WinBoardPassword(this);
		}

		private void writeButton_Click (object sender, System.EventArgs e)
		{
			actionMode = ActionMode.Write;

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

			this.titleBox.ReadOnly = false;
			this.writerBox.ReadOnly = false;
			this.emailBox.ReadOnly = false;
			this.msgBox.ReadOnly = false;
			this.msgBox.BackColor = Color.White;
			this.pwdBox.ReadOnly = false;
			this.uploadBox.ReadOnly = false;

			this.saveButton.Enabled = true;
			this.resetButton.Enabled = true;
			this.replyButton.Enabled = false;
			this.modifyButton.Enabled = false;
			this.deleteButton.Enabled = false;

			this.uploadButton.Enabled = true;
			this.uploadButton.Text = "Select File";

			this.editMenu.MenuItems[0].Enabled = true;
            this.editMenu.MenuItems[1].Enabled = true;
            this.editMenu.MenuItems[2].Enabled = true;

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

		private void listButton_Click(object sender, System.EventArgs e)
		{
			this.listPanel.Visible = true;
			this.inputPanel.Visible = false;
		}

		private void saveButton_Click(object sender, System.EventArgs e)
		{
			string titleStr = this.titleBox.Text;
			string writerStr = this.writerBox.Text;
			string emailStr = this.emailBox.Text;
			string msgStr = this.msgBox.Text;
			string pwdStr = this.pwdBox.Text;
			string ipStr = WC.GetXML(this.localID, "li");
			string fileStr = this.uploadBox.Text;

			if (titleStr.Length == 0 || writerStr.Length == 0 || emailStr.Length == 0 || msgStr.Length == 0 || pwdStr.Length == 0)
			{
				MessageBox.Show(WC.lineStr8);
				return;
			}
			else
			{
				if (fileStr.Length > 0)
				{
					try
					{
						FileStream fs = new FileStream(fileStr, FileMode.Open);
						int fileLen = Convert.ToInt32(fs.Length);
						fs.Close();

						if (fileLen > 300000)
						{
							MessageBox.Show(this, WC.lineStr19);
							return;
						}
					}
					catch (Exception ex)
					{
						MessageBox.Show(this, WC.lineStr18);
						return;
					}
				}

				if (actionMode == ActionMode.Write)
				{
					this.WriteProcess(titleStr, writerStr, emailStr, msgStr, pwdStr, ipStr, fileStr);
				}
				else if (actionMode == ActionMode.Reply)
				{
					this.ReplyProcess(titleStr, writerStr, emailStr, msgStr, pwdStr, ipStr, fileStr);
				}
				else if (actionMode == ActionMode.Modify)
				{
					this.ModifyProcess(titleStr, writerStr, emailStr, msgStr, pwdStr, ipStr);
				}
			}
		}

		private void resetButton_Click(object sender, System.EventArgs e)
		{
			this.titleBox.Text = "";
			this.writerBox.Text = "";
			this.emailBox.Text = "";
			this.msgBox.Text = "";
			this.pwdBox.Text = "";
		}

		private void modifyButton_Click(object sender, System.EventArgs e)
		{
			if (this.pwdBox.Text.Length > 0)
			{
				if (this.pwdBox.Text == this.msgPassword)
				{
                    actionMode = ActionMode.Modify;

					this.titleBox.ReadOnly = false;
					this.writerBox.ReadOnly = false;
					this.emailBox.ReadOnly = false;
					this.msgBox.ReadOnly = false;
                    this.msgBox.BackColor = Color.White;
					this.pwdBox.ReadOnly = false;

					this.saveButton.Enabled = true;
					this.resetButton.Enabled = true;
					this.replyButton.Enabled = false;
					this.modifyButton.Enabled = false;
					this.deleteButton.Enabled = false;

					this.uploadButton.Enabled = false;
					this.uploadButton.Text = "Select File";

					this.editMenu.MenuItems[0].Enabled = true;
					this.editMenu.MenuItems[1].Enabled = true;
					this.editMenu.MenuItems[2].Enabled = true;
				}
				else
				{
					MessageBox.Show(this, WC.lineStr6);
				}
			}
			else
			{
				MessageBox.Show(this, WC.lineStr7);
			}
		}

		private void replyButton_Click(object sender, System.EventArgs e)
		{
			actionMode = ActionMode.Reply;

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

			this.titleBox.ReadOnly = false;
			this.writerBox.ReadOnly = false;
			this.emailBox.ReadOnly = false;
			this.msgBox.ReadOnly = false;
            this.msgBox.BackColor = Color.White;
			this.pwdBox.ReadOnly = false;
			this.uploadBox.ReadOnly = false;

			this.saveButton.Enabled = true;
			this.resetButton.Enabled = true;
			this.replyButton.Enabled = false;
			this.modifyButton.Enabled = false;
			this.deleteButton.Enabled = false;

			this.uploadButton.Enabled = true;
			this.uploadButton.Text = "Select File";

			this.editMenu.MenuItems[0].Enabled = true;
			this.editMenu.MenuItems[1].Enabled = true;
			this.editMenu.MenuItems[2].Enabled = true;
		}

		private void deleteButton_Click(object sender, System.EventArgs e)
		{
			if (this.pwdBox.Text.Length > 0)
			{
				if (this.pwdBox.Text == this.msgPassword)
				{
					this.listPanel.Visible = true;
					this.inputPanel.Visible = false;

					this.DeleteProcess();
				}
				else
				{
					MessageBox.Show(this, WC.lineStr6);
				}
			}
			else
			{
				MessageBox.Show(this, WC.lineStr7);
			}
		}

		private void searchButton_Click(object sender, System.EventArgs e)
		{
			int index = this.typeCombo.SelectedIndex;

			if (index != -1)
			{
				if (this.searchBox.Text.Length > 0)
				{
                    this.searchKeyword = this.searchBox.Text;

					if (index == 0) this.searchType = "title";
					else if (index == 1) this.searchType = "writer";
					else if (index == 2) this.searchType = "msg";

					this.SearchProcess();
					this.searchBox.Text = "";
				}
				else
				{
					MessageBox.Show(this, WC.lineStr17);
				}
			}
			else
			{
				MessageBox.Show(this, WC.lineStr16);
			}
		}

		private void allButton_Click(object sender, System.EventArgs e)
		{
			this.ListProcess();
		}

		private void uploadButton_Click(object sender, System.EventArgs e)
		{
			if (actionMode == ActionMode.Write || actionMode == ActionMode.Reply)
			{
				openDialog.Title = "Select File";
				openDialog.InitialDirectory = "C:\\";
				openDialog.ShowDialog();
				uploadBox.Text = openDialog.FileName;
			}
			else if (actionMode == ActionMode.Msg)
			{
				saveDialog.FileName = this.uploadBox.Text;
                saveDialog.ShowDialog();
			}
		}

		private void saveDialogButton_Click (object sender, System.ComponentModel.CancelEventArgs e)
		{
			string originFileName = this.uploadBox.Text;
			string changeFileName = saveDialog.FileName;

			string sendStr = WC.MakeXML("ms", "ILOVEAICACABFI") + localID + rootID + WC.MakeXML("xo", originFileName) + WC.MakeXML("xc", changeFileName);
			xWinClient.SendRootMsg(sendStr);
		}

		private void mainGrid_Click(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			DataGrid myGrid = (DataGrid) sender;
			System.Windows.Forms.DataGrid.HitTestInfo hti = myGrid.HitTest(e.X, e.Y);

			if (hti.Type == System.Windows.Forms.DataGrid.HitTestType.Cell)
			{
				actionMode = ActionMode.Msg;

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

				this.titleBox.ReadOnly = true;
				this.writerBox.ReadOnly = true;
				this.emailBox.ReadOnly = true;
				this.msgBox.ReadOnly = true;
				this.msgBox.BackColor = Color.LightBlue;
				this.pwdBox.ReadOnly = false;
				this.uploadBox.ReadOnly = true;

				if (boardType == "Notice")
				{
					this.saveButton.Enabled = false;
					this.resetButton.Enabled = false;
					this.pwdBox.Enabled = false;
					this.replyButton.Enabled = false;
					this.modifyButton.Enabled = false;
					this.deleteButton.Enabled = false;
				}
				else
				{
					this.saveButton.Enabled = false;
					this.resetButton.Enabled = false;
					this.replyButton.Enabled = true;
					this.modifyButton.Enabled = true;
					this.deleteButton.Enabled = true;
					this.pwdBox.Enabled = true;
				}

				this.editMenu.MenuItems[0].Enabled = false;
				this.editMenu.MenuItems[1].Enabled = true;
				this.editMenu.MenuItems[2].Enabled = false;

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

				this.MsgProcess(this.mainGrid[hti.Row, 0].ToString());
			}
		}

		private void Cut_Clicked(object sender, System.EventArgs e)
		{
			msgBox.Cut();
		}

		private void Copy_Clicked(object sender, System.EventArgs e)
		{
			msgBox.Copy();
		}

		private void Paste_Clicked(object sender, System.EventArgs e)
		{
			msgBox.Paste();
		}

		private void SetConfig()
		{
			this.editMenu.MenuItems.Add(0, new MenuItem("Cut", new EventHandler(this.Cut_Clicked), Shortcut.CtrlX));
			this.editMenu.MenuItems.Add(1, new MenuItem("Copy", new EventHandler(this.Copy_Clicked), Shortcut.CtrlC));
			this.editMenu.MenuItems.Add(2, new MenuItem("Paste", new EventHandler(this.Paste_Clicked), Shortcut.CtrlV));

⌨️ 快捷键说明

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