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 23:07:28 -05:00
|
|
|
|
private CodeLabel _originalLabel;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
2016-11-22 23:07:28 -05:00
|
|
|
|
public frmEditLabel(CodeLabel label, CodeLabel originalLabel = null)
|
2016-11-21 22:34:47 -05:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2016-11-22 23:07:28 -05:00
|
|
|
|
_originalLabel = originalLabel;
|
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()
|
|
|
|
|
{
|
2016-11-22 23:07:28 -05:00
|
|
|
|
UpdateObject();
|
2016-11-22 18:28:59 -05:00
|
|
|
|
|
2016-11-22 23:07:28 -05:00
|
|
|
|
CodeLabel sameLabel = LabelManager.GetLabel(txtLabel.Text);
|
|
|
|
|
CodeLabel sameAddress = LabelManager.GetLabel(((CodeLabel)Entity).Address, ((CodeLabel)Entity).AddressType);
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
(sameLabel == null || sameLabel == _originalLabel)
|
|
|
|
|
&& (sameAddress == null || sameAddress == _originalLabel)
|
|
|
|
|
&& (_originalLabel != null || txtLabel.Text.Length > 0 || txtComment.Text.Length > 0)
|
2017-03-09 23:50:20 -05:00
|
|
|
|
&& !txtComment.Text.Contains('\x1')
|
2016-12-02 21:57: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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|