2016-11-21 22:34:47 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2016-11-22 18:28:59 -05:00
|
|
|
|
using System.Text.RegularExpressions;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesen.GUI.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Debugger
|
|
|
|
|
{
|
|
|
|
|
public partial class frmEditLabel : BaseConfigForm
|
|
|
|
|
{
|
2016-11-22 22:38:14 -05:00
|
|
|
|
private UInt32 _originalAddress;
|
|
|
|
|
private AddressType _originalMemoryType;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
public frmEditLabel(CodeLabel label)
|
2016-11-21 22:34:47 -05:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
_originalAddress = label.Address;
|
|
|
|
|
_originalMemoryType = label.AddressType;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
|
|
|
|
Entity = label;
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
AddBinding("AddressType", cboRegion);
|
|
|
|
|
AddBinding("Address", txtAddress);
|
2016-11-21 22:34:47 -05:00
|
|
|
|
AddBinding("Label", txtLabel);
|
|
|
|
|
AddBinding("Comment", txtComment);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
protected override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
|
|
|
|
txtLabel.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 22:34:47 -05:00
|
|
|
|
protected override bool ValidateInput()
|
|
|
|
|
{
|
|
|
|
|
CodeLabel existingLabel = LabelManager.GetLabel(txtLabel.Text);
|
2016-11-22 18:28:59 -05:00
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
return (existingLabel == null || (existingLabel.Address == _originalAddress && existingLabel.AddressType == _originalMemoryType))
|
2016-11-21 22:34:47 -05:00
|
|
|
|
&& !txtComment.Text.Contains('\x1') && !txtComment.Text.Contains('\x2')
|
2016-11-22 18:28:59 -05:00
|
|
|
|
&& (txtLabel.Text.Length == 0 || Regex.IsMatch(txtLabel.Text, "^[_a-zA-Z]+[_a-zA-Z0-9]*"));
|
2016-11-21 22:34:47 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFormClosed(FormClosedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
txtLabel.Text = txtLabel.Text.Replace("$", "");
|
|
|
|
|
base.OnFormClosed(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if(keyData == (Keys.Control | Keys.Enter)) {
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|