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; } }
private async void Commands_AddRssFeed(object sender, ExecutedRoutedEventArgs e) { var query = new UI.AddRSSFeed() { Icon = this.Icon, Owner = this }; if (query.ShowDialog() == true) { if (string.IsNullOrWhiteSpace(query.Url)) { MessageBox.Show(this, "Url cannot be empty.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!query.Url.StartsWith("http://") || !query.Url.StartsWith("https://")) { query.Url = "http://" + query.Url; } var rss_entry = new RssUrlEntry() { Url = query.Url, Alias = query.CustomAlias, AutoDownload = query.AutoDownload == true, Filters = query.Filters, DownloadDirectory = string.IsNullOrWhiteSpace(query.DownloadPath) ? App.Settings.DefaultDownloadPath : query.DownloadPath, IsCustomtUpdateInterval = query.UpdateIntervalType == 1, CustomUpdateInterval = new TimeSpan(0, 0, query.CustomIntervalSeconds), DefaultSettings = App.Settings.DefaultTorrentProperties }; if (await rss_entry.TestAsync()) { FeedsManager.Add(rss_entry); } else { MessageBox.Show( this, "This RSS entry seem to be invalid. \n\n If your internet connection is down, try adding it when it's up again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }