protected virtual void OnPadClick(KeyboardPadEventArgs e) { StringBuilder sb = new StringBuilder(messageBox.Text); int selectionStart = messageBox.SelectionStart; int addPos = 1; if (!e.IsControlKey) { if (messageBox.SelectionLength > 0) sb.Remove(messageBox.SelectionStart, messageBox.SelectionLength); sb.Insert(messageBox.SelectionStart, e.KeyChar); messageBox.Lines = sb.Replace("\r","").ToString().Split('\n'); for (int i = 0;i <= selectionStart && i < sb.Length; i++) { if (sb[i] == '\n') addPos++; } selectionStart = selectionStart + addPos; } else { if (e.KeyCode == BUTTON_BACKSPACE) { if (messageBox.SelectionLength > 0) { sb.Remove(messageBox.SelectionStart, messageBox.SelectionLength); messageBox.Text = sb.ToString(); } else if (messageBox.SelectionStart > 0) { sb.Remove(messageBox.SelectionStart - 1, 1); messageBox.Text = sb.ToString(); selectionStart--; } } } messageBox.SelectionStart = selectionStart; messageBox.ScrollToCaret(); messageBox.Focus(); if (PadClick != null) { if (e.KeyCode == BUTTON_OK) e.Text = String.Join("\n", messageBox.Lines); PadClick(this, e); } }
protected virtual void OnPadClick(KeyboardPadEventArgs e) { StringBuilder builder = new StringBuilder(this.messageBox.Text); int selectionStart = this.messageBox.SelectionStart; int num2 = 1; if (!e.IsControlKey) { if (this.messageBox.SelectionLength > 0) { builder.Remove(this.messageBox.SelectionStart, this.messageBox.SelectionLength); } builder.Insert(this.messageBox.SelectionStart, e.KeyChar); this.messageBox.Lines = builder.Replace("\r", "").ToString().Split(new char[] { '\n' }); for (int i = 0; (i <= selectionStart) && (i < builder.Length); i++) { if (builder[i] == '\n') { num2++; } } selectionStart += num2; } else if (e.KeyCode == BUTTON_BACKSPACE) { if (this.messageBox.SelectionLength > 0) { builder.Remove(this.messageBox.SelectionStart, this.messageBox.SelectionLength); this.messageBox.Text = builder.ToString(); } else if (this.messageBox.SelectionStart > 0) { builder.Remove(this.messageBox.SelectionStart - 1, 1); this.messageBox.Text = builder.ToString(); selectionStart--; } } this.messageBox.SelectionStart = selectionStart; this.messageBox.ScrollToCaret(); this.messageBox.Focus(); if (this.PadClick != null) { if (e.KeyCode == BUTTON_OK) { e.Text = string.Join("\n", this.messageBox.Lines); } this.PadClick(this, e); } }
private void MessagePad_PadClick(object sender, KeyboardPadEventArgs e) { if (e.KeyCode == KeyboardPad.BUTTON_OK) { this.dialogResult = true; base.Close(); } else if (e.KeyCode == KeyboardPad.BUTTON_CANCEL) { this.dialogResult = false; base.Close(); } }