Initialize
This commit is contained in:
commit
3ba0690174
BIN
.vs/Test_SearchAndFind.git/v16/.suo
Normal file
BIN
.vs/Test_SearchAndFind.git/v16/.suo
Normal file
Binary file not shown.
25
Test_SearchAndFind.git.sln
Normal file
25
Test_SearchAndFind.git.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30413.136
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_SearchAndFind", "Test_SearchAndFind\Test_SearchAndFind.csproj", "{866F66E5-8525-4F23-B31E-969C083A343B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{866F66E5-8525-4F23-B31E-969C083A343B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{866F66E5-8525-4F23-B31E-969C083A343B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{866F66E5-8525-4F23-B31E-969C083A343B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{866F66E5-8525-4F23-B31E-969C083A343B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0099A69B-4400-4B11-95FA-D55A082C8E22}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
Test_SearchAndFind/App.config
Normal file
6
Test_SearchAndFind/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
247
Test_SearchAndFind/Form1.Designer.cs
generated
Normal file
247
Test_SearchAndFind/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,247 @@
|
||||
namespace Test_SearchAndFind
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Erforderliche Designervariable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Verwendete Ressourcen bereinigen.
|
||||
/// </summary>
|
||||
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Vom Windows Form-Designer generierter Code
|
||||
|
||||
/// <summary>
|
||||
/// Erforderliche Methode für die Designerunterstützung.
|
||||
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.textBoxText = new System.Windows.Forms.TextBox();
|
||||
this.groupBoxSearchAndFind = new System.Windows.Forms.GroupBox();
|
||||
this.buttonSelectAll = new System.Windows.Forms.Button();
|
||||
this.checkBoxFullword = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxCase = new System.Windows.Forms.CheckBox();
|
||||
this.buttonPrevious = new System.Windows.Forms.Button();
|
||||
this.buttonNext = new System.Windows.Forms.Button();
|
||||
this.textBoxSearchstring = new System.Windows.Forms.TextBox();
|
||||
this.labelSearchstring = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.buttonReplaceAll = new System.Windows.Forms.Button();
|
||||
this.buttonReplace = new System.Windows.Forms.Button();
|
||||
this.textBoxReplacementString = new System.Windows.Forms.TextBox();
|
||||
this.labelReplaceText = new System.Windows.Forms.Label();
|
||||
this.groupBoxSearchAndFind.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxText
|
||||
//
|
||||
this.textBoxText.Location = new System.Drawing.Point(12, 13);
|
||||
this.textBoxText.Multiline = true;
|
||||
this.textBoxText.Name = "textBoxText";
|
||||
this.textBoxText.Size = new System.Drawing.Size(375, 425);
|
||||
this.textBoxText.TabIndex = 0;
|
||||
this.textBoxText.Text = resources.GetString("textBoxText.Text");
|
||||
//
|
||||
// groupBoxSearchAndFind
|
||||
//
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.buttonSelectAll);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.checkBoxFullword);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.checkBoxCase);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.buttonPrevious);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.buttonNext);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.textBoxSearchstring);
|
||||
this.groupBoxSearchAndFind.Controls.Add(this.labelSearchstring);
|
||||
this.groupBoxSearchAndFind.Location = new System.Drawing.Point(395, 13);
|
||||
this.groupBoxSearchAndFind.Name = "groupBoxSearchAndFind";
|
||||
this.groupBoxSearchAndFind.Size = new System.Drawing.Size(393, 123);
|
||||
this.groupBoxSearchAndFind.TabIndex = 10;
|
||||
this.groupBoxSearchAndFind.TabStop = false;
|
||||
this.groupBoxSearchAndFind.Text = "Suchen";
|
||||
//
|
||||
// buttonSelectAll
|
||||
//
|
||||
this.buttonSelectAll.Enabled = false;
|
||||
this.buttonSelectAll.Location = new System.Drawing.Point(289, 91);
|
||||
this.buttonSelectAll.Name = "buttonSelectAll";
|
||||
this.buttonSelectAll.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonSelectAll.TabIndex = 12;
|
||||
this.buttonSelectAll.Text = "Alle Auswählen";
|
||||
this.buttonSelectAll.UseVisualStyleBackColor = true;
|
||||
this.buttonSelectAll.Click += new System.EventHandler(this.buttonSelectAll_Click);
|
||||
//
|
||||
// checkBoxFullword
|
||||
//
|
||||
this.checkBoxFullword.AutoSize = true;
|
||||
this.checkBoxFullword.Location = new System.Drawing.Point(6, 68);
|
||||
this.checkBoxFullword.Name = "checkBoxFullword";
|
||||
this.checkBoxFullword.Size = new System.Drawing.Size(88, 17);
|
||||
this.checkBoxFullword.TabIndex = 4;
|
||||
this.checkBoxFullword.Text = "Ganzes Wort";
|
||||
this.checkBoxFullword.UseVisualStyleBackColor = true;
|
||||
this.checkBoxFullword.CheckedChanged += new System.EventHandler(this.checkBoxFullword_CheckedChanged);
|
||||
//
|
||||
// checkBoxCase
|
||||
//
|
||||
this.checkBoxCase.AutoSize = true;
|
||||
this.checkBoxCase.Location = new System.Drawing.Point(6, 45);
|
||||
this.checkBoxCase.Name = "checkBoxCase";
|
||||
this.checkBoxCase.Size = new System.Drawing.Size(181, 17);
|
||||
this.checkBoxCase.TabIndex = 3;
|
||||
this.checkBoxCase.Text = "Groß-/Kleinschreibung ignorieren";
|
||||
this.checkBoxCase.UseVisualStyleBackColor = true;
|
||||
this.checkBoxCase.CheckedChanged += new System.EventHandler(this.checkBoxCase_CheckedChanged);
|
||||
//
|
||||
// buttonPrevious
|
||||
//
|
||||
this.buttonPrevious.Location = new System.Drawing.Point(6, 91);
|
||||
this.buttonPrevious.Name = "buttonPrevious";
|
||||
this.buttonPrevious.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonPrevious.TabIndex = 5;
|
||||
this.buttonPrevious.Text = "Vorheriger Treffer";
|
||||
this.buttonPrevious.UseVisualStyleBackColor = true;
|
||||
this.buttonPrevious.Click += new System.EventHandler(this.buttonPrevious_Click);
|
||||
//
|
||||
// buttonNext
|
||||
//
|
||||
this.buttonNext.Location = new System.Drawing.Point(147, 91);
|
||||
this.buttonNext.Name = "buttonNext";
|
||||
this.buttonNext.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonNext.TabIndex = 6;
|
||||
this.buttonNext.Text = "Nächster Treffer";
|
||||
this.buttonNext.UseVisualStyleBackColor = true;
|
||||
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
|
||||
//
|
||||
// textBoxSearchstring
|
||||
//
|
||||
this.textBoxSearchstring.Location = new System.Drawing.Point(61, 19);
|
||||
this.textBoxSearchstring.Name = "textBoxSearchstring";
|
||||
this.textBoxSearchstring.Size = new System.Drawing.Size(326, 20);
|
||||
this.textBoxSearchstring.TabIndex = 1;
|
||||
this.textBoxSearchstring.TextChanged += new System.EventHandler(this.textBoxSearchstring_TextChanged);
|
||||
this.textBoxSearchstring.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxSearchstring_KeyDown);
|
||||
//
|
||||
// labelSearchstring
|
||||
//
|
||||
this.labelSearchstring.AutoSize = true;
|
||||
this.labelSearchstring.Location = new System.Drawing.Point(6, 22);
|
||||
this.labelSearchstring.Name = "labelSearchstring";
|
||||
this.labelSearchstring.Size = new System.Drawing.Size(49, 13);
|
||||
this.labelSearchstring.TabIndex = 0;
|
||||
this.labelSearchstring.Text = "Suchtext";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.button1);
|
||||
this.groupBox1.Controls.Add(this.buttonReplaceAll);
|
||||
this.groupBox1.Controls.Add(this.buttonReplace);
|
||||
this.groupBox1.Controls.Add(this.textBoxReplacementString);
|
||||
this.groupBox1.Controls.Add(this.labelReplaceText);
|
||||
this.groupBox1.Location = new System.Drawing.Point(395, 143);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(393, 77);
|
||||
this.groupBox1.TabIndex = 11;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Ersetzen durch";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Enabled = false;
|
||||
this.button1.Location = new System.Drawing.Point(147, 46);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(98, 23);
|
||||
this.button1.TabIndex = 13;
|
||||
this.button1.Text = "Überspringen";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonReplaceAll
|
||||
//
|
||||
this.buttonReplaceAll.Location = new System.Drawing.Point(289, 46);
|
||||
this.buttonReplaceAll.Name = "buttonReplaceAll";
|
||||
this.buttonReplaceAll.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonReplaceAll.TabIndex = 8;
|
||||
this.buttonReplaceAll.Text = "Alle Ersetzen";
|
||||
this.buttonReplaceAll.UseVisualStyleBackColor = true;
|
||||
this.buttonReplaceAll.Click += new System.EventHandler(this.buttonReplaceAll_Click);
|
||||
//
|
||||
// buttonReplace
|
||||
//
|
||||
this.buttonReplace.Location = new System.Drawing.Point(6, 46);
|
||||
this.buttonReplace.Name = "buttonReplace";
|
||||
this.buttonReplace.Size = new System.Drawing.Size(98, 23);
|
||||
this.buttonReplace.TabIndex = 7;
|
||||
this.buttonReplace.Text = "Ersetzen";
|
||||
this.buttonReplace.UseVisualStyleBackColor = true;
|
||||
this.buttonReplace.Click += new System.EventHandler(this.buttonReplace_Click);
|
||||
//
|
||||
// textBoxReplacementString
|
||||
//
|
||||
this.textBoxReplacementString.Location = new System.Drawing.Point(65, 20);
|
||||
this.textBoxReplacementString.Name = "textBoxReplacementString";
|
||||
this.textBoxReplacementString.Size = new System.Drawing.Size(322, 20);
|
||||
this.textBoxReplacementString.TabIndex = 2;
|
||||
this.textBoxReplacementString.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxReplaceText_KeyDown);
|
||||
//
|
||||
// labelReplaceText
|
||||
//
|
||||
this.labelReplaceText.AutoSize = true;
|
||||
this.labelReplaceText.Location = new System.Drawing.Point(6, 23);
|
||||
this.labelReplaceText.Name = "labelReplaceText";
|
||||
this.labelReplaceText.Size = new System.Drawing.Size(53, 13);
|
||||
this.labelReplaceText.TabIndex = 0;
|
||||
this.labelReplaceText.Text = "Ersetztext";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.groupBoxSearchAndFind);
|
||||
this.Controls.Add(this.textBoxText);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Test_Search, Find and Replace";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.groupBoxSearchAndFind.ResumeLayout(false);
|
||||
this.groupBoxSearchAndFind.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBoxText;
|
||||
private System.Windows.Forms.GroupBox groupBoxSearchAndFind;
|
||||
private System.Windows.Forms.Button buttonPrevious;
|
||||
private System.Windows.Forms.Button buttonNext;
|
||||
private System.Windows.Forms.TextBox textBoxSearchstring;
|
||||
private System.Windows.Forms.Label labelSearchstring;
|
||||
private System.Windows.Forms.CheckBox checkBoxCase;
|
||||
private System.Windows.Forms.CheckBox checkBoxFullword;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button buttonReplaceAll;
|
||||
private System.Windows.Forms.Button buttonReplace;
|
||||
private System.Windows.Forms.TextBox textBoxReplacementString;
|
||||
private System.Windows.Forms.Label labelReplaceText;
|
||||
private System.Windows.Forms.Button buttonSelectAll;
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
||||
|
||||
236
Test_SearchAndFind/Form1.cs
Normal file
236
Test_SearchAndFind/Form1.cs
Normal file
@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Test_SearchAndFind
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
#region Version und Copyright
|
||||
// Version und Copyright
|
||||
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
|
||||
string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
||||
string copyright = GenerateCopyright();
|
||||
string icon = Application.StartupPath + "\\Info.bmp";
|
||||
//Assembly Datum und Zeit
|
||||
static DateTime value = AssemblyDateTime();
|
||||
string date = value.ToShortDateString();
|
||||
string time = value.ToLongTimeString();
|
||||
private static DateTime AssemblyDateTime()
|
||||
{
|
||||
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||
//Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
|
||||
return buildDateTime;
|
||||
}
|
||||
|
||||
private static string CurrentYear()
|
||||
{
|
||||
DateTime dtn = DateTime.Now;
|
||||
return dtn.Year.ToString();
|
||||
}
|
||||
|
||||
private static string StartYear()
|
||||
{
|
||||
string startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
||||
return startYear.Remove(0, startYear.LastIndexOf(" ") + 1);
|
||||
}
|
||||
|
||||
private static string GenerateCopyright()
|
||||
{
|
||||
string startYear = StartYear();
|
||||
string currentYear = CurrentYear();
|
||||
|
||||
if (startYear == currentYear)
|
||||
{
|
||||
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Concat(((AssemblyCopyrightAttribute)attributes[0]).Copyright, "-", currentYear);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Programm-Info
|
||||
/// <summary>
|
||||
/// Contains the name of the program file
|
||||
/// </summary>
|
||||
public static string ProgramName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the version of the program file
|
||||
/// </summary>
|
||||
public static string ProgramVersion { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the copyright notice
|
||||
/// </summary>
|
||||
public static string Copyright { set; get; }
|
||||
|
||||
private void SetProgramInfo()
|
||||
{
|
||||
//Name, Version und Copyright setzen
|
||||
ProgramName = programName;
|
||||
ProgramVersion = programVersion;
|
||||
Copyright = copyright;
|
||||
}
|
||||
#endregion
|
||||
public Form1()
|
||||
{
|
||||
SetProgramInfo();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Text = String.Concat("Test_Search, Find and Replace - Version: ", ProgramVersion, " - ", Copyright, " by E. Höglinger");
|
||||
textBoxText.Focus();
|
||||
textBoxText.Select(0, 0);
|
||||
|
||||
//textBoxSearchstring.Focus();
|
||||
//textBoxSearchstring.Text = "";
|
||||
this.ActiveControl = textBoxSearchstring;
|
||||
}
|
||||
|
||||
Search search = new Search();
|
||||
|
||||
private void SearchAndSelect()
|
||||
{
|
||||
try
|
||||
{
|
||||
search.StartSearch(textBoxText.Text, textBoxSearchstring.Text, checkBoxCase.Checked, checkBoxFullword.Checked);
|
||||
if (!search.Error)
|
||||
{
|
||||
SelectSearchString(search.CurrentCursorPosition, textBoxSearchstring.Text.Length);
|
||||
}
|
||||
}
|
||||
catch (StringNotMatchException)
|
||||
{
|
||||
MessageBox.Show("Suchstring wurde nicht gefunden!");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Unbekannter Fehler passiert!");
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectSearchString(int position, int length)
|
||||
{
|
||||
textBoxText.Focus();
|
||||
textBoxText.Select(position, length);
|
||||
textBoxText.Refresh();
|
||||
}
|
||||
|
||||
private void NextPosition()
|
||||
{
|
||||
search.NextPosition();
|
||||
SelectSearchString(search.CurrentCursorPosition, textBoxSearchstring.Text.Length);
|
||||
}
|
||||
|
||||
private void PreviousPosition()
|
||||
{
|
||||
search.PreviousPosition();
|
||||
SelectSearchString(search.CurrentCursorPosition, textBoxSearchstring.Text.Length);
|
||||
}
|
||||
|
||||
private void SelectAll()
|
||||
{
|
||||
//TODO: Select All
|
||||
}
|
||||
|
||||
Replace replace = new Replace();
|
||||
private void ReplaceString()
|
||||
{
|
||||
textBoxText.Text = replace.ReplaceString(textBoxText.Text, textBoxSearchstring.Text, textBoxReplacementString.Text, search.CurrentCursorPosition);
|
||||
textBoxText.Refresh();
|
||||
|
||||
SearchAndSelect();
|
||||
}
|
||||
|
||||
private void ReplaceAll()
|
||||
{
|
||||
List<int> newList = new List<int>();
|
||||
newList = search.AllPositions;
|
||||
newList.Reverse();
|
||||
|
||||
foreach (var item in newList)
|
||||
{
|
||||
textBoxText.Text = replace.ReplaceString(textBoxText.Text, textBoxSearchstring.Text, textBoxReplacementString.Text, item);
|
||||
textBoxText.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxSearchstring_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
SearchAndSelect();
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxSearchstring_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//TODO: Nichts tun
|
||||
}
|
||||
|
||||
private void checkBoxCase_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(textBoxSearchstring.Text))
|
||||
{
|
||||
SearchAndSelect();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBoxFullword_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(textBoxSearchstring.Text))
|
||||
{
|
||||
SearchAndSelect();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonPrevious_Click(object sender, EventArgs e)
|
||||
{
|
||||
PreviousPosition();
|
||||
}
|
||||
|
||||
private void buttonNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
NextPosition();
|
||||
}
|
||||
|
||||
private void buttonSelectAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectAll();
|
||||
}
|
||||
|
||||
private void textBoxReplaceText_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
textBoxText.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonReplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
ReplaceString();
|
||||
}
|
||||
|
||||
private void buttonReplaceAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
ReplaceAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
129
Test_SearchAndFind/Form1.resx
Normal file
129
Test_SearchAndFind/Form1.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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>
|
||||
<data name="textBoxText.Text" xml:space="preserve">
|
||||
<value>Das ist ein Probetext. Er dient zum Testen einer Suchen und Finden Funktion.
|
||||
Wird ein angegebener Suchstring im Text gefunden, dann wird die Textstelle selektiert.
|
||||
Ist der Suchstring nicht im Text enthalten, dann wird eine Meldung ausgegeben.
|
||||
Mit "Nächster Treffer" wird im Text nach dem nächsten Vorkommen des Suchstrings gesucht. Wird ein weiteres Vorkommen gefunden, dann wird die Textstelle markiert.
|
||||
"Vorheriger Treffer" hat die gleiche Funktion wie "Nächster", nur ist die Suchrichtung rückwärts.
|
||||
Die Anderen Optionen müssen noch definiert werden.
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
22
Test_SearchAndFind/Program.cs
Normal file
22
Test_SearchAndFind/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Test_SearchAndFind
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Test_SearchAndFind/Properties/AssemblyInfo.cs
Normal file
36
Test_SearchAndFind/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("Test_SearchAndFind")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Test_SearchAndFind")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("866f66e5-8525-4f23-b31e-969c083a343b")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
Test_SearchAndFind/Properties/Resources.Designer.cs
generated
Normal file
71
Test_SearchAndFind/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion: 4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code neu generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Test_SearchAndFind.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
|
||||
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_SearchAndFind.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Test_SearchAndFind/Properties/Resources.resx
Normal file
117
Test_SearchAndFind/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?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.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: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" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</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" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
Test_SearchAndFind/Properties/Settings.Designer.cs
generated
Normal file
30
Test_SearchAndFind/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Test_SearchAndFind.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Test_SearchAndFind/Properties/Settings.settings
Normal file
7
Test_SearchAndFind/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
23
Test_SearchAndFind/Replace.cs
Normal file
23
Test_SearchAndFind/Replace.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Test_SearchAndFind
|
||||
{
|
||||
class Replace
|
||||
{
|
||||
public Replace()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Search search = new Search();
|
||||
|
||||
public string ReplaceString(string text, string searchString, string textBoxReplacementString, int currentCursorPosition)
|
||||
{
|
||||
return text.Remove(currentCursorPosition, searchString.Length).Insert(currentCursorPosition, textBoxReplacementString);
|
||||
}
|
||||
}
|
||||
}
|
||||
171
Test_SearchAndFind/Search.cs
Normal file
171
Test_SearchAndFind/Search.cs
Normal file
@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Test_SearchAndFind
|
||||
{
|
||||
/// <summary>
|
||||
/// Searches the specified string in a text
|
||||
/// </summary>
|
||||
class Search
|
||||
{
|
||||
public void StartSearch(string text, string searchString, bool noCaseSensitve, bool onlyFullWord)
|
||||
{
|
||||
Text = text;
|
||||
SearchString = searchString;
|
||||
NoCaseSensitve = noCaseSensitve;
|
||||
OnlyFullWord = onlyFullWord;
|
||||
|
||||
SearchEntities();
|
||||
if (!Error)
|
||||
{
|
||||
CurrentCursorPosition = AllPositions[0];
|
||||
Index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Suchstring wurde nicht gefunden
|
||||
throw new StringNotMatchException();
|
||||
}
|
||||
}
|
||||
|
||||
private string Text { set; get; }
|
||||
private string SearchString { set; get; }
|
||||
private bool NoCaseSensitve { set; get; }
|
||||
private bool OnlyFullWord { set; get; }
|
||||
public int Index { private set; get; }
|
||||
/// <summary>
|
||||
/// Contains the current cursor position
|
||||
/// </summary>
|
||||
public int CurrentCursorPosition { private set; get; }
|
||||
/// <summary>
|
||||
/// Contains a list with all found positions
|
||||
/// </summary>
|
||||
public List<int> AllPositions { private set; get; }
|
||||
/// <summary>
|
||||
/// Is true if an error has occurred
|
||||
/// </summary>
|
||||
public bool Error { private set; get; }
|
||||
|
||||
private void SearchEntities()
|
||||
{
|
||||
Error = false;
|
||||
|
||||
string text = Text;
|
||||
string searchString = SearchString;
|
||||
|
||||
if (NoCaseSensitve)
|
||||
{
|
||||
//Groß-/Kleinschreibung ignorieren
|
||||
text = text.ToLower();
|
||||
searchString = searchString.ToLower();
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(searchString) && text.Contains(searchString))
|
||||
{
|
||||
AllPositions = Positions(text, searchString);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = true;
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> Positions(string text, string searchString)
|
||||
{
|
||||
List<int> positions = new List<int>();
|
||||
|
||||
if (String.IsNullOrEmpty(text) || String.IsNullOrEmpty(searchString))
|
||||
{
|
||||
return positions;
|
||||
}
|
||||
|
||||
int position = 0;
|
||||
int currentPos = 0;
|
||||
|
||||
while (text.Contains(searchString))
|
||||
{
|
||||
if (OnlyFullWord)
|
||||
{
|
||||
//Nur ganzes Wort suchen
|
||||
currentPos = IndexOfWord(text, searchString);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Suchstring suchen
|
||||
currentPos = text.IndexOf(searchString);
|
||||
}
|
||||
|
||||
position += currentPos;
|
||||
positions.Add(position);
|
||||
position += searchString.Length;
|
||||
|
||||
text = text.Remove(0, currentPos + searchString.Length);
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
private Regex myRegex;
|
||||
|
||||
private int IndexOfWord(string myString, string myWord)
|
||||
{
|
||||
myRegex = new Regex("\\b" + Regex.Escape(myWord) + "\\b", RegexOptions.Compiled);
|
||||
|
||||
Match mtch = myRegex.Match(myString);
|
||||
|
||||
if (mtch.Success)
|
||||
return mtch.Index;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Jumps to the next occurrence position
|
||||
/// </summary>
|
||||
public void NextPosition()
|
||||
{
|
||||
if (Index + 1 < AllPositions.Count)
|
||||
{
|
||||
Index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Index = 0;
|
||||
}
|
||||
CurrentCursorPosition = AllPositions[Index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Jumps to previous occurrence position
|
||||
/// </summary>
|
||||
public void PreviousPosition()
|
||||
{
|
||||
if (Index > 0)
|
||||
{
|
||||
Index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
Index = AllPositions.Count - 1;
|
||||
}
|
||||
CurrentCursorPosition = AllPositions[Index];
|
||||
}
|
||||
}
|
||||
|
||||
#region Exceptions
|
||||
public class StringNotMatchException : Exception
|
||||
{
|
||||
public StringNotMatchException() { }
|
||||
|
||||
public StringNotMatchException(string message)
|
||||
: base(message) { }
|
||||
|
||||
public StringNotMatchException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
85
Test_SearchAndFind/Test_SearchAndFind.csproj
Normal file
85
Test_SearchAndFind/Test_SearchAndFind.csproj
Normal file
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{866F66E5-8525-4F23-B31E-969C083A343B}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Test_SearchAndFind</RootNamespace>
|
||||
<AssemblyName>Test_SearchAndFind</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>false</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Replace.cs" />
|
||||
<Compile Include="Search.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
BIN
Test_SearchAndFind/bin/Debug/Test_SearchAndFind.exe
Normal file
BIN
Test_SearchAndFind/bin/Debug/Test_SearchAndFind.exe
Normal file
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
Test_SearchAndFind/bin/Debug/Test_SearchAndFind.pdb
Normal file
BIN
Test_SearchAndFind/bin/Debug/Test_SearchAndFind.pdb
Normal file
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
||||
Binary file not shown.
Binary file not shown.
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.Form1.resources
Normal file
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.Form1.resources
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
a5725c5ac4ec3b009961fe601e1d6dd207d7a621
|
||||
@ -0,0 +1,20 @@
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.exe.config
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.exe
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.pdb
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csprojAssemblyReference.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.Form1.resources
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.Properties.Resources.resources
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csproj.GenerateResource.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csproj.CoreCompileInputs.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.exe
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.pdb
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.exe.config
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.exe
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\bin\Debug\Test_SearchAndFind.pdb
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csprojAssemblyReference.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.Form1.resources
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.Properties.Resources.resources
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csproj.GenerateResource.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.csproj.CoreCompileInputs.cache
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.exe
|
||||
H:\Programmieren\Git-Repository\VisualStudio\2017\_TEST\Test_SearchAndFind_V2.git\Test_SearchAndFind\obj\Debug\Test_SearchAndFind.pdb
|
||||
Binary file not shown.
Binary file not shown.
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.exe
Normal file
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.exe
Normal file
Binary file not shown.
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.pdb
Normal file
BIN
Test_SearchAndFind/obj/Debug/Test_SearchAndFind.pdb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user