internal static void BreakDownCountryYear(Dictionary <int, string> hhTypes = null, List <string> outputFiles = null)
        {
            try
            {
                List <HHTypes_Files> hhTypes_files = new List <HHTypes_Files>();
                if (hhTypes == null) // call from Stastics-Menu: let user select files
                {                    // and find out which HH-types are contained in which files
                    if (!MenuCall_GetSelection(TEMPLATE_NAME_BARS_PER_COUNTRYYEAR, out hhTypes_files))
                    {
                        return;
                    }
                }
                else // call from Wizard: all files contain all hh-types
                {    // put parameter-content into Dictionary, to allow for common further treatment
                    foreach (var hhType in hhTypes)
                    {
                        hhTypes_files.Add(new HHTypes_Files()
                        {
                            hhTypeID = hhType.Key.ToString(), hhTypeName = hhType.Value, files = outputFiles
                        });
                    }
                }

                List <FilePackageContent> filePackages = new List <FilePackageContent>();
                List <Template.TemplateInfo.UserVariable> userVariables = new List <Template.TemplateInfo.UserVariable>();
                foreach (HHTypes_Files hhtf in hhTypes_files)
                {
                    FilePackageContent fpc = new FilePackageContent();
                    foreach (string file in hhtf.files)
                    {
                        fpc.PathsAlt.Add(file);
                    }
                    userVariables.Add(new Template.TemplateInfo.UserVariable()
                    {
                        name        = USER_VARIABLE_HHTYPE_SELECTED,
                        description = hhtf.hhTypeName,
                        value       = hhtf.hhTypeID,
                        packageKey  = fpc.Key
                    });
                    filePackages.Add(fpc);
                }

                StartPresenter(TEMPLATE_NAME_BARS_PER_COUNTRYYEAR, filePackages, userVariables);
            }
            catch (Exception e) { MessageBox.Show("Failed to generate Statistics." + Environment.NewLine + e.Message); }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (listBase.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a file for the base scenario."); return;
            }

            int selCount = listAlt.SelectedIndices.Count;

            if (selCount < templateInfo.minFiles || selCount > templateInfo.maxFiles)
            {
                if (templateInfo.maxFiles == 1)
                {
                    MessageBox.Show("Please select a file for the alternative scenario.");                             // is the same as selCount=0 (as list is in single-selection mode)
                }
                else if (templateInfo.minFiles == templateInfo.maxFiles)
                {
                    MessageBox.Show(string.Format("Please select {0} files for the alternative scenarios.", templateInfo.maxFiles));
                }
                else if (templateInfo.maxFiles == int.MaxValue)
                {
                    MessageBox.Show(string.Format("Please select at least {0} files for the alternative scenarios.", templateInfo.minFiles));
                }
                else
                {
                    MessageBox.Show(string.Format("Please select {0} to {1} files for the alternative scenarios.", templateInfo.minFiles, templateInfo.maxFiles));
                }
                return;
            }

            FilePackageContent filePackage = new FilePackageContent()
            {
                PathBase = Path.Combine(textBasePath.Text, listBase.SelectedItem.ToString())
            };

            foreach (string altFile in selectedIndices.Select(i => listAlt.Items[i]))  // get alt selections in order
            {
                filePackage.PathsAlt.Add(Path.Combine(textAltPath.Text, altFile));
            }

            // in fact the dialog always returns exactly one file-package, the list is just for consistency-reasons with SelectFilesForm and SelectTemplateForm
            filePackages = new List <FilePackageContent>()
            {
                filePackage
            };

            // save selected paths in UI-user-settings (see description in SelectFileForm.cs )
            if (!EMPath.IsSamePath(textBasePath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower()))
            {
                UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER, textBasePath.Text);
            }
            else
            {
                UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER);
            }
            if (!EMPath.IsSamePath(textAltPath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower()))
            {
                UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER, textAltPath.Text);
            }
            else
            {
                UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }