Esempio n. 1
0
        /// <summary>
        /// Removes the current feed (which is an error state) from the feeds list.
        /// </summary>
        public void RemoveBadFeed()
        {
            var index = Feeds.IndexOf(CurrentFeed);

            Feeds.Remove(CurrentFeed);
            CurrentFeed = Feeds[Feeds.Count > index ? index : index - 1];
            var withoutAwait = SaveFeedsAsync();

            BadFeedRemoved?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 2
0
        public void ExecuteRemoveFeed(object parameter)
        {
            int index = Feeds.IndexOf(SelectedFeed);

            Feeds.Remove(SelectedFeed);

            //SelectedFeed = index > 0? Feeds[index - 1] : Feeds[0];
            SelectedFeed = null;
            onPropertyChanged("CountFeeds");
        }
Esempio n. 3
0
        public void ExecuteDeleteFeedCommand(object parameter)
        {
            Feed feed  = parameter as Feed;
            int  index = Feeds.IndexOf(feed);

            SelectedFilterIndex = -1;

            foreach (var filter in Filters.Where(x => x.Feed == feed))
            {
                filter.Feed = null; filter.FeedIndex = -1;
            }

            Feeds.RemoveAt(index);
        }
Esempio n. 4
0
        public void ExecuteSaveBackup(object parameter)
        {
            if (!Directory.Exists(Path.GetDirectoryName(FeedsPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(FeedsPath));
            }

            XmlWriterSettings xws = new XmlWriterSettings()
            {
                Indent = true
            };
            DataContractSerializer dcs;

            // Feeds
            dcs = new DataContractSerializer(Feeds.GetType());
            using (XmlWriter xw = XmlWriter.Create(FeedsPath, xws))
            {
                dcs.WriteObject(xw, Feeds);
            }

            // Saves the index of SearchInFeed so that the feed can be loaded on Restore
            foreach (Filter f in Filters)
            {
                if (f.HasFeed)
                {
                    f.SearchInFeedIndex = Feeds.IndexOf(f.SearchInFeed);
                }
                else
                {
                    f.SearchInFeedIndex = -1;
                }
            }

            // Filters
            dcs = new DataContractSerializer(Filters.GetType());
            using (XmlWriter xw = XmlWriter.Create(FiltersPath, xws))
            {
                dcs.WriteObject(xw, Filters);
            }

            // Downloads
            dcs = new DataContractSerializer(ManuallyDownloadedTorrents.GetType());
            using (XmlWriter xw = XmlWriter.Create(ManuallyDownloadedTorrentsPath, xws))
            {
                dcs.WriteObject(xw, ManuallyDownloadedTorrents);
            }
        }