Exemple #1
0
        private void LsCatalog_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = LsCatalog.SelectedItem as ChaptersInfo;

            if (item != null)
            {
                Chapterpbar.Value = 0;
                _currentChapter   = item;
                var index = _chapters.IndexOf(item);
                try
                {
                    if (index < (_chapters.Count - 1))
                    {
                        var item2 = _chapters[index + 1];
                        TbContent.Text = GetChapterContent(item.LineNum, item2.LineNum - 1);
                    }
                    else
                    {
                        TbContent.Text = GetChapterContent(item.LineNum, -1);
                    }
                }
                catch
                {
                    ReloadBook();
                    return;
                }
                if (_autoLoad)
                {
                    UpdateLayout();
                    var c = _bookInfo.ChapterOffset + TbContent.ViewportHeight;
                    Chapterpbar.Value = c / TbContent.ExtentHeight * 100;
                    TbContent.ScrollToVerticalOffset(c);
                }
                else
                {
                    TbContent.ScrollToHome();
                }
                TbChapter.Text = item.Content;
            }
            TotalCpbar.PercentValue = (LsCatalog.SelectedIndex + 1) / (double)_chapters.Count * 100;
            _autoLoad = false;
            if (LsCatalog.Visibility == Visibility.Visible)
            {
                LsCatalog.Visibility      = Visibility.Collapsed;
                CbCatalogVisble.IsChecked = false;
            }
        }
Exemple #2
0
        private void PageUp()
        {
            if (Chapterpbar.Value <= 0)
            {
                ChapterUp();
                return;
            }
            var o = TbContent.VerticalOffset - TbContent.ViewportHeight;

            Chapterpbar.Value = o / TbContent.ExtentHeight * 100;
            if (Chapterpbar.Value <= 0)
            {
                TbContent.ScrollToHome();
                Chapterpbar.Value = 0;
                return;
            }
            TbContent.ScrollToVerticalOffset(o);
        }