Пример #1
0
        /// <summary>
        /// Loads the settings.
        /// </summary>
        public void LoadSettings()
        {
            //  Do we have a settings file?
            if (File.Exists(GetSettingsPath()))
            {
                //  Try and load it.
                try
                {
                    using (var stream = new FileStream(GetSettingsPath(), FileMode.Open))
                    {
                        //  Create a serializer.
                        var serializer = new XmlSerializer(typeof(Settings));

                        //  Read the settings.
                        Settings = (Settings)serializer.Deserialize(stream);

                    }
                }
                catch (Exception exception)
                {
                    //  Trace the exception.
                    System.Diagnostics.Trace.WriteLine("Exception loading settings file: " + exception);

                    //  Warn the user.
                    MessageBox.Show("Failed to load the settings file.", "Error");
                }
            }
            else
            {
                //  We have no settings file - create the default settings.
                CreateDefaultSettings();
                SaveSettings();
            }
        }
Пример #2
0
 /// <summary>
 /// Creates the default settings.
 /// </summary>
 private void CreateDefaultSettings()
 {
     Settings = new Settings
                    {
                        Accents = new List<Accent>()
                                      {
                                          new Accent
                                              {
                                                  DisplayName = "à",
                                                  AccentValue = "à",
                                                  AltCode = "Alt + 133",
                                                  ShowInMenu = true,
                                                  SortCode = 0
                                              }
                                      },
                                      UseWindowsHotkey = true,
                                      StartOnWindowsLogon = true
                    };
 }