private void btnAdd_Click(object sender, EventArgs e)
        {
            SettingFrame sf;

            switch (tcSettings.SelectedIndex)
            {
            case 0:
                sf = new SettingFrame(FileType.Reports, flpReports, "", 2, true, SetSelectedFrameAction);
                ReportSettingFrames.Add(sf);
                selectedFrame = sf;
                break;

            case 1:
                sf = new SettingFrame(FileType.Customisations, flpCustomisations, "", 2, true, SetSelectedFrameAction);
                CustomisationSettingFrames.Add(sf);
                selectedFrame = sf;
                break;

            case 2:
                sf = new SettingFrame(FileType.Templates, flpTemplates, "", 2, true, SetSelectedFrameAction);
                TemplateSettingFrames.Add(sf);
                selectedFrame = sf;
                break;

            case 3:
                sf = new SettingFrame(FileType.XMLUI, flpXMLUI, "", 2, true, SetSelectedFrameAction);
                XMLUISettingFrames.Add(sf);
                selectedFrame = sf;
                break;
            }
        }
        private void btnSubtract_Click(object sender, EventArgs e)
        {
            if ((selectedFrame != null) && (selectedFrame.label != Config.MasterLabel))
            {
                switch (tcSettings.SelectedIndex)
                {
                case 0:     //Reports
                    flpReports.Controls.Remove(selectedFrame.gb);
                    ReportSettingFrames.Remove(selectedFrame);
                    break;

                case 1:     //Customisations
                    flpCustomisations.Controls.Remove(selectedFrame.gb);
                    CustomisationSettingFrames.Remove(selectedFrame);
                    break;

                case 2:     //Templates
                    flpTemplates.Controls.Remove(selectedFrame.gb);
                    TemplateSettingFrames.Remove(selectedFrame);
                    break;

                case 3:     //XMLUI
                    flpXMLUI.Controls.Remove(selectedFrame.gb);
                    XMLUISettingFrames.Remove(selectedFrame);
                    break;
                }

                selectedFrame = null;
            }
        }
        private void Settings_Load(object sender, EventArgs e)
        {
            //If a file is copied from prod to master, the whole screen needs to be reloaded.
            //So need to pass this function inside the MissingFileFrame, so it can be called there.
            SetSelectedFrameAction = SetSelectedFrame;

            string[] allKeys = Config.AllSettings();
            for (int i = 0; i < allKeys.Length; i++)
            {
                SettingFrame sf;
                string       key   = allKeys[i];
                string       label = Config.LabelFromKey(key);
                if (key.StartsWith(Config.ReportPrefix) && !key.EndsWith(Config.BackupSuffix))
                {
                    sf = new SettingFrame(FileType.Reports, flpReports, label, 2, false, SetSelectedFrameAction);
                    flpReports.Controls.Add(sf.gb);
                    ReportSettingFrames.Add(sf);
                }
                else if (key.StartsWith(Config.CustomisationPrefix) && !key.EndsWith(Config.BackupSuffix))
                {
                    sf = new SettingFrame(FileType.Customisations, flpCustomisations, label, 2, false, SetSelectedFrameAction);
                    flpCustomisations.Controls.Add(sf.gb);
                    CustomisationSettingFrames.Add(sf);
                }
                else if (key.StartsWith(Config.TemplatePrefix) && !key.EndsWith(Config.BackupSuffix))
                {
                    sf = new SettingFrame(FileType.Templates, flpTemplates, label, 2, false, SetSelectedFrameAction);
                    flpTemplates.Controls.Add(sf.gb);
                    TemplateSettingFrames.Add(sf);
                }
                else if (key.StartsWith(Config.XMLUIPrefix) && !key.EndsWith(Config.BackupSuffix))
                {
                    sf = new SettingFrame(FileType.XMLUI, flpXMLUI, label, 2, false, SetSelectedFrameAction);
                    flpXMLUI.Controls.Add(sf.gb);
                    XMLUISettingFrames.Add(sf);
                }
            }

            //switch tabs depending on file type chosen
            switch (Config.FileType)
            {
            case FileType.Reports:
                tcSettings.SelectedIndex = 0;
                break;

            case FileType.Customisations:
                tcSettings.SelectedIndex = 1;
                break;

            case FileType.Templates:
                tcSettings.SelectedIndex = 2;
                break;

            case FileType.XMLUI:
                tcSettings.SelectedIndex = 3;
                break;
            }
        }
 private void SetSelectedFrame(SettingFrame sf)
 {
     selectedFrame = sf;
 }