2011-02-16 16:35:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2012-06-09 22:04:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A simple form that prompts the user for a single line of input
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class InputPrompt : Form
|
|
|
|
|
{
|
2012-08-17 03:04:35 +00:00
|
|
|
|
public enum InputType { HEX, UNSIGNED, SIGNED, TEXT };
|
InputPrompt. I made the UserOK variable to change to false if the user clicks the Cancel button.
LuaWriter. Adding "end" after pressing Enter if the current line has "if", "for", etc. is now fixed. Also added some more edit menu items, like Undo, Redo, Cut, Copy, Paste, Select All, Search, Replace and Go To...
Search and Replace still need to be implemente. Implemente Go To, if the user inserts an invalid text (letters, symbols, etc) it will not close and prompt an error. Otherwise, it will go to the specified line.
2012-08-02 21:45:06 +00:00
|
|
|
|
public bool UserOK; //Will be true if the user selects Ok
|
2012-06-09 22:04:09 +00:00
|
|
|
|
public string UserText = ""; //What the user selected
|
2012-08-17 03:04:35 +00:00
|
|
|
|
|
|
|
|
|
private InputType itype = InputType.TEXT;
|
|
|
|
|
|
|
|
|
|
public InputType TextInputType
|
|
|
|
|
{
|
|
|
|
|
get { return itype; }
|
|
|
|
|
set { itype = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-09 22:04:09 +00:00
|
|
|
|
public InputPrompt()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMessage(string message)
|
|
|
|
|
{
|
|
|
|
|
PromptLabel.Text = message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCasing(CharacterCasing casing)
|
|
|
|
|
{
|
|
|
|
|
PromptBox.CharacterCasing = casing;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-09 22:45:24 +00:00
|
|
|
|
public void SetInitialValue(string value)
|
|
|
|
|
{
|
|
|
|
|
PromptBox.Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 03:04:35 +00:00
|
|
|
|
public void SetTitle(string value)
|
|
|
|
|
{
|
|
|
|
|
Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-09 22:04:09 +00:00
|
|
|
|
private void InputPrompt_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UserOK = true;
|
|
|
|
|
UserText = PromptBox.Text;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-08-17 03:04:35 +00:00
|
|
|
|
UserOK = false;
|
2012-06-09 22:04:09 +00:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PromptBox_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
|
|
{
|
2012-08-17 03:04:35 +00:00
|
|
|
|
switch (itype)
|
2012-06-09 22:04:09 +00:00
|
|
|
|
{
|
2012-08-17 03:04:35 +00:00
|
|
|
|
default:
|
|
|
|
|
case InputType.TEXT:
|
|
|
|
|
break;
|
|
|
|
|
case InputType.HEX:
|
2012-09-30 13:38:37 +00:00
|
|
|
|
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
|
2012-08-17 03:04:35 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InputType.SIGNED:
|
2012-09-30 13:38:37 +00:00
|
|
|
|
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
|
2012-08-17 03:04:35 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InputType.UNSIGNED:
|
2012-09-30 13:38:37 +00:00
|
|
|
|
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
|
2012-08-17 03:04:35 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (!InputValidate.IsValidSignedNumber(e.KeyChar))
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2012-06-09 22:04:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-16 16:35:51 +00:00
|
|
|
|
}
|