### 2023-02-21更新

------
#### SuperDesign    V3.0.2302.2101
- *.[新增]全新文本编辑器,支持高亮、FTP查看和编辑、目录浏览,历史版本等众多功能。
This commit is contained in:
鑫Intel committed 2023-02-21 09:46:13 +08:00
1 parent c7b33920bd
commit 03bcb8c5fd
406 files changed
+312053 -48889

No files matched your search

@@ -0,0 +1,319 @@
namespace SuperDesign.Controls.Highlight.FindReplace
{
partial class FindConfig
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.rdoFileStandardR = new System.Windows.Forms.RadioButton();
this.rdoFileExtendedR = new System.Windows.Forms.RadioButton();
this.rdoFileRegexR = new System.Windows.Forms.RadioButton();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pnlStandardOptions = new System.Windows.Forms.Panel();
this.chkFileWordStartR = new System.Windows.Forms.CheckBox();
this.chkFileWholeWordR = new System.Windows.Forms.CheckBox();
this.chkFileMatchCaseR = new System.Windows.Forms.CheckBox();
this.pnlRegexpOptions = new System.Windows.Forms.Panel();
this.chkFileSinglelineR = new System.Windows.Forms.CheckBox();
this.chkFileRightToLeftR = new System.Windows.Forms.CheckBox();
this.chkFileMultilineR = new System.Windows.Forms.CheckBox();
this.chkFileIgnorePatternWhitespaceR = new System.Windows.Forms.CheckBox();
this.chkFileIgnoreCaseR = new System.Windows.Forms.CheckBox();
this.chkFileExplicitCaptureR = new System.Windows.Forms.CheckBox();
this.chkFileEcmaScriptR = new System.Windows.Forms.CheckBox();
this.chkFileCultureInvariantR = new System.Windows.Forms.CheckBox();
this.chkFileCompiledR = new System.Windows.Forms.CheckBox();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.pnlStandardOptions.SuspendLayout();
this.pnlRegexpOptions.SuspendLayout();
this.SuspendLayout();
//
// groupBox2
//
this.groupBox2.Controls.Add(this.rdoFileStandardR);
this.groupBox2.Controls.Add(this.rdoFileExtendedR);
this.groupBox2.Controls.Add(this.rdoFileRegexR);
this.groupBox2.Location = new System.Drawing.Point(3, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(158, 82);
this.groupBox2.TabIndex = 38;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "搜索模式";
//
// rdoFileStandardR
//
this.rdoFileStandardR.AutoSize = true;
this.rdoFileStandardR.Checked = true;
this.rdoFileStandardR.Location = new System.Drawing.Point(6, 20);
this.rdoFileStandardR.Name = "rdoFileStandardR";
this.rdoFileStandardR.Size = new System.Drawing.Size(47, 16);
this.rdoFileStandardR.TabIndex = 5;
this.rdoFileStandardR.TabStop = true;
this.rdoFileStandardR.Text = "标准";
this.rdoFileStandardR.UseVisualStyleBackColor = true;
this.rdoFileStandardR.CheckedChanged += new System.EventHandler(this.RdoFileStandardR_CheckedChanged);
//
// rdoFileExtendedR
//
this.rdoFileExtendedR.AutoSize = true;
this.rdoFileExtendedR.Location = new System.Drawing.Point(6, 41);
this.rdoFileExtendedR.Name = "rdoFileExtendedR";
this.rdoFileExtendedR.Size = new System.Drawing.Size(149, 16);
this.rdoFileExtendedR.TabIndex = 6;
this.rdoFileExtendedR.Text = "扩展 (\\n, \\r, \\t, \\0)";
this.rdoFileExtendedR.UseVisualStyleBackColor = true;
this.rdoFileExtendedR.CheckedChanged += new System.EventHandler(this.RdoFileExtendedR_CheckedChanged);
//
// rdoFileRegexR
//
this.rdoFileRegexR.AutoSize = true;
this.rdoFileRegexR.Location = new System.Drawing.Point(6, 62);
this.rdoFileRegexR.Name = "rdoFileRegexR";
this.rdoFileRegexR.Size = new System.Drawing.Size(83, 16);
this.rdoFileRegexR.TabIndex = 7;
this.rdoFileRegexR.Text = "正则表达式";
this.rdoFileRegexR.UseVisualStyleBackColor = true;
this.rdoFileRegexR.CheckedChanged += new System.EventHandler(this.RdoFileRegexR_CheckedChanged);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.pnlRegexpOptions);
this.groupBox1.Controls.Add(this.pnlStandardOptions);
this.groupBox1.Location = new System.Drawing.Point(164, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(371, 82);
this.groupBox1.TabIndex = 39;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "选项";
//
// pnlStandardOptions
//
this.pnlStandardOptions.Controls.Add(this.chkFileWordStartR);
this.pnlStandardOptions.Controls.Add(this.chkFileWholeWordR);
this.pnlStandardOptions.Controls.Add(this.chkFileMatchCaseR);
this.pnlStandardOptions.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlStandardOptions.Location = new System.Drawing.Point(3, 17);
this.pnlStandardOptions.Name = "pnlStandardOptions";
this.pnlStandardOptions.Size = new System.Drawing.Size(365, 62);
this.pnlStandardOptions.TabIndex = 0;
//
// chkFileWordStartR
//
this.chkFileWordStartR.AutoSize = true;
this.chkFileWordStartR.Location = new System.Drawing.Point(10, 37);
this.chkFileWordStartR.Name = "chkFileWordStartR";
this.chkFileWordStartR.Size = new System.Drawing.Size(96, 16);
this.chkFileWordStartR.TabIndex = 2;
this.chkFileWordStartR.Text = "单词开头匹配";
this.chkFileWordStartR.UseVisualStyleBackColor = true;
//
// chkFileWholeWordR
//
this.chkFileWholeWordR.AutoSize = true;
this.chkFileWholeWordR.Location = new System.Drawing.Point(10, 20);
this.chkFileWholeWordR.Name = "chkFileWholeWordR";
this.chkFileWholeWordR.Size = new System.Drawing.Size(72, 16);
this.chkFileWholeWordR.TabIndex = 1;
this.chkFileWholeWordR.Text = "全词匹配";
this.chkFileWholeWordR.UseVisualStyleBackColor = true;
//
// chkFileMatchCaseR
//
this.chkFileMatchCaseR.AutoSize = true;
this.chkFileMatchCaseR.Location = new System.Drawing.Point(10, 3);
this.chkFileMatchCaseR.Name = "chkFileMatchCaseR";
this.chkFileMatchCaseR.Size = new System.Drawing.Size(84, 16);
this.chkFileMatchCaseR.TabIndex = 0;
this.chkFileMatchCaseR.Text = "匹配大小写";
this.chkFileMatchCaseR.UseVisualStyleBackColor = true;
//
// pnlRegexpOptions
//
this.pnlRegexpOptions.Controls.Add(this.chkFileSinglelineR);
this.pnlRegexpOptions.Controls.Add(this.chkFileRightToLeftR);
this.pnlRegexpOptions.Controls.Add(this.chkFileMultilineR);
this.pnlRegexpOptions.Controls.Add(this.chkFileIgnorePatternWhitespaceR);
this.pnlRegexpOptions.Controls.Add(this.chkFileIgnoreCaseR);
this.pnlRegexpOptions.Controls.Add(this.chkFileExplicitCaptureR);
this.pnlRegexpOptions.Controls.Add(this.chkFileEcmaScriptR);
this.pnlRegexpOptions.Controls.Add(this.chkFileCultureInvariantR);
this.pnlRegexpOptions.Controls.Add(this.chkFileCompiledR);
this.pnlRegexpOptions.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlRegexpOptions.Location = new System.Drawing.Point(3, 17);
this.pnlRegexpOptions.Name = "pnlRegexpOptions";
this.pnlRegexpOptions.Size = new System.Drawing.Size(365, 62);
this.pnlRegexpOptions.TabIndex = 1;
//
// chkFileSinglelineR
//
this.chkFileSinglelineR.AutoSize = true;
this.chkFileSinglelineR.Location = new System.Drawing.Point(251, 37);
this.chkFileSinglelineR.Name = "chkFileSinglelineR";
this.chkFileSinglelineR.Size = new System.Drawing.Size(72, 16);
this.chkFileSinglelineR.TabIndex = 8;
this.chkFileSinglelineR.Text = "单行模式";
this.toolTip1.SetToolTip(this.chkFileSinglelineR, "指定单行模式。 更改点 (.) 的含义,以使它与每个字符(而不是除 \\n 之外的所有字符)匹配。");
this.chkFileSinglelineR.UseVisualStyleBackColor = true;
//
// chkFileRightToLeftR
//
this.chkFileRightToLeftR.AutoSize = true;
this.chkFileRightToLeftR.Location = new System.Drawing.Point(251, 20);
this.chkFileRightToLeftR.Name = "chkFileRightToLeftR";
this.chkFileRightToLeftR.Size = new System.Drawing.Size(72, 16);
this.chkFileRightToLeftR.TabIndex = 7;
this.chkFileRightToLeftR.Text = "从右到左";
this.toolTip1.SetToolTip(this.chkFileRightToLeftR, "指定搜索从右向左而不是从左向右进行。");
this.chkFileRightToLeftR.UseVisualStyleBackColor = true;
//
// chkFileMultilineR
//
this.chkFileMultilineR.AutoSize = true;
this.chkFileMultilineR.Location = new System.Drawing.Point(251, 3);
this.chkFileMultilineR.Name = "chkFileMultilineR";
this.chkFileMultilineR.Size = new System.Drawing.Size(72, 16);
this.chkFileMultilineR.TabIndex = 6;
this.chkFileMultilineR.Text = "多行模式";
this.toolTip1.SetToolTip(this.chkFileMultilineR, "多行模式。 更改 ^ 和 $ 的含义,使它们分别在任意一行的行首和行尾匹配,而不仅仅在整个字符串的开头和结尾匹配。 ");
this.chkFileMultilineR.UseVisualStyleBackColor = true;
//
// chkFileIgnorePatternWhitespaceR
//
this.chkFileIgnorePatternWhitespaceR.AutoSize = true;
this.chkFileIgnorePatternWhitespaceR.Location = new System.Drawing.Point(130, 37);
this.chkFileIgnorePatternWhitespaceR.Name = "chkFileIgnorePatternWhitespaceR";
this.chkFileIgnorePatternWhitespaceR.Size = new System.Drawing.Size(84, 16);
this.chkFileIgnorePatternWhitespaceR.TabIndex = 5;
this.chkFileIgnorePatternWhitespaceR.Text = "忽略空白符";
this.toolTip1.SetToolTip(this.chkFileIgnorePatternWhitespaceR, "消除模式中的非转义空白并启用由 # 标记的注释。 \r\n但是,此值不影响或消除标记单独的正则表达式语言元素的开头的字符类、数值量词或标记的空格。 ");
this.chkFileIgnorePatternWhitespaceR.UseVisualStyleBackColor = true;
//
// chkFileIgnoreCaseR
//
this.chkFileIgnoreCaseR.AutoSize = true;
this.chkFileIgnoreCaseR.Location = new System.Drawing.Point(130, 20);
this.chkFileIgnoreCaseR.Name = "chkFileIgnoreCaseR";
this.chkFileIgnoreCaseR.Size = new System.Drawing.Size(84, 16);
this.chkFileIgnoreCaseR.TabIndex = 4;
this.chkFileIgnoreCaseR.Text = "忽略大小写";
this.toolTip1.SetToolTip(this.chkFileIgnoreCaseR, "指定不区分大小写的匹配。 ");
this.chkFileIgnoreCaseR.UseVisualStyleBackColor = true;
//
// chkFileExplicitCaptureR
//
this.chkFileExplicitCaptureR.AutoSize = true;
this.chkFileExplicitCaptureR.Location = new System.Drawing.Point(130, 3);
this.chkFileExplicitCaptureR.Name = "chkFileExplicitCaptureR";
this.chkFileExplicitCaptureR.Size = new System.Drawing.Size(72, 16);
this.chkFileExplicitCaptureR.TabIndex = 3;
this.chkFileExplicitCaptureR.Text = "显式捕获";
this.toolTip1.SetToolTip(this.chkFileExplicitCaptureR, "指定唯一有效的捕获是显式命名或编号的 (?<name>...) 形式的组。\r\n这使未命名的圆括号可以充当非捕获组,并且不会使表达式的语法 (?:...) 显得笨拙" +
"。");
this.chkFileExplicitCaptureR.UseVisualStyleBackColor = true;
//
// chkFileEcmaScriptR
//
this.chkFileEcmaScriptR.AutoSize = true;
this.chkFileEcmaScriptR.Location = new System.Drawing.Point(3, 37);
this.chkFileEcmaScriptR.Name = "chkFileEcmaScriptR";
this.chkFileEcmaScriptR.Size = new System.Drawing.Size(72, 16);
this.chkFileEcmaScriptR.TabIndex = 2;
this.chkFileEcmaScriptR.Text = "ECMA脚本";
this.toolTip1.SetToolTip(this.chkFileEcmaScriptR, "指定搜索从右向左而不是从左向右进行。");
this.chkFileEcmaScriptR.UseVisualStyleBackColor = true;
this.chkFileEcmaScriptR.CheckedChanged += new System.EventHandler(this.chkFileEcmaScriptR_CheckedChanged);
//
// chkFileCultureInvariantR
//
this.chkFileCultureInvariantR.AutoSize = true;
this.chkFileCultureInvariantR.Location = new System.Drawing.Point(3, 20);
this.chkFileCultureInvariantR.Name = "chkFileCultureInvariantR";
this.chkFileCultureInvariantR.Size = new System.Drawing.Size(120, 16);
this.chkFileCultureInvariantR.TabIndex = 1;
this.chkFileCultureInvariantR.Text = "忽略语言区域差异";
this.toolTip1.SetToolTip(this.chkFileCultureInvariantR, "指定忽略语言中的区域性差异。");
this.chkFileCultureInvariantR.UseVisualStyleBackColor = true;
//
// chkFileCompiledR
//
this.chkFileCompiledR.AutoSize = true;
this.chkFileCompiledR.Location = new System.Drawing.Point(3, 3);
this.chkFileCompiledR.Name = "chkFileCompiledR";
this.chkFileCompiledR.Size = new System.Drawing.Size(60, 16);
this.chkFileCompiledR.TabIndex = 0;
this.chkFileCompiledR.Text = "已编译";
this.toolTip1.SetToolTip(this.chkFileCompiledR, "指定正则表达式编译为 MSIL 代码,而不是解释。 \r\n已编译的正则表达式最大限度地提高运行时性能,代价是会影响初始化时间。");
this.chkFileCompiledR.UseVisualStyleBackColor = true;
//
// FindConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "FindConfig";
this.Size = new System.Drawing.Size(538, 90);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.pnlStandardOptions.ResumeLayout(false);
this.pnlStandardOptions.PerformLayout();
this.pnlRegexpOptions.ResumeLayout(false);
this.pnlRegexpOptions.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton rdoFileStandardR;
private System.Windows.Forms.RadioButton rdoFileExtendedR;
private System.Windows.Forms.RadioButton rdoFileRegexR;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Panel pnlRegexpOptions;
private System.Windows.Forms.CheckBox chkFileSinglelineR;
private System.Windows.Forms.CheckBox chkFileRightToLeftR;
private System.Windows.Forms.CheckBox chkFileMultilineR;
private System.Windows.Forms.CheckBox chkFileIgnorePatternWhitespaceR;
private System.Windows.Forms.CheckBox chkFileIgnoreCaseR;
private System.Windows.Forms.CheckBox chkFileExplicitCaptureR;
private System.Windows.Forms.CheckBox chkFileEcmaScriptR;
private System.Windows.Forms.CheckBox chkFileCultureInvariantR;
private System.Windows.Forms.CheckBox chkFileCompiledR;
private System.Windows.Forms.Panel pnlStandardOptions;
private System.Windows.Forms.CheckBox chkFileWordStartR;
private System.Windows.Forms.CheckBox chkFileWholeWordR;
private System.Windows.Forms.CheckBox chkFileMatchCaseR;
}
}
@@ -0,0 +1,284 @@
using Newtonsoft.Json.Linq;
using ryCommon;
using ScintillaNET;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SuperDesign.Controls.Highlight.FindReplace
{
public partial class FindConfig : UserControl
{
public FindConfig()
{
InitializeComponent();
pnlStandardOptions.BringToFront();
}
/// <summary>
/// 搜索模式,0表示标准,1表示扩展,2表示正则
/// </summary>
[Description("搜索模式,0表示标准,1表示扩展,2表示正则")]
public int SearchMode
{
get
{
if (rdoFileStandardR.Checked) { return 0; }
if (rdoFileExtendedR.Checked) { return 1; }
if (rdoFileRegexR.Checked) { return 2; }
return -1;
}
set
{
if (value == 0) { rdoFileStandardR.Checked = true; }
else if (value ==1) { rdoFileExtendedR.Checked = true; }
else if (value == 2) { rdoFileRegexR.Checked = true; }
else { rdoFileStandardR.Checked = true; }
}
}
/// <summary>
/// 匹配大小写
/// </summary>
[Description("匹配大小写")]
public bool MatchCase
{
get { return chkFileMatchCaseR.Checked; }
set { chkFileMatchCaseR.Checked = value; }
}
/// <summary>
/// 全词匹配
/// </summary>
[Description("全词匹配")]
public bool FileWholeWord
{
get { return chkFileWholeWordR.Checked; }
set { chkFileWholeWordR.Checked = value; }
}
/// <summary>
/// 单词开头匹配
/// </summary>
[Description("单词开头匹配")]
public bool FileWordStart
{
get { return chkFileWordStartR.Checked; }
set { chkFileWordStartR.Checked = value; }
}
/// <summary>
/// 【正则】已编译
/// </summary>
[Description("【正则】已编译")]
public bool RegexCompiled
{
get { return chkFileCompiledR.Checked; }
set { chkFileCompiledR.Checked = value; }
}
/// <summary>
/// 【正则】显式捕获
/// </summary>
[Description("【正则】显式捕获")]
public bool RegexExplicitCapture
{
get { return chkFileExplicitCaptureR.Checked; }
set { chkFileExplicitCaptureR.Checked = value; }
}
/// <summary>
/// 【正则】多行模式
/// </summary>
[Description("【正则】多行模式")]
public bool RegexMultiline
{
get { return chkFileMultilineR.Checked; }
set { chkFileMultilineR.Checked = value; }
}
/// <summary>
/// 【正则】忽略语言区域差异
/// </summary>
[Description("【正则】忽略语言区域差异")]
public bool RegexFileCultureInvariant
{
get { return chkFileCultureInvariantR.Checked; }
set { chkFileCultureInvariantR.Checked = value; }
}
/// <summary>
/// 【正则】忽略大小写
/// </summary>
[Description("【正则】忽略大小写")]
public bool RegexIgnoreCase
{
get { return chkFileIgnoreCaseR.Checked; }
set { chkFileIgnoreCaseR.Checked = value; }
}
/// <summary>
/// 【正则】从右到左
/// </summary>
[Description("【正则】从右到左")]
public bool RegexRightToLeft
{
get { return chkFileRightToLeftR.Checked; }
set { chkFileRightToLeftR.Checked = value; }
}
/// <summary>
/// 【正则】ECMA脚本
/// </summary>
[Description("【正则】ECMA脚本")]
public bool RegexEcmaScript
{
get { return chkFileEcmaScriptR.Checked; }
set { chkFileEcmaScriptR.Checked = value; }
}
/// <summary>
/// 【正则】忽略空白符
/// </summary>
[Description("【正则】忽略空白符")]
public bool RegexIgnorePatternWhitespace
{
get { return chkFileIgnorePatternWhitespaceR.Checked; }
set { chkFileIgnorePatternWhitespaceR.Checked = value; }
}
/// <summary>
/// 【正则】单行模式
/// </summary>
[Description("【正则】单行模式")]
public bool RegexFileSingleline
{
get { return chkFileSinglelineR.Checked; }
set { chkFileSinglelineR.Checked = value; }
}
/// <summary>
/// 获取正则选项
/// </summary>
/// <returns></returns>
public RegexOptions GetRegexOptions()
{
RegexOptions ro = RegexOptions.None;
if (chkFileCompiledR.Checked)
ro |= RegexOptions.Compiled;
if (chkFileCultureInvariantR.Checked)
ro |= RegexOptions.CultureInvariant;
if (chkFileEcmaScriptR.Checked)
ro |= RegexOptions.ECMAScript;
if (chkFileExplicitCaptureR.Checked)
ro |= RegexOptions.ExplicitCapture;
if (chkFileIgnoreCaseR.Checked)
ro |= RegexOptions.IgnoreCase;
if (chkFileIgnorePatternWhitespaceR.Checked)
ro |= RegexOptions.IgnorePatternWhitespace;
if (chkFileMultilineR.Checked)
ro |= RegexOptions.Multiline;
if (chkFileRightToLeftR.Checked)
ro |= RegexOptions.RightToLeft;
if (chkFileSinglelineR.Checked)
ro |= RegexOptions.Singleline;
return ro;
}
/// <summary>
/// 设置正则选项
/// </summary>
/// <returns></returns>
public void SetRegexOptions(RegexOptions ro)
{
chkFileCompiledR.Checked = (ro & RegexOptions.Compiled) == RegexOptions.Compiled;
chkFileCultureInvariantR.Checked = (ro & RegexOptions.CultureInvariant) == RegexOptions.CultureInvariant;
chkFileEcmaScriptR.Checked = (ro & RegexOptions.ECMAScript) == RegexOptions.ECMAScript;
chkFileExplicitCaptureR.Checked = (ro & RegexOptions.ExplicitCapture) == RegexOptions.ExplicitCapture;
chkFileIgnoreCaseR.Checked = (ro & RegexOptions.IgnoreCase) == RegexOptions.IgnoreCase;
chkFileIgnorePatternWhitespaceR.Checked = (ro & RegexOptions.IgnorePatternWhitespace) == RegexOptions.IgnorePatternWhitespace;
chkFileMultilineR.Checked = (ro & RegexOptions.Multiline) == RegexOptions.Multiline;
chkFileRightToLeftR.Checked = (ro & RegexOptions.RightToLeft) == RegexOptions.RightToLeft;
chkFileSinglelineR.Checked = (ro & RegexOptions.Singleline) == RegexOptions.Singleline;
}
/// <summary>
/// 获取普通搜索选项
/// </summary>
/// <returns></returns>
public SearchFlags GetSearchFlags()
{
SearchFlags sf = SearchFlags.None;
if (chkFileMatchCaseR.Checked)
sf |= SearchFlags.MatchCase;
if (chkFileWholeWordR.Checked)
sf |= SearchFlags.WholeWord;
if (chkFileWordStartR.Checked)
sf |= SearchFlags.WordStart;
return sf;
}
/// <summary>
/// 设置普通搜索选项
/// </summary>
/// <returns></returns>
public void SetSearchFlags(SearchFlags sf)
{
chkFileMatchCaseR.Checked = (sf & SearchFlags.MatchCase) == SearchFlags.MatchCase;
chkFileWholeWordR.Checked = (sf & SearchFlags.WholeWord) == SearchFlags.WholeWord;
chkFileWordStartR.Checked = (sf & SearchFlags.WordStart) == SearchFlags.WordStart;
}
/// <summary>
/// 从另一个控件复制配置
/// </summary>
/// <param name="fc"></param>
public void LoadConfig(FindConfig fc)
{
SearchMode = fc.SearchMode;
fc.SetSearchFlags(fc.GetSearchFlags());
fc.SetRegexOptions(fc.GetRegexOptions());
}
private void RdoFileExtendedR_CheckedChanged(object sender, EventArgs e)
{
if (rdoFileExtendedR.Checked)
pnlStandardOptions.BringToFront();
//cmdExtCharAndRegExFindR.Enabled = !rdoStandardR.Checked;
//cmdExtCharAndRegExReplace.Enabled = !rdoStandardR.Checked;
}
private void RdoFileStandardR_CheckedChanged(object sender, EventArgs e)
{
if (rdoFileStandardR.Checked)
pnlStandardOptions.BringToFront();
}
private void RdoFileRegexR_CheckedChanged(object sender, EventArgs e)
{
if (rdoFileRegexR.Checked)
pnlRegexpOptions.BringToFront();
}
private void chkFileEcmaScriptR_CheckedChanged(object sender, EventArgs e)
{
if (((CheckBox)sender).Checked)
{
chkFileExplicitCaptureR.Checked = false;
chkFileExplicitCaptureR.Enabled = false;
chkFileIgnorePatternWhitespaceR.Checked = false;
chkFileIgnorePatternWhitespaceR.Enabled = false;
chkFileRightToLeftR.Checked = false;
chkFileRightToLeftR.Enabled = false;
chkFileSinglelineR.Checked = false;
chkFileSinglelineR.Enabled = false;
}
else
{
chkFileExplicitCaptureR.Enabled = true;
chkFileIgnorePatternWhitespaceR.Enabled = true;
chkFileRightToLeftR.Enabled = true;
chkFileSinglelineR.Enabled = true;
}
}
}
}
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -0,0 +1,40 @@
#region Using Directives
using System;
#endregion Using Directives
namespace ScintillaNET_FindReplaceDialog
{
/// <summary>
/// Controls find behavior for non-regular expression searches
/// </summary>
public enum FindOption
{
/// <summary>
/// Find must match the whole word
/// </summary>
WholeWord = 2,
/// <summary>
/// Find must match the case of the expression
/// </summary>
MatchCase = 4,
/// <summary>
/// Only match the _start of a word
/// </summary>
WordStart = 0x00100000,
/// <summary>
/// Not used in ScintillaNET
/// </summary>
RegularExpression = 0x00200000,
/// <summary>
/// Not used in ScintillaNET
/// </summary>
Posix = 0x00400000,
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
</metadata>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>114, 56</value>
</metadata>
<metadata name="mnuExtendedCharFindF.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="mnuRecentFindF.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>576, 17</value>
</metadata>
<metadata name="mnuExtendedCharFindR.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>198, 17</value>
</metadata>
<metadata name="mnuExtendedCharReplace.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>381, 17</value>
</metadata>
<metadata name="mnuRecentFindR.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>719, 17</value>
</metadata>
<metadata name="mnuRecentReplace.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>863, 17</value>
</metadata>
<metadata name="mnuRegExCharFindF.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>223, 56</value>
</metadata>
<metadata name="mnuRegExCharFindR.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>378, 56</value>
</metadata>
<metadata name="mnuRegExCharReplace.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>533, 56</value>
</metadata>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>721, 56</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>86</value>
</metadata>
</root>
@@ -0,0 +1,92 @@
namespace ScintillaNET_FindReplaceDialog
{
partial class FrmFinding
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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()
{
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label1 = new System.Windows.Forms.Label();
this.BtnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// progressBar1
//
this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar1.Location = new System.Drawing.Point(12, 12);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(578, 23);
this.progressBar1.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(113, 12);
this.label1.TabIndex = 1;
this.label1.Text = "状态:正在查找中...";
//
// BtnClose
//
this.BtnClose.Location = new System.Drawing.Point(258, 62);
this.BtnClose.Name = "BtnClose";
this.BtnClose.Size = new System.Drawing.Size(72, 25);
this.BtnClose.TabIndex = 2;
this.BtnClose.Text = "关闭";
this.BtnClose.UseVisualStyleBackColor = true;
this.BtnClose.Click += new System.EventHandler(this.BtnClose_Click);
//
// FrmFinding
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(602, 93);
this.Controls.Add(this.BtnClose);
this.Controls.Add(this.label1);
this.Controls.Add(this.progressBar1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "FrmFinding";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "正在查找...";
this.TopMost = true;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmFinding_FormClosing);
this.Load += new System.EventHandler(this.FrmFinding_Load);
this.Shown += new System.EventHandler(this.FrmFinding_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button BtnClose;
}
}
@@ -0,0 +1,415 @@
using ryCommon;
using ryControls;
using ScintillaNET;
using SuperDesign.Tools.SmartEditor;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using 开发辅助工具.Tools.SmartEditor;
using static ScintillaNET.Style;
using static System.Net.Mime.MediaTypeNames;
namespace ScintillaNET_FindReplaceDialog
{
public partial class FrmFinding : Form
{
public FrmFinding()
{
InitializeComponent();
}
bool IsExit = false;
bool IsRunning = false;
/// <summary>
/// 搜索配置
/// </summary>
public SearchDirConfig SearchConfig=new SearchDirConfig();
/// <summary>
/// 获取待搜索的文件数量
/// </summary>
/// <returns></returns>
private int GetFileCount()
{
var count = 0;
GetCount(SearchConfig.SearchDir);
return count;
void GetCount(string folder)
{
if(!SearchConfig.SearchHiddenDir)
{
DirectoryInfo directory = new DirectoryInfo(folder);
if((directory.Attributes & FileAttributes.Hidden)== FileAttributes.Hidden) {
return;
}
}
var split_ext = SearchConfig.Exts.Split(';');
for (int i = 0; i < split_ext.Length; i++)
{
if (IsExit) { break; }
var files = System.IO.Directory.GetFiles(folder, split_ext[i]);
if (files != null)
count += files.Length;
}
if (SearchConfig.SearchSubDir)
{
if (IsExit) { return ; }
var folder_list = System.IO.Directory.GetDirectories(folder);
if (folder_list != null)
{
for (int i = 0; i < folder_list.Length; i++)
{
if (IsExit) { break; }
GetCount(folder_list[i]);
}
}
}
}
}
private void ShowText(string text)
{
this.Invoke(new Action(() =>
{
label1.Text = "状态:" + text;
}));
}
private List<CharacterRange> SearchText(string Text)
{
var list = new List<CharacterRange>();
var start_i = 0;
var all_text = Text;
while (start_i>=0)
{
CharacterRange foundRange = new CharacterRange(start_i, Text.Length);
try
{
if (SearchConfig.SearchMode == 2)//正则
{
Regex r = new Regex(SearchConfig.FindText, SearchConfig.RegexOptions);
Match m = r.Match(all_text);
if (!m.Success)
return list;
int start = foundRange.CpMin + all_text.Substring(0, m.Index).Length;
int end = all_text.Substring(m.Index, m.Length).Length;
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum=LineNum, LinePos=LinePos,RangeText=Text.Substring(start,end) });
start_i = start+end + 1;
}
else
{
string textToFind = SearchConfig.SearchMode == 1 ? FindReplace.Transform(SearchConfig.FindText) : SearchConfig.FindText;
int start = 0;
if ((SearchConfig.SearchFlags & SearchFlags.MatchCase) == SearchFlags.MatchCase) //忽略大小写
{
start=Text.IndexOfEx(textToFind,start_i);
}
else
{
start = Text.IndexOf(textToFind, start_i, StringComparison.Ordinal);
}
int end = textToFind.Length;
if (start >= 0)
{
if ((SearchConfig.SearchFlags & SearchFlags.WholeWord) == SearchFlags.WholeWord) //全词匹配
{
if (start >= 0)
{
bool Word_Start = false;
bool Word_End = false;
if (start == 0) { Word_Start = true; }
else
{
var char_i = Text[start - 1];
if ((char_i >= '0' && char_i <= '9') || (char_i >= 'a' && char_i <= 'z')
|| (char_i >= 'A' && char_i <= 'Z'))
{
Word_Start = false;
}
else { Word_Start = true; }
}
if ((start + end)>=(Text.Length-1)) { Word_End = true; }
else
{
var char_i = Text[start + end];
if ((char_i >= '0' && char_i <= '9') || (char_i >= 'a' && char_i <= 'z')
|| (char_i >= 'A' && char_i <= 'Z'))
{
Word_End = false;
}
else { Word_End = true; }
}
if (Word_Start && Word_End)
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
}
start_i = start+ end + 1;
}
else
{
break;
}
}
else if ((SearchConfig.SearchFlags & SearchFlags.WordStart) == SearchFlags.WordStart) //开头匹配
{
if (start >= 0)
{
bool Word_Start = false;
if (start == 0) { Word_Start = true; }
else
{
var char_i = Text[start - 1];
if ((char_i >= '0' && char_i <= '9') || (char_i >= 'a' && char_i <= 'z')
|| (char_i >= 'A' && char_i <= 'Z'))
{
Word_Start = false;
}
else { Word_Start = true; }
}
if (Word_Start)
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
}
start_i = start+ end + 1;
}
else
{
break;
}
}
else
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
start_i = start+end + 1;
}
}
else
{
break;
}
}
}
catch (ArgumentException ex)
{
}
if (foundRange.CpMin == foundRange.CpMax) { break; }
if (start_i < Text.Length)
{
all_text = Text.Substring(start_i);
}
}
//根据位置来获取该位置所在行
int GetLineNum(int pos,out int LinePos)
{
LinePos = -1;
var split_txt = Text.Split('\n');
var count = 0;
for (int i = 0; i < split_txt.Length; i++)
{
if (count+split_txt[i].Length+1>=pos)
{
LinePos = count;
return i;
}
else
{
count += split_txt[i].Length+1;
}
}
return -1;
}
return list;
}
/// <summary>
/// 获取待搜索的文件数量
/// </summary>
/// <returns></returns>
private void SearchFiles()
{
IsRunning = true;
var count = 0;
ShowText("正在统计总文件数...");
var total_count= GetFileCount();
this.Invoke(new Action(() =>
{
progressBar1.Maximum = total_count;
}));
ShowText("统计结束,正在查找...");
Dictionary<string,List<CharacterRange>> dict_list = new Dictionary<string, List<CharacterRange>>();
new Thread(Start).Start();
void Start()
{
Search(SearchConfig.SearchDir);
this.Invoke(new Action(() =>
{
var opens = System.Windows.Forms.Application.OpenForms;
for (int i = 0; i < opens.Count; i++)
{
if (opens[i] is FrmResultText frm2)
{
frm2.findAllResultsPanel1.UpdateFindAllResults(dict_list);
frm2.Show(FrmMainEditor.MainEditor.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);
IsRunning = false;
this.Close();
return;
}
}
FrmResultText frm = new FrmResultText();
frm.findAllResultsPanel1.UpdateFindAllResults(dict_list);
frm.Show(FrmMainEditor.MainEditor.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);
IsRunning = false;
this.Close();
}));
}
void Search(string folder)
{
if (!SearchConfig.SearchHiddenDir)
{
DirectoryInfo directory = new DirectoryInfo(folder);
if ((directory.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
return;
}
}
var split_ext = SearchConfig.Exts.Split(';');
for (int i = 0; i < split_ext.Length; i++)
{
if (IsExit) { break; }
var files = System.IO.Directory.GetFiles(folder, split_ext[i]);
if (files != null)
{
for (int f = 0; f < files.Length; f++)
{
ShowText("正在查找=>" + files[f]);
if(SearchConfig.IgnoreBinExt)
{
var ext= Path.GetExtension(files[f]);
if (";.exe;.apk;.bin;.dll;.msi;.sys;.zip;.rar;.7z;.iso;.cab;.tar;.tgz;.crx;.psd;.jpg;.bmp;.gif;.webp;.png;.jpeg;.ico;.mp3;.wav;.ape;.aac;.flac;.ogg;.mp4;.rmvb;.flv;.wmv;.mov;.3gp;.mpeg;".IndexOfEx(";" + ext + ";") >= 0) { continue; }
}
if(SearchConfig.LimitFileSize>0)
{
if(RyFiles.GetFileSize(files[f])> SearchConfig.LimitFileSize) { continue; }
}
var text = RyFiles.ReadAllText(files[f]);
var find_list= SearchText(text);
if(find_list.Count>0)
{
dict_list.Add(files[f],find_list);
}
count++;
if (count <= total_count)
{
this.Invoke(new Action(() =>
{
progressBar1.Value = count;
}));
}
}
}
}
if (SearchConfig.SearchSubDir)
{
if (IsExit) { return; }
var folder_list = System.IO.Directory.GetDirectories(folder);
if (folder_list != null)
{
for (int i = 0; i < folder_list.Length; i++)
{
if (IsExit) { break; }
if(SearchConfig.SkipDirName.Length>0)
{
var name = Path.GetFileName(folder_list[i]);
if((";"+SearchConfig.SkipDirName+";").IndexOfEx(";"+name+";")>=0) { continue; }
}
Search(folder_list[i]);
}
}
}
}
}
private void FrmFinding_Load(object sender, EventArgs e)
{
}
private void BtnClose_Click(object sender, EventArgs e)
{
IsExit = true;
}
private void FrmFinding_FormClosing(object sender, FormClosingEventArgs e)
{
if (IsRunning) { e.Cancel = true; }
}
private void FrmFinding_Shown(object sender, EventArgs e)
{
SearchFiles();
}
}
public class FindResult
{
public string Path { get; set; } = "";
public CharacterRange Result { get; set; }
}
public class SearchDirConfig
{
/// <summary>
/// 搜索文件夹
/// </summary>
public string SearchDir { get; set; } = "";
/// <summary>
/// 是否搜索子目录
/// </summary>
public bool SearchSubDir { get; set; } = false;
/// <summary>
/// 忽略常见二进制格式
/// </summary>
public bool IgnoreBinExt { get; set; } = true;
/// <summary>
/// 是否搜索隐藏目录
/// </summary>
public bool SearchHiddenDir { get; set; } = false;
/// <summary>
/// 要查找的文本
/// </summary>
public string FindText { get; set; } = "";
/// <summary>
/// 要替换的文本
/// </summary>
public string ReplaceText { get; set; } = "";
/// <summary>
/// 要搜索的扩展名列表
/// </summary>
public string Exts { get; set; } = "";
/// <summary>
/// 跳过的目录名
/// </summary>
public string SkipDirName { get; set; } = "";
/// <summary>
/// 超过该大小的文件将不再查找
/// </summary>
public long LimitFileSize { get; set; } = 0;
/// <summary>
/// 是否开启替换模式,默认是查找模式
/// </summary>
public bool ReplaceModeOn { get; set; } = false;
/// <summary>
/// 正则表达式选项
/// </summary>
public RegexOptions RegexOptions { get; set; } = RegexOptions.None;
public ScintillaNET.SearchFlags SearchFlags { get; set; }
/// <summary>
/// 查找模式,0为普通查找,1表示扩展查找,2表示正则查找
/// </summary>
public int SearchMode { get; set; } = 0;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,180 @@
namespace ScintillaNET_FindReplaceDialog
{
partial class IncrementalSearcher
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component 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()
{
this.components = new System.ComponentModel.Container();
this.lblFind = new System.Windows.Forms.Label();
this.txtFind = new System.Windows.Forms.TextBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnNext = new System.Windows.Forms.Button();
this.brnPrevious = new System.Windows.Forms.Button();
this.btnHighlightAll = new System.Windows.Forms.Button();
this.btnClearHighlights = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// lblFind
//
this.lblFind.AutoSize = true;
this.lblFind.Dock = System.Windows.Forms.DockStyle.Left;
this.lblFind.Location = new System.Drawing.Point(0, 0);
this.lblFind.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.lblFind.Name = "lblFind";
this.lblFind.Size = new System.Drawing.Size(27, 22);
this.lblFind.TabIndex = 0;
this.lblFind.Text = "&Find";
this.lblFind.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtFind
//
this.txtFind.Location = new System.Drawing.Point(33, 1);
this.txtFind.Margin = new System.Windows.Forms.Padding(3, 1, 0, 0);
this.txtFind.Name = "txtFind";
this.txtFind.Size = new System.Drawing.Size(135, 20);
this.txtFind.TabIndex = 1;
this.txtFind.TextChanged += new System.EventHandler(this.txtFind_TextChanged);
this.txtFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFind_KeyDown);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.lblFind);
this.flowLayoutPanel1.Controls.Add(this.txtFind);
this.flowLayoutPanel1.Controls.Add(this.btnNext);
this.flowLayoutPanel1.Controls.Add(this.brnPrevious);
this.flowLayoutPanel1.Controls.Add(this.btnHighlightAll);
this.flowLayoutPanel1.Controls.Add(this.btnClearHighlights);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(259, 22);
this.flowLayoutPanel1.TabIndex = 4;
this.flowLayoutPanel1.WrapContents = false;
//
// btnNext
//
this.btnNext.AutoSize = true;
this.btnNext.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnNext.BackgroundImage = global::SuperDesign.Properties.Resources.GoToNextMessage;
this.btnNext.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.btnNext.FlatAppearance.BorderSize = 0;
this.btnNext.Image = global::SuperDesign.Properties.Resources.GoToNextMessage;
this.btnNext.Location = new System.Drawing.Point(171, 0);
this.btnNext.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(22, 22);
this.btnNext.TabIndex = 2;
this.toolTip.SetToolTip(this.btnNext, "Find Next");
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// brnPrevious
//
this.brnPrevious.AutoSize = true;
this.brnPrevious.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.brnPrevious.FlatAppearance.BorderSize = 0;
this.brnPrevious.Image = global::SuperDesign.Properties.Resources.GoToPreviousMessage;
this.brnPrevious.Location = new System.Drawing.Point(193, 0);
this.brnPrevious.Margin = new System.Windows.Forms.Padding(0);
this.brnPrevious.Name = "brnPrevious";
this.brnPrevious.Size = new System.Drawing.Size(22, 22);
this.brnPrevious.TabIndex = 3;
this.toolTip.SetToolTip(this.brnPrevious, "Find Previous");
this.brnPrevious.UseVisualStyleBackColor = true;
this.brnPrevious.Click += new System.EventHandler(this.brnPrevious_Click);
//
// btnHighlightAll
//
this.btnHighlightAll.AutoSize = true;
this.btnHighlightAll.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnHighlightAll.BackgroundImage = global::SuperDesign.Properties.Resources.LineColorHS;
this.btnHighlightAll.FlatAppearance.BorderSize = 0;
this.btnHighlightAll.Font = new System.Drawing.Font("Microsoft Sans Serif", 1.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnHighlightAll.ForeColor = System.Drawing.Color.SkyBlue;
this.btnHighlightAll.Image = global::SuperDesign.Properties.Resources.LineColorHS;
this.btnHighlightAll.Location = new System.Drawing.Point(215, 0);
this.btnHighlightAll.Margin = new System.Windows.Forms.Padding(0);
this.btnHighlightAll.Name = "btnHighlightAll";
this.btnHighlightAll.Size = new System.Drawing.Size(22, 22);
this.btnHighlightAll.TabIndex = 4;
this.btnHighlightAll.Text = "&h";
this.toolTip.SetToolTip(this.btnHighlightAll, "Highlight All Matches (ALT+H)");
this.btnHighlightAll.UseVisualStyleBackColor = true;
this.btnHighlightAll.Click += new System.EventHandler(this.btnHighlightAll_Click);
//
// btnClearHighlights
//
this.btnClearHighlights.AutoSize = true;
this.btnClearHighlights.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnClearHighlights.FlatAppearance.BorderSize = 0;
this.btnClearHighlights.Font = new System.Drawing.Font("Microsoft Sans Serif", 1.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClearHighlights.Image = global::SuperDesign.Properties.Resources.DeleteHS;
this.btnClearHighlights.Location = new System.Drawing.Point(237, 0);
this.btnClearHighlights.Margin = new System.Windows.Forms.Padding(0);
this.btnClearHighlights.Name = "btnClearHighlights";
this.btnClearHighlights.Size = new System.Drawing.Size(22, 22);
this.btnClearHighlights.TabIndex = 5;
this.btnClearHighlights.Text = "&j";
this.toolTip.SetToolTip(this.btnClearHighlights, "Clear Highlights (ALT+J)");
this.btnClearHighlights.UseVisualStyleBackColor = true;
this.btnClearHighlights.Click += new System.EventHandler(this.btnClearHighlights_Click);
//
// IncrementalSearcher
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.Color.LightSteelBlue;
this.Controls.Add(this.flowLayoutPanel1);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "IncrementalSearcher";
this.Size = new System.Drawing.Size(259, 22);
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblFind;
private System.Windows.Forms.TextBox txtFind;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button brnPrevious;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnHighlightAll;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Button btnClearHighlights;
}
}
@@ -0,0 +1,294 @@
namespace ScintillaNET_FindReplaceDialog
{
using ScintillaNET;
using ScintillaNET_FindReplaceDialog;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public partial class IncrementalSearcher : UserControl
{
#region Fields
private bool _autoPosition = true;
private Scintilla _scintilla;
private bool _toolItem = false;
private FindReplace _findReplace;
#endregion Fields
#region Constructors
public IncrementalSearcher()
{
InitializeComponent();
}
public IncrementalSearcher(bool toolItem)
{
InitializeComponent();
_toolItem = toolItem;
if (toolItem)
BackColor = Color.Transparent;
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets or sets whether the control should automatically move away from the current
/// selection to prevent obscuring it.
/// </summary>
/// <returns>true to automatically move away from the current selection; otherwise, false.
/// If ToolItem is enabled, this defaults to false.</returns>
public bool AutoPosition
{
get
{
return _autoPosition;
}
set
{
if (!ToolItem)
_autoPosition = value;
else
_autoPosition = false;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public FindReplace FindReplace
{
get
{
return _findReplace;
}
set
{
_findReplace = value;
if (value!=null)
{
_scintilla = _findReplace.Scintilla;
}
else
{
_scintilla = null;
}
}
}
[Browsable(false)]
public Scintilla Scintilla
{
get
{
return _scintilla;
}
set
{
_scintilla = value;
}
}
public bool ToolItem
{
get { return _toolItem; }
set
{
_toolItem = value;
if (_toolItem)
BackColor = Color.Transparent;
else
BackColor = Color.LightSteelBlue;
}
}
#endregion Properties
#region Event Handlers
private void brnPrevious_Click(object sender, EventArgs e)
{
findPrevious();
}
private void btnClearHighlights_Click(object sender, EventArgs e)
{
if (_scintilla == null)
return;
_findReplace.ClearAllHighlights();
}
private void btnHighlightAll_Click(object sender, EventArgs e)
{
if (txtFind.Text == string.Empty)
return;
if (_scintilla == null)
return;
int foundCount = _findReplace.FindAll(txtFind.Text, false, true).Count;
}
private void btnNext_Click(object sender, EventArgs e)
{
findNext();
}
#endregion Event Handlers
#region Methods
public virtual void MoveFormAwayFromSelection()
{
if (!Visible || _scintilla == null)
return;
if (!AutoPosition)
return;
int pos = _scintilla.CurrentPosition;
int x = _scintilla.PointXFromPosition(pos);
int y = _scintilla.PointYFromPosition(pos);
Point cursorPoint = new Point(x, y);
Rectangle r = new Rectangle(Location, Size);
if (_scintilla != null)
{
r.Location = new Point(_scintilla.ClientRectangle.Right - Size.Width, 0);
}
if (r.Contains(cursorPoint))
{
Point newLocation;
if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2))
{
//TODO - replace lineheight with ScintillaNET command, when added
int SCI_TEXTHEIGHT = 2279;
int lineHeight = _scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32();
// Top half of the screen
newLocation = new Point(r.X, cursorPoint.Y + lineHeight * 2);
}
else
{
//TODO - replace lineheight with ScintillaNET command, when added
int SCI_TEXTHEIGHT = 2279;
int lineHeight = _scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32();
// Bottom half of the screen
newLocation = new Point(r.X, cursorPoint.Y - Height - (lineHeight * 2));
}
Location = newLocation;
}
else
{
Location = r.Location;
}
}
protected override void OnCreateControl()
{
base.OnCreateControl();
MoveFormAwayFromSelection();
txtFind.Focus();
}
protected override void OnLeave(EventArgs e)
{
base.OnLostFocus(e);
if (!_toolItem)
Hide();
}
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
txtFind.Text = string.Empty;
txtFind.BackColor = SystemColors.Window;
MoveFormAwayFromSelection();
if (Visible)
txtFind.Focus();
else if (_scintilla != null)
_scintilla.Focus();
}
private void findNext()
{
if (txtFind.Text == string.Empty)
return;
if (_scintilla == null)
return;
ScintillaNET_FindReplaceDialog.CharacterRange r = _findReplace.FindNext(txtFind.Text, true, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
_scintilla.SetSel(r.CpMin, r.CpMax);
MoveFormAwayFromSelection();
}
private void findPrevious()
{
if (txtFind.Text == string.Empty)
return;
if (_scintilla == null)
return;
ScintillaNET_FindReplaceDialog.CharacterRange r = _findReplace.FindPrevious(txtFind.Text, true, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
_scintilla.SetSel(r.CpMin, r.CpMax);
MoveFormAwayFromSelection();
}
private void txtFind_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
case Keys.Down:
findNext();
e.Handled = true;
break;
case Keys.Up:
findPrevious();
e.Handled = true;
break;
case Keys.Escape:
if (!_toolItem)
Hide();
break;
}
}
private void txtFind_TextChanged(object sender, EventArgs e)
{
txtFind.BackColor = SystemColors.Window;
if (txtFind.Text == string.Empty)
return;
if (_scintilla == null)
return;
int pos = Math.Min(_scintilla.CurrentPosition, _scintilla.AnchorPosition);
ScintillaNET_FindReplaceDialog.CharacterRange r = _findReplace.Find(pos, _scintilla.TextLength, txtFind.Text, _findReplace.Window.GetSearchFlags());
if (r.CpMin == r.CpMax)
r = _findReplace.Find(0, pos, txtFind.Text, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
_scintilla.SetSel(r.CpMin, r.CpMax);
else
txtFind.BackColor = Color.Tomato;
MoveFormAwayFromSelection();
}
#endregion Methods
}
}
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -0,0 +1,40 @@
#region Using Directives
using ScintillaNET;
using ScintillaNET_FindReplaceDialog;
using System;
using System.Windows.Forms;
#endregion Using Directives
namespace ScintillaNET_FindReplaceDialog
{
public class ToolStripIncrementalSearcher : ToolStripControlHost
{
#region Properties
public Scintilla Scintilla
{
get { return Searcher.Scintilla; }
set { Searcher.Scintilla = value; }
}
public IncrementalSearcher Searcher
{
get { return Control as IncrementalSearcher; }
}
#endregion Properties
#region Constructors
public ToolStripIncrementalSearcher() : base(new IncrementalSearcher(true))
{
}
#endregion Constructors
}
}