private void _okButton_Click(object sender, System.EventArgs e)
{
var breakpoint = Breakpoint;
if (_breakBySourceLine.Checked)
{
int lineNumber;
if (!int.TryParse(_fileLineNumber.Text, out lineNumber) || lineNumber < 1)
{
Program.Error("Invalid line number. Must be a valid number.");
return;
}
if (breakpoint.File != _fileSelect.SelectedItem || breakpoint.CurrentLine != lineNumber)
{
breakpoint.File = _fileSelect.SelectedItem as AsmProjectFile;
breakpoint.BuildLine = breakpoint.CurrentLine = lineNumber;
}
breakpoint.Symbol = null;
breakpoint.StartAddress = -1;
breakpoint.EndAddress = null;
breakpoint.AddressType = Breakpoint.AddressTypes.PrgRom;
_breakOnExecute.Checked = true;
}
else if (_breakBySymbol.Checked)
{
breakpoint.File = null;
breakpoint.Symbol = _symbol.Text.Trim();
breakpoint.StartAddress = -1;
breakpoint.EndAddress = null;
breakpoint.AddressType = Breakpoint.AddressTypes.Cpu;
breakpoint.UpdateFromSymbols(_project.DebugSymbols);
}
else
{
int startAddress;
int endAddress;
if (!int.TryParse(_fromAddress.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out startAddress))
{
Program.Error("Invalid start address. Must be a hex value.");
return;
}
if (string.IsNullOrWhiteSpace(_toAddress.Text)) endAddress = -1;
else if (!int.TryParse(_toAddress.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out endAddress))
{
Program.Error("Invalid end address. Must be a hex value.");
return;
}
breakpoint.File = null;
breakpoint.Symbol = null;
breakpoint.StartAddress = startAddress;
breakpoint.EndAddress = endAddress >= 0 ? endAddress : null as int?;
if (_addressFromCpu.Checked) breakpoint.AddressType = Breakpoint.AddressTypes.Cpu;
if (_addressFromRom.Checked) breakpoint.AddressType = Breakpoint.AddressTypes.PrgRom;
if (_addressFromVram.Checked) breakpoint.AddressType = Breakpoint.AddressTypes.Ppu;
}
breakpoint.Type = 0;
if (_breakOnExecute.Checked) breakpoint.Type |= Breakpoint.Types.Execute;
if (_breakOnRead.Checked) breakpoint.Type |= Breakpoint.Types.Read;
if (_breakOnWrite.Checked) breakpoint.Type |= Breakpoint.Types.Write;
DialogResult = DialogResult.OK;
Close();
}
}