using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq; namespace VirtualKeyboard { public partial class QwertzKeyboard : Form { public event EventHandler KeyBoardShown; public event EventHandler KeyBoardClosed; private TextBox targetTextBox; //private Button okBtn; private bool isNumeric = false; private bool isCalc = false; private bool isShift = false; private Screen screen = Screen.PrimaryScreen; // Erweiterte keys auf mehr Buttons (z.B. 14 pro Reihe) private Button[][] keys = new Button[5][] { new Button[14], new Button[14], new Button[14], new Button[14], new Button[8]}; private Button[][] numkeys = new Button[4][] { new Button[4], new Button[4], new Button[4], new Button[4]}; // **Echtes QWERTZ-Layout** (5 Reihen + Funktion/Steuerung) private string[] qwertzRows = { "?1234567890ß⌫↵", // Ziffernreihe "↔qwertzuiopü+", // Hauptbuchstaben 1 (versetzt) " asdfghjklöä#", // Hauptbuchstaben 2 (versetzt) "⇧ 0) targetTextBox.Text = targetTextBox.Text.Substring(0, targetTextBox.Text.Length - 1); break; case var t when t == "Leertaste": targetTextBox.Text += " "; break; case var t when t == "_": targetTextBox.Text += " "; break; default: targetTextBox.Text += btn.Text; break; } if (isShift && char.IsLetter(ch)) ch = char.ToUpper(ch); } private void Shift_Click(object sender, EventArgs e) { Button shiftBtn = (Button)sender; isShift = !isShift; shiftBtn.BackColor = isShift ? Color.Yellow : Color.FromArgb(240, 240, 240); UpdateLayout(); } private void UpdateLayout() { if (!isNumeric) { // Zeige ALLE QWERTZ-Buttons for (int row = 0; row < qwertzRows.Length; row++) { string rowText = qwertzRows[row]; for (int col = 0; col < keys[row].Length && col < rowText.Length; col++) { char ch = rowText[col]; if (keys[row][col].Text.Length > 1) continue; keys[row][col].Text = isShift && char.IsLetter(ch) ? char.ToUpper(ch).ToString() : ch.ToString(); keys[row][col].Tag = ch; keys[row][col].Visible = true; // QWERTZ sichtbar } } } this.Refresh(); targetTextBox.Focus(); } protected override void OnShown(EventArgs e) { base.OnShown(e); this.Location = new Point((screen.WorkingArea.Width - this.Width) / 2, screen.WorkingArea.Height - this.Height); KeyBoardShown?.Invoke(this, EventArgs.Empty); } } }