Refactor dictionary application UI to replace ListBox with TextBox for displaying meanings and enhance responsiveness

This commit is contained in:
vista-man
2025-01-27 22:37:33 +01:00
parent eec73a1d81
commit 29d74ade51
25 changed files with 68 additions and 11 deletions

View File

@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}

View File

@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\Program.cs",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

View File

@@ -0,0 +1,37 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\Woordenboek\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\Woordenboek\\Program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\Woordenboek\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\Woordenboek\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAACsAAAA6AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-01-27T21:20:19.643Z",
"EditorCaption": ""
}
]
}
]
}
]
}

Binary file not shown.

View File

@@ -10,26 +10,33 @@ namespace DictionaryApp
{ {
private TextBox wordTextBox; private TextBox wordTextBox;
private Button searchButton; private Button searchButton;
private ListBox meaningListBox; private TextBox meaningTextBox;
private static readonly HttpClient client = new HttpClient(); private static readonly HttpClient client = new HttpClient();
public Program() public Program()
{ {
wordTextBox = new TextBox { Left = 50, Top = 20, Width = 200 }; wordTextBox = new TextBox { Left = 50, Top = 20, Width = 200 };
searchButton = new Button { Text = "Search", Left = 260, Top = 20, Width = 100 }; searchButton = new Button { Text = "Search", Left = 260, Top = 20, Width = 100 };
meaningListBox = new ListBox { Left = 50, Top = 60, Width = 310, Height = 200 }; meaningTextBox = new TextBox { Left = 50, Top = 60, Width = 310, Height = 200, Multiline = true, ScrollBars = ScrollBars.Vertical, ReadOnly = true };
searchButton.Click += new EventHandler(SearchButton_Click); searchButton.Click += new EventHandler(SearchButton_Click);
wordTextBox.KeyDown += new KeyEventHandler(WordTextBox_KeyDown); wordTextBox.KeyDown += new KeyEventHandler(WordTextBox_KeyDown);
this.Resize += new EventHandler(Form_Resize);
Controls.Add(wordTextBox); Controls.Add(wordTextBox);
Controls.Add(searchButton); Controls.Add(searchButton);
Controls.Add(meaningListBox); Controls.Add(meaningTextBox);
Text = "Dictionary"; Text = "Dictionary";
Size = new System.Drawing.Size(400, 300); Size = new System.Drawing.Size(400, 300);
} }
private void Form_Resize(object? sender, EventArgs e)
{
meaningTextBox.Width = this.ClientSize.Width - 100;
meaningTextBox.Height = this.ClientSize.Height - 100;
}
private void WordTextBox_KeyDown(object? sender, KeyEventArgs e) private void WordTextBox_KeyDown(object? sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)
@@ -43,8 +50,7 @@ namespace DictionaryApp
{ {
string word = wordTextBox.Text; string word = wordTextBox.Text;
string? meaning = await GetMeaningFromApi(word); string? meaning = await GetMeaningFromApi(word);
meaningListBox.Items.Clear(); meaningTextBox.Text = meaning ?? "Meaning not found.";
meaningListBox.Items.Add(meaning ?? "Meaning not found.");
} }
private async Task<string?> GetMeaningFromApi(string word) private async Task<string?> GetMeaningFromApi(string word)

View File

@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("woordenboek")] [assembly: System.Reflection.AssemblyCompanyAttribute("woordenboek")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ca3a62d7744d2cbad686550a04e7f0edbf1507ba")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eec73a1d812ba8f40afe25e7bab003bd3de2082e")]
[assembly: System.Reflection.AssemblyProductAttribute("woordenboek")] [assembly: System.Reflection.AssemblyProductAttribute("woordenboek")]
[assembly: System.Reflection.AssemblyTitleAttribute("woordenboek")] [assembly: System.Reflection.AssemblyTitleAttribute("woordenboek")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
7fdaf72c06cd35ed008236cce24530d9814f5189d5f4d6d7744da073e9b12c9f bb38180e7c0587398b52330abb0ba9f085212ca0fc463348c895233de61d85cf

View File

@@ -1 +1 @@
{"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/ca3a62d7744d2cbad686550a04e7f0edbf1507ba/*"}} {"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/eec73a1d812ba8f40afe25e7bab003bd3de2082e/*"}}

View File

@@ -1660,12 +1660,14 @@
], ],
"configFilePaths": [ "configFilePaths": [
"C:\\Users\\steen\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Users\\steen\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config" "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
], ],
"originalTargetFrameworks": [ "originalTargetFrameworks": [
"net9.0-windows" "net9.0-windows"
], ],
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {

View File

@@ -1,6 +1,6 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "1CfoT9DKTd4=", "dgSpecHash": "e87e08pxRQc=",
"success": true, "success": true,
"projectFilePath": "C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\woordenboek\\woordenboek.csproj", "projectFilePath": "C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\Csharp\\woordenboek\\woordenboek.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [

View File

@@ -18,12 +18,14 @@
], ],
"configFilePaths": [ "configFilePaths": [
"C:\\Users\\steen\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Users\\steen\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config" "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
], ],
"originalTargetFrameworks": [ "originalTargetFrameworks": [
"net9.0-windows" "net9.0-windows"
], ],
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {