Beispiel #1
0
        /// <summary>
        /// Updates from the provided serialization object
        /// </summary>
        /// <param name="serial">The serializable version of the new settings. May be null (acts as a reset)</param>
        /// <param name="preferencesOnly">When true, only the user preferences will be reimported, not plans, characters, accounts and such.</param>
        public static void Import(SerializableSettings serial, bool preferencesOnly)
        {
            // When null, we just reset
            if (serial == null)
            {
                Reset();
                return;
            }

            IsRestoringSettings = true;
            try
            {
                EveClient.Trace("Settings.Import() - begin");

                // Import the characters, accounts and plans
                if (!preferencesOnly)
                {
                    // The above check prevents the settings form to trigger a
                    // characters updates since the last queried infos would be lost.
                    EveClient.Characters.Import(serial.Characters);
                    EveClient.Characters.ImportPlans(serial.Plans);
                    EveClient.MonitoredCharacters.Import(serial.MonitoredCharacters);
                    EveClient.Accounts.Import(serial.Accounts);
                }

                // Global settings
                Settings.Compatibility = serial.Compatibility;

                // API providers
                EveClient.APIProviders.Import(serial.APIProviders);

                // Scheduler
                Scheduler.Import(serial.Scheduler);

                // User settings
                Settings.UI            = serial.UI.Clone();
                Settings.G15           = serial.G15.Clone();
                Settings.IGB           = serial.IGB.Clone();
                Settings.Proxy         = serial.Proxy.Clone();
                Settings.Updates       = serial.Updates.Clone();
                Settings.Notifications = serial.Notifications.Clone();
                Settings.Exportation   = serial.Exportation.Clone();
                Settings.Calendar      = serial.Calendar.Clone();

                // Trim the data
                OnImportCompleted();

                // Save
                SaveImmediate();

                // Updates the data right now
                EveClient.UpdateOnOneSecondTick();
                EveClient.OnSettingsChanged();

                EveClient.Trace("Settings.Import() - done");
            }
            finally
            {
                IsRestoringSettings = false;
            }
        }