void ChangeLayout() { //for (int i = 0; i < 3; i++) {} foreach (var c in this.Controls) { if (c is CharacterButton) { CharacterButton button = (CharacterButton)c; if (button.Ignore) { continue; } button.Text = arabic ? button.ArabicChar : button.EnglishChar; } } }
public Keyboard() { arabic = true; int height = CharacterButton.DefaultHeight * 6; int width = Screen.PrimaryScreen.Bounds.Width; int left = 0;// (Screen.PrimaryScreen.Bounds.Width - width) / 2; int top = Screen.PrimaryScreen.Bounds.Height - height; RightToLeftLayout = true; AutoScaleMode = AutoScaleMode.None; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Normal; StartPosition = FormStartPosition.Manual; Location = new Point(left, top - 20); Size = new Size(width, height + 40); Padding = new Padding(10); Name = "Keyboard"; #if !DEBUG TopMost = true; #endif Visible = false; box = new TextBox { Multiline = true, ReadOnly = true, Dock = DockStyle.Top, Height = CharacterButton.DefaultHeight, BorderStyle = BorderStyle.FixedSingle, BackColor = Color.LightGray, Margin = new Padding(0), TextAlign = HorizontalAlignment.Right, //Text = myControl != null ? myControl.Text : "", }; rows[0] = @"ض ص ث ق ف غ ع ه خ ح ج د"; rows[1] = @"ش س ي ب ل ا ت ن م ك ط ذ"; rows[2] = @"$ ئ ء ؤ ر * ى ة و ز ظ @"; rows[3] = @" Q W E R T Y U I O P "; rows[4] = @"A B C D E F G H I J K L"; rows[5] = @"$ Z X C V B N M @"; int x = LEFT; int y = TOP + box.Height; for (int i = 0; i < 3; i++) { for (int k = 0; k < 23; k++) { var ar = rows[i][k]; var en = rows[i + 3][k]; if (ar == ' ') { continue; } if (ar == '#') { Label label = new Label { AutoSize = false, BackColor = Color.Transparent, Location = new Point(x, y), Size = new Size(CharacterButton.DefaultWidth, 68), }; Controls.Add(label); } else { CharacterButton b = new CharacterButton(ar, en, x, y); b.Click += OnCharacterKeyClick; Controls.Add(b); } x += CharacterButton.XStep; } x = LEFT; y += CharacterButton.YStep; } Button sbacebar = new Button { BackColor = Color.White, FlatStyle = FlatStyle.Flat, Font = new Font(Fonts.ALMohanadBold, 25f), Location = new Point(LEFT, y), Size = new Size((CharacterButton.DefaultWidth * 12) + (110), CharacterButton.DefaultHeight - 5), Cursor = Cursors.Hand, TabStop = false, Text = " ", Tag = " ", UseVisualStyleBackColor = false, }; sbacebar.Click += OnCharacterKeyClick; Controls.Add(sbacebar); x = (Screen.PrimaryScreen.Bounds.Right - (10 + NumaricKeyboard.DefaultWidth)) - CharacterButton.DefaultWidth; y = (TOP - 5) + box.Height; numaricKeyboard = new NumaricKeyboard(new Point(x, y), box); Controls.Add(numaricKeyboard); x = numaricKeyboard.Right + 0; y = numaricKeyboard.Top; Button close = new Button { Text = ('\u00CF').ToString(), Size = new Size(CharacterButton.DefaultWidth, CharacterButton.DefaultHeight), Location = new Point(x, y), BackColor = Color.Black, ForeColor = Color.WhiteSmoke, Font = new Font(Fonts.Wingdings2, 30f), Cursor = Cursors.Hand, }; close.Click += OnCloseKeyClick; Controls.Add(box); Controls.Add(close); }