Esempio n. 1
0
        private bool ContinueDialog()
        {
            if (ConfigHasChanged)
            {
                switch (MessageBox.Show(Owner, "The current configuration has changed. Do you want to save the changes?\nPress Yes to save your changes.\nPress No to discard your changes.\nPress Cancel to abort this operation.", "Save changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                {
                case System.Windows.Forms.DialogResult.Yes:
                    SaveGlobalConfigDialog.FileName = ConfigFilename;

                    if (SaveGlobalConfigDialog.ShowDialog(Owner) == DialogResult.OK)
                    {
                        SaveConfig(SaveGlobalConfigDialog.FileName);
                    }
                    else
                    {
                        if (MessageBox.Show(Owner, "You config has not been saved.\nDo you want to continue and discard your changes?", "Discard changes", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
                        {
                            return(false);
                        }
                    }
                    return(true);

                case System.Windows.Forms.DialogResult.No:
                    return(true);

                default:
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveGlobalConfigDialog.FileName = ConfigFilename;

            if (SaveGlobalConfigDialog.ShowDialog(Owner) == DialogResult.OK)
            {
                SaveConfig(SaveGlobalConfigDialog.FileName);
            }
        }
Esempio n. 3
0
        public bool SaveConfigData()
        {
            try
            {
                if (!ValidateConfigData())
                {
                    MessageBox.Show(this, "The data specified for the Global Configuration contains some invalid data.\nPlease correct the data before saving.", "Invalid global configuration data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                if (GlobalConfig.GlobalConfigFilename.IsNullOrWhiteSpace())
                {
                    SaveGlobalConfigDialog.InitialDirectory = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
                    if (SaveGlobalConfigDialog.ShowDialog(this) != DialogResult.OK)
                    {
                        return(false);
                    }
                    GlobalConfig.GlobalConfigFilename = SaveGlobalConfigDialog.FileName;
                }


                UpdateGlobalConfigData(GlobalConfig);

                GlobalConfig.SaveGlobalConfig();

                MessageBox.Show(this, "Global config saved to\n{0}.\n\nYou must restart the framework to activate the new global config settings.".Build(GlobalConfig.GlobalConfigFilename), "Global configuration saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Modified = false;
                return(true);
            }
            catch (Exception E)
            {
                MessageBox.Show(this, "Could not save global configuration.\nA exception occured:\n{0}".Build(E.Message), "Global config save error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Exception("Could not save global configuration.\nA exception occured", E);
                return(false);
            }
        }