Example #1
0
        public void GetAllPassagesInfoTest()
        {
            var passageInfoList = PassageManage.GetAllPassagesInfo();

            Assert.AreEqual("test0", passageInfoList.FirstOrDefault(p => p.Id.Equals(1)).Name);
            Assert.AreEqual("test1", passageInfoList.FirstOrDefault(p => p.Id.Equals(2)).Name);
        }
Example #2
0
        public void ifExistTest()
        {
            var passage0 = new ExReaderPlus.Manage.PassageManager.Passage
            {
                Content = "Mr. Johnson had never been up in an aerophane before and he " +
                          "had read a lot about air accidents, so one day when a friend offered to take him for a ride in his own small phane, " +
                          "Mr. Johnson was very worried about accepting. Finally, however, his friend persuaded him that it was very safe, and Mr. Johnson boarded the plane.",
                HeadName = "test0"
            };

            Assert.AreEqual("test0", PassageManage.ifExsist(passage0).Name);
        }
Example #3
0
 //清空历史文章列表
 private void clearPassage_button_Click(object sender, RoutedEventArgs e)
 {
     if (passagelists.Count != 0)
     {
         passagelists.Clear();
         PassageManage.ClearPassages();
         Empty_PassageLabel.Opacity = 1;
     }
     else
     {
         Empty_PassageLabel.Opacity = 0;
     }
 }
Example #4
0
 //根据按钮选择生成提词列表
 private void SearchWordList(string type, int t)
 {
     SetHighLight(Colors.Transparent);
     GetEditBoxText();  //从文本框获取文章内容
     reader.MatchWords(type, t);
     UpdateBindingData(reader.ReaderWordLists, t);
     SetModeLabel(t);
     reader.ReaderPassage.HighLightInfo = PassageManage.GetHighLightInfo(reader.ReaderPassage.Content, reader.ReaderWordLists);
     if (toggle_state == true)
     {
         SetModeHighLight(t);
     }
     CacheReaderManage.CacheReader = reader;
 }
Example #5
0
        public void DeleteDeletePassageInfoAndPassageTest()
        {
            var passage0 = new ExReaderPlus.Manage.PassageManager.Passage
            {
                Content = "Mr. Johnson had never been up in an aerophane before and he " +
                          "had read a lot about air accidents, so one day when a friend offered to take him for a ride in his own small phane, " +
                          "Mr. Johnson was very worried about accepting. Finally, however, his friend persuaded him that it was very safe, and Mr. Johnson boarded the plane.",
                HeadName = "test3"
            };

            PassageManage.SavaPassageInfoAndPassage(passage0);

            Assert.AreEqual(1, PassageManage.DeletePassageInfoAndPassage(new UserDictionary.Passage
            {
                Id = 4
            }));
        }
Example #6
0
        //保存文章
        private async void save_file_Click(object sender, RoutedEventArgs e)
        {
            //保存当前editor文本到readerPassage的Content
            // if(reader.ReaderPassage.HeadName)
            {
                string headname = await InputHeaderDialogAsync("输入文章标题:");

                if (headname == "")
                {
                    reader.ReaderPassage.HeadName = "Passage " + i++;
                }
                else
                {
                    reader.ReaderPassage.HeadName = headname;
                }
            }

            GetEditBoxText();  //从文本框获取文章内容

            if (reader.ReaderPassage.Content == null)
            {
                var dialog = new ContentDialog()
                {
                    Title             = "exReader提示",
                    Content           = "没有可保存的文章!",
                    PrimaryButtonText = "确定",
                    // SecondaryButtonText = "取消",
                    FullSizeDesired = false,
                };
                await dialog.ShowAsync();
            }
            else
            {
                PassageManage.SavePassage(reader.ReaderPassage);
                var dialog = new ContentDialog()
                {
                    Title             = "exReader提示",
                    Content           = "成功保存到阅读历史记录!",
                    PrimaryButtonText = "确定",
                    FullSizeDesired   = false,
                };
                await dialog.ShowAsync();
            }
            // CacheReaderManage.CacheReader = reader;
        }
Example #7
0
        public void SavaPassageInfoAndPassageTest()
        {
            var passage0 = new ExReaderPlus.Manage.PassageManager.Passage
            {
                Content = "Mr. Johnson had never been up in an aerophane before and he " +
                          "had read a lot about air accidents, so one day when a friend offered to take him for a ride in his own small phane, " +
                          "Mr. Johnson was very worried about accepting. Finally, however, his friend persuaded him that it was very safe, and Mr. Johnson boarded the plane.",
                HeadName = "test0"
            };

            // var passage1 = new ExReaderPlus.Manage.PassageManager.Passage
            // {
            //     Content = "First Flight Mr. Johnson had never been up in an aerophane before and he had read a lot about air accidents",
            //     HeadName="test1"

            // };
            PassageManage.SavaPassageInfoAndPassage(passage0);
            //PassageManage.SavaPassageInfoAndPassage(passage1);
        }
Example #8
0
 //设置指定文本高亮
 private void SetHighLight(Windows.UI.Color color)
 {
     if (reader.ReaderWordLists != null)
     {
         int count = 0;
         List <ITextSelection> Selections = new List <ITextSelection>();
         reader.ReaderPassage.HighLightInfo = PassageManage.GetHighLightInfo(reader.ReaderPassage.Content, reader.ReaderWordLists);
         while (count < reader.ReaderPassage.HighLightInfo.Count)
         {
             ITextSelection selection = editor.Document.Selection;
             selection.StartPosition = reader.ReaderPassage.HighLightInfo[count].Item1;
             selection.EndPosition   = selection.StartPosition + reader.ReaderPassage.HighLightInfo[count].Item2;
             selection.CharacterFormat.BackgroundColor = color;
             Selections.Add(selection);
             count++;
         }
     }
     else
     {
     }
 }
Example #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Title1.Value == "")
            {
                Response.Write("<script>alert('" + "标题不能为空" + "')</script>");
                return;
            }
            if (TextArea1.Value == "")
            {
                Response.Write("<script>alert('" + "内容不能为空" + "')</script>");
                return;
            }
            int type = 0;

            if (radio1.Checked)
            {
                type = 1;
            }
            if (radio2.Checked)
            {
                type = 2;
            }
            if (UserManage.GetMyAccount() == null)
            {
                Response.Write("<script>alert('" + "请先登录" + "')</script>");
                return;
            }
            else
            {
                if (PassageManage.Insert(Title1.Value, TextArea1.Value,
                                         UserManage.GetMyAccount().Aid, type))
                {
                    Response.Write("<script>alert('" + "发布成功" + "')</script>");
                }
                else
                {
                    Response.Write("<script>alert('" + "发布失败" + "')</script>");
                }
            }
        }
Example #10
0
 //加载历史文章
 private void LoadPassages()
 {
     if (PassageManage.HistoryPassages.Count != 0)
     {
         Empty_PassageLabel.Opacity = 0;
         ObservableCollection <Passage> passages = new ObservableCollection <Passage>(PassageManage.LoadPassages());
         foreach (var p in passages)
         {
             passagelists.Add(p);
         }
     }
     else
     {
         Empty_PassageLabel.Opacity = 1;
     }
 }