diff --git a/FiveMRcon/CmdHistoryNode.cs b/FiveMRcon/CmdHistoryNode.cs
new file mode 100644
index 0000000..b98f8e5
--- /dev/null
+++ b/FiveMRcon/CmdHistoryNode.cs
@@ -0,0 +1,14 @@
+namespace FiveMRcon
+{
+ public class CmdHistoryNode
+ {
+ public string Command;
+ public CmdHistoryNode PreviousCmdNode { get; }
+ public CmdHistoryNode NextCmdNode;
+
+ public CmdHistoryNode(CmdHistoryNode prevNode)
+ {
+ PreviousCmdNode = prevNode;
+ }
+ }
+}
diff --git a/FiveMRcon/FiveMRcon.csproj b/FiveMRcon/FiveMRcon.csproj
index f7d0caa..5d1e0a0 100644
--- a/FiveMRcon/FiveMRcon.csproj
+++ b/FiveMRcon/FiveMRcon.csproj
@@ -46,6 +46,7 @@
+
Form
diff --git a/FiveMRcon/RconForm.Designer.cs b/FiveMRcon/RconForm.Designer.cs
index 9bcef75..cd1e990 100644
--- a/FiveMRcon/RconForm.Designer.cs
+++ b/FiveMRcon/RconForm.Designer.cs
@@ -45,6 +45,7 @@ private void InitializeComponent()
this.InputText.Size = new System.Drawing.Size(707, 20);
this.InputText.TabIndex = 0;
this.InputText.TextChanged += new System.EventHandler(this.InputText_TextChanged);
+ this.InputText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.InputText_KeyUp);
//
// InputSend
//
diff --git a/FiveMRcon/RconForm.cs b/FiveMRcon/RconForm.cs
index b858d4a..dea71b0 100644
--- a/FiveMRcon/RconForm.cs
+++ b/FiveMRcon/RconForm.cs
@@ -1,4 +1,5 @@
using System;
+using System.Media;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -8,8 +9,12 @@ namespace FiveMRcon
{
public partial class RconForm : Form
{
+ private CmdHistoryNode _CurrentCmdHistoryNode;
+
public RconForm()
{
+ _CurrentCmdHistoryNode = new CmdHistoryNode(null);
+
InitializeComponent();
ActiveControl = InputText;
}
@@ -25,6 +30,37 @@ private void InputText_TextChanged(object sender, EventArgs e)
InputSend.Enabled = InputText.Text.Trim().Length > 0;
}
+ private void InputText_KeyUp(object sender, KeyEventArgs e)
+ {
+ bool relevantKeyUp = false;
+ if (e.KeyCode == Keys.Up)
+ {
+ if (_CurrentCmdHistoryNode.PreviousCmdNode != null)
+ {
+ _CurrentCmdHistoryNode = _CurrentCmdHistoryNode.PreviousCmdNode;
+ relevantKeyUp = true;
+ }
+ else
+ SystemSounds.Beep.Play();
+ }
+ else if (e.KeyCode == Keys.Down)
+ {
+ if (_CurrentCmdHistoryNode.NextCmdNode != null)
+ {
+ _CurrentCmdHistoryNode = _CurrentCmdHistoryNode.NextCmdNode;
+ relevantKeyUp = true;
+ }
+ else
+ SystemSounds.Beep.Play();
+ }
+
+ if (relevantKeyUp)
+ {
+ InputText.Text = _CurrentCmdHistoryNode.Command;
+ InputText.SelectionStart = InputText.TextLength;
+ }
+ }
+
private void InputSend_Click(object sender, EventArgs e)
{
InputSend.Enabled = false;
@@ -69,6 +105,13 @@ private void InputSend_Click(object sender, EventArgs e)
}
}
+ CmdHistoryNode newCmdHistoryNode = new CmdHistoryNode(_CurrentCmdHistoryNode);
+ // Set command and next node of current node
+ _CurrentCmdHistoryNode.Command = InputText.Text;
+ _CurrentCmdHistoryNode.NextCmdNode = newCmdHistoryNode;
+ // Set current node to new one
+ _CurrentCmdHistoryNode = newCmdHistoryNode;
+
InputText.ResetText();
ActiveControl = InputText;
}