Example #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));
        }
Example #2
0
        internal async Task InitiateAsync(RemotingAgent agent)
        {
            if (agent == null)
            {
                throw new ArgumentNullException(nameof(agent));
            }

            Settings.Load();

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

            _current.MainWindow              = new MainWindow(this);
            _current.MainWindow.Deactivated += OnMainWindowDeactivated;

            if (!StartupService.IsStartedOnSignIn(Settings.LastSaveTime))
            {
                _current.MainWindow.Show();
            }

            agent.ShowRequested += OnMainWindowShowRequested;

            await ScanAsync();

            _settingsWatcher.Subscribe(() => ScanAsync());
            _powerWatcher.Subscribe(() => ScanAsync());
            _brightnessWatcher.Subscribe((instanceName, brightness) => Update(instanceName, brightness));
        }
Example #3
0
        internal async Task InitiateAsync()
        {
            Settings.Initiate();
            Settings.KnownMonitors.AbsoluteCapacity = _maxNameCount.Value;
            Settings.PropertyChanged += OnSettingsChanged;

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

            _current.MainWindow = new MainWindow(this);

            if (!StartupAgent.IsStartedOnSignIn())
            {
                _current.MainWindow.Show();
            }

            StartupAgent.ShowRequested += OnMainWindowShowRequestedByOther;

            await ScanAsync();

            _settingsWatcher.Subscribe(() => ScanAsync());
            _powerWatcher.Subscribe(() => ScanAsync());
            _brightnessWatcher.Subscribe((instanceName, brightness) => Update(instanceName, brightness));
        }
Example #4
0
        public async Task InitiateAsync()
        {
            Settings.Current.Initiate();

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

            await LoadProfilesAsync();

            _current.MainWindow = new MainWindow(this);

            if (!StartupAgent.IsStartedOnSignIn())
            {
                _current.MainWindow.Show();
            }

            StartupAgent.ShowRequested += OnMainWindowShowRequested;

            Observable.FromEventPattern(
                h => _current.MainWindow.Activated += h,
                h => _current.MainWindow.Activated -= h)
            .StartWith(new object())                     // This is for initial scan.
            .Subscribe(async _ => await ScanNetworkAsync())
            .AddTo(this.Subscription);
        }