I'm coding an application and I want to have a console embedded in the form. I am using a richtextbox currently but that is not nessecary. I want to disable everything in the richtextbox like: Selection, deleting with del key and backspace, show a _ after every word I type. And have commands that are recognised when typed in and entered. Thanks alot! ~Layne~
Asked
Active
Viewed 2,863 times
0
-
Why not try to embed the console? http://stackoverflow.com/questions/3284500/embed-a-console-window-inside-a-wpf-window – Johan Larsson Sep 30 '12 at 00:03
-
because I dont want stock cmd commands. I want my own. – Layne3 Sep 30 '12 at 00:05
-
Try using the `SelectionProtected` method to protect everything above the line the use can type on. Usually requires freezing the control in order to hide the massive flicker. – LarsTech Sep 30 '12 at 01:50
-
Is this now an answer or still a question? – LarsTech Oct 01 '12 at 22:55
-
I rolled it back to the original. Answers go in the "Your Answer" box below. – LarsTech Oct 01 '12 at 23:09
2 Answers
1
Answer. I created a listbox and a richtextbox. Textbox text (commands) get sent to the listbox. Here is the code I am using.
private void richTextBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
listBox2.Items.Add(richTextBox2.Text);
if (richTextBox2.Text == a1)
{
MessageBox.Show("-c can't be used as a raw command, it is used to define when another command is being used. Try -c r to run the game...");
}
else if (richTextBox2.Text == a2)
{
System.Diagnostics.Process.Start("Arcanists.jar");
}
else if (richTextBox2.Text == a3)
{
foreach (System.Diagnostics.Process myProc in System.Diagnostics.Process.GetProcesses())
{
if (myProc.ProcessName == "javaw")
{
myProc.Kill();
}
}
}
else if (richTextBox2.Text == a4)
{
MessageBox.Show("Type -c r to run the game");
}
else
{
listBox2.Items.Add("*!Invalid Command!*");
}
}
}

Layne3
- 71
- 1
- 2
- 7
0
Use your clicks to focus to your text input via a text box. Your going to need a richtextbox for output and a text box for input like a video game with a console option

Ray
- 1
-
1It's usually best to give a short example to demonstrate your solution. – Gareth Jun 20 '17 at 09:00