Ejemplo n.º 1
0
 void OnPreviewKeyDown(FakeConsoleTextEditorKeyEventArgs e)
 {
     if (PreviewKeyDown != null)
     {
         PreviewKeyDown(this, e);
     }
 }
Ejemplo n.º 2
0
        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;
		}
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void RaisePreviewKeyDownEvent(FakeConsoleTextEditorKeyEventArgs e)
 {
     OnPreviewKeyDown(e);
 }
		public void RaisePreviewKeyDownEvent(FakeConsoleTextEditorKeyEventArgs e)
		{
			OnPreviewKeyDown(e);
		}
		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;
		}