public static TimerBaseForm CreateForType(TimerFormType timerFormType, Worksheet sheet, string title) { TimerBaseForm timerBase = new TimerBaseForm { Text = title }; switch (timerFormType) { case TimerFormType.CHECKIN: timerBase.SetupCheckinTimersForm(sheet); break; case TimerFormType.CHECKIN_ARRIVAL: timerBase.SetupCheckinArrivalTimersForm(sheet); break; case TimerFormType.VOTING_BOOTH: timerBase.SetupVotingBoothTimersForm(sheet); break; case TimerFormType.BMD: timerBase.SetupBMDTimersForm(sheet); break; case TimerFormType.BALLOT_SCANNING: timerBase.SetupBallotScanningTimersForm(sheet); break; case TimerFormType.THROUGHPUT_ARRIVAL: timerBase.SetupThroughputArrivalTimersForm(sheet); break; } return(timerBase); }
public static TimerBaseForm CreateWithTimerTypes(TimerControl.TimerType[] timerTypes, bool includeArrival, Worksheet sheet, string title) { TimerBaseForm baseForm = new TimerBaseForm { Text = title }; if (includeArrival) { baseForm.PopulateArrivalTimer(sheet); } baseForm.PopulateTimersTablePanel(timerTypes, sheet, 0, includeArrival ? 3 : 0); return(baseForm); }
private void TimerOpenButton_Click(object sender, RibbonControlEventArgs e) { TimerBaseForm form; string name = ((Microsoft.Office.Tools.Ribbon.RibbonButton)sender).Label; Worksheet sheet = Util.TryAddingSheetWithName(name); for (int i = 2; i < 50 && sheet == null; i++) { // Try adding sheets with successively increasing suffixes in case the first name we tried // was already taken. sheet = Util.TryAddingSheetWithName(name + " " + i); } if (sheet == null) { // If sheet is still null after 50 tries to create it, something is seriously wrong. Bail out. Util.MessageBox("A worksheet could not be created for the timers."); return; } switch (e.Control.Id) { case "CheckinTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.CHECKIN, sheet, name); break; case "CheckinArrivalTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.CHECKIN_ARRIVAL, sheet, name); break; case "VotingBoothTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.VOTING_BOOTH, sheet, name); break; case "BMDTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.BMD, sheet, name); break; case "BallotScanningTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.BALLOT_SCANNING, sheet, name); break; case "ThroughputArrivalTimerButton": form = TimerBaseForm.CreateForType(TimerBaseForm.TimerFormType.THROUGHPUT_ARRIVAL, sheet, name); break; default: throw new NotImplementedException(); } form.Show(); }
private void CreateButton_Click(object sender, EventArgs e) { int count = this.timersListBox.Items.Count; if (count == 0 && !this.arrivalTimerCheckbox.Checked) { Util.MessageBox("Please select at least one timer."); return; } string[] niceNames = new string[count]; this.timersListBox.Items.CopyTo(niceNames, 0); TimerControl.TimerType[] toCreateTypes = niceNames.Select( name => this.allTypes[Array.IndexOf(this.allNiceNames, name)]).ToArray(); TimerBaseForm.CreateWithTimerTypes(toCreateTypes, this.arrivalTimerCheckbox.Checked, this.worksheet, Properties.Resources.customTimersTitle).Show(); this.created = true; this.Dispose(); }