예제 #1
0
        private void buttonExportXML_Click(object sender, EventArgs e)
        {
            var result = xmlSaveFileDialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var tempSettings = new EditorSettingsSaved();
                tempSettings.CopyFrom(EditorState.SavedPrefs);
                tempSettings.CopyFrom(EditorState.Prefs);
                tempSettings.RecentFiles.Clear(); // don't save recent files
                tempSettings.SaveToFile(xmlSaveFileDialog.FileName);
                if (EditorState.ShouldDisplayMessage(InformationLevel.Normal))
                {
                    MessageBox.Show(this,
                                    "Settings have been successfully exported.",
                                    "Info",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
예제 #2
0
        private void buttonImportXML_Click(object sender, EventArgs e)
        {
            var result = xmlOpenFileDialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var tempSettings = new EditorSettingsSaved();
                if (!tempSettings.ReloadFromFile(xmlOpenFileDialog.FileName))
                {
                    MessageBox.Show(this,
                                    "The selected file is invalid.",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                    return;
                }

                if (MessageBox.Show(this,
                                    "Are you sure you want to replace your existing settings with the imported settings?\nImporting from: " + xmlOpenFileDialog.FileName,
                                    "Confirm",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    EditorState.SavedPrefs.CopyFrom(EditorState.DefaultPrefs);
                    EditorState.SavedPrefs.CopyFrom(tempSettings);
                    EditorState.Prefs.CopyFrom(EditorState.SavedPrefs);

                    if (EditorState.ShouldDisplayMessage(InformationLevel.Normal))
                    {
                        MessageBox.Show(this,
                                        "Settings have been successfully imported.",
                                        "Info",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
            }
        }