示例#1
0
 private async void buttonTips_Click(object sender, RoutedEventArgs e)
 {
     ContentTipsDialog   scd = new ContentTipsDialog();
     ContentDialogResult cdr = await scd.ShowAsync();
 }
示例#2
0
        /// <summary>
        /// 设置按钮状态,弹窗请求输入Cookie,设置Cookie,尝试更新Main。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void buttonSetCookie_Click(object sender, RoutedEventArgs e)
        {
            buttonSetCookie.IsEnabled          = false;
            buttonSetCookieProgress.IsActive   = true;
            buttonSetCookieProgress.Visibility = Visibility.Visible;

            ShowLoading("Cookie设置流程中...");
            ContentWelcomeDialog cwd       = new ContentWelcomeDialog();
            ContentDialogResult  resultCwd = await cwd.ShowAsync();

            if (resultCwd == ContentDialogResult.Primary)
            {
                ContentTeachDialog ctd = new ContentTeachDialog();
                await ctd.ShowAsync();

                ContentHelpDialog chd = new ContentHelpDialog();
                await chd.ShowAsync();
            }


            ContentSetCookieDialog scd = new ContentSetCookieDialog();
            ContentDialogResult    cdr = await scd.ShowAsync();

            HideLoading();
            if (cdr == ContentDialogResult.None)
            {
                ShowMessageDialog("设置取消", "设置取消,保持原状。");
                buttonSetCookie.IsEnabled          = true;
                buttonSetCookieProgress.IsActive   = false;
                buttonSetCookieProgress.Visibility = Visibility.Collapsed;

                return;
            }
            if (scd.userInputCookie.Trim() == "")
            {
                ShowMessageDialog("输入为空", "设置取消,保持原状。");
                buttonSetCookie.IsEnabled          = true;
                buttonSetCookieProgress.IsActive   = false;
                buttonSetCookieProgress.Visibility = Visibility.Collapsed;
                return;
            }


            bool isCookieOK = ExpManager.SetCookie(scd.userInputCookie);



            if (!isCookieOK)
            {
                ShowMessageDialog("Cookie添加", ExpManager.setcookieFailedInfo);
                buttonSetCookie.IsEnabled          = true;
                buttonSetCookieProgress.IsActive   = false;
                buttonSetCookieProgress.Visibility = Visibility.Collapsed;
                return;
            }
            VisualStateManager.GoToState(buttonSetCookie, "stateWaiting", false);
            bool isValid = await UpdateMain();

            VisualStateManager.GoToState(buttonSetCookie, "stateNormal", false);

            buttonSetCookie.IsEnabled          = true;
            buttonSetCookieProgress.IsActive   = false;
            buttonSetCookieProgress.Visibility = Visibility.Collapsed;
            if (isValid)
            {
                await StorageManager.SaveCookie(ExpManager.cookie);

                buttonSetCookieText.Text = "√ Cookie";
                await ShowMessageDialog("设置完成", "Cookie有效,可以更新信息了。\n点击头像链接到个人中心。");


                ContentTipsDialog scd3 = new ContentTipsDialog();
                await scd3.ShowAsync();
            }
            else
            {
                ShowMessageDialog("验证Cookie", "Cookie无效,请重新设置");
            }

            HideLoading();
        }