Add project files.

This commit is contained in:
maxwes08
2026-02-24 10:42:19 +01:00
parent 1734b76502
commit e09ab9bf57
6 changed files with 473 additions and 0 deletions

3
Glosor.slnx Normal file
View File

@@ -0,0 +1,3 @@
<Solution>
<Project Path="Glosor/Glosor.csproj" />
</Solution>

188
Glosor/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,188 @@
namespace Glosor
{
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()
{
lst_words = new ListBox();
btn_add = new Button();
tbx_original = new TextBox();
tbx_translation = new TextBox();
btn_start = new Button();
btn_clear = new Button();
lbl_original = new Label();
tbx_input = new TextBox();
btn_skip = new Button();
btn_check = new Button();
lbl_correct = new Label();
SuspendLayout();
//
// lst_words
//
lst_words.FormattingEnabled = true;
lst_words.ItemHeight = 25;
lst_words.Location = new Point(247, 40);
lst_words.Name = "lst_words";
lst_words.Size = new Size(314, 129);
lst_words.TabIndex = 0;
lst_words.Visible = false;
//
// btn_add
//
btn_add.Location = new Point(449, 175);
btn_add.Name = "btn_add";
btn_add.Size = new Size(112, 34);
btn_add.TabIndex = 1;
btn_add.Text = "Lägg till";
btn_add.UseVisualStyleBackColor = true;
btn_add.Visible = false;
btn_add.Click += btn_add_Click;
//
// tbx_original
//
tbx_original.Location = new Point(247, 175);
tbx_original.Name = "tbx_original";
tbx_original.PlaceholderText = "Glosa";
tbx_original.Size = new Size(196, 31);
tbx_original.TabIndex = 2;
tbx_original.Visible = false;
//
// tbx_translation
//
tbx_translation.Location = new Point(247, 212);
tbx_translation.Name = "tbx_translation";
tbx_translation.PlaceholderText = "Översättning";
tbx_translation.Size = new Size(196, 31);
tbx_translation.TabIndex = 3;
tbx_translation.Visible = false;
//
// btn_start
//
btn_start.Location = new Point(449, 215);
btn_start.Name = "btn_start";
btn_start.Size = new Size(112, 34);
btn_start.TabIndex = 4;
btn_start.Text = "Starta Prov";
btn_start.UseVisualStyleBackColor = true;
btn_start.Visible = false;
btn_start.Click += btn_start_Click;
//
// btn_clear
//
btn_clear.Location = new Point(567, 40);
btn_clear.Name = "btn_clear";
btn_clear.Size = new Size(112, 34);
btn_clear.TabIndex = 5;
btn_clear.Text = "Rensa";
btn_clear.UseVisualStyleBackColor = true;
btn_clear.Visible = false;
btn_clear.Click += btn_clear_Click;
//
// lbl_original
//
lbl_original.AutoSize = true;
lbl_original.Location = new Point(345, 99);
lbl_original.Name = "lbl_original";
lbl_original.Size = new Size(59, 25);
lbl_original.TabIndex = 6;
lbl_original.Text = "label1";
lbl_original.TextAlign = ContentAlignment.MiddleLeft;
//
// tbx_input
//
tbx_input.Location = new Point(345, 127);
tbx_input.Name = "tbx_input";
tbx_input.Size = new Size(150, 31);
tbx_input.TabIndex = 7;
tbx_input.TextAlign = HorizontalAlignment.Center;
//
// btn_skip
//
btn_skip.Location = new Point(425, 164);
btn_skip.Name = "btn_skip";
btn_skip.Size = new Size(112, 34);
btn_skip.TabIndex = 8;
btn_skip.Text = "Skippa";
btn_skip.UseVisualStyleBackColor = true;
btn_skip.Click += btn_skip_Click;
//
// btn_check
//
btn_check.Location = new Point(307, 164);
btn_check.Name = "btn_check";
btn_check.Size = new Size(112, 34);
btn_check.TabIndex = 9;
btn_check.Text = "Svara";
btn_check.UseVisualStyleBackColor = true;
btn_check.Click += btn_check_Click;
//
// lbl_correct
//
lbl_correct.AutoSize = true;
lbl_correct.Location = new Point(384, 201);
lbl_correct.Name = "lbl_correct";
lbl_correct.Size = new Size(0, 25);
lbl_correct.TabIndex = 10;
lbl_correct.TextAlign = ContentAlignment.MiddleCenter;
//
// Form1
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(lbl_correct);
Controls.Add(btn_check);
Controls.Add(btn_skip);
Controls.Add(tbx_input);
Controls.Add(lbl_original);
Controls.Add(btn_clear);
Controls.Add(btn_start);
Controls.Add(tbx_translation);
Controls.Add(tbx_original);
Controls.Add(btn_add);
Controls.Add(lst_words);
Name = "Form1";
Text = "Glosor";
ResumeLayout(false);
PerformLayout();
}
#endregion
private ListBox lst_words;
private Button btn_add;
private TextBox tbx_original;
private TextBox tbx_translation;
private Button btn_start;
private Button btn_clear;
private Label lbl_original;
private TextBox tbx_input;
private Button btn_skip;
private Button btn_check;
private Label lbl_correct;
}
}

134
Glosor/Form1.cs Normal file
View File

@@ -0,0 +1,134 @@
namespace Glosor
{
public partial class Form1 : Form
{
public Dictionary<string, string> Words = new Dictionary<string, string>(); // original, translation
int step = 0;
int points = 0;
string correctAnswer;
bool useExampleWords = true;
public Form1()
{
InitializeComponent();
SetEditingMode(true);
AddExampleWords();
}
public void AddExampleWords()
{
if (!useExampleWords) return;
AddWord("Apple", "<22>pple");
AddWord("Banana", "Banan");
AddWord("Orange", "Apelsin");
AddWord("Watermelon", "Vattenmelon");
}
// Actions
public void AddWord(string original, string translation)
{
Words.Add(original, translation);
lst_words.Items.Add(original + " -> " + translation);
}
private void SetEditingMode(bool editing)
{
tbx_translation.Visible = editing;
tbx_original.Visible = editing;
lst_words.Visible = editing;
btn_clear.Visible = editing;
btn_add.Visible = editing;
btn_start.Visible = editing;
lbl_correct.Visible = !editing;
tbx_input.Visible = !editing;
lbl_original.Visible = !editing;
btn_check.Visible = !editing;
btn_skip.Visible = !editing;
}
public void StartTest()
{
SetEditingMode(false);
step = 0;
points = 0;
Question();
}
// Questioning logic
public void Question()
{
if (step == Words.Count)
{
MessageBox.Show("Du fick " + points.ToString() + " av " + Words.Count + " po<70>ng");
SetEditingMode(true);
return;
}
var entry = Words.ElementAt(step);
string original = entry.Key;
correctAnswer = entry.Value.ToLower();
lbl_original.Text = original;
tbx_input.Text = "";
lbl_correct.Text = "";
tbx_input.Focus();
step++;
}
public void Answer()
{
string input = tbx_input.Text.ToLower();
if (input == correctAnswer)
{
points++;
Question();
}
else
{
lbl_correct.Text = "Fel Svar";
}
}
// Buttons
private void btn_add_Click(object sender, EventArgs e)
{
string original = tbx_original.Text;
string translation = tbx_translation.Text;
tbx_original.Text = "";
tbx_translation.Text = "";
AddWord(original, translation);
}
private void btn_clear_Click(object sender, EventArgs e)
{
lst_words.Items.Clear();
Words.Clear();
}
private void btn_start_Click(object sender, EventArgs e)
{
StartTest();
}
private void btn_check_Click(object sender, EventArgs e)
{
Answer();
}
private void btn_skip_Click(object sender, EventArgs e)
{
Question();
}
}
}

120
Glosor/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
Glosor/Glosor.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
Glosor/Program.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace Glosor
{
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());
}
}
}