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

📄 findreplace.cs

📁 Fireball.CodeEditor is an source code editor control derived from the best compona SyntaxBox Control
💻 CS
📖 第 1 页 / 共 2 页
字号:
            this.btnReplace.Size = new System.Drawing.Size(80, 24);
            this.btnReplace.TabIndex = 3;
            this.btnReplace.Text = "Replace";
            this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click);
            // 
            // btnFind
            // 
            this.btnFind.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.btnFind.Location = new System.Drawing.Point(8, 8);
            this.btnFind.Name = "btnFind";
            this.btnFind.Size = new System.Drawing.Size(80, 24);
            this.btnFind.TabIndex = 2;
            this.btnFind.Text = "&FindNext";
            this.btnFind.Click += new System.EventHandler(this.btnFind_Click);
            // 
            // pnlFind
            // 
            this.pnlFind.Controls.Add(this.cboFind);
            this.pnlFind.Controls.Add(this.lblFindWhat);
            this.pnlFind.Controls.Add(this.btnRegex1);
            this.pnlFind.Dock = System.Windows.Forms.DockStyle.Top;
            this.pnlFind.Location = new System.Drawing.Point(0, 0);
            this.pnlFind.Name = "pnlFind";
            this.pnlFind.Size = new System.Drawing.Size(400, 40);
            this.pnlFind.TabIndex = 1;
            // 
            // cboFind
            // 
            this.cboFind.Location = new System.Drawing.Point(104, 8);
            this.cboFind.Name = "cboFind";
            this.cboFind.Size = new System.Drawing.Size(288, 21);
            this.cboFind.TabIndex = 1;
            // 
            // lblFindWhat
            // 
            this.lblFindWhat.Location = new System.Drawing.Point(8, 8);
            this.lblFindWhat.Name = "lblFindWhat";
            this.lblFindWhat.Size = new System.Drawing.Size(96, 24);
            this.lblFindWhat.TabIndex = 0;
            this.lblFindWhat.Text = "Fi&nd what:";
            // 
            // btnRegex1
            // 
            this.btnRegex1.Image = ((System.Drawing.Image)(resources.GetObject("btnRegex1.Image")));
            this.btnRegex1.Location = new System.Drawing.Point(368, 8);
            this.btnRegex1.Name = "btnRegex1";
            this.btnRegex1.Size = new System.Drawing.Size(21, 21);
            this.btnRegex1.TabIndex = 2;
            this.btnRegex1.Visible = false;
            // 
            // pnlReplace
            // 
            this.pnlReplace.Controls.Add(this.cboReplace);
            this.pnlReplace.Controls.Add(this.lblReplaceWith);
            this.pnlReplace.Controls.Add(this.button1);
            this.pnlReplace.Dock = System.Windows.Forms.DockStyle.Top;
            this.pnlReplace.Location = new System.Drawing.Point(0, 40);
            this.pnlReplace.Name = "pnlReplace";
            this.pnlReplace.Size = new System.Drawing.Size(400, 40);
            this.pnlReplace.TabIndex = 2;
            this.pnlReplace.Visible = false;
            // 
            // cboReplace
            // 
            this.cboReplace.Location = new System.Drawing.Point(106, 8);
            this.cboReplace.Name = "cboReplace";
            this.cboReplace.Size = new System.Drawing.Size(286, 21);
            this.cboReplace.TabIndex = 4;
            // 
            // lblReplaceWith
            // 
            this.lblReplaceWith.Location = new System.Drawing.Point(10, 8);
            this.lblReplaceWith.Name = "lblReplaceWith";
            this.lblReplaceWith.Size = new System.Drawing.Size(96, 24);
            this.lblReplaceWith.TabIndex = 3;
            this.lblReplaceWith.Text = "Re&place with:";
            // 
            // button1
            // 
            this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
            this.button1.Location = new System.Drawing.Point(368, 8);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(21, 21);
            this.button1.TabIndex = 5;
            this.button1.Visible = false;
            // 
            // pnlSettings
            // 
            this.pnlSettings.Controls.Add(this.groupBox1);
            this.pnlSettings.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnlSettings.Location = new System.Drawing.Point(0, 80);
            this.pnlSettings.Name = "pnlSettings";
            this.pnlSettings.Size = new System.Drawing.Size(400, 98);
            this.pnlSettings.TabIndex = 3;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.chkRegEx);
            this.groupBox1.Controls.Add(this.chkWholeWord);
            this.groupBox1.Controls.Add(this.chkMatchCase);
            this.groupBox1.Location = new System.Drawing.Point(8, 0);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(384, 88);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Search";
            // 
            // chkRegEx
            // 
            this.chkRegEx.Location = new System.Drawing.Point(8, 64);
            this.chkRegEx.Name = "chkRegEx";
            this.chkRegEx.Size = new System.Drawing.Size(144, 16);
            this.chkRegEx.TabIndex = 2;
            this.chkRegEx.Text = "Use Regular expressions";
            // 
            // chkWholeWord
            // 
            this.chkWholeWord.Location = new System.Drawing.Point(8, 40);
            this.chkWholeWord.Name = "chkWholeWord";
            this.chkWholeWord.Size = new System.Drawing.Size(144, 16);
            this.chkWholeWord.TabIndex = 1;
            this.chkWholeWord.Text = "Match &whole word";
            // 
            // chkMatchCase
            // 
            this.chkMatchCase.Location = new System.Drawing.Point(8, 16);
            this.chkMatchCase.Name = "chkMatchCase";
            this.chkMatchCase.Size = new System.Drawing.Size(144, 16);
            this.chkMatchCase.TabIndex = 0;
            this.chkMatchCase.Text = "Match &case";
            // 
            // FindReplaceForm
            // 
            this.AcceptButton = this.btnFind;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this.btnClose;
            this.ClientSize = new System.Drawing.Size(496, 178);
            this.Controls.Add(this.pnlSettings);
            this.Controls.Add(this.pnlReplace);
            this.Controls.Add(this.pnlFind);
            this.Controls.Add(this.pnlButtons);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.Name = "FindReplaceForm";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Find";
            this.Closing += new System.ComponentModel.CancelEventHandler(this.FindReplace_Closing);
            this.pnlButtons.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.pnlReplaceButtons.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.pnlFind.ResumeLayout(false);
            this.pnlReplace.ResumeLayout(false);
            this.pnlSettings.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);

		}

		#endregion

		private void btnReplace_Click(object sender, EventArgs e)
		{
			ShowReplace();
		}

		private void FindReplace_Closing(object sender, CancelEventArgs e)
		{
			e.Cancel = true;
			this.Hide();
		}

		private void btnFind_Click(object sender, EventArgs e)
		{
			this.FindNext();
			cboFind.Focus();
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			mOwner.Focus();
			this.Hide();
		}

		private void btnDoReplace_Click(object sender, EventArgs e)
		{
			this.mOwner.ReplaceSelection(cboReplace.Text);
			btnFind_Click(null, null);
		}

		private void btnReplaceAll_Click(object sender, EventArgs e)
		{
			string text = cboFind.Text;
			if (text == "")
				return;

			bool found = false;
			foreach (string s in cboFind.Items)
			{
				if (s == text)
				{
					found = true;
					break;
				}
			}
			if (!found)
				cboFind.Items.Add(text);

			int x = mOwner.Caret.Position.X;
			int y = mOwner.Caret.Position.Y;
			mOwner.Caret.Position.X = 0;
			mOwner.Caret.Position.Y = 0;
			while (mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked))
			{
				this.mOwner.ReplaceSelection(cboReplace.Text);
			}

			mOwner.Selection.ClearSelection();
			//	mOwner.Caret.Position.X=x;
			//	mOwner.Caret.Position.Y=y;
			//	mOwner.ScrollIntoView ();

			cboFind.Focus();
		}

		private void btnMarkAll_Click(object sender, EventArgs e)
		{
			string text = cboFind.Text;
			if (text == "")
				return;

			bool found = false;
			foreach (string s in cboFind.Items)
			{
				if (s == text)
				{
					found = true;
					break;
				}
			}
			if (!found)
				cboFind.Items.Add(text);

			int x = mOwner.Caret.Position.X;
			int y = mOwner.Caret.Position.Y;
			mOwner.Caret.Position.X = 0;
			mOwner.Caret.Position.Y = 0;
			while (mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked))
			{
				this.mOwner.Caret.CurrentRow.Bookmarked = true;
			}

			mOwner.Selection.ClearSelection();
			//	mOwner.Caret.Position.X=x;
			//	mOwner.Caret.Position.Y=y;
			//	mOwner.ScrollIntoView ();

			cboFind.Focus();
		}

		public void FindNext()
		{
			string text = cboFind.Text;

			if (_Last != "" && _Last != text)
			{
				this.mOwner.Caret.Position.X = 0;
				this.mOwner.Caret.Position.Y = 0;
				this.mOwner.ScrollIntoView();
			}

			_Last = text;

			if (text == "")
				return;

			bool found = false;
			foreach (string s in cboFind.Items)
			{
				if (s == text)
				{
					found = true;
					break;
				}
			}
			if (!found)
				cboFind.Items.Add(text);

			mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked);
		}
	}
}

⌨️ 快捷键说明

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