Ejemplo n.º 1
0
        private bool StopPrepare(out string warningMessage)
        {
            if (_killingTimer != null)
            {
                _killingTimer.Dispose();
                _killingTimer = null;
            }

            this.BlurApply(UiUtils.DefaultBlurRadius, TimeSpan.FromMilliseconds(200), TimeSpan.Zero);
            var killingWaitWindow = new WaitWindow(_selfTesterAppName, "Killing Visual Studio's...")
            {
                Owner = this
            };
            var       countdownThreshold  = 10;
            const int launchTimerInterval = 500;

            /* В течении countdownThreshold * launchTimerInterval миллисекунд будем
             * принудительно завершать процессы, порожденные SelfTester'ом */
            _killingTimer = AutoResetTimer.Create(() =>
            {
                if (countdownThreshold-- > 0)
                {
                    ProcessUtils.MandatoryKill(Process.GetCurrentProcess(), false);
                }
                else
                {
                    _killingTimer.Dispose();
                    RunInUiSynchronizationContext(() =>
                    {
                        killingWaitWindow.Close();
                        this.BlurDisable(TimeSpan.FromSeconds(1), TimeSpan.Zero);
                    });
                }
            }, launchTimerInterval)
                            .Shedule(() => { RunInUiSynchronizationContext(() => killingWaitWindow.ShowDialogAlt()); });

            if (_testWorker != null && _testWorker.IsBusy)
            {
                _testWorker.CancelAsync();
                SetupSolutionInfoDataGrid(TestedSolutionsManager.RefreshTestingRunModel(_selectedRunFolder));
                SetUiCompletedState();
                UiUtils.ResetActiveStatuses(_currentSelectedSolutions, true);
                warningMessage = string.Empty;
                return(true);
            }

            warningMessage = Properties.Resources.AnalisysNotRunningNow;
            return(false);
        }
Ejemplo n.º 2
0
        public RootViewModel(
            IViewModelFactory viewModelFactory,
            DialogManager dialogManager,
            SettingsService settingsService,
            UpdateService updateService)
        {
            _viewModelFactory = viewModelFactory;
            _dialogManager    = dialogManager;
            _settingsService  = settingsService;

            Core = viewModelFactory.CreateCoreViewModel();

            DisplayName = $"{App.Name} v{App.VersionString}";

            _checkForUpdatesTimer = new AutoResetTimer(async() => await updateService.CheckPrepareUpdateAsync());
        }
Ejemplo n.º 3
0
        public RootViewModel(IViewModelFactory viewModelFactory, DialogManager dialogManager,
                             SettingsService settingsService, UpdateService updateService,
                             GammaService gammaService, HotKeyService hotKeyService,
                             RegistryService registryService, ExternalApplicationService externalApplicationService,
                             SystemEventService systemEventService)
        {
            _viewModelFactory           = viewModelFactory;
            _dialogManager              = dialogManager;
            _settingsService            = settingsService;
            _updateService              = updateService;
            _gammaService               = gammaService;
            _hotKeyService              = hotKeyService;
            _registryService            = registryService;
            _externalApplicationService = externalApplicationService;
            _systemEventService         = systemEventService;

            // Title
            DisplayName = $"{App.Name} v{App.VersionString}";

            // Cancel 'disable temporarily' when switched on
            this.Bind(o => o.IsEnabled, (sender, args) =>
            {
                if (IsEnabled)
                {
                    _enableAfterDelayTimer.Stop();
                }
            });

            // Initialize timers
            _updateConfigurationTimer = new AutoResetTimer(UpdateConfiguration);
            _updateInstantTimer       = new AutoResetTimer(UpdateInstant);
            _updateIsPausedTimer      = new AutoResetTimer(UpdateIsPaused);
            _checkForUpdatesTimer     = new AutoResetTimer(async() => await _updateService.CheckPrepareUpdateAsync());
            _pollingTimer             = new AutoResetTimer(PollGamma);
            _enableAfterDelayTimer    = new ManualResetTimer(Enable);

            // Reset gamma when power settings change
            _systemEventService.DisplayStateChanged += (sender, args) => InvalidateGamma();
            SystemEvents.DisplaySettingsChanging    += (sender, args) => InvalidateGamma();
            SystemEvents.DisplaySettingsChanged     += (sender, args) => InvalidateGamma();
        }
Ejemplo n.º 4
0
        public CoreViewModel(
            SettingsService settingsService,
            GammaService gammaService,
            HotKeyService hotKeyService,
            ExternalApplicationService externalApplicationService)
        {
            _settingsService            = settingsService;
            _gammaService               = gammaService;
            _hotKeyService              = hotKeyService;
            _externalApplicationService = externalApplicationService;

            _updateConfigurationTimer = new AutoResetTimer(UpdateConfiguration);
            _updateInstantTimer       = new AutoResetTimer(UpdateInstant);
            _updateIsPausedTimer      = new AutoResetTimer(UpdateIsPaused);
            _pollingTimer             = new AutoResetTimer(PollGamma);
            _enableAfterDelayTimer    = new ManualResetTimer(Enable);

            // Cancel 'disable temporarily' when switched to enabled
            this.Bind(o => o.IsEnabled, (sender, args) =>
            {
                if (IsEnabled)
                {
                    _enableAfterDelayTimer.Stop();
                }
            });

            // Handle settings changes
            _settingsService.SettingsSaved += (sender, args) =>
            {
                _isStale = true;
                Refresh();
                RegisterHotKeys();
            };

            // Handle display settings changes
            _systemEvents.DisplaySettingsChanged += (sender, args) => _isStale = true;
            _systemEvents.DisplayStateChanged    += (sender, args) => _isStale = true;
        }
Ejemplo n.º 5
0
        public RootViewModel(IEventAggregator eventAggregator, IViewModelFactory viewModelFactory,
                             SettingsService settingsService, UpdateService updateService,
                             CalculationService calculationService, LocationService locationService,
                             WinApiService winApiService)
        {
            _settingsService    = settingsService;
            _calculationService = calculationService;
            _winApiService      = winApiService;

            // Handle messages
            eventAggregator.Subscribe(this);

            // Initialize view models
            GeneralSettings  = viewModelFactory.CreateGeneralSettingsViewModel();
            LocationSettings = viewModelFactory.CreateLocationSettingsViewModel();
            AdvancedSettings = viewModelFactory.CreateAdvancedSettingsViewModel();

            // When IsEnabled switches to 'true' - cancel 'disable temporarily'
            this.Bind(o => o.IsEnabled, (sender, args) =>
            {
                if (IsEnabled)
                {
                    _enableAfterDelayTimer.Stop();
                }
            });

            // Initialize timers
            _updateTimer = new AutoResetTimer(() =>
            {
                UpdateIsPaused();
                UpdateInstant();
                UpdateGamma();
            });

            _settingsAutoSaveTimer = new AutoResetTimer(() => _settingsService.SaveIfNeeded());

            _internetSyncTimer = new AutoResetTimer(async() =>
            {
                if (!_settingsService.IsInternetSyncEnabled)
                {
                    return;
                }

                // TODO: rework later
                var location = await locationService.GetLocationAsync();

                if (_settingsService.IsInternetSyncEnabled)
                {
                    _settingsService.Location = location;

                    var date = DateTimeOffset.Now;
                    _settingsService.SunriseTime = _calculationService.CalculateSunrise(location, date).TimeOfDay;
                    _settingsService.SunsetTime  = _calculationService.CalculateSunset(location, date).TimeOfDay;
                }
            });

            _checkForUpdatesTimer = new AutoResetTimer(async() =>
            {
                IsUpdateAvailable = await updateService.CheckForUpdatesAsync();
            });

            _enableAfterDelayTimer = new ManualResetTimer(Enable);
        }
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
				case 7:
					{
						// remove m_TrapOnLockpick
						// see case 6
						goto case 6;
					}
				case 6:
					{
						m_IsShipwreckedItem = reader.ReadBool();
						if (version < 7)
						{
							reader.ReadBool(); // m_TrapOnLockpick
						}
						goto case 5;
					}
				case 5:
					{
						m_AutoReset = reader.ReadBool();
						m_AutoResetTime = reader.ReadTimeSpan();
						if (m_AutoReset == true)
						{
							m_AutoResetTimer = new AutoResetTimer(this, m_AutoResetTime);
							m_AutoResetTimer.Start();
						}
						goto case 4;
					}
				case 4:
					{
						m_RequiredSkill = reader.ReadInt();

						goto case 3;
					}
				case 3:
					{
						m_MaxLockLevel = reader.ReadInt();

						goto case 2;
					}
				case 2:
					{
						m_KeyValue = reader.ReadUInt();

						goto case 1;
					}
				case 1:
					{
						m_LockLevel = reader.ReadInt();

						goto case 0;
					}
				case 0:
					{
						if (version < 3)
							m_MaxLockLevel = 100;

						if (version < 4)
						{
							if ((m_MaxLockLevel - m_LockLevel) == 40)
							{
								m_RequiredSkill = m_LockLevel + 6;
								m_LockLevel = m_RequiredSkill - 10;
								m_LockLevel = m_RequiredSkill + 39;
							}
							else
							{
								m_RequiredSkill = m_LockLevel;
							}
						}

						m_Locked = reader.ReadBool();

						break;
					}
			}

		}