Exemple #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 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
            }
        }