void PlaceButtons() { int width = (Allocation.Width - 1) / 2; int height = Allocation.Height; up.SetSizeRequest(width, height); Put(up, 0, 0); up.QueueDraw(); down.SetSizeRequest(width, height); Put(down, width + 1, 0); down.QueueDraw(); buttonsPlaced = true; }
public VirtualKeyboard(Entry e, ButtonReleaseEventHandler handler) { SetSizeRequest(505, 205); row1 = new KeyButton[10]; row2 = new KeyButton[9]; row3 = new KeyButton[7]; for (int i = 0; i < 10; ++i) { row1[i] = new KeyButton(qwerty1Lower[i].ToString(), handler); Put(row1[i], (i * 50) + 5, 5); row1[i].Show(); } for (int i = 0; i < 9; ++i) { row2[i] = new KeyButton(qwerty2Lower[i].ToString(), handler); Put(row2[i], (i * 50) + 30, 55); row2[i].Show(); } for (int i = 0; i < 7; ++i) { row3[i] = new KeyButton(qwerty3Lower[i].ToString(), handler); Put(row3[i], (i * 50) + 80, 105); row3[i].Show(); } shiftState = ShiftKeyState.Lower; var shiftKey = new TouchButton(); shiftKey.SetSizeRequest(70, 45); shiftKey.text = Convert.ToChar(0x21E7).ToString(); shiftKey.buttonColor = "grey3"; shiftKey.ButtonReleaseEvent += (o, args) => { if (shiftState == ShiftKeyState.Lower) { ToUpper(); shiftKey.buttonColor = "pri"; shiftKey.QueueDraw(); shiftState = ShiftKeyState.Shifted; } else if (shiftState == ShiftKeyState.Shifted) { shiftKey.buttonColor = "seca"; shiftKey.QueueDraw(); shiftState = ShiftKeyState.Caps; } else // Caps { ToLower(); shiftKey.buttonColor = "grey3"; shiftKey.QueueDraw(); shiftState = ShiftKeyState.Lower; } }; Put(shiftKey, 5, 105); shiftKey.Show(); var delete = new TouchButton(); delete.SetSizeRequest(70, 45); delete.text = Convert.ToChar(0x232B).ToString(); delete.textSize = 15; delete.ButtonReleaseEvent += (o, args) => { int pos = e.Position; e.DeleteText(e.Position - 1, e.Position); }; Put(delete, 430, 105); delete.Show(); var space = new TouchButton(); space.text = "Space"; space.SetSizeRequest(245, 45); space.ButtonReleaseEvent += (o, args) => { int pos = e.Position; e.InsertText(" ", ref pos); ++e.Position; }; Put(space, 130, 155); space.Show(); e.TextInserted += (o, args) => { if (shiftState == ShiftKeyState.Shifted) { ToLower(); shiftKey.buttonColor = "grey3"; shiftKey.QueueDraw(); shiftState = ShiftKeyState.Lower; } }; Show(); }