Add project files.

This commit is contained in:
maxwes08
2026-01-19 11:00:58 +01:00
parent f11f90ac4c
commit a6cebe27e6
6 changed files with 379 additions and 0 deletions

135
Metoder/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,135 @@
namespace Metoder
{
partial class Form1
{
/// <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()
{
btn_find = new Button();
txtbx_find = new TextBox();
btn_clear = new Button();
lbl_found = new Label();
txtbx_text = new RichTextBox();
txbx_replace = new TextBox();
btn_replace = new Button();
SuspendLayout();
//
// btn_find
//
btn_find.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btn_find.Location = new Point(676, 6);
btn_find.Name = "btn_find";
btn_find.Size = new Size(112, 34);
btn_find.TabIndex = 1;
btn_find.Text = "Find";
btn_find.UseVisualStyleBackColor = true;
btn_find.Click += btn_find_Click;
//
// txtbx_find
//
txtbx_find.Anchor = AnchorStyles.Top | AnchorStyles.Right;
txtbx_find.Location = new Point(520, 6);
txtbx_find.Name = "txtbx_find";
txtbx_find.PlaceholderText = "Search text";
txtbx_find.Size = new Size(150, 31);
txtbx_find.TabIndex = 2;
//
// btn_clear
//
btn_clear.Location = new Point(12, 9);
btn_clear.Name = "btn_clear";
btn_clear.Size = new Size(112, 34);
btn_clear.TabIndex = 3;
btn_clear.Text = "Clear";
btn_clear.UseVisualStyleBackColor = true;
btn_clear.Click += btn_clear_Click;
//
// lbl_found
//
lbl_found.Anchor = AnchorStyles.Top | AnchorStyles.Right;
lbl_found.AutoSize = true;
lbl_found.Location = new Point(676, 44);
lbl_found.Name = "lbl_found";
lbl_found.Size = new Size(108, 25);
lbl_found.TabIndex = 4;
lbl_found.Text = "items found";
lbl_found.Visible = false;
//
// txtbx_text
//
txtbx_text.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
txtbx_text.Location = new Point(12, 72);
txtbx_text.Name = "txtbx_text";
txtbx_text.Size = new Size(776, 352);
txtbx_text.TabIndex = 5;
txtbx_text.Text = "";
//
// txbx_replace
//
txbx_replace.Location = new Point(171, 8);
txbx_replace.Name = "txbx_replace";
txbx_replace.PlaceholderText = "Replace found text with";
txbx_replace.Size = new Size(197, 31);
txbx_replace.TabIndex = 6;
//
// btn_replace
//
btn_replace.Location = new Point(374, 6);
btn_replace.Name = "btn_replace";
btn_replace.Size = new Size(112, 34);
btn_replace.TabIndex = 7;
btn_replace.Text = "Replace found";
btn_replace.UseVisualStyleBackColor = true;
btn_replace.Click += btn_replace_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(btn_replace);
Controls.Add(txbx_replace);
Controls.Add(txtbx_text);
Controls.Add(lbl_found);
Controls.Add(btn_clear);
Controls.Add(txtbx_find);
Controls.Add(btn_find);
Name = "Form1";
Text = "TextChecker";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button btn_find;
private TextBox txtbx_find;
private Button btn_clear;
private Label lbl_found;
private RichTextBox txtbx_text;
private TextBox txbx_replace;
private Button btn_replace;
}
}

93
Metoder/Form1.cs Normal file
View File

@@ -0,0 +1,93 @@
using System;
using System.Net.Security;
using System.Reflection;
using static System.Net.Mime.MediaTypeNames;
namespace Metoder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn_find_Click(object sender, EventArgs e)
{
string searchWord = txtbx_find.Text;
Highlight(searchWord);
}
private void btn_clear_Click(object sender, EventArgs e)
{
lbl_found.Visible = false;
}
void UpdateFindResult(int foundCount)
{
lbl_found.Visible = true;
string suffix;
// correct grammar
if (foundCount == 1)
suffix = " item found";
else
suffix = " items found";
lbl_found.Text = foundCount.ToString() + suffix;
}
(int start, int length) FindTextIndex(string text, int startIndex)
{
int start = (text.IndexOf(text, startIndex, StringComparison.OrdinalIgnoreCase));
if (start == -1) return (-1, 0);
return (start, text.Length);
}
void Highlight(string word)
{
if (word == "") return; // avoid errors, infinite loop
RichTextBox richTextBox = txtbx_text;
string text = richTextBox.Text;
// reset old highlight
richTextBox.SelectAll();
richTextBox.SelectionBackColor = richTextBox.BackColor;
int found = 0;
int caret = richTextBox.SelectionStart; // set cursor
var words = GetWords();
int index = 0;
while ((index = text.IndexOf(word, index, StringComparison.OrdinalIgnoreCase)) != -1)
{
richTextBox.Select(index, word.Length); // select word
richTextBox.SelectionBackColor = Color.LightBlue;
found++; // count found
index = index + word.Length; // offset (ignore word next loop)
}
// reset cursor
richTextBox.Select(caret, 0);
// update find label
UpdateFindResult(found);
}
List<string> GetWords() // get list of words separated by spaces
{
string text = txtbx_text.Text;
string[] words = text.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
return words.ToList();
}
private void btn_replace_Click(object sender, EventArgs e)
{
}
}
}

120
Metoder/Form1.resx Normal file
View File

@@ -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>

11
Metoder/Metoder.csproj Normal file
View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

17
Metoder/Program.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace Metoder
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}