/// <summary> Initializes a new instance of the <see cref="VoterSelectionController"/> class. </summary> /// <param name="mainModel"> The main model. </param> /// <param name="view"> A voter selection view. </param> public VoterSelectionController(VoterSelection mainModel, VoterSelectionWindow view) { this.mainModel = mainModel; this.view = view; view.AddPSSelectionChangedHandler(this.PSSelectionChanged); view.AddMSelectionChangedHandler(this.MSelectionChanged); view.addCPRTextChangedHandler(this.CPRTextChanged); this.view.Closed += (o, eA) => Environment.Exit(-1); }
/// <summary> /// A view for controlling and monitoring the Voter Selector. /// /// Depicts the current state of the Voter Selector /// Raises events about user input (to be listened to by controller(s)). /// </summary> /// <param name="model"></param> public VoterSelectionWindow(VoterSelection model) { InitializeComponent(); this.model = model; this.pshandlers = new List<EventHandler>(); // Get initial values (default selection = no filter) this.cbxMunicipalities.DataSource = model.Municipalities; this.cbxPollingStation.DataSource = model.PollingStations; this.setVoterCount(model.VoterCount); // Subscribe to updates in model model.PollingStationsChanged += this.UpdatePollingStations; model.VoterCountChanged += this.UpdateVoterCount; model.SelectedMunicipalityChanged += this.UpdateSelectedMunicipality; model.SelectedPollingStationChanged += this.UpdateSelectedPollingStation; // Setup text box this.txbCPRNO.KeyPress += this.TextBoxOnlyAllowDigits; }
/// <summary> /// A view for controlling and monitoring the Voter Selector. /// /// Depicts the current state of the Voter Selector /// Raises events about user input (to be listened to by controller(s)). /// </summary> /// <param name="model"></param> public VoterSelectionWindow(VoterSelection model) { InitializeComponent(); this.model = model; this.pshandlers = new List <EventHandler>(); // Get initial values (default selection = no filter) this.cbxMunicipalities.DataSource = model.Municipalities; this.cbxPollingStation.DataSource = model.PollingStations; this.setVoterCount(model.VoterCount); // Subscribe to updates in model model.PollingStationsChanged += this.UpdatePollingStations; model.VoterCountChanged += this.UpdateVoterCount; model.SelectedMunicipalityChanged += this.UpdateSelectedMunicipality; model.SelectedPollingStationChanged += this.UpdateSelectedPollingStation; // Setup text box this.txbCPRNO.KeyPress += this.TextBoxOnlyAllowDigits; }