Exemplo n.º 1
0
        private async void DateSearchTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                string date = DateSearchTextBox.Text.Trim();
                if (string.IsNullOrEmpty(date))
                {
                    new PopToast("日期不能为空哟").ShowPopup();
                    return;
                }
                Regex dateReg = new Regex("^((((([1|2])[0-9]{1})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[13579][26])00))0229)|([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))$");
                if (dateReg.IsMatch(date))
                {
                    var parseDate = AppTools.GetDateTime(date);
                    if (parseDate < new DateTime(2011, 3, 8))
                    {
                        new PopToast("最远只能到2011年3月8日哦~").ShowPopup();
                    }
                    else if (parseDate > DateTime.Now)
                    {
                        new PopToast("软件尚未提供预知能力哟~").ShowPopup();
                    }
                    else
                    {
                        WaittingRing.Visibility = Visibility.Visible;
                        MainContent.Visibility  = Visibility.Collapsed;
                        var webArticle = await AppTools.GetAsyncJson <WebArticleModel>(AppTools.SOMEDAY_URL + date);

                        UserInterfaceInit(webArticle);
                    }
                }
                else
                {
                    var dialog = new ConfirmDialog("日期提醒", "日期的输入是有一定格式的:\n比如说要查找2018年1月1日的文章,则应输入-\n20180101\n\n输入201811或者2018/1/1这些都是不行的哟~", "");
                    await dialog.ShowAsync();
                }
            }
        }
Exemplo n.º 2
0
        private void SettingPageInit()
        {
            string userName = AppTools.GetLocalSetting(Models.AppSettings.UserName, "");

            UserNameRun.Text = userName;
            bool isLight = AppTools.GetLocalSetting(Models.AppSettings.Theme, "Light") == "Light";

            if (isLight)
            {
                LightRadioButton.IsChecked = true;
            }
            else
            {
                DarkRadioButton.IsChecked = true;
            }
            IsInit = true;
            int startTime = Convert.ToInt32(AppTools.GetLocalSetting(AppSettings.FirstRunTime, "0"));
            var startDate = AppTools.GetDateTime(startTime);
            var span      = DateTime.Now - startDate;

            DurationDayRun.Text = span.Days.ToString();
            ReadCountRun.Text   = MainPage.Current.ReadArticleCollection.Count.ToString();
            double wordCount = 0;

            foreach (var article in MainPage.Current.ReadArticleCollection)
            {
                wordCount += article.WordCount;
            }
            if (wordCount > 10000)
            {
                WordCountRun.Text = Math.Round(wordCount / 10000, 2) + "万";
            }
            else
            {
                WordCountRun.Text = wordCount.ToString();
            }
        }