protected override void OnVisibleChanged(EventArgs e) { if (Visible) { DialogResult = DialogResult.None; CurrentMemoryManipulation = null; } base.OnVisibleChanged(e); }
private void FinishMemoryManipulation() { if (string.IsNullOrEmpty(txtManipulationValue.Text)) { MessageBox.Show("You have to set the value first.", "Value not set", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!int.TryParse(txtOffset.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var offset)) { MessageBox.Show("The offset is invalid.", "Invalid offset.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } switch (cmbType.Text) { case "Value": if (!byte.TryParse(txtManipulationValue.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var value)) { MessageBox.Show("The value doesn't fit in a byte.", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CurrentMemoryManipulation = new ValueMemoryManipulation(offset, value); break; case "File": if (!File.Exists(txtManipulationValue.Text)) { MessageBox.Show("The file does not exist.", "Invalid file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CurrentMemoryManipulation = new FileMemoryManipulation(offset, txtManipulationValue.Text); break; } DialogResult = DialogResult.OK; Close(); }