Exemple #1
0
        /// <summary>
        /// save report settings with a new name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MI_SaveSettingsAs_Click(System.Object sender, System.EventArgs e)
        {
            if (ColumnChangedWithErrorMessage(Catalog.GetString("Settings cannot be saved")))
            {
                return;
            }

            // read the settings and parameters from the controls
            if (!ReadControlsWithErrorHandling(TReportActionEnum.raSave))
            {
                return;
            }

            if (FCurrentSettingsName == "")
            {
                FCurrentSettingsName = FCurrentReport;
            }

            TFrmSettingsSave SettingsDialog = new TFrmSettingsSave(FStoredSettings, FCurrentSettingsName);

            if (SettingsDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StringCollection RecentlyUsedSettings = null;

                FCurrentSettingsName = SettingsDialog.GetNewName();

                try
                {
                    RecentlyUsedSettings = this.FStoredSettings.SaveSettings(FCurrentSettingsName, FCalculator.GetParameters());
                    // set the title of the window
                    SetWindowTitle();
                }
                catch (Exception)
                {
                    MessageBox.Show("Not a valid name. Please use letters numbers and underscores etc. Values not saved");
                }

                if (RecentlyUsedSettings != null)
                {
                    UpdateLoadingMenu(RecentlyUsedSettings);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// save report settings with a new name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MI_SaveSettingsAs_Click(System.Object sender, System.EventArgs e)
        {
            if (ColumnChangedWithErrorMessage(Catalog.GetString("Settings cannot be saved")))
            {
                return;
            }

            // Find the currently active control
            Control CurrentActiveControl;
            ContainerControl ParentControl = GetForm();

            do
            {
                CurrentActiveControl = ParentControl.ActiveControl;
                ParentControl = CurrentActiveControl as ContainerControl;
            } while (ParentControl != null);

            // Temporily remove focus from active control. This ensures OnLeave event is fired for control.
            GetForm().ActiveControl = null;

            try
            {
                // read the settings and parameters from the controls
                if (!ReadControlsWithErrorHandling(TReportActionEnum.raSave))
                {
                    return;
                }

                if (FCurrentSettingsName == "")
                {
                    FCurrentSettingsName = FCurrentReport;
                }

                TFrmSettingsSave SettingsDialog = new TFrmSettingsSave(FStoredSettings, FCurrentSettingsName);

                if (SettingsDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    StringCollection RecentlyUsedSettings = null;

                    FCurrentSettingsName = SettingsDialog.GetNewName();

                    try
                    {
                        RecentlyUsedSettings = this.FStoredSettings.SaveSettings(FCurrentSettingsName, FCalculator.GetParameters());
                        // set the title of the window
                        SetWindowTitle();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Not a valid name. Please use letters numbers and underscores etc. Values not saved");
                    }

                    if (RecentlyUsedSettings != null)
                    {
                        UpdateLoadingMenu(RecentlyUsedSettings);
                    }
                }
            }
            finally
            {
                // Return focus to control.
                GetForm().ActiveControl = CurrentActiveControl;
            }
        }