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

📄 form1.cs

📁 c#编的CSDN离线助手
💻 CS
📖 第 1 页 / 共 5 页
字号:
			//此处如果用户在点击帖子后未等待更新完毕就再切换到别的讨论区
			//将有可能造成帖子状态显示不实,但是不影响实际的帖子状态
		}

		private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{	
			if(e.Node.Parent != null)
			{
				forum = WhichRoom(e.Node.Text);
				room = WhichRoom(e.Node.Parent.Text);
				block = WhichBlock(e.Node.Text);
				if(room !=0 && block !=0)
				{
					ChangeDataSource();
				}
			}
		}

		private void ChangeDataSource()
		{
			dvTopicIndex = core.GetTopicIndexDataView(room,block);
			UpdateListView();
		}

		private void UpdateDataSource()
		{
			try
			{
				this.statusBar1.Text = "正在下载帖子列表...";
				core.UpdateTopicIndex(room,block);
				this.statusBar1.Text = "列表下载完毕";
				dvTopicIndex = core.GetTopicIndexDataView(room,block);
				UpdateListView();
			}
			catch(Exception ex)
			{
				this.statusBar1.Text = ex.Message;
			}
		}

		private int WhichBlock(string blockname)
		{
			int b = 0;
			switch(blockname)
			{
				case "非技术区":
					b = 1;
					break;
				case "技术区":
					b = 2;
					break;
				case "已解决区":
					b = 3;
					break;
				case "精华区":
					b = 4;
					break;
				default :
					b = 0;
					break;
			}
			return b;
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			SaveData sd = new SaveData();
			sd.Show();
		}

		private void UpdateListView()
		{
			this.listView1.BeginUpdate();
			this.listView1.Items.Clear();
			ListViewItem item1;
			for(int i = 0; i < dvTopicIndex.Count; i++)
			{
				item1 = new ListViewItem(this.dvTopicIndex[i]["TopicName"].ToString(),(int)this.dvTopicIndex[i]["TopicStatus"]);
				item1.SubItems.Add(dvTopicIndex[i]["PostUserName"].ToString());
				item1.SubItems.Add(dvTopicIndex[i]["Point"].ToString());
				item1.SubItems.Add(dvTopicIndex[i]["ReplyNum"].ToString());
				item1.SubItems.Add(dvTopicIndex[i]["ReplyDateTime"].ToString());
				listView1.Items.Add(item1);
			}
			this.listView1.EndUpdate();
		}

		private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(this.listView1.SelectedIndices.Count != 0)
			{
				this.listViewIndex = this.listView1.SelectedIndices[0];
				this.richTextBox1.Text = "正在读取帖子信息.....";
				this.topicid = this.dvTopicIndex[this.listView1.SelectedIndices[0]]["TopicId"].ToString();
				Thread t = new Thread(new ThreadStart(ShowTopic));
				t.Start();
			}
			else
				topicid = null;
		}

		private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			SaveData sd = new SaveData();
			sd.Show();
			try
			{
				core.SaveDate();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void treeView1_DoubleClick(object sender, System.EventArgs e)
		{
			if(room != 0 && block != 0)
			{
				Thread t = new Thread(new ThreadStart(UpdateDataSource));
				t.Start();
			}
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			if(room != 0 && block != 0)
			{
				Thread t = new Thread(new ThreadStart(UpdateDataSource));
				t.Start();
			}
			else
			{
				MessageBox.Show("请选择一个论坛讨论区","系统错误");
			}
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			if(room !=0 && block != 0)
			{
				if(MessageBox.Show("本操作将会下载此讨论区中所有新加入的问题及\n更新过的回复,费时较长,您确定吗?","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK)
				{
					//UpdateDataSource();
					
					dvForumUpdate = core.GetForumUpdateView(room.ToString(),block.ToString());
					if(dvForumUpdate.Count > 0)
					{
						int max = dvForumUpdate.Count + 1;
						fu.SetMax(max);
						fu.ProgressText = "1/" + max.ToString();
						this.statusBar1.Text = "开始同步讨论区...";
						Thread t = new Thread(new ThreadStart(ForumUpdating));
						t.Start();

						fu.ShowDialog();
						dvTopicIndex = core.GetTopicIndexDataView(room,block);
						this.UpdateListView();
					}
				}
			}
			else
			{
				MessageBox.Show("请选择一个论坛讨论区","系统错误");
			}
		}

		private void ForumUpdating()
		{
			while(dvForumUpdate.Count != 0)
			{
				this.statusBar1.Text = "正在同步:" + dvForumUpdate[0]["TopicName"].ToString() + "(" + dvForumUpdate[0]["ReplyNum"].ToString() + " Replys)";
				try
				{
					core.GetTopic(dvForumUpdate[0]["TopicId"].ToString());
				}
				catch(Exception ex)
				{
					MessageBox.Show("出现错误:" + ex.Message);
				}
				fu.Add();
			}
		}

		private void menuItem8_Click(object sender, System.EventArgs e)
		{
			this.statusBar1.Text = "正在进行搜索...";
			Thread t = new Thread(new ThreadStart(Seaching));
			t.Start();
		}

		private void Seaching()
		{
			seach seachwindow = new seach();
			if(room == 0 || block == 0)
			{
				seachwindow.AllForum();
			}
			seachwindow.ShowDialog();
			dvTopicIndex = core.Seach(room,block,seachwindow.BeginTime,seachwindow.EndTime,seachwindow.SeachAll,seachwindow.SeachReply,seachwindow.SeachType,seachwindow.KeyWord);
			dvTopicIndex.Sort = "ReplyDateTime Desc";
			this.statusBar1.Text = "搜索结果:总共有" + dvTopicIndex.Count.ToString() + "条记录符合搜索结果";
			UpdateListView();
		}

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			Post post = new Post();
			if(forum == 0)
				post.SetPostRange();
			post.ShowDialog();
			if(post.OK)
			{
				if(post.PostRange == 1)
				{
					try
					{
						core.Post(post.TypeState.ToString(),post.Point.ToString(),post.Title,WhichRoom(this.listView1.SelectedItems[0].Text).ToString(),post.Content);
					}
					catch(Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
				}
				else
				{
					if(post.SelectedForumList != null && post.SelectedForumList.Count != 0)
					{
						for(int i = 0; i < post.SelectedForumList.Count; i++)
						{
							try
							{
								core.Post(post.TypeState.ToString(),post.Point.ToString(),post.Title,post.SelectedForumList[i].ToString(),post.Content);
							}
							catch(Exception ex)
							{
								MessageBox.Show(ex.Message);

⌨️ 快捷键说明

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