📄 findreplace.cs
字号:
//ORIGINAL LGPL SOURCE CODE FINDED ON COMPONA LGPL SOURCE CODE
//MODIFIED BY <sebastian.faltoni@gmail.com>
//Added localization support
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace Fireball.Windows.Forms.CodeEditor
{
/// <summary>
/// Summary description for FindReplace.
/// </summary>
public class FindReplaceForm : Form
{
private Panel pnlButtons;
private Panel pnlFind;
private Panel pnlReplace;
private Panel pnlSettings;
private Label lblFindWhat;
private Button btnRegex1;
private Button button1;
private Label lblReplaceWith;
private Panel panel1;
private Panel panel3;
private Panel pnlReplaceButtons;
private GroupBox groupBox1;
private ComboBox cboFind;
private ComboBox cboReplace;
private Button btnReplace;
/// <summary>
/// Required designer variable.
/// </summary>
private Container components = null;
private Button btnFind;
private Button btnClose;
private CheckBox chkWholeWord;
private CheckBox chkMatchCase;
private Button btnReplaceAll;
private CheckBox chkRegEx;
private Button btnMarkAll;
private WeakReference _Control = null;
private EditViewControl mOwner
{
get
{
if (_Control != null)
return (EditViewControl) _Control.Target;
else
return null;
}
set { _Control = new WeakReference(value); }
}
private Button btnDoReplace;
private string _Last = "";
/// <summary>
/// Default constructor for the FindReplaceForm.
/// </summary>
public FindReplaceForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
btnFind.Text = Localizations.FindNextButtonText;
btnReplace.Text = Localizations.FindReplaceButtonText;
btnMarkAll.Text = Localizations.FindMarkAllButtonText;
btnReplaceAll.Text = Localizations.FindReplaceAllButtonText;
btnClose.Text = Localizations.FindCloseButtonText;
lblFindWhat.Text = Localizations.FindWhatLabelText;
lblReplaceWith.Text = Localizations.FindReplaceWithLabelText;
chkMatchCase.Text = Localizations.FindMatchCaseLabel;
chkWholeWord.Text = Localizations.FindMatchWholeWordLabel;
chkRegEx.Text = Localizations.FindUseRegExLabel;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
// unchecked
// {
// int i= (int)0x80000000;
// cp.Style |=i;
// }
return cp;
}
}
/// <summary>
/// Creates a FindReplaceForm that will be assigned to a specific Owner control.
/// </summary>
/// <param name="Owner">The SyntaxBox that will use the FindReplaceForm</param>
public FindReplaceForm(EditViewControl Owner)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
mOwner = Owner;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// Displays the FindReplaceForm and sets it in "Find" mode.
/// </summary>
public void ShowFind()
{
pnlReplace.Visible = false;
pnlReplaceButtons.Visible = false;
this.Text = Localizations.FindDialogText;
this.Show();
this.Height = 160;
btnDoReplace.Visible = false;
btnReplace.Visible = true;
_Last = "";
cboFind.Focus();
}
/// <summary>
/// Displays the FindReplaceForm and sets it in "Replace" mode.
/// </summary>
public void ShowReplace()
{
pnlReplace.Visible = true;
pnlReplaceButtons.Visible = true;
this.Text = Localizations.ReplaceDialogText;
this.Show();
this.Height = 200;
btnDoReplace.Visible = true;
btnReplace.Visible = false;
_Last = "";
cboFind.Focus();
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FindReplaceForm));
this.pnlButtons = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.btnClose = new System.Windows.Forms.Button();
this.btnMarkAll = new System.Windows.Forms.Button();
this.pnlReplaceButtons = new System.Windows.Forms.Panel();
this.btnReplaceAll = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.btnDoReplace = new System.Windows.Forms.Button();
this.btnReplace = new System.Windows.Forms.Button();
this.btnFind = new System.Windows.Forms.Button();
this.pnlFind = new System.Windows.Forms.Panel();
this.cboFind = new System.Windows.Forms.ComboBox();
this.lblFindWhat = new System.Windows.Forms.Label();
this.btnRegex1 = new System.Windows.Forms.Button();
this.pnlReplace = new System.Windows.Forms.Panel();
this.cboReplace = new System.Windows.Forms.ComboBox();
this.lblReplaceWith = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.pnlSettings = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.chkRegEx = new System.Windows.Forms.CheckBox();
this.chkWholeWord = new System.Windows.Forms.CheckBox();
this.chkMatchCase = new System.Windows.Forms.CheckBox();
this.pnlButtons.SuspendLayout();
this.panel3.SuspendLayout();
this.pnlReplaceButtons.SuspendLayout();
this.panel1.SuspendLayout();
this.pnlFind.SuspendLayout();
this.pnlReplace.SuspendLayout();
this.pnlSettings.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// pnlButtons
//
this.pnlButtons.Controls.Add(this.panel3);
this.pnlButtons.Controls.Add(this.pnlReplaceButtons);
this.pnlButtons.Controls.Add(this.panel1);
this.pnlButtons.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlButtons.Location = new System.Drawing.Point(400, 0);
this.pnlButtons.Name = "pnlButtons";
this.pnlButtons.Size = new System.Drawing.Size(96, 178);
this.pnlButtons.TabIndex = 0;
//
// panel3
//
this.panel3.Controls.Add(this.btnClose);
this.panel3.Controls.Add(this.btnMarkAll);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(0, 96);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(96, 82);
this.panel3.TabIndex = 4;
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(8, 40);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(80, 24);
this.btnClose.TabIndex = 3;
this.btnClose.Text = "Close";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnMarkAll
//
this.btnMarkAll.Location = new System.Drawing.Point(8, 8);
this.btnMarkAll.Name = "btnMarkAll";
this.btnMarkAll.Size = new System.Drawing.Size(80, 24);
this.btnMarkAll.TabIndex = 2;
this.btnMarkAll.Text = "Mark all";
this.btnMarkAll.Click += new System.EventHandler(this.btnMarkAll_Click);
//
// pnlReplaceButtons
//
this.pnlReplaceButtons.Controls.Add(this.btnReplaceAll);
this.pnlReplaceButtons.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlReplaceButtons.Location = new System.Drawing.Point(0, 64);
this.pnlReplaceButtons.Name = "pnlReplaceButtons";
this.pnlReplaceButtons.Size = new System.Drawing.Size(96, 32);
this.pnlReplaceButtons.TabIndex = 3;
this.pnlReplaceButtons.Visible = false;
//
// btnReplaceAll
//
this.btnReplaceAll.Location = new System.Drawing.Point(8, 8);
this.btnReplaceAll.Name = "btnReplaceAll";
this.btnReplaceAll.Size = new System.Drawing.Size(80, 24);
this.btnReplaceAll.TabIndex = 2;
this.btnReplaceAll.Text = "Replace All";
this.btnReplaceAll.Click += new System.EventHandler(this.btnReplaceAll_Click);
//
// panel1
//
this.panel1.Controls.Add(this.btnDoReplace);
this.panel1.Controls.Add(this.btnReplace);
this.panel1.Controls.Add(this.btnFind);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(96, 64);
this.panel1.TabIndex = 2;
//
// btnDoReplace
//
this.btnDoReplace.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnDoReplace.Location = new System.Drawing.Point(8, 40);
this.btnDoReplace.Name = "btnDoReplace";
this.btnDoReplace.Size = new System.Drawing.Size(80, 24);
this.btnDoReplace.TabIndex = 4;
this.btnDoReplace.Text = "Replace";
this.btnDoReplace.Click += new System.EventHandler(this.btnDoReplace_Click);
//
// btnReplace
//
this.btnReplace.Image = ((System.Drawing.Image)(resources.GetObject("btnReplace.Image")));
this.btnReplace.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnReplace.Location = new System.Drawing.Point(8, 40);
this.btnReplace.Name = "btnReplace";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -