private string IsInputValid(string input) { string err = "Invalid format, must be \"<address in hex>(; <x>; <y>; <z>)\""; var parts = input.Replace(" ", "").Split(";"); if (parts.Length != 1 && parts.Length != 4) { return(err); } string addrStr = parts[0]; if (addrStr.StartsWith("0x")) { addrStr = addrStr.Substring(2); } if (!SegmentedAddress.TryParse(addrStr, true, out SegmentedAddress addr)) { return(err); } for (int i = 1; i < parts.Length; i++) { if (!int.TryParse(parts[i], out int res)) { return(err); } } return(null); }
private void addressValue_TextChanged(object sender, EventArgs e) { okBtn.Enabled = SegmentedAddress.TryParse(addressValue.Text, true, out var _); }