Esempio n. 1
0
        private void ParagraphListBox_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            if (m_CurNovelContents.Count > 0)
            {
                if (e.VerticalChange <= 0)
                {
                    //判断是否滚动到顶部
                    if (e.VerticalOffset == 0 && e.VerticalChange != 0)
                    {
                        Content curContent = m_CurNovelContents[0];
                        AddContentToRead(curContent, e.VerticalChange <= 0);

                        ParagraphListBox.SelectedIndex = m_CurNovelContents.Count - 1;
                        ParagraphListBox.ScrollIntoView(ParagraphListBox.SelectedItem);
                        ParagraphListBox.UpdateLayout();
                        ParagraphListBox.ScrollIntoView(curContent);
                    }
                }
                else
                {
                    //判断是否滚动到底部
                    if (IsVerticalScrollBarAtButtom(e.OriginalSource as ScrollViewer))
                    {
                        AddContentToRead(m_CurNovelContents[m_CurNovelContents.Count - 1], e.VerticalChange <= 0);
                    }
                }
            }
        }
Esempio n. 2
0
 private void LoadDefaultContent(int lineNum)
 {
     if (lineNum < m_NovelConents.Count)
     {
         m_CurNovelContents.Clear();
         Content lastContent = m_NovelConents[lineNum];
         for (int i = 0; i < m_NovelConents.Count; i++)
         {
             if (m_NovelConents[i].Chapter == lastContent.Chapter - 1 ||
                 m_NovelConents[i].Chapter == lastContent.Chapter)
             {
                 m_CurNovelContents.Add(m_NovelConents[i]);
             }
         }
         ParagraphListBox.SelectedIndex = m_CurNovelContents.Count - 1;
         ParagraphListBox.ScrollIntoView(ParagraphListBox.SelectedItem);
         ParagraphListBox.UpdateLayout();
         ParagraphListBox.ScrollIntoView(lastContent);
     }
 }