public async Task StartAsync()
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            _identityService.InitializeWithAadAndPersonalMsAccounts(_config.IdentityClientId, "http://localhost");
            var silentLoginSuccess = await _identityService.AcquireTokenSilentAsync();

            if (!silentLoginSuccess || !_identityService.IsAuthorized())
            {
                _logInWindow = SimpleIoc.Default.GetInstance <ILogInWindow>();
                _logInWindow.ShowWindow();
                await StartupAsync();

                return;
            }

            _shellWindow = SimpleIoc.Default.GetInstance <IShellWindow>();
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
コード例 #2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            // https://aka.ms/msal-net-token-cache-serialization
            // this generates a file-system safe directory name to stick the cache in - or use something like Resources.AppDisplayName
            // should also consider this root dir for other configuration data
            var safeAppDirectoryName      = System.IO.Path.GetInvalidFileNameChars().Aggregate(typeof(App).Assembly.GetName().Name, (current, c) => current.Replace(c, '-'));
            var rootCacheDirectory        = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), safeAppDirectoryName, _config.IdentityCacheDirectoryName);
            var storageCreationProperties = new StorageCreationPropertiesBuilder(_config.IdentityCacheFileName, rootCacheDirectory, _config.IdentityClientId).Build();
            var cacheHelper = await MsalCacheHelper.CreateAsync(storageCreationProperties).ConfigureAwait(false);

            _identityService.InitializeWithAadAndPersonalMsAccounts(_config.IdentityClientId, "http://localhost", cacheHelper);
            var silentLoginSuccess = await _identityService.AcquireTokenSilentAsync();

            if (!silentLoginSuccess || !_identityService.IsAuthorized())
            {
                _logInWindow = _serviceProvider.GetService(typeof(ILogInWindow)) as ILogInWindow;
                _logInWindow.ShowWindow();
                await StartupAsync();

                return;
            }

            _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
//^^
//{[{
        private void OnLoggedIn(object sender, EventArgs e)
        {
            _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(Param_HomeNameViewModel).FullName);
            _logInWindow.CloseWindow();
        }
 private void OnLoggedIn(object sender, EventArgs e)
 {
     _shellWindow = SimpleIoc.Default.GetInstance <IShellWindow>(Guid.NewGuid().ToString());
     _navigationService.Initialize(_shellWindow.GetNavigationFrame());
     _shellWindow.ShowWindow();
     _navigationService.NavigateTo(typeof(MainViewModel).FullName);
     _logInWindow.CloseWindow();
     _logInWindow = null;
 }
コード例 #5
0
 private async Task HandleActivationAsync()
 {
     if (App.Current.Windows.OfType <IShellWindow>().Count() == 0)
     {
         // Default activation that navigates to the apps default page
         _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
         _navigationService.Initialize(_shellWindow.GetNavigationFrame());
         _shellWindow.ShowWindow();
         _navigationService.NavigateTo(typeof(GucklochViewModel).FullName);
         await Task.CompletedTask;
     }
 }
コード例 #6
0
 private async Task HandleActivationAsync()
 {
     if (App.Current.Windows.OfType <IShellWindow>().Count() == 0)
     {
         // Default activation that navigates to the apps default page
         _shellWindow = SimpleIoc.Default.GetInstance <IShellWindow>(Guid.NewGuid().ToString());
         _navigationService.Initialize(_shellWindow.GetNavigationFrame());
         _shellWindow.ShowWindow();
         _navigationService.NavigateTo(typeof(MainViewModel).FullName);
         await Task.CompletedTask;
     }
 }
        public async Task StartAsync()
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            _shellWindow = SimpleIoc.Default.GetInstance <IShellWindow>();
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
コード例 #8
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
コード例 #9
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            _identityService.InitializeWithAadAndPersonalMsAccounts(_config.IdentityClientId, "http://localhost");
            await _identityService.AcquireTokenSilentAsync();

            _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
コード例 #10
0
        private async Task HandleActivationAsync()
        {
            if (!Application.Current.Windows.OfType <IShellWindow>().Any())
            {
                // Default activation that navigates to the apps default page
                _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
                if (_shellWindow != null)
                {
                    _navigationService.Initialize(_shellWindow.GetNavigationFrame());
                    _shellWindow.ShowWindow();
                }

                _navigationService.NavigateTo(typeof(SimulatorPage));
                await Task.CompletedTask;
            }
        }
コード例 #11
0
        private async Task HandleActivationAsync()
        {
            var activationHandler = _activationHandlers
                                    .FirstOrDefault(h => h.CanHandle());

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync();
            }

            if (App.Current.Windows.OfType <IShellWindow>().Count() == 0)
            {
                // Default activation
                _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
                _navigationService.Initialize(_shellWindow.GetNavigationFrame());
                _shellWindow.ShowWindow();
                _navigationService.NavigateTo(typeof(MainViewModel).FullName);
            }
        }
コード例 #12
0
        private async Task HandleActivationAsync()
        {
            var activationHandler = SimpleIoc.Default.GetAllInstances <IActivationHandler>()
                                    .FirstOrDefault(h => h.CanHandle());

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync();
            }
            await Task.CompletedTask;

            if (App.Current.Windows.OfType <IShellWindow>().Count() == 0)
            {
                // Default activation
                _shellWindow = SimpleIoc.Default.GetInstance <IShellWindow>();
                _navigationService.Initialize(_shellWindow.GetNavigationFrame());
                _shellWindow.ShowWindow();
                _navigationService.NavigateTo(typeof(MainViewModel).FullName);
            }
        }
コード例 #13
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // Initialize services that you need before app activation
            await InitializeAsync();

            // https://aka.ms/msal-net-token-cache-serialization
            var storageCreationProperties = new StorageCreationPropertiesBuilder(_config.IdentityCacheFileName, _config.IdentityCacheDirectoryName, _config.IdentityClientId).Build();
            var cacheHelper = await MsalCacheHelper.CreateAsync(storageCreationProperties).ConfigureAwait(false);

            _identityService.InitializeWithAadAndPersonalMsAccounts(_config.IdentityClientId, "http://localhost", cacheHelper);
            await _identityService.AcquireTokenSilentAsync();

            _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
            _navigationService.Initialize(_shellWindow.GetNavigationFrame());
            _shellWindow.ShowWindow();
            _navigationService.NavigateTo(typeof(MainViewModel).FullName);

            // Tasks after activation
            await StartupAsync();
        }
コード例 #14
0
        private async Task HandleActivationAsync()
        {
            var activationHandler = _activationHandlers.FirstOrDefault(h => h.CanHandle());

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync();
            }

            await Task.CompletedTask;

            if (App.Current.Windows.OfType <IShellWindow>().Count() == 0)
            {
                // Default activation that navigates to the apps default page
                _shellWindow = _serviceProvider.GetService(typeof(IShellWindow)) as IShellWindow;
                _navigationService.Initialize(_shellWindow.GetNavigationFrame());
                _shellWindow.ShowWindow();
                _navigationService.NavigateTo(typeof(Param_HomeNamePage));
                await Task.CompletedTask;
            }
        }
コード例 #15
0
 public ApplicationHostService(INavigationService navigationService, IShellWindow shellWindow)
 {
     _navigationService = navigationService;
     _shellWindow       = shellWindow;
     _navigationService.Initialize(_shellWindow.GetNavigationFrame());
 }