void OnPreviewKeyDown(FakeConsoleTextEditorKeyEventArgs e) { if (PreviewKeyDown != null) { PreviewKeyDown(this, e); } }
public bool RaisePreviewKeyDownEventForDialogKey(Key key) { FakeConsoleTextEditorKeyEventArgs e = new FakeConsoleTextEditorKeyEventArgs(key); OnPreviewKeyDown(e); if (!e.Handled) { switch (key) { case Key.Enter: { if (IsCursorAtEnd) { LineBuilder.Append(Environment.NewLine); PreviousLines.Append(LineBuilder.ToString()); LineBuilder = new StringBuilder(); Column = 0; SelectionStart = Column; } else { int length = LineBuilder.Length; string currentLine = LineBuilder.ToString(); PreviousLines.Append(currentLine.Substring(0, Column) + Environment.NewLine); LineBuilder = new StringBuilder(); LineBuilder.Append(currentLine.Substring(Column)); Column = length - Column; SelectionStart = Column; } TotalLines++; Line++; } break; case Key.Back: { OnBackspaceKeyPressed(); } break; case Key.Left: { Column--; SelectionStart = Column; } break; case Key.Right: { Column++; SelectionStart = Column; } break; } } return(e.Handled); }
public bool RaisePreviewKeyDownEvent(Key key) { FakeConsoleTextEditorKeyEventArgs e = new FakeConsoleTextEditorKeyEventArgs(key); OnPreviewKeyDown(e); if (!e.Handled) { KeyConverter converter = new KeyConverter(); string text = converter.ConvertToString(key); if (IsCursorAtEnd) { LineBuilder.Append(text); } else { LineBuilder.Insert(Column, text); } Column++; SelectionStart = Column; } return e.Handled; }
public bool RaisePreviewKeyDownEvent(Key key) { FakeConsoleTextEditorKeyEventArgs e = new FakeConsoleTextEditorKeyEventArgs(key); OnPreviewKeyDown(e); if (!e.Handled) { KeyConverter converter = new KeyConverter(); string text = converter.ConvertToString(key); if (IsCursorAtEnd) { LineBuilder.Append(text); } else { LineBuilder.Insert(Column, text); } Column++; SelectionStart = Column; } return(e.Handled); }
public void RaisePreviewKeyDownEvent(FakeConsoleTextEditorKeyEventArgs e) { OnPreviewKeyDown(e); }
public bool RaisePreviewKeyDownEventForDialogKey(Key key) { FakeConsoleTextEditorKeyEventArgs e = new FakeConsoleTextEditorKeyEventArgs(key); OnPreviewKeyDown(e); if (!e.Handled) { switch (key) { case Key.Enter: { if (IsCursorAtEnd) { LineBuilder.Append(Environment.NewLine); PreviousLines.Append(LineBuilder.ToString()); LineBuilder = new StringBuilder(); Column = 0; SelectionStart = Column; } else { int length = LineBuilder.Length; string currentLine = LineBuilder.ToString(); PreviousLines.Append(currentLine.Substring(0, Column) + Environment.NewLine); LineBuilder = new StringBuilder(); LineBuilder.Append(currentLine.Substring(Column)); Column = length - Column; SelectionStart = Column; } TotalLines++; Line++; } break; case Key.Back: { OnBackspaceKeyPressed(); } break; case Key.Left: { Column--; SelectionStart = Column; } break; case Key.Right: { Column++; SelectionStart = Column; } break; } } return e.Handled; }