Beispiel #1
0
        private void Btn_Yes_Click(object sender, EventArgs e)
        {
            reportFormatName = textBox1.Text;
            //check if the name is valid
            if (reportFormatName.Length < 1)
            {
                UIHelperFunctions.postWarning(ReportResource.plrSettings, ReportResource.formatNameMsg);
            }
            else
            {
                //check if the name exists
                PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;
                PressureLossReportData        reportData    = reportDataMgr.getData(reportFormatName);
                if (reportData != null) //post task dialog
                {
                    TaskDialog tdlg = new TaskDialog(ReportResource.plrSettings);
                    tdlg.MainInstruction   = ReportResource.formatNameDuplicateMsg;
                    tdlg.AllowCancellation = true;
                    tdlg.CommonButtons     = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
                    tdlg.DefaultButton     = TaskDialogResult.No;
                    tdlg.TitleAutoPrefix   = false; // suppress the prefix of title.
                    if (tdlg.Show() != TaskDialogResult.Yes)
                    {
                        textBox1.Focus();
                        return;
                    }
                }

                DialogResult = DialogResult.OK;
            }
        }
        private void comboBoxFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;

            settings = reportDataMgr.getData(this.comboBoxFormat.SelectedItem.ToString());
            if (hasFittingsInSystem() && (settings.FittingFields == null || settings.FittingFields.Count < 1))
            {
                FittingsInfo.generateFittingFields(settings);
            }

            fillSettingsControlsFromFormat(settings);
        }
        private void buttonFormatDelete_Click(object sender, EventArgs e)
        {
            PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;
            PressureLossReportFormats     allFormats    = reportDataMgr.getAllFormats();

            if (allFormats == null || allFormats.Count < 1 || this.comboBoxFormat.Items.Count < 1)
            {
                return;
            }

            if (allFormats.Count == 1 || (allFormats.Count == 2 && reportDataMgr.getLastUsedReportData() != null))
            {
                UIHelperFunctions.postWarning(ReportResource.deleteFormatTitle, ReportResource.deleteLastFormatMsg, ReportResource.deleteLastFormatSubMsg);
                return;
            }

            TaskDialog tdlg = new TaskDialog(ReportResource.deleteFormatTitle);

            tdlg.MainInstruction   = ReportResource.deleteFormatMsg;
            tdlg.AllowCancellation = true;
            tdlg.CommonButtons     = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
            tdlg.DefaultButton     = TaskDialogResult.No;
            tdlg.TitleAutoPrefix   = false; // suppress the prefix of title.
            if (tdlg.Show() == TaskDialogResult.Yes)
            {
                // delete the report format, and update the combo list, set the next one as current
                string name = this.comboBoxFormat.SelectedItem.ToString();
                if (name == reportDataMgr.getLastUsedReportName())
                {
                    PressureLossReportData lastData = reportDataMgr.getLastUsedReportData();
                    if (lastData != null)
                    {
                        reportDataMgr.remove(lastData.Name);
                    }
                }

                reportDataMgr.remove(name);

                this.comboBoxFormat.Items.Remove(name);

                if (this.comboBoxFormat.Items.Count > 0)
                {
                    this.comboBoxFormat.SelectedIndex = 0;
                }
            }
        }
 public void executeUpgrades()
 {
     try
     {
         //get format manager
         PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;
         PressureLossReportFormats     formats       = reportDataMgr.getAllFormats();
         if (formats != null && formats.Count > 0)
         {
             foreach (PressureLossReportData data in formats)
             {
                 //get format version
                 upgrades(data);
             }
         }
     }
     catch
     {
     }
 }
        private void buttonSaveFormat_Click(object sender, EventArgs e)
        {
            ReportFormatNameDlg reportFormatDlg = new ReportFormatNameDlg();

            if (reportFormatDlg.ShowDialog() == DialogResult.OK)
            {
                readSettingsDataFromDlg();

                // get report name, and save the report format
                settings.Name = reportFormatDlg.ReportFormatName;
                PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;
                reportDataMgr.save(settings);
                reportFormatDlg.Close();

                if (!this.comboBoxFormat.Items.Contains(settings.Name))
                {
                    int nIndex = this.comboBoxFormat.Items.Add(settings.Name);
                    this.comboBoxFormat.SelectedIndex = nIndex;
                }
            }
        }
        private void FillingData()
        {
            try
            {
                //Way 1:
                //1. Fill in the combo: report format names or "untitled format"
                //?: Which i=one is the default selected?
                PressureLossReportHelper      helper        = PressureLossReportHelper.instance;
                PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance;
                PressureLossReportFormats     formats       = reportDataMgr.getAllFormats();
                if (formats != null && formats.Count > 0)
                {
                    PressureLossReportData lastData = reportDataMgr.getLastUsedReportData();
                    string lastUsedName             = "";
                    foreach (PressureLossReportData data in formats)
                    {
                        if (lastData != null && lastData.Name == data.Name)
                        {
                            lastUsedName = reportDataMgr.getLastUsedReportName();
                            if (formats.Count == 1)
                            {
                                this.comboBoxFormat.Items.Add(lastUsedName);
                            }
                        }
                        else
                        {
                            this.comboBoxFormat.Items.Add(data.Name);
                        }
                    }

                    if (lastUsedName.Length > 0 && this.comboBoxFormat.Items.IndexOf(lastUsedName) > -1)
                    {
                        this.comboBoxFormat.SelectedIndex = this.comboBoxFormat.Items.IndexOf(lastUsedName);
                    }
                    else
                    {
                        this.comboBoxFormat.SelectedIndex = 0;
                    }
                    settings = reportDataMgr.getData(this.comboBoxFormat.SelectedItem.ToString());

                    resetSettings();
                }


                if (settings == null) //fill in default values
                {
                    settings = new PressureLossReportData();

                    generateDefaultFormatData();
                    settings.Name = ReportResource.formatDefaultName;
                    reportDataMgr.save(settings);
                    this.comboBoxFormat.Items.Add(settings.Name);
                    this.comboBoxFormat.SelectedIndex = 0;
                }

                if (settings != null)
                {
                    fillSettingsControlsFromFormat(settings);
                }

                this.buttonUp.Enabled   = false;
                this.buttonDown.Enabled = false;

                this.listBoxAvailableFields.Focus();
                this.listBoxAvailableFields.SetSelected(0, true);

                //title
                if (helper.Domain == ReportResource.pipeDomain)
                {
                    this.Text = ReportResource.pipeSettingsDlgTitle;
                }
                else
                {
                    this.Text = ReportResource.ductSettingsDlgTitle;
                }
            }
            catch
            {
                //do nothing
            }
        }