コード例 #1
0
        private void Button_Click(object sender, EventArgs e)
        {
            try {
                if (sender == this.buttonApply)
                {
                    // Get Property Grids
                    List <PropertyGrid> propertyGrids = this.GetPropertyGrids(this.tabControlOptions);

                    // Loop through each Property Grid
                    foreach (PropertyGrid propertyGrid in propertyGrids)
                    {
                        // Get Application Settings
                        ApplicationSettingsBase settings = (ApplicationSettingsBase)propertyGrid.SelectedObject;

                        // Reload Application Settings
                        settings.Save();

                        // Reload Application Settings
                        propertyGrid.Refresh();
                    }

                    // Disable Edited Button
                    this.m_edited = false;
                }
                else if (sender == this.buttonCancel)
                {
                    // Get Property Grids
                    List <PropertyGrid> propertyGrids = this.GetPropertyGrids(this.tabControlOptions);

                    // Reload
                    foreach (PropertyGrid propertyGrid in propertyGrids)
                    {
                        // Get Application Settings
                        ApplicationSettingsBase settings = (ApplicationSettingsBase)propertyGrid.SelectedObject;

                        // Reload Application Settings
                        settings.Reload();
                    }

                    // Close
                    this.Close();
                }
                else if (sender == this.buttonReset)
                {
                    DialogResult dialogResult = MessageBox.Show(
                        Resources.TEXT_RESET_CURRENT_TAB_WARNING,
                        Resources.TEXT_ARCDIAGRAMMER,
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button3,
                        MessageBoxOptions.DefaultDesktopOnly);
                    switch (dialogResult)
                    {
                    case DialogResult.Cancel:
                    case DialogResult.No:
                        break;

                    case DialogResult.Yes:
                        // Find Current Tab
                        PropertyGrid propertyGrid = this.SelectedPropertGrid(this.tabControlOptions);
                        if (propertyGrid == null)
                        {
                            return;
                        }
                        if (propertyGrid.SelectedObject == null)
                        {
                            return;
                        }
                        if (!(propertyGrid.SelectedObject is ApplicationSettingsBase))
                        {
                            return;
                        }

                        // Get Application Settings
                        ApplicationSettingsBase settings = (ApplicationSettingsBase)propertyGrid.SelectedObject;

                        // Reset Application Settings
                        settings.Reset();

                        // Refresh Application Settings
                        propertyGrid.Refresh();

                        break;
                    }
                }
                else if (sender == this.buttonResetAll)
                {
                    DialogResult dialogResult = MessageBox.Show(
                        Resources.TEXT_RESET_ALL_TABS_WARNING,
                        Resources.TEXT_ARCDIAGRAMMER,
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button3,
                        MessageBoxOptions.DefaultDesktopOnly);
                    switch (dialogResult)
                    {
                    case DialogResult.Cancel:
                    case DialogResult.No:
                        break;

                    case DialogResult.Yes:
                        // Get Property Grids
                        List <PropertyGrid> propertyGrids = this.GetPropertyGrids(this.tabControlOptions);

                        // Loop for each Grid
                        foreach (PropertyGrid propertyGrid in propertyGrids)
                        {
                            // Get Application Settings
                            ApplicationSettingsBase settings = (ApplicationSettingsBase)propertyGrid.SelectedObject;

                            // Reset Application Settings
                            settings.Reset();

                            // Refresh Application Settings
                            propertyGrid.Refresh();
                        }

                        // Disable Edited Button
                        this.m_edited = false;
                        break;
                    }
                }
                else if (sender == this.buttonOK)
                {
                    // Get Property Grids
                    List <PropertyGrid> propertyGrids = this.GetPropertyGrids(this.tabControlOptions);

                    // Loop for each Grid
                    foreach (PropertyGrid propertyGrid in propertyGrids)
                    {
                        // Get Application Settings
                        ApplicationSettingsBase settings = (ApplicationSettingsBase)propertyGrid.SelectedObject;

                        // Save Application Settings
                        settings.Save();
                    }

                    //Close
                    this.Close();
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
コード例 #2
0
 public static void Reset(ApplicationSettingsBase config)
 {
     config.Reset();
 }
コード例 #3
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     settings.Reset();
     //Properties.Settings.Default.Reset ();
     propertyGrid1.Refresh();
 }
コード例 #4
0
 /// <summary>
 /// 設定を規定値にリセットする
 /// </summary>
 /// <param name="settings"></param>
 public static void ResetSettings(ApplicationSettingsBase settings)
 {
     settings.Reset();
 }