mirror of
https://github.com/Alvin-Zilverstand/ict-algemeen-opdrachten.git
synced 2026-03-06 21:29:36 +01:00
Translate user prompts and comments to Dutch; delete unused weather log file
This commit is contained in:
@@ -15,8 +15,9 @@ namespace DictionaryApp
|
||||
|
||||
public Program()
|
||||
{
|
||||
// Initialiseer de GUI-componenten
|
||||
wordTextBox = new TextBox { Left = 50, Top = 20, Width = 200 };
|
||||
searchButton = new Button { Text = "Search", Left = 260, Top = 20, Width = 100 };
|
||||
searchButton = new Button { Text = "Zoek", Left = 260, Top = 20, Width = 100 };
|
||||
meaningTextBox = new TextBox { Left = 50, Top = 60, Width = 310, Height = 200, Multiline = true, ScrollBars = ScrollBars.Vertical, ReadOnly = true };
|
||||
|
||||
searchButton.Click += new EventHandler(SearchButton_Click);
|
||||
@@ -27,42 +28,45 @@ namespace DictionaryApp
|
||||
Controls.Add(searchButton);
|
||||
Controls.Add(meaningTextBox);
|
||||
|
||||
Text = "Dictionary";
|
||||
Text = "Woordenboek";
|
||||
Size = new System.Drawing.Size(400, 300);
|
||||
}
|
||||
|
||||
private void Form_Resize(object? sender, EventArgs e)
|
||||
{
|
||||
// Pas de grootte van het tekstvak aan bij het wijzigen van de grootte van het formulier
|
||||
meaningTextBox.Width = this.ClientSize.Width - 100;
|
||||
meaningTextBox.Height = this.ClientSize.Height - 100;
|
||||
}
|
||||
|
||||
private void WordTextBox_KeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
// Zoek bij het indrukken van de Enter-toets
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
SearchButton_Click(this, new EventArgs());
|
||||
e.SuppressKeyPress = true; // Prevent the beep sound on Enter key press
|
||||
e.SuppressKeyPress = true; // Voorkom het piepgeluid bij het indrukken van de Enter-toets
|
||||
}
|
||||
}
|
||||
|
||||
private async void SearchButton_Click(object? sender, EventArgs e)
|
||||
{
|
||||
// Haal de betekenis van het woord op van de API
|
||||
string word = wordTextBox.Text;
|
||||
string? meaning = await GetMeaningFromApi(word);
|
||||
meaningTextBox.Text = meaning ?? "Meaning not found.";
|
||||
meaningTextBox.Text = meaning ?? "Betekenis niet gevonden.";
|
||||
}
|
||||
|
||||
private async Task<string?> GetMeaningFromApi(string word)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Maak een verzoek naar de woordenboek-API
|
||||
string apiUrl = $"https://api.dictionaryapi.dev/api/v2/entries/en/{word}";
|
||||
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
||||
response.EnsureSuccessStatusCode();
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
// Parse the responseBody to extract the meaning
|
||||
// This is a simplified example, you may need to adjust the parsing based on the actual API response format
|
||||
// Parse de JSON-respons om de betekenis te extraheren
|
||||
var json = System.Text.Json.JsonDocument.Parse(responseBody);
|
||||
var meaning = json.RootElement[0].GetProperty("meanings")[0].GetProperty("definitions")[0].GetProperty("definition").GetString();
|
||||
return meaning;
|
||||
@@ -76,6 +80,7 @@ namespace DictionaryApp
|
||||
[STAThread]
|
||||
public static void Main()
|
||||
{
|
||||
// Start de applicatie
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Program());
|
||||
|
||||
Reference in New Issue
Block a user