コード例 #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;
            }
        }
コード例 #2
0
        private void PageDown()
        {
            if (Chapterpbar.Value >= 100)
            {
                ChapterDown();
                return;
            }
            var c = TbContent.VerticalOffset + TbContent.ViewportHeight;

            Chapterpbar.Value = c / TbContent.ExtentHeight * 100;
            if (Chapterpbar.Value >= 100)
            {
                TbContent.ScrollToEnd();
                Chapterpbar.Value = 100;
                return;
            }
            TbContent.ScrollToVerticalOffset(c);
        }
コード例 #3
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);
        }
コード例 #4
0
        private void MainWindow_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Right:
            case Key.D:
                ChapterDown();
                break;

            case Key.A:
            case Key.Left:
                ChapterUp();
                break;

            case Key.PageUp:
            case Key.W:
                PageUp();
                break;

            case Key.PageDown:
            case Key.S:
                PageDown();
                break;

            case Key.Down:
            case Key.E:
                TbContent.LineDown();
                TbContent_OnPreviewMouseWheel(null, null);
                break;

            case Key.Up:
            case Key.Q:
                TbContent.LineUp();
                TbContent_OnPreviewMouseWheel(null, null);
                break;

            case Key.Escape:
                WindowState = WindowState.Minimized;
                break;
            }
        }