public PollingMain() { Model model = new Model(); PtView view = new PtView(model); Controller controller = new Controller(model, view); if (SingleInstance) { // get the name of our process string proc = Process.GetCurrentProcess().ProcessName; // get the list of all processes by that name Process[] processes = Process.GetProcessesByName(proc); // if there is more than one process... if (processes.Length > 1) { MessageBox.Show("Application is already running"); return; } view.SetupWindow.ShowDialog(); view.ScannerWindow.TableNumber.Text = model.SetupInfo.TableNo.ToString(); Application.Run(view.ScannerWindow); } else //Only used when allowing more than one instance of the polling table. #pragma warning disable 162 { view.SetupWindow.ShowDialog(); view.ScannerWindow.TableNumber.Text = model.SetupInfo.TableNo.ToString(); Application.Run(view.ScannerWindow); } #pragma warning restore 162 }
public Controller(Model model, PtView view) { this.view = view; this.model = model; //Button subscriptions. When the user presses a button the controller is notified. view.ScannerWindow.FindVoterButton.Click += this.ReactTofindVoterRequest; view.VoterShown += this.ReactToRegisterRequest; view.Unregister += this.ReactToUnregRequest; view.SetupWindow.ConnectBtn.Click += this.ReactToConnectRequest; this.SetupPollingTable(); //Setup polling table with setup.conf information. }