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

📄 frmoption.cs

📁 小型搜索软件的源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.tabPage_IFilter.Name = "tabPage_IFilter";
			this.tabPage_IFilter.Size = new System.Drawing.Size(432, 271);
			this.tabPage_IFilter.TabIndex = 1;
			this.tabPage_IFilter.Text = "文件类型";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(224, 16);
			this.label1.TabIndex = 3;
			this.label1.Text = "添加或移除要下载的文件后缀";
			// 
			// button_IFilter_Delelt
			// 
			this.button_IFilter_Delelt.Location = new System.Drawing.Point(336, 8);
			this.button_IFilter_Delelt.Name = "button_IFilter_Delelt";
			this.button_IFilter_Delelt.Size = new System.Drawing.Size(64, 24);
			this.button_IFilter_Delelt.TabIndex = 2;
			this.button_IFilter_Delelt.Text = "删除";
			this.button_IFilter_Delelt.Click += new System.EventHandler(this.button_IFilter_Delelt_Click);
			// 
			// button_IFilter_Add
			// 
			this.button_IFilter_Add.Location = new System.Drawing.Point(264, 8);
			this.button_IFilter_Add.Name = "button_IFilter_Add";
			this.button_IFilter_Add.Size = new System.Drawing.Size(64, 24);
			this.button_IFilter_Add.TabIndex = 1;
			this.button_IFilter_Add.Text = "添加";
			this.button_IFilter_Add.Click += new System.EventHandler(this.button_IFilter_Add_Click);
			// 
			// listView_IFilter
			// 
			this.listView_IFilter.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																							   this.columnHeader_Ext,
																							   this.columnHeader_Dec});
			this.listView_IFilter.FullRowSelect = true;
			this.listView_IFilter.GridLines = true;
			this.listView_IFilter.LabelEdit = true;
			this.listView_IFilter.Location = new System.Drawing.Point(16, 48);
			this.listView_IFilter.MultiSelect = false;
			this.listView_IFilter.Name = "listView_IFilter";
			this.listView_IFilter.Size = new System.Drawing.Size(400, 208);
			this.listView_IFilter.TabIndex = 0;
			this.listView_IFilter.TabStop = false;
			this.listView_IFilter.View = System.Windows.Forms.View.Details;
			// 
			// columnHeader_Ext
			// 
			this.columnHeader_Ext.Text = "文件后缀";
			this.columnHeader_Ext.Width = 98;
			// 
			// columnHeader_Dec
			// 
			this.columnHeader_Dec.Text = "描述";
			this.columnHeader_Dec.Width = 283;
			// 
			// tabPage_Console
			// 
			this.tabPage_Console.Controls.Add(this.checkBox_ConsoleResultURL);
			this.tabPage_Console.Controls.Add(this.checkBox_ConsolePorcessURL);
			this.tabPage_Console.Controls.Add(this.checkBox_ConsoleFileOut);
			this.tabPage_Console.Location = new System.Drawing.Point(4, 21);
			this.tabPage_Console.Name = "tabPage_Console";
			this.tabPage_Console.Size = new System.Drawing.Size(432, 271);
			this.tabPage_Console.TabIndex = 4;
			this.tabPage_Console.Text = "控制台输出";
			// 
			// checkBox_ConsoleResultURL
			// 
			this.checkBox_ConsoleResultURL.Location = new System.Drawing.Point(32, 112);
			this.checkBox_ConsoleResultURL.Name = "checkBox_ConsoleResultURL";
			this.checkBox_ConsoleResultURL.Size = new System.Drawing.Size(224, 24);
			this.checkBox_ConsoleResultURL.TabIndex = 2;
			this.checkBox_ConsoleResultURL.Text = "显示每个URL处理结果";
			// 
			// checkBox_ConsolePorcessURL
			// 
			this.checkBox_ConsolePorcessURL.Location = new System.Drawing.Point(32, 72);
			this.checkBox_ConsolePorcessURL.Name = "checkBox_ConsolePorcessURL";
			this.checkBox_ConsolePorcessURL.Size = new System.Drawing.Size(224, 24);
			this.checkBox_ConsolePorcessURL.TabIndex = 1;
			this.checkBox_ConsolePorcessURL.Text = "显示处理的URL";
			// 
			// checkBox_ConsoleFileOut
			// 
			this.checkBox_ConsoleFileOut.Location = new System.Drawing.Point(32, 32);
			this.checkBox_ConsoleFileOut.Name = "checkBox_ConsoleFileOut";
			this.checkBox_ConsoleFileOut.Size = new System.Drawing.Size(224, 24);
			this.checkBox_ConsoleFileOut.TabIndex = 0;
			this.checkBox_ConsoleFileOut.Text = "自动文件输出";
			// 
			// frmOption
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(464, 357);
			this.Controls.Add(this.tabControl_Options);
			this.Controls.Add(this.button_Cancel);
			this.Controls.Add(this.button_Save);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.Name = "frmOption";
			this.Text = "其他设置选项";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmOption_Closing);
			this.Load += new System.EventHandler(this.frmOption_Load);
			this.tabControl_Options.ResumeLayout(false);
			this.tabPage_Normal.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numUpDown_ThreadCount)).EndInit();
			this.tabPage_IndexType.ResumeLayout(false);
			this.groupBox_CacheType.ResumeLayout(false);
			this.tabPage_IFilter.ResumeLayout(false);
			this.tabPage_Console.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmOption_Load(object sender, System.EventArgs e)
		{

		}

		#region 加载界面设置
		/// <summary>
		/// 加载界面设置
		/// </summary>
		public void Load_Config_For_Interface(frmMain p_frmMain)
		{
			this.Show();
			m_frmMain=p_frmMain;
			m_frmMain.Enabled = false;
			//
			Config.Load_Config();
			//
			checkBox_OnlyStartURL.Checked = Config.OnlyStartURL ;
			numUpDown_ThreadCount.Value = Config.ThreadCount ;
			textBox_IndexDirectory.Text = Config.IndexDirectory ;
			checkBox_AutoIndexUpdate.Checked = Config.AutoUpdateIndex ;
			//
			checkBox_EnableCache.Checked = Config.EnableCache ;
			textBox_CacheDirectory.Text = Config.CacheDirectory ;
			if(Config.CacheType=="NORMAL")
				radioButton_CacheTypeNormal.Checked = true ;
			else
				radioButton_CacheTypeKB.Checked = true ;
			comboBox_CacheTemplate.Text = Config.CacheTemplate ;
			//设置其他界面
			set_Enable_For_Cache(checkBox_EnableCache.Checked) ;

			for(int i = 0 ; i < Config.FileTypes.Count ; i++ )
			{
				
				string [] strItems = Config.FileTypes[i].ToString().Split(':');
				this.listView_IFilter.Items.Add(new ListViewItem(strItems));
			}

			this.checkBox_ConsoleFileOut.Checked = Config.ConsoleFileOut ;
			this.checkBox_ConsolePorcessURL.Checked = Config.ConsoleProcessURL ; 
			this.checkBox_ConsoleResultURL.Checked = Config.ConsoleResultURL ;

		}

		#endregion

		#region 保存设置
		/// <summary>
		/// 保存设置
		/// </summary>
		public void Save_Config_From_Interface()
		{

			Config.OnlyStartURL = checkBox_OnlyStartURL.Checked ;
			Config.ThreadCount = Convert.ToInt32(numUpDown_ThreadCount.Value) ;
			Config.IndexDirectory = textBox_IndexDirectory.Text ;
			Config.AutoUpdateIndex = checkBox_AutoIndexUpdate.Checked ;
			//
			Config.EnableCache = checkBox_EnableCache.Checked ;
			Config.CacheDirectory = textBox_CacheDirectory.Text ;
			if(radioButton_CacheTypeNormal.Checked)
				Config.CacheType = "NORMAL" ;
			else
				Config.CacheType = "KB" ;
			Config.CacheTemplate = comboBox_CacheTemplate.Text ;

			Config.FileTypes = new ArrayList();
			
			for(int i = 0 ; i < listView_IFilter.Items.Count ; i++ )
			{
				Config.FileTypes.Add(listView_IFilter.Items[i].Text + ":" + listView_IFilter.Items[i].SubItems[1].Text.Replace(":",""));
			}

			
			Config.ConsoleFileOut = this.checkBox_ConsoleFileOut.Checked ;
			Config.ConsoleProcessURL = this.checkBox_ConsolePorcessURL.Checked ; 
			Config.ConsoleResultURL =  this.checkBox_ConsoleResultURL.Checked  ;

			Config.Save_Config();
		}
		#endregion

		/// <summary>
		/// 保存按钮,保存并关闭窗体
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_Save_Click(object sender, System.EventArgs e)
		{
			Save_Config_From_Interface();
			form_Exit();
		}

		/// <summary>
		/// 还原配置,关闭窗体
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void frmOption_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			Config.Load_Config();
			form_Exit();
		}

		/// <summary>
		/// 关闭窗体
		/// </summary>
		private void form_Exit()
		{
			m_frmMain.Enabled = true ;
			Dispose(true);
		}


		/// <summary>
		/// 设置启用选项的界面
		/// </summary>
		/// <param name="p_Enable"></param>
		private void set_Enable_For_Cache(bool p_Enable)
		{
			label_CacheDirectory.Enabled = p_Enable ;
			textBox_CacheDirectory.Enabled = p_Enable ;
			button_CacheDirectory.Enabled = p_Enable ;
			groupBox_CacheType.Enabled = p_Enable ;
			label_CacheTemplate.Enabled = p_Enable ;
			comboBox_CacheTemplate.Enabled = p_Enable ;
		}

		/// <summary>
		/// 随着启用选项的点击设置界面
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void checkBox_EnableCache_CheckedChanged(object sender, System.EventArgs e)
		{
			set_Enable_For_Cache(checkBox_EnableCache.Checked) ;
		}


		/// <summary>
		/// 设置路径
		/// </summary>
		/// <param name="p_textBox">需要显示路径的TextBox</param>
		private void Select_Directory(System.Windows.Forms.TextBox p_textBox)
		{
			
			folderBrwDlg_Directory.SelectedPath = p_textBox.Text;
			folderBrwDlg_Directory.ShowDialog();
			
			if(folderBrwDlg_Directory.SelectedPath.Length != 0 )
				p_textBox.Text = folderBrwDlg_Directory.SelectedPath;
		}


		/// <summary>
		/// 设置索引路径
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_IndexDirectory_Click(object sender, System.EventArgs e)
		{
			Select_Directory(textBox_IndexDirectory);
			
		}

		/// <summary>
		/// 设置快照
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_CacheDirectory_Click(object sender, System.EventArgs e)
		{
			Select_Directory(textBox_CacheDirectory);
		}

		/// <summary>
		/// 取消按钮
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_Cancel_Click(object sender, System.EventArgs e)
		{
			form_Exit();
		}

		/// <summary>
		/// 增加文件类型
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_IFilter_Add_Click(object sender, System.EventArgs e)
		{
			try
			{
				string strNewIFilter = Tools.ShowInputMessageBox("输入文件类型(格式 \".xxx:描述信息\" 无引号 : 为文件后缀和描述信息分隔符):" , "输入新文件类型" 
					, ".xls:微软Excel文件" ,this.Left + 100 ,this.Top + 100 );
				string [] strFilter = strNewIFilter.Split(':');

				if( Tools.IsValidIFilter( strFilter[0] ) )
				{
					strFilter[0] = strFilter[0].ToUpper();
					this.listView_IFilter.Items.Add(new ListViewItem(strFilter));
				}
			}
			catch{}

		}

		/// <summary>
		/// 删除一个文件类型
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button_IFilter_Delelt_Click(object sender, System.EventArgs e)
		{
				while(listView_IFilter.SelectedItems.Count > 0)
                    listView_IFilter.Items.Remove(listView_IFilter.SelectedItems[0]);

		}

	}
}

⌨️ 快捷键说明

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