private static readonly Regex _regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text public AddStudent(AttendanceDatabase database, ArduinoSerialComms arduino, bool editStudent = false, Student student = null) { InitializeComponent(); this.database = database; this.arduino = arduino; this.arduino.TagReceived += TagReceived; editMode = editStudent; //If we are editing, the setup the window if (editMode) { this.student = student; Title = "Edit student"; txbTitle.Text = "Edit student"; txtFirstname.Text = student.firstname; txtLastname.Text = student.lastname; txtOasisID.Text = student.oasisid.ToString(); txtFinishYear.Text = student.finishyear.ToString(); currentUid = student.uid; btnSaveNext.IsEnabled = false; //If we have a uid, then update the textblock if (currentUid != 0) { txbUID.Text = $"Tag will be set to {BitConverter.ToString(BitConverter.GetBytes(currentUid))}"; txbUID.Foreground = Brushes.PaleGreen; } } }