Example #1
0
        public static bool CommitDefaultSettings(this ApplicationOptions settings, bool waitWindow = true)
        {
            try
            {
                if (waitWindow)
                {
                    return((bool)WaitWindow.WaitWindow.Show(CommitDefaultSettings, @"Saving settings", settings));
                }
                else
                {
                    //write all new settings
                    var protectedFile = new ProtectedFile(SettingsFile);
                    protectedFile.WriteAllText(settings.ProfileToXml(), ProtectedSettings);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, @"CommitToDefaultError");
            }

            //default
            return(false);
        }
Example #2
0
        public static void ProfileToFile(string fileName, ApplicationOptions options, bool silent = false)
        {
            try
            {
                //delete the existing file if there is one; the user was asked if they wanted to replace it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                //write the profile to the XML file
                File.WriteAllText(fileName, options.ProfileToXml());
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "@SaveProfileError");
                if (!silent)
                {
                    UIMessages.Error(ex.ToString(), @"XML Save Error");
                }
            }
        }