Example #1
0
        private void AddFavoritesContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem cmi   = sender as MenuItem;
            dynamic  item  = cmi.DataContext;
            string   title = item.Title;

            if (metaData.tags.ContainsKey(title))
            {
                var tids = metaData.tags[title];
                metaData.tags.Remove(title);
                SuperKeyword superKeyword = new SuperKeyword
                {
                    simple  = true,
                    keyword = title,
                    authors = new List <string> {
                        item.Author
                    },
                    tids        = tids,
                    read        = -1,
                    groups      = new List <List <string> >(),
                    groupedTids = tids.ConvertAll(x => new Group {
                        exampleId = x, tooltips = ""
                    })
                };
                metaData.superKeywords.Add(superKeyword);
                MetaDataLoader.Save(this.metaData);
                currentId    = -1;
                currentState = AppState.TOPICS;
                ReloadTopics();
                UpdateView();
            }
        }
Example #2
0
        private void UnreadContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem cmi  = sender as MenuItem;
            dynamic  item = cmi.DataContext;

            if (!item.IsFolder)
            {
                dynamic topic = topics[currentId];
                if (topic.Favorite)
                {
                    int favoriteId = topic.FavoriteId;
                    int index      = articles.IndexOf(item) + 1;
                    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();
                        UpdateView();
                    }
                }
            }
        }
Example #3
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;
            }
        }
Example #4
0
        private void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            ScriptDialog dialog = new ScriptDialog(ScriptDialog.ScriptId.UPDATE_ALL);

            if (dialog.ShowDialog() ?? false)
            {
                this.metaData    = MetaDataLoader.Load();
                currentId        = -1;
                searchingKeyword = null;
                currentState     = AppState.TOPICS;
                ReloadTopics();
                UpdateView();
            }
        }
Example #5
0
        private void CancelAdvancedKeywordContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem cmi  = sender as MenuItem;
            dynamic  item = cmi.DataContext;

            if (!item.Simple)
            {
                int FavoriteId = item.FavoriteId;
                metaData.superKeywords.RemoveAt(FavoriteId);
                MetaDataLoader.Save(this.metaData);
                currentState = AppState.TOPICS;
                ReloadTopics();
                UpdateView();
            }
        }
Example #6
0
        private void BlackContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem cmi   = sender as MenuItem;
            dynamic  item  = cmi.DataContext;
            string   title = item.Title;

            if (item.Simple)
            {
                metaData.blacklist.Add(title);
                metaData.tags.Remove(title);
                MetaDataLoader.Save(this.metaData);
                currentId    = -1;
                currentState = AppState.TOPICS;
                ReloadTopics();
                UpdateView();
            }
        }
Example #7
0
        private void RemoveFavoritesContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem     cmi          = sender as MenuItem;
            dynamic      item         = cmi.DataContext;
            string       title        = item.Title;
            int          FavoriteId   = item.FavoriteId;
            SuperKeyword superKeyword = metaData.superKeywords[FavoriteId];

            if (superKeyword.simple)
            {
                var tids    = superKeyword.tids;
                var keyword = superKeyword.keyword;
                metaData.superKeywords.Remove(superKeyword);
                metaData.tags[keyword] = tids;
                MetaDataLoader.Save(this.metaData);
                currentId    = -1;
                currentState = AppState.TOPICS;
                ReloadTopics();
                UpdateView();
            }
        }
Example #8
0
        public MainWindow()
        {
            InitializeComponent();

            this.metaData = MetaDataLoader.Load();

            topics = new ObservableCollection <object>();
            TopicListView.DataContext = topics;

            articles = new ObservableCollection <object>();
            ArticleListView.DataContext = articles;

            ServerInd.DataContext = MyServer.GetInstance();

            searchingKeyword = null;
            ReloadTopics();

            currentState = AppState.TOPICS;
            currentId    = -1;

            text = "";
            UpdateView();
        }
Example #9
0
        private void SetAdvancedKeywordContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem cmi    = sender as MenuItem;
            dynamic  item   = cmi.DataContext;
            string   title  = item.Title;
            string   author = item.Author;

            var dialog = new AdvancedKeywordDialog
            {
                Owner         = this,
                Keyword       = title,
                DefaultAuthor = author
            };
            var dr = dialog.ShowDialog() ?? false;

            if (dr)
            {
                SuperKeyword superKeyword = new SuperKeyword
                {
                    simple      = false,
                    keyword     = dialog.Keyword,
                    authors     = new List <string>(dialog.AuthorList),
                    tids        = new List <int>(),
                    read        = -1,
                    groups      = new List <List <string> >(),
                    groupedTids = new List <Group>()
                };
                if (!metaData.superKeywords.Contains(superKeyword))
                {
                    metaData.superKeywords.Add(superKeyword);
                    MetaDataLoader.Save(this.metaData);
                    currentState = AppState.TOPICS;
                    ReloadTopics();
                    UpdateView();
                }
            }
        }