📄 finddialog.cs
字号:
// FindDialog.cs
// Copyright (C) 2000 Andrea Paatz
// Copyright (C) 2000 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using SharpDevelop.Gui;
using SharpDevelop.Internal.Text.Search;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Gui.Dialogs {
/// <summary>
/// Summary description for FindDialog.
/// </summary>
public class FindDialog : Form {
/// <summary>
/// Required by the Win Forms designer
/// </summary>
private System.ComponentModel.Container components;
private RadioButton radioButton2;
private RadioButton radioButton1;
private GroupBox groupBox1;
private Label label2;
private ComboBox OptionCombo;
private CheckBox checkBox3;
private CheckBox checkBox2;
private CheckBox checkBox1;
private Button button4;
private Button button3;
// private Button button2;
private Button button1;
private ComboBox FindComboBox;
private Label label1;
private MainWindow main;
private static int lastIndex = 0;
private static bool searchup = false;
public static Find find;
public FindDialog(MainWindow main) {
Find.Main = main;
// Required for Win Form Designer support
InitializeComponent();
this.main = main;
MaximizeBox = MinimizeBox = false;
ShowInTaskbar = false;
// TODO: Add any constructor code after InitializeComponent call
button1.Click += new System.EventHandler(ClickFind);
button3.Click += new System.EventHandler(Close);
AcceptButton = button1;
CancelButton = button3;
Icon = null;
Owner = main;
StartPosition = FormStartPosition.CenterParent;
FormBorderStyle = FormBorderStyle.FixedDialog;
Show();
FindComboBox.Focus();
}
/// <summary>
/// Clean up any resources being used
/// </summary>
public override void Dispose() {
base.Dispose();
components.Dispose();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
// public static void Main(string[] args) {
// Application.Run(new FindDialog());
// }
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with an editor
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.radioButton1 = new RadioButton();
this.button4 = new Button();
this.groupBox1 = new GroupBox();
this.button3 = new Button();
this.button1 = new Button();
this.label2 = new Label();
this.checkBox2 = new CheckBox();
this.checkBox3 = new CheckBox();
this.checkBox1 = new CheckBox();
this.FindComboBox = new ComboBox();
this.label1 = new Label();
this.OptionCombo = new ComboBox();
this.radioButton2 = new RadioButton();
radioButton1.Location = new System.Drawing.Point(8, 16);
radioButton1.Size = new System.Drawing.Size(64, 16);
radioButton1.TabIndex = 0;
radioButton1.Text = Resource.GetString("Dialog.NewProject.SearchReplace.Up");
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.Text = Resource.GetString("Dialog.NewProject.SearchReplace.FindDialogName");
//@design this.TrayLargeIcon = true;
//@design this.SnapToGrid = false;
//@design this.TrayHeight = 0;
// this.TopMost = true;
this.ClientSize = new System.Drawing.Size(426 + 35, 121);
button4.Location = new System.Drawing.Point(352, 88);
button4.Size = new System.Drawing.Size(96, 24);
button4.TabIndex = 5;
button4.Text = Resource.GetString("Global.HelpButtonText");
groupBox1.Location = new System.Drawing.Point(160, 72);
groupBox1.TabIndex = 11;
groupBox1.TabStop = false;
groupBox1.Text = Resource.GetString("Dialog.NewProject.SearchReplace.DirectionText");
groupBox1.Size = new System.Drawing.Size(134, 40);
button3.Location = new System.Drawing.Point(352, 40);
button3.Size = new System.Drawing.Size(96, 24);
button3.TabIndex = 4;
button3.Text = Resource.GetString("Global.CloseButtonText");
button1.Location = new System.Drawing.Point(352, 8);
button1.Size = new System.Drawing.Size(96, 24);
button1.TabIndex = 2;
button1.Text = Resource.GetString("Dialog.NewProject.SearchReplace.Find");
label2.Location = new System.Drawing.Point(133, 48);
label2.Text = Resource.GetString("Dialog.NewProject.SearchReplace.SearchIn");
label2.Size = new System.Drawing.Size(60, 14);
label2.TabIndex = 10;
checkBox2.Location = new System.Drawing.Point(8, 72);
checkBox2.Text = Resource.GetString("Dialog.NewProject.SearchReplace.WholeWord");
checkBox2.Size = new System.Drawing.Size(112, 25);
// checkBox2.AccessibleRole = AccessibleRoles.CheckButton;
checkBox2.TabIndex = 7;
checkBox2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
checkBox3.Location = new System.Drawing.Point(8, 96);
checkBox3.Text = Resource.GetString("Dialog.NewProject.SearchReplace.WrapEnd");
checkBox3.Size = new System.Drawing.Size(112, 25);
// checkBox3.AccessibleRole = AccessibleRoles.CheckButton;
checkBox3.TabIndex = 8;
checkBox3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
checkBox1.Location = new System.Drawing.Point(8, 48);
checkBox1.Text = Resource.GetString("Dialog.NewProject.SearchReplace.CaseSensitive");
checkBox1.Size = new System.Drawing.Size(112, 25);
// checkBox1.AccessibleRole = AccessibleRoles.CheckButton;
checkBox1.TabIndex = 6;
checkBox1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
FindComboBox.Location = new System.Drawing.Point(74, 12);
FindComboBox.Text = Find.search.What;
FindComboBox.Size = new System.Drawing.Size(264, 21);
FindComboBox.TabIndex = 1;
label1.Location = new System.Drawing.Point(2, 16);
label1.Text = Resource.GetString("Dialog.NewProject.SearchReplace.FindWhat");
label1.Size = new System.Drawing.Size(80, 24);
label1.TabIndex = 0;
OptionCombo.Text = "";
OptionCombo.Location = new System.Drawing.Point(193, 45);
OptionCombo.Size = new System.Drawing.Size(144, 21);
// OptionCombo.Style = ComboBoxStyle.DropDownList;
OptionCombo.TabIndex = 9;
OptionCombo.Items.Add(Resource.GetString("Global.Location.currentfile"));
OptionCombo.Items.Add(Resource.GetString("Global.Location.allopenfiles"));
OptionCombo.Items.Add(Resource.GetString("Global.Location.wholeproject"));
OptionCombo.SelectedIndex = lastIndex;
radioButton2.Location = new System.Drawing.Point(64, 16);
radioButton2.Size = new System.Drawing.Size(64, 16);
radioButton2.TabIndex = 1;
radioButton2.Text = Resource.GetString("Dialog.NewProject.SearchReplace.Down");
this.Controls.Add(groupBox1);
this.Controls.Add(label2);
this.Controls.Add(OptionCombo);
this.Controls.Add(checkBox3);
this.Controls.Add(checkBox2);
this.Controls.Add(checkBox1);
this.Controls.Add(button4);
this.Controls.Add(button3);
this.Controls.Add(button1);
this.Controls.Add(FindComboBox);
this.Controls.Add(label1);
groupBox1.Controls.Add(radioButton2);
groupBox1.Controls.Add(radioButton1);
radioButton1.Checked = searchup;
radioButton2.Checked = !searchup;
checkBox1.Checked = !Find.search.BigOnly;
checkBox2.Checked = Find.search.WholeWords;
checkBox3.Checked = Find.WrapAtTheEnd;
}
private void Close(object sender, System.EventArgs e){
Close();
}
private void ClickFind(object sender, System.EventArgs e){
switch (OptionCombo.SelectedIndex){
case 0:
find = new FindInBuffer();
break;
case 1:
find = new FindInAllOpenFiles();
break;
case 2:
find = new FindInWholeProject();
break;
}
Find.search.BigOnly = !checkBox1.Checked;
Find.search.What = FindComboBox.Text;
Find.search.WholeWords = checkBox2.Checked;
Find.WrapAtTheEnd = checkBox3.Checked;
lastIndex = OptionCombo.SelectedIndex;
if(!find.FindNext())
MessageBox.Show(Resource.GetString("Dialog.NewProject.SearchReplace.SearchStringNotFound"));
/* if (window != null) {
Buffer b = window.TextArea.Buffer;
Point begin = window.TextArea.Caret.CaretPos;
Point end = new Point(0, b.Length);
search.BigOnly = !checkBox1.Checked;
System.String go = FindComboBox.Text;
search.What = go;
Point here = search.Find(b, begin, end);
if(!Found(here, end, go.Length)){
if(checkBox3.Checked){
here = search.Find(b, new Point(0, 0), begin);
if(!Found(here, begin, go.Length))
MessageBox.Show("!not found!");
}else
MessageBox.Show("!not found!");
}
}*/
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -