Ejemplo n.º 1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (_settings.Display.Count == 0)
            {
                _settings.ResetDisplay();
            }

            if (_settings.DisplaySystray.Count == 0)
            {
                _settings.ResetDisplaySystray();
            }

            _settings.Save();

            if (_settings.LaunchAtStartup != _launchAtStartup)
            {
                try
                {
                    RegistryKey rkAutorun = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);

                    if (rkAutorun != null)
                    {
                        if (_settings.LaunchAtStartup)
                        {
                            rkAutorun.SetValue("CIV", System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CIV.exe"), RegistryValueKind.String);
                        }
                        else
                        {
                            rkAutorun.DeleteValue("CIV", false);
                        }
                        rkAutorun.Close();
                    }
                }
                catch (Exception regError)
                {
                    if (regError is UnauthorizedAccessException)
                    {
                        MessageBox.Show(CIV.strings.GeneralSettings_LaunchAtStartupUnauthorized);
                    }
                    else
                    {
                        LogFactory.LogEngine.Instance.Add(regError);
                    }
                }
            }

            if (defaultLanguage != _settings.UserLanguage &&
                MessageBox.Show(CIV.strings.GeneralSettings_LangChanged, CIV.strings.GeneralSettings_Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                App.Restart();
            }

            this.DialogResult = true;

            this.Close();
        }
Ejemplo n.º 2
0
        public static ProgramSettings Load()
        {
            ProgramSettings result;

            if (File.Exists(Filename))
            {
                try
                {
                    #if DEBUG
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings());
                    #else
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings()
                    {
                        Password = _key
                    });
#endif

                    if (result.Display.Count == 0)
                    {
                        result.ResetDisplay();
                    }

                    if (result.DisplaySystray.Count == 0)
                    {
                        result.ResetDisplaySystray();
                    }

                    return(result);
                }
                catch (Exception loadException)
                {
                    MessageBox.Show(loadException.ToString());
                }
            }

            result = new ProgramSettings();
            result.ResetDisplay();
            result.ResetDisplaySystray();

            try
            {
                // Si on arrive pas à sauvegarder, un met un Guid vide. Pour ne pas avoir plein de Guid unique inutile dans les logs
                if (!result.Save())
                {
                    result.Id = Guid.Empty;
                }
            }
            catch { }

            return(result);
        }
Ejemplo n.º 3
0
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     _settings.Save();
     this.DialogResult = true;
     this.Close();
 }
Ejemplo n.º 4
0
        public static ProgramSettings Load()
        {
            ProgramSettings result;

            if (File.Exists(Filename))
            {
                try
                {
                    #if DEBUG
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings());
                    #else
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings() { Password = _key });
            #endif

                    if (result.Display.Count == 0)
                        result.ResetDisplay();

                    if (result.DisplaySystray.Count == 0)
                        result.ResetDisplaySystray();

                    return result;
                }
                catch (Exception loadException)
                {
                    MessageBox.Show(loadException.ToString());
                }
            }

            result = new ProgramSettings();
            result.ResetDisplay();
            result.ResetDisplaySystray();

            try
            {
                // Si on arrive pas à sauvegarder, un met un Guid vide. Pour ne pas avoir plein de Guid unique inutile dans les logs
                if (!result.Save())
                    result.Id = Guid.Empty;
            }
            catch { }

            return result;
        }