Beispiel #1
0
        /// <summary>
        /// React to generate request.
        /// Validate selection and destination before passing on final generate order.
        /// </summary>
        /// <param name="destination">Destination folder for resulting files (folder path).</param>
        /// <param name="property">Index of the desired grouping function.</param>
        /// <param name="limit">Batch size limit (voters / file).</param>
        public void GenerateHandler(string destination, int property, int limit)
        {
            // Selection validation.
            int          old    = model.ValidateSelection();
            DialogResult result = DialogResult.None;

            if (old > 0)
            {
                result = MessageBox.Show("The selection contains " + old + " voters who already had their voter cards generated previously, do you wish to continue?", "Cards already generated", MessageBoxButtons.YesNo);
            }
            if (old == -1)
            {
                return;
            }
            if (result == DialogResult.No)
            {
                return;
            }

            // Destination validation.
            result = DialogResult.None;
            if (Directory.Exists(destination))
            {
                result = MessageBox.Show("The specified folder does not exist and will be created, do you wish to continue?", "Unknown folder", MessageBoxButtons.OKCancel);
            }
            if (result == DialogResult.OK)
            {
                Directory.CreateDirectory(destination);
            }
            else if (result == DialogResult.Cancel)
            {
                return;
            }

            view.GeneratingMode("Initializing..");
            model.Generate(destination, property, limit);
        }