示例#1
0
 /// <summary>
 /// 此部分中提供的方法只是用于使
 /// NavigationHelper 可响应页面的导航方法。
 /// <para>
 /// 应将页面特有的逻辑放入用于
 /// <see cref="NavigationHelper.LoadState"/>
 /// 和 <see cref="NavigationHelper.SaveState"/> 的事件处理程序中。
 /// 除了在会话期间保留的页面状态之外
 /// LoadState 方法中还提供导航参数。
 /// </para>
 /// </summary>
 /// <param name="e">提供导航方法数据和
 /// 无法取消导航请求的事件处理程序。</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     this.navigationHelper.OnNavigatedTo(e);
     LogoStoryboard.Begin();
     if (SettingUtils.Get("username") != null && SettingUtils.Get("password") != null)
     {
         UsernameTextBox.Text = SettingUtils.Get("username") as string;
         PasswordBox.Password = SettingUtils.Get("password") as string;
         InfoTextBlock.Text   = "已登录!";
     }
 }
        /// <summary>
        /// 此部分中提供的方法只是用于使
        /// NavigationHelper 可响应页面的导航方法。
        /// <para>
        /// 应将页面特有的逻辑放入用于
        /// <see cref="NavigationHelper.LoadState"/>
        /// 和 <see cref="NavigationHelper.SaveState"/> 的事件处理程序中。
        /// 除了在会话期间保留的页面状态之外
        /// LoadState 方法中还提供导航参数。
        /// </para>
        /// </summary>
        /// <param name="e">提供导航方法数据和
        /// 无法取消导航请求的事件处理程序。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);
            AppHelper.ShowStatusBar();

            string username = SettingUtils.Get("username") as string;

            if (username != null)
            {
                UserTextBlock.Text = username;
            }
        }
示例#3
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 当启动应用程序以打开特定的文件或显示搜索结果等操作时,
        /// 将使用其他入口点。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                // TODO: 将此值更改为适合您的应用程序的缓存大小
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // 删除用于启动的旋转门导航。
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;

                // 当导航堆栈尚未还原时,导航到第一页,
                // 并通过将所需信息作为导航参数传入来配置
                // 新页面
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            object username = SettingUtils.Get("username");
            object password = SettingUtils.Get("password");
            if (password != null && username != null)
            {
                await AppHelper.UserLogin(username as string, password as string);
            }

            // 确保当前窗口处于活动状态
            Window.Current.Activate();
        }