コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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
            }
        }