Ejemplo n.º 1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await InitializeAsync();

//{[{

            if (!_isInitialized)
            {
                _identityService.InitializeWithAadAndPersonalMsAccounts(_appConfig.IdentityClientId, "http://localhost");
            }

            var silentLoginSuccess = await _identityService.AcquireTokenSilentAsync();

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

                    _isInitialized = true;
                }

                return;
            }
//}]}
        }
Ejemplo n.º 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // 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 = _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();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
//^^
//{[{

        private async void OnLoggedIn(object sender, EventArgs e)
        {
            await HandleActivationAsync();

            _logInWindow.CloseWindow();
            _logInWindow = null;
        }
Ejemplo n.º 5
0
        public async Task StartAsync()
        {
            await InitializeAsync();

//{[{

            if (!_isInitialized)
            {
                _identityService.InitializeWithAadAndPersonalMsAccounts(_appConfig.IdentityClientId, "http://localhost");
            }

            var silentLoginSuccess = await _identityService.AcquireTokenSilentAsync();

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

                    _isInitialized = true;
                }

                return;
            }
//}]}
        }
        private void OnLoggedOut(object sender, EventArgs e)
        {
            _logInWindow = SimpleIoc.Default.GetInstance <ILogInWindow>(Guid.NewGuid().ToString());
            _logInWindow.ShowWindow();

            _shellWindow.CloseWindow();
            _navigationService.UnsubscribeNavigation();
        }
Ejemplo n.º 7
0
        private void OnLoggedOut(object sender, EventArgs e)
        {
            _logInWindow = _serviceProvider.GetService(typeof(ILogInWindow)) as ILogInWindow;
            _logInWindow.ShowWindow();

            _shellWindow.CloseWindow();
            _navigationService.UnsubscribeNavigation();
        }
 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;
 }
Ejemplo n.º 9
0
        public LogInPresenter(ILogInWindow logInPage)
        {
            this.logInPage = logInPage;

            logInPage.LogIn += (sender, e) =>
            {
                if (logInPage.FighterName.Length < 3 || logInPage.FighterName.Length > 20)
                {
                    logInPage.Error = "Имя бойца должно содержать от 3 до 20 символов";
                }
                else
                {
                    MainWindows.Fighter1Window = new Fighter1Window(new Fighter(logInPage.FighterName));
                    MainWindows.Fighter2Window = new Fighter2Window(new ComputerAI("Тайлер Дёрден"));
                    MainWindows.LogWindow      = new LogWindow();

                    MainWindows.FightPresenter = new FightPresenter(MainWindows.FighterPresenter, MainWindows.ComputerPresenter, MainWindows.LogPresenter);

                    MainWindows.StartFight();
                }
            };
        }