示例#1
0
        public virtual async Task InitiateAsync()
        {
            Settings.Initiate();
            Settings.KnownMonitors.AbsoluteCapacity = MaxKnownMonitorsCount;
            Settings.PropertyChanged += OnSettingsChanged;

            NotifyIconContainer.ShowIcon("pack://application:,,,/Monitorian.Core;component/Resources/Icons/TrayIcon.ico", ProductInfo.Title);

            _current.MainWindow              = new MainWindow(this);
            _current.MainWindow.Deactivated += (sender, e) => MonitorsResetByKey();

            if (StartupAgent.IsWindowShowExpected())
            {
                _current.MainWindow.Show();
            }

            if (Settings.MakesOperationLog)
            {
                _recorder = new OperationRecorder("Initiated");
            }

            await ScanAsync();

            StartupAgent.Requested += (sender, e) => e.Response = OnRequested(sender, e.Args);

            NotifyIconContainer.MouseLeftButtonClick  += OnMainWindowShowRequestedBySelf;
            NotifyIconContainer.MouseRightButtonClick += OnMenuWindowShowRequested;

            _displayWatcher.Subscribe(() => OnMonitorsChangeInferred(nameof(DisplayWatcher)));
            _powerWatcher.Subscribe((e) => OnMonitorsChangeInferred($"{nameof(PowerWatcher)} - {e.Mode}"), PowerManagement.GetOnPowerSettingChanged());
            _brightnessWatcher.Subscribe((instanceName, brightness) => Update(instanceName, brightness));
        }