Exemplo n.º 1
0
        private void ForwardAtArticles(dynamic item)
        {
            string fPath = Constants.LOCAL_PATH + item.SiteId + "/" + item.ThreadId + ".txt";

            if (File.Exists(fPath))
            {
                using (StreamReader sr = new StreamReader(fPath, new UTF8Encoding(false)))
                {
                    text            = sr.ReadToEnd();
                    currentState    = AppState.READER;
                    ReaderText.Text = text;
                    ReaderScroll.ScrollToHome();
                    UpdateView();
                }

                dynamic topic      = topics[currentId];
                int     favoriteId = topic.FavoriteId;
                int     index      = articles.IndexOf(item);
                var     sk         = metaData.superKeywords[favoriteId];
                int     i          = sk.groupedTids.Count - index - 1;
                if (i > sk.read)
                {
                    sk.read = i;
                    metaData.superKeywords[favoriteId] = sk;
                    MetaDataLoader.Save(this.metaData);
                    ReloadArticles();
                    ReloadTopics();
                }
                readId = index;
            }
        }
Exemplo n.º 2
0
        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (SearchBox.IsFocused)
            {
                return;
            }

            if (e.Key == System.Windows.Input.Key.Space)
            {
                if (currentState == AppState.READER)
                {
                    ReaderScroll.PageDown();
                    //ReaderScroll.LineUp();
                    //ReaderScroll.LineUp();
                    ReaderScroll.Focus();
                }
                else if (currentState == AppState.ARTICLES)
                {
                    int i = ArticleListView.SelectedIndex;
                    if (i < 0)
                    {
                        ArticleListView.SelectedIndex = 0;
                    }
                    if (ArticleListView.ItemContainerGenerator.ContainerFromIndex(ArticleListView.SelectedIndex) is ListViewItem item)
                    {
                        item.Focus();
                    }
                }
                else if (currentState == AppState.TOPICS)
                {
                    int i = TopicListView.SelectedIndex;
                    if (i < 0)
                    {
                        TopicListView.SelectedIndex = 0;
                    }
                    if (TopicListView.ItemContainerGenerator.ContainerFromIndex(TopicListView.SelectedIndex) is ListViewItem item)
                    {
                        item.Focus();
                    }
                }
            }
            else if (e.Key == Key.Right || e.Key == Key.Enter || e.Key == Key.R)
            {
                if (currentState == AppState.TOPICS)
                {
                    dynamic item = TopicListView.SelectedItem;
                    if (item == null)
                    {
                        TopicListView.SelectedIndex = 0;
                    }
                    item = TopicListView.SelectedItem;
                    if (item != null)
                    {
                        ForwardAtTopics(item);
                    }
                }
                else if (currentState == AppState.ARTICLES)
                {
                    dynamic item = ArticleListView.SelectedItem;
                    if (item == null)
                    {
                        item = ArticleListView.SelectedItem;
                    }
                    if (item != null)
                    {
                        ForwardAtArticles(item);
                    }
                }
            }
            else if (e.Key == Key.Left || e.Key == Key.E || e.Key == Key.Q)
            {
                Backward();
            }
            else if (e.Key == Key.J)
            {
                if (currentState == AppState.READER)
                {
                    if (readId > 0)
                    {
                        dynamic nextItem = articles[readId - 1];
                        ForwardAtArticles(nextItem);
                    }
                    else
                    {
                        notifier.ShowInformation("There is the LAST chapter.");
                    }
                }
            }
            else if (e.Key == Key.K)
            {
                if (currentState == AppState.READER)
                {
                    if (readId + 1 < articles.Count())
                    {
                        dynamic prevItem = articles[readId + 1];
                        ForwardAtArticles(prevItem);
                    }
                    else
                    {
                        notifier.ShowInformation("There is the FIRST chapter.");
                    }
                }
            }
        }