示例#1
0
 public void Closing()
 {
     if (UpdateTroveGameStatus)
     {
         TroveGameStatus.StopTimer();
     }
 }
示例#2
0
        public void LoadData()
        {
            canSaveData = false;
            try
            {
                log.Info("Loading location settings");

                // Setup auto-saving of locations when the collection or items in the collection change
                Locations.CollectionChanged += (s, e) =>
                {
                    if (e.OldItems != null)
                    {
                        foreach (INotifyPropertyChanged item in e.OldItems)
                        {
                            item.PropertyChanged -= SaveLocationSettings;
                        }
                    }
                    if (e.NewItems != null)
                    {
                        foreach (INotifyPropertyChanged item in e.NewItems)
                        {
                            item.PropertyChanged += SaveLocationSettings;
                        }
                    }

                    SaveLocationSettings();
                };

                // Load locations from model and create view model objects
                foreach (TroveLocation loc in TroveLocation.Locations)
                {
                    Locations.Add(new TroveLocationViewModel(loc));
                }

                // Start Trove game status timer on load if setting is enabled
                if (UpdateTroveGameStatus)
                {
                    TroveGameStatus.StartTimer(TrovesaurusAccountLinkKey);
                }

                // Setup auto update interval options
#if DEBUG
                _AutoUpdateIntervals.Add(new TimeSpan(0, 0, 30));
                _AutoUpdateIntervals.Add(new TimeSpan(0, 1, 0));
#endif
                _AutoUpdateIntervals.Add(new TimeSpan(0, 5, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(0, 10, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(0, 15, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(0, 30, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(0, 45, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(1, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(2, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(3, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(4, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(5, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(6, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(12, 0, 0));
                _AutoUpdateIntervals.Add(new TimeSpan(1, 0, 0, 0));

                if (_AutoUpdateIntervals.Contains(SettingsDataProvider.AutoUpdateInterval))
                {
                    AutoUpdateIntervalsView.MoveCurrentTo(SettingsDataProvider.AutoUpdateInterval);
                }
                AutoUpdateIntervalsView.CurrentChanged += (s, e) =>
                {
                    SettingsDataProvider.AutoUpdateInterval = (TimeSpan)AutoUpdateIntervalsView.CurrentItem;
                    if (AutoUpdateMods)
                    {
                        MainWindowViewModel.Instance.MyMods.StartUpdateTimer(SettingsDataProvider.AutoUpdateInterval);
                    }
                };

                canSaveData = true;
                SaveLocationSettings();
            }
            catch (Exception ex)
            {
                log.Error("Error loading location settings", ex);
            }
            finally
            {
                canSaveData = true;
            }
        }