Esempio n. 1
0
        public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IOptionsMonitor <ConfigWrapper> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper)
        {
            InitializeComponent();

            LoadAboutMe();

            _graphservice = graphService;

            _lifxService     = lifxService;
            _hueService      = hueService;
            _options         = optionsAccessor.CurrentValue;
            _lIFXOAuthHelper = lifxOAuthHelper;
            LoadSettings().ContinueWith(
                t =>
            {
                if (t.IsFaulted)
                {
                }

                this.Dispatcher.Invoke(() =>
                {
                    LoadApp();

                    var tbContext = notificationIcon.DataContext;
                    DataContext   = Config;
                    notificationIcon.DataContext = tbContext;
                });
            });
        }
        public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IYeelightService yeelightService, ICustomApiService customApiService, IOptionsMonitor <ConfigWrapper> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper)
        {
            InitializeComponent();

            System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding);

            LoadAboutMe();

            _graphservice     = graphService;
            _yeelightService  = yeelightService;
            _lifxService      = lifxService;
            _hueService       = hueService;
            _customApiService = customApiService;
            _options          = optionsAccessor.CurrentValue;
            _lIFXOAuthHelper  = lifxOAuthHelper;
            LoadSettings().ContinueWith(
                t =>
            {
                if (t.IsFaulted)
                {
                }

                this.Dispatcher.Invoke(() =>
                {
                    LoadApp();

                    var tbContext = notificationIcon.DataContext;
                    DataContext   = Config;
                    notificationIcon.DataContext = tbContext;
                });
            });
        }
Esempio n. 3
0
        public MainWindow(IGraphService graphService,
                          IWorkingHoursService workingHoursService,
                          MediatR.IMediator mediator,
                          IOptionsMonitor <BaseConfig> optionsAccessor,
                          LIFXOAuthHelper lifxOAuthHelper,
                          DiagnosticsClient diagClient,
                          ILogger <MainWindow> logger,
                          ISettingsService settingsService)
        {
            _logger = logger;
            InitializeComponent();
            System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding);

            LoadAboutMe();

            _workingHoursService = workingHoursService;
            _graphservice        = graphService;


            logs.LogFilePath = App.StaticConfig["Serilog:WriteTo:1:Args:Path"];

            _mediator        = mediator;
            _options         = optionsAccessor != null ? optionsAccessor.CurrentValue : throw new NullReferenceException("Options Accessor is null");
            _lIFXOAuthHelper = lifxOAuthHelper;
            _diagClient      = diagClient;
            _settingsService = settingsService;

            LoadSettings().ContinueWith(
                t =>
            {
                if (t.IsFaulted)
                {
                }

                this.Dispatcher.Invoke(() =>
                {
                    LoadApp();

                    var tbContext = landingPage.notificationIcon.DataContext;
                    DataContext   = Config;
                    landingPage.notificationIcon.DataContext = tbContext;

                    if (Config.StartMinimized)
                    {
                        this.Hide();
                    }
                });
            }, TaskScheduler.Current);
        }
Esempio n. 4
0
        public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IYeelightService yeelightService, IRemoteHueService remoteHueService,
                          ICustomApiService customApiService, IOptionsMonitor <BaseConfig> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper, DiagnosticsClient diagClient, ILogger <MainWindow> logger,
                          ISettingsService settingsService)
        {
            _logger = logger;
            InitializeComponent();

            System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding);

            LoadAboutMe();

            _graphservice     = graphService;
            _yeelightService  = yeelightService;
            _lifxService      = lifxService;
            _hueService       = hueService;
            _remoteHueService = remoteHueService;
            _customApiService = customApiService;
            _options          = optionsAccessor != null ? optionsAccessor.CurrentValue : throw new NullReferenceException("Options Accessor is null");
            _lIFXOAuthHelper  = lifxOAuthHelper;
            _diagClient       = diagClient;
            _settingsService  = settingsService;

            LoadSettings().ContinueWith(
                t =>
            {
                if (t.IsFaulted)
                {
                }

                this.Dispatcher.Invoke(() =>
                {
                    LoadApp();

                    var tbContext = notificationIcon.DataContext;
                    DataContext   = Config;
                    notificationIcon.DataContext = tbContext;
                });
            }, TaskScheduler.Current);
        }
Esempio n. 5
0
        public MainWindow(IGraphService graphService,
                          IWorkingHoursService workingHoursService,
                          MediatR.IMediator mediator,
                          IOptionsMonitor <BaseConfig> optionsAccessor,
                          LIFXOAuthHelper lifxOAuthHelper,
                          DiagnosticsClient diagClient,
                          ILogger <MainWindow> logger,
                          ISettingsService settingsService,
                          AppState appState)
        {
            var currentApp = (App)System.Windows.Application.Current;

            Resources.Add("services", currentApp.ServiceProvider);

            _appState = appState;

            _logger = logger;
            InitializeComponent();
            System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding);

            _workingHoursService = workingHoursService;
            _graphservice        = graphService;


            _mediator        = mediator;
            _options         = optionsAccessor != null ? optionsAccessor.CurrentValue : throw new NullReferenceException("Options Accessor is null");
            _lIFXOAuthHelper = lifxOAuthHelper;
            _diagClient      = diagClient;
            _settingsService = settingsService;

            LoadSettings().ContinueWith(
                async t =>
            {
                if (t.IsFaulted)
                {
                }

                await Task.Run(() =>
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        appState.SignedIn = false;
                        LoadApp();

                        var tbContext = notificationIcon.DataContext;
                        DataContext   = _appState.Config;
                        notificationIcon.DataContext = tbContext;

                        if (_appState.Config.StartMinimized)
                        {
                            this.Hide();
                        }
                    });

                    while (true)
                    {
                        if (_appState.SignInRequested)
                        {
                            _appState.SignInRequested = false;

                            this.Dispatcher.Invoke(() =>
                            {
                                SignIn();
                            });
                        }

                        if (_appState.SignOutRequested)
                        {
                            _appState.SignOutRequested = false;
                            this.Dispatcher.Invoke(() =>
                            {
                                SignOut();
                            });
                        }
                    }
                });
            }, TaskScheduler.Current);
        }