public frmTheButton(Edgework edges) { InitializeComponent(); cboButtonText.SelectedIndex = 0; cboButtonColor.SelectedIndex = 0; nudBatteries.Value = edges.getBatteries(); chkLitCAR.Checked = edges.findIndicator("CAR", true); chkLitFRK.Checked = edges.findIndicator("FRK", true); }
public frmComplexWires(Edgework edges) { InitializeComponent(); currentBomb = edges; clbEdgeworkData.Enabled = false; btnResetEdgework.Enabled = false; clbEdgeworkData.SetItemChecked(0, !(edges.isSerialOdd())); clbEdgeworkData.SetItemChecked(1, (edges.getBatteries() >= 2)); clbEdgeworkData.SetItemChecked(2, (edges.portCount("PARALLEL") >= 1)); startTable(); }
private void applyEdgework(object sender, EventArgs e) { //Time for a whole lot of checking! //Here's some temporary variables to make it easier to read everything and have fewer calls to controls mid-statement. //Shoutouts to @Blananas2#6835 in the KTaNE discord for making a post long ago explaining the format of the serial number. //I then turned his post into a regex! Could probably use a little optimization, but it'll do for now //I tried to use the [[:alpha:]] shorthand in it but apparently it doesn't like that bool readyToApply = true; erpEdgeworkValidator.Clear(); int numBatteries = decimal.ToInt32(nudBatteries.Value); int numHolders = decimal.ToInt32(nudHolders.Value); String litList = txtLitIndicators.Text; String unlitList = txtUnlitIndicators.Text; String portList = txtPorts.Text; String serialNum = txtSerial.Text; //First, the batteries. There must be the correct ratio of batteries to holders: //Each holder must have exactly 1 or 2 batteries in it. (D or AA) if (((numBatteries == 0) ^ (numHolders == 0)) || (numBatteries < numHolders)) { readyToApply = false; erpEdgeworkValidator.SetError(nudBatteries, "All batteries must have holders, and all holders must have batteries"); } else if (numBatteries > (numHolders * 2)) { readyToApply = false; erpEdgeworkValidator.SetError(nudBatteries, "There must not be more than 2 batteries per holder."); } if (!VALID_SERIAL_REGEX.IsMatch(serialNum)) { readyToApply = false; erpEdgeworkValidator.SetError(txtSerial, "Invalid serial number. Must be in the form XXNLLN, where X is alphanumeric, N is a number, and L is a letter."); } if (readyToApply) { edgework = new Edgework(numBatteries, numHolders, litList, unlitList, portList, serialNum); lblCurrentEdges.Text = "Current Edgework: " + edgework.ToString(); edgeworkReady = true; } else { edgeworkReady = false; } }