상속: EntityBase
예제 #1
0
        private async void OnMark(object sender, EventArgs e)
        {
            Mark m = this.chapter.Mark;

            if (m == null)
            {
                m = new Mark();
                this.chapter.Mark = m;
            }

            ChapterMark item = m.Marks.FirstOrDefault(x => x.Current == this.location && x.ChapterNo == this.currentChapter);

            if (item == null)
            {
                item           = new ChapterMark();
                item.ChapterNo = this.currentChapter;
                item.Title     = this.chapter.Title;
                item.Date      = DateTime.Now.ToString("yyyy/mm/dd hh:MM:ss");
                item.Current   = this.location;
                item.Percent   = ((((double)this.current) / ((double)this.chapter.PageNum)) * 100).ToString("N2") + "%";
                OKr.Win8Book.Client.Core.Data.Page page = this.chapter.Pages[this.current];
                item.Content = page.Row[0].Trim() + page.Row[1].Trim();

                this.mark.Marks.Insert(0, item);

                this.bigMark.IsMarked    = true;
                this.appBarMark.IsMarked = true;
            }
            else
            {
                int chapterNo = item.ChapterNo;

                List <ChapterMark> list = new List <ChapterMark>();
                list = this.mark.Marks.Where(x => x.ChapterNo == chapterNo && x.Current == this.location).ToList();

                foreach (var mark in list)
                {
                    this.mark.Marks.Remove(mark);
                }

                this.bigMark.IsMarked    = false;
                this.appBarMark.IsMarked = false;
            }

            this.ShowMark();

            await this.mc.Save(this.mark);

            App.HomeViewModel.NotifyMarksChanged();
        }
예제 #2
0
        public static Page GetOnePage(string str, int start, int[] count, ref int location)
        {
            Page result = new Page();
            int num = 1;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int length = 0;
            int startIndex = start;

            for (int i = start; i < str.Length; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"[\r\n]"))
                {
                    num2 = 0;
                    length++;
                    num3++;
                    num4++;
                    if (num4 == 1)
                    {
                        num++;
                        result.Row.Add(str.Substring(startIndex, length));
                    }
                    length = 0;
                    startIndex = i + 1;
                    if (num != count[0])
                    {
                        continue;
                    }
                    break;
                }
                num4 = 0;
                string s = str.Substring(i, 1);
                byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(s);
                if (bytes.Length == 3)
                {
                    if (((count[1] * 2) - num2) >= 3)
                    {
                        num2 += 3;
                    }
                    else
                    {
                        num++;
                        result.Row.Add(str.Substring(startIndex, length));
                        length = 0;
                        startIndex = i;
                        num2 = 3;
                        if (num == count[0])
                        {
                            break;
                        }
                    }
                }
                else if (bytes.Length != 2)
                {
                    if (((count[1] * 2) - num2) >= 1)
                    {
                        num2++;
                    }
                    else
                    {
                        num++;
                        result.Row.Add(str.Substring(startIndex, length));
                        length = 0;
                        startIndex = i;
                        num2 = 1;
                        if (num == count[0])
                        {
                            break;
                        }
                    }
                }

                if (s.Contains("。") || s.Contains("."))
                {
                    result.Locations.Add(location);
                    location++;
                }

                num3++;
                length++;
            }
            result.CharNum = num3;
            return result;
        }