示例#1
0
 public DXGUI()
 {
     InitializeComponent();
     _currentLine = new StringBuilder();
     _prevLines.Add("");
     _currentInput = new StringBuilder();
     _currentInputLocation = 0;
     _graphics = new WrapperGraphics(this);
     _graphics.AddLine(new ConsoleString("Welcome to the DirectX Console Wrapper!", Color.FromArgb(255, 63, 63)));
     _graphics.AddLine(new ConsoleString("Use Ctrl-(Up/Down/Home/End) :: PageUp/PageDown :: MouseWheel for navigation.", Color.FromArgb(255, 127, 0)));
     _graphics.AddLine(new ConsoleString("ConsoleWrapper Copyright (c) Tom Mitchell 2007-2008", Color.FromArgb(255, 255, 0)));
     _graphics.AddLine(new ConsoleString(" "));
     _wrapper = new WrapperShell();
     _wrapper.AddListener(this);
 }
示例#2
0
 private void DXGUI_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode.Equals(Keys.Enter) || e.KeyCode.Equals(Keys.Return))
     {
         _prevLines.Insert(_prevLines.Count - 1, _currentInput.ToString());
         _prevLineNum = _prevLines.Count - 1;
         _wrapper.SendLine(_currentInput.ToString(), ConsoleString.StringType.Input);
         _currentInput = new StringBuilder();
         _currentInputLocation = 0;
     }
     else if (e.KeyCode.Equals(Keys.Back))
     {
         if (_currentInput.Length > 0 && _currentInputLocation > 0)
         {
             _currentInput.Remove(_currentInputLocation - 1, 1);
             _currentInputLocation--;
             UpdateCurrentLine();
         }
     }
     else if (e.KeyCode.Equals(Keys.Delete))
     {
         if (_currentInput.Length > 0 && _currentInputLocation < _currentInput.Length)
         {
             _currentInput.Remove(_currentInputLocation, 1);
             UpdateCurrentLine();
         }
     }
     else if (e.KeyCode.Equals(Keys.Left))
     {
         if (_currentInputLocation > 0)
         {
             _currentInputLocation--;
             UpdateCurrentLine();
         }
     }
     else if (e.KeyCode.Equals(Keys.Right))
     {
         if (_currentInputLocation < _currentInput.Length)
         {
             _currentInputLocation++;
             UpdateCurrentLine();
         }
     }
     else if (e.Control && e.KeyCode.Equals(Keys.Home))
     {
         _graphics.MoveViewHome();
     }
     else if (e.Control && e.KeyCode.Equals(Keys.End))
     {
         _graphics.MoveViewEnd();
     }
     else if (e.KeyCode.Equals(Keys.Home))
     {
         _currentInputLocation = 0;
         UpdateCurrentLine();
     }
     else if (e.KeyCode.Equals(Keys.End))
     {
         _currentInputLocation = _currentInput.Length;
         UpdateCurrentLine();
     }
     else if (e.Control && e.KeyCode.Equals(Keys.Up))
     {
         _graphics.MoveView(-2);
     }
     else if (e.Control && e.KeyCode.Equals(Keys.Down))
     {
         _graphics.MoveView(2);
     }
     else if (e.KeyCode.Equals(Keys.Up))
     {
         _prevLineNum--;
         _prevLineNum = Math.Max(0, _prevLineNum);
         _currentInput = new StringBuilder(_prevLines[_prevLineNum]);
         _currentInputLocation = _currentInput.Length;
         _graphics.CurrentLine.Text = CurrentLineWithCaret();
     }
     else if (e.KeyCode.Equals(Keys.Down))
     {
         _prevLineNum++;
         _prevLineNum = Math.Min(_prevLines.Count - 1, _prevLineNum);
         _currentInput = new StringBuilder(_prevLines[_prevLineNum]);
         _currentInputLocation = _currentInput.Length;
         _graphics.CurrentLine.Text = CurrentLineWithCaret();
     }
     else if (e.KeyCode.Equals(Keys.PageUp))
     {
         _graphics.MoveView(-30);
     }
     else if (e.KeyCode.Equals(Keys.PageDown))
     {
         _graphics.MoveView(30);
     }
     else if (e.Control && e.KeyCode.Equals(Keys.C))
     {
         DirectoryInfo currentDirectory = ((WrapperShell)_wrapper).CurrentDirectory;
         _wrapper.Dispose();
         _wrapper = new WrapperShell(currentDirectory);
         _wrapper.AddListener(this);
     }
 }