2 using System.Collections.Generic;
6 using System.Windows.Controls;
7 using System.Windows.Data;
8 using System.Windows.Documents;
9 using System.Windows.Input;
10 using System.Windows.Media;
11 using System.Windows.Media.Imaging;
12 using System.Windows.Navigation;
13 using System.Windows.Shapes;
16 namespace SiliconStudio.
Paradox.DebugTools
25 InitializeComponent();
27 ReplTextBox.KeyDown +=
new KeyEventHandler(ReplTextBox_KeyDown);
28 ReplTextBox.PreviewKeyDown +=
new KeyEventHandler(ReplTextBox_PreviewKeyDown);
31 private EngineContext engineContext;
35 this.engineContext = engineContext;
38 List<string> replHistory =
new List<string>();
39 private int historyIndex = -1;
41 void HistoryAdd(
string command)
43 if (historyIndex != -1)
44 replHistory[replHistory.Count - 1] = command;
46 replHistory.Add(command);
47 if (replHistory.Last() == string.Empty)
48 replHistory.RemoveAt(replHistory.Count - 1);
52 void ReplTextBox_PreviewKeyDown(
object sender, KeyEventArgs e)
55 if (e.Key == Key.Up || e.Key == Key.Down)
57 if (historyIndex == -1)
59 historyIndex = replHistory.Count;
60 replHistory.Add(ReplTextBox.Text);
64 replHistory[historyIndex] = ReplTextBox.Text;
68 if (e.Key == Key.Up && historyIndex > 0)
71 ReplTextBox.Text = replHistory[historyIndex];
72 ReplTextBox.SelectionStart = ReplTextBox.Text.Length;
74 if (e.Key == Key.Down && historyIndex < replHistory.Count - 1)
77 ReplTextBox.Text = replHistory[historyIndex];
78 ReplTextBox.SelectionStart = ReplTextBox.Text.Length;
83 void ReplTextBox_KeyDown(
object sender, KeyEventArgs e)
85 if (e.Key == Key.Enter)
87 HistoryAdd(ReplTextBox.Text);
92 throw new NotSupportedException();
96 ReplResults.AppendText(string.Format(
"Exception {0}: {1}", ex.GetType().FullName, ex.Message));
100 ReplTextBox.Text = string.Empty;
101 ReplResults.ScrollToEnd();