Cleanup the InputPrompt class, removing unused methods, and converting some silly methods into properties allowing some pretty array initializers instead of function calls

This commit is contained in:
adelikat 2014-07-28 02:40:30 +00:00
parent 5d4ff76ed6
commit aeea08a823
5 changed files with 25 additions and 29 deletions

View File

@ -1480,14 +1480,15 @@ namespace BizHawk.Client.EmuHawk
var inputPrompt = new InputPrompt
{
Text = "Go to Address",
StartLocation = this.ChildPointToScreen(MemoryViewerBox)
StartLocation = this.ChildPointToScreen(MemoryViewerBox),
Message = "Enter a hexadecimal value"
};
inputPrompt.SetMessage("Enter a hexadecimal value");
var result = inputPrompt.ShowHawkDialog();
if (result == DialogResult.OK && inputPrompt.UserText.IsHex())
if (result == DialogResult.OK && inputPrompt.PromptText.IsHex())
{
GoToAddress(int.Parse(inputPrompt.UserText, NumberStyles.HexNumber));
GoToAddress(int.Parse(inputPrompt.PromptText, NumberStyles.HexNumber));
}
AddressLabel.Text = GenerateAddressString();

View File

@ -18,28 +18,25 @@ namespace BizHawk.Client.EmuHawk
}
public enum InputType { Hex, Unsigned, Signed, Text }
public string UserText { get; set; } // What the user selected
public Point StartLocation { get; set; }
public InputType TextInputType { get; set; }
public void SetMessage(string message)
public string Message
{
PromptLabel.Text = message;
get { return PromptLabel.Text; }
set { PromptLabel.Text = value ?? string.Empty; }
}
public void SetCasing(CharacterCasing casing)
public string InitialValue
{
PromptBox.CharacterCasing = casing;
get { return PromptBox.Text; }
set { PromptBox.Text = value ?? string.Empty; }
}
public void SetInitialValue(string value)
public string PromptText
{
PromptBox.Text = value;
}
public void SetTitle(string value)
{
Text = value;
get { return PromptBox.Text ?? string.Empty; }
}
private void InputPrompt_Load(object sender, EventArgs e)
@ -53,7 +50,6 @@ namespace BizHawk.Client.EmuHawk
private void Ok_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
UserText = PromptBox.Text;
Close();
}

View File

@ -443,15 +443,15 @@ namespace BizHawk.Client.EmuHawk
InputPrompt i = new InputPrompt
{
Text = "Marker for frame " + markerFrame,
TextInputType = InputPrompt.InputType.Text
TextInputType = InputPrompt.InputType.Text,
Message = "Enter a message"
};
i.SetMessage("Enter a message");
var result = i.ShowHawkDialog();
if (result == DialogResult.OK)
{
_tas.Markers.Add(markerFrame, i.UserText);
_tas.Markers.Add(markerFrame, i.PromptText);
MarkerControl.Refresh();
}

View File

@ -288,16 +288,15 @@ namespace BizHawk.Client.EmuHawk
var prompt = new InputPrompt
{
StartLocation = this.ChildPointToScreen(TraceView),
TextInputType = InputPrompt.InputType.Unsigned
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Max lines to display in the window",
InitialValue = Global.Config.TraceLoggerMaxLines.ToString()
};
prompt.SetMessage("Max lines to display in the window");
prompt.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
var result = prompt.ShowHawkDialog();
if (result == DialogResult.OK)
{
var max = int.Parse(prompt.UserText);
var max = int.Parse(prompt.PromptText);
if (max > 0)
{
Global.Config.TraceLoggerMaxLines = max;

View File

@ -934,17 +934,17 @@ namespace BizHawk.Client.EmuHawk
var prompt = new InputPrompt
{
Text = "Go to Address",
StartLocation = this.ChildPointToScreen(WatchListView)
StartLocation = this.ChildPointToScreen(WatchListView),
Message = "Enter a hexadecimal value"
};
prompt.SetMessage("Enter a hexadecimal value");
var result = prompt.ShowHawkDialog();
if (result == DialogResult.OK)
{
if (prompt.UserText.IsHex())
if (prompt.PromptText.IsHex())
{
var addr = int.Parse(prompt.UserText, NumberStyles.HexNumber);
var addr = int.Parse(prompt.PromptText, NumberStyles.HexNumber);
WatchListView.SelectItem(addr, true);
WatchListView.ensureVisible();
}