Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            if (!ApplicationData.Current.LocalSettings.Containers.ContainsKey("UserInfo"))
            {
                ApplicationData.Current.LocalSettings.CreateContainer("UserInfo", ApplicationDataCreateDisposition.Always);
            }

            NavigationService navService = new NavigationService();

            navService.Configure("ShellVIew", typeof(ShellVIew));

            navService.Configure("LoginPageView", typeof(LoginPageView));

            var   navManager = new AppNavServiceManager(navService);
            Frame rootFrame  = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (string.IsNullOrEmpty(AppDataUtil.LoadValue(AppDataUtil.KeyUsername)))
                {
                    rootFrame.Navigate(typeof(LoginPageView), e.Arguments);
                }
                else
                {
                    rootFrame.Navigate(typeof(ShellVIew), e.Arguments);
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Ejemplo n.º 2
0
        private async void LoginAsync(object passwordBox)
        {
            Password = (passwordBox as PasswordBox).Password;

            LoginModel model = new LoginModel
            {
                Username = UserName,
                Password = Password
            };

            try
            {
                var response =
                    await
                    m_httpClient.PostAsJsonAsync <LoginModel>(HttpClientUtil.GetUriForUrl(HttpClientUtil.LoginUrl),
                                                              model);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    if (content == bool.FalseString.ToLowerInvariant())
                    {
                        throw new ArgumentException("Login Failed");
                    }
                    LoginFailed = false;
                    AppDataUtil.SaveValue(AppDataUtil.KeyUsername, UserName);
                    AppDataUtil.SaveValue(AppDataUtil.KeyMd5Password, Password);
                    m_navigationService.NavigateTo(nameof(ShellVIew));
                }
                else
                {
                    LoginFailed = true;
                }
            }
            catch (Exception ex)
            {
                LoginFailed = true;
            }
        }
Ejemplo n.º 3
0
 public static Type GetSupportedGameType(this IAppDataInitializer initializer)
 {
     return(AppDataUtil.GetSupportedGameType(initializer?.GetType()));
 }
Ejemplo n.º 4
0
 public static uint?GetAppID(this IGame game)
 {
     return(AppDataUtil.GetAppID(game?.GetType()));
 }
Ejemplo n.º 5
0
 public static uint?GetAppID(this IAppDataInitializer initializer)
 {
     return(AppDataUtil.GetAppID(initializer?.GetSupportedGameType()));
 }
Ejemplo n.º 6
0
 public static IEnumerable <(PropertyInfo Property, CheatAttribute Cheat)> GetCheats(this IGame game)
 {
     return(AppDataUtil.GetCheats(game?.GetType()));
 }
Ejemplo n.º 7
0
 public static IEnumerable <Title> GetInitializationTitleIDs(this IGame game)
 {
     return(AppDataUtil.GetInitializationTitleIDs(game?.GetType()));
 }
Ejemplo n.º 8
0
 public static IEnumerable <Title> GetInitializationTitleIDs(this IAppDataInitializer initializer)
 {
     return(AppDataUtil.GetInitializationTitleIDs(initializer?.GetSupportedGameType()));
 }