Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VoterCardGeneratorWindow"/> class.
 /// </summary>
 /// <param name="model"> Model depicted by the view. </param>
 public VoterCardGeneratorWindow(VoterCardGenerator model)
 {
     InitializeComponent();
     this.model = model;
     this.InitialValues();    // Set up initial values for controls.
     this.SubscribeToModel(); // Subscribe to changes in model.
 }
Example #2
0
        public void SetUp()
        {
            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            // Create a municipality
            var mDAO = new MunicipalityDAO();

            mDAO.Create(new MunicipalityDO(9998, "Teststreet 42", "4242 Testcity", "Municipality of Test"));
            IEnumerator <MunicipalityDO> muns =
                mDAO.Read(m => m.Name.StartsWith("Municipality of Test")).GetEnumerator();

            muns.MoveNext();
            this.mun = muns.Current;

            // Create 3 polling stations.
            var pDAO = new PollingStationDAO();

            pDAO.Create(new PollingStationDO(this.mun.PrimaryKey, 10000, "Test Polling Station 1", "Teststreet 44"));
            pDAO.Create(new PollingStationDO(this.mun.PrimaryKey, 10001, "Test Polling Station 2", "Teststreet 45"));
            pDAO.Create(new PollingStationDO(this.mun.PrimaryKey, 10002, "Test Polling Station 3", "Teststreet 46"));
            IEnumerator <PollingStationDO> pss =
                pDAO.Read(po => po.Name.StartsWith("Test Polling Station")).GetEnumerator();
            int pi = 0;

            while (pss.MoveNext())
            {
                this.ps[pi++] = pss.Current;
            }

            // Create 10 voters.
            var vDAO = new VoterDAO();

            vDAO.Create(new VoterDO(this.ps[0].PrimaryKey, 101264242, "Test Testson 1", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[1].PrimaryKey, 101264243, "Test Testson 2", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[2].PrimaryKey, 101264244, "Test Testson 3", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[0].PrimaryKey, 101264245, "Test Testson 4", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[0].PrimaryKey, 101264246, "Test Testson 5", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[1].PrimaryKey, 101264247, "Test Testson 6", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[1].PrimaryKey, 101264248, "Test Testson 7", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[2].PrimaryKey, 101264249, "Test Testson 8", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[2].PrimaryKey, 101264250, "Test Testson 9", "Teststreet 47", "4242 Testcity", false, false));
            vDAO.Create(new VoterDO(this.ps[2].PrimaryKey, 101264251, "Test Testson 10", "Teststreet 47", "4242 Testcity", false, false));
            IEnumerator <VoterDO> voters = vDAO.Read(vo => vo.Name.StartsWith("Test Testson")).GetEnumerator();
            int vi = 0;

            while (voters.MoveNext())
            {
                this.v[vi++] = voters.Current;
            }

            // Setup Voter Card Generator sub-system.
            this.filter        = new VoterFilter(mun);
            this.vcg           = new VoterCardGenerator(filter);
            this.vcgView       = new VoterCardGeneratorWindow(this.vcg);
            this.vcgController = new VoterCardGeneratorController(this.vcg, this.vcgView);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VoterCardGeneratorController"/> class.
        /// </summary>
        /// <param name="model"> The associated model (Voter Card Generator). </param>
        /// <param name="view"> The associated view (Voter Card Generator Window). </param>
        public VoterCardGeneratorController(VoterCardGenerator model, VoterCardGeneratorWindow view)
        {
            this.model = model;
            this.view = view;

            // Subscribe to View
            view.AddGenerateHandler(this.GenerateHandler);
            view.AddAbortHandler(model.Abort);

            // Show View
            view.Show();
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VoterCardGeneratorController"/> class.
        /// </summary>
        /// <param name="model"> The associated model (Voter Card Generator). </param>
        /// <param name="view"> The associated view (Voter Card Generator Window). </param>
        public VoterCardGeneratorController(VoterCardGenerator model, VoterCardGeneratorWindow view)
        {
            this.model = model;
            this.view  = view;

            // Subscribe to View
            view.AddGenerateHandler(this.GenerateHandler);
            view.AddAbortHandler(model.Abort);

            // Show View
            view.Show();
        }
Example #5
0
        static void Main()
        {
            string ElectionName = "Election 23";
            string ElectionDate = "01-01-01";
            string ElectionTime = "12:00";

            string SenderMunicipality = "Københavns Kommune";
            string SenderStreet       = "Aabyvej 23";
            string SenderCity         = "København Ø";

            string VoterFirstName = "Frank";
            string VoterLastName  = "Hansen";
            string VoterStreet    = "Poppelvej 3";
            string VoterCity      = "Ganløse";

            string PollingTable = "9";
            string VoterNumber  = "12345678";

            string VenueName   = "Ganløse Skole";
            string VenueStreet = "Genvej 66";
            string VenueCity   = "Ganløse";

            var vcg = new VoterCardGenerator(ElectionName, ElectionDate, ElectionTime);

            vcg.CreatePollingCard(SenderMunicipality,
                                  SenderStreet,
                                  SenderCity,
                                  VoterFirstName,
                                  VoterLastName,
                                  VoterStreet,
                                  VoterCity,
                                  PollingTable,
                                  VoterNumber,
                                  VenueName,
                                  VenueStreet,
                                  VenueCity);
            vcg.SaveToDisk("../VoterCard.pdf");


            uint Rows = 21;

            var vlg = new VoterListGenerator(Rows, ElectionName, ElectionDate, PollingTable);

            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.AddVoter(VoterFirstName, VoterLastName, "1234567890", VoterNumber);
            vlg.SaveToDisk("../voterList.pdf");
        }