示例#1
0
        private void OperationOnRssItem(object sender, RoutedEventArgs e)
        {
            RssUrlEntry entry = null;

            MenuItem source = (MenuItem)e.Source;

            entry = (RssUrlEntry)source.CommandParameter;

            switch (source.Tag.ToString())
            {
            case "Refresh":
                FeedsManager.ForceUpdate(entry);
                break;

            case "Remove":
                FeedsManager.Remove(entry);
                break;

            case "Edit":
                var query = new UI.AddRSSFeed()
                {
                    Owner = this, Icon = this.Icon, Title = "Edit rss feed"
                };
                query.AllowUrlChange = false;
                query.Url            = entry.Url;
                query.CustomAlias    = entry.Alias;
                query.LoadFilters(entry.Filters.ToArray());
                query.AutoDownload                = entry.AutoDownload;
                query.DownloadPath                = entry.DownloadDirectory;
                query.UpdateIntervalType          = entry.IsCustomtUpdateInterval ? 1 : 0;
                query.ManualUpdateIntervalSeconds = entry.CustomUpdateInterval.TotalSeconds.ToString();

                if (query.ShowDialog() == true)
                {
                    entry.Alias                   = query.CustomAlias;
                    entry.AutoDownload            = query.AutoDownload == true;
                    entry.Filters                 = query.Filters;
                    entry.DownloadDirectory       = string.IsNullOrWhiteSpace(query.DownloadPath) ? App.Settings.DefaultDownloadPath : query.DownloadPath;
                    entry.CustomUpdateInterval    = new TimeSpan(0, 0, query.CustomIntervalSeconds);
                    entry.IsCustomtUpdateInterval = query.UpdateIntervalType == 1;
                    entry.NotifyUpdate();
                    FeedsManager.Save();
                }
                break;

            case "View":
                UI.FeedViewer fv = new UI.FeedViewer()
                {
                    Owner = this, Icon = this.Icon, DataContext = entry
                };
                fv.Show();
                break;
            }
        }