private bool FilterBySearch(TorrentViewModel torrent)
        {
            if (torrent.Name.ToLower().Contains(SearchText))
            {
                return true;
            }

            return false;
        }
示例#2
0
        private void ClearState()
        {
            backingTorrents.Clear();
            TorrentWindow.Clear();
            SelectedItem = null;
            SelectedItems.Clear();
            Torrents.Filter = ListFilter.GetFilter(Filter.All);

            if (_cancelToken != null)
            {
                if (!_cancelToken.IsCancellationRequested)
                {
                    _cancelToken.Cancel();
                }

                _cancelToken.Dispose();
            }

            if (_torrentClient != null)
            {
                (_torrentClient as IDisposable).Dispose();
            }
        }
示例#3
0
        public void Update(UpdateData updateData)
        {
            for (int i = 0; i < backingTorrents.Count; ++i)
            {
                var item = backingTorrents[i];
                if (updateData.DeletedTorrents.Contains(item.Id))
                {
                    var torrent = backingTorrents[i--];
                    backingTorrents.Remove(torrent);
                    continue;
                }
                else if (updateData.UpdatedTorrents.ContainsKey(item.Id))
                {
                    item.Update(updateData.UpdatedTorrents[item.Id], updateData.ServerStats.SpeedUnits, updateData.ServerStats.SizeUnits);
                    continue;
                }
            }

            foreach (var torrent in updateData.NewTorrents)
            {
                var torrentVM = new TorrentViewModel(torrent, _eventAggregator, _errorTracker, updateData.ServerStats.SpeedUnits, updateData.ServerStats.SizeUnits);
                backingTorrents.Add(torrentVM);
            }

            UpdateMenu();
            FilterList.Update(backingTorrents);
            Server.Update(updateData.ServerStats);
        }
示例#4
0
 internal void ClearSelection()
 {
     SelectedItem = null;
     SelectedItems.Clear();
 }
示例#5
0
        private void ClearState()
        {
            backingTorrents.Clear();
            TorrentWindow.Clear();
            SelectedItem = null;
            SelectedItems.Clear();
            Torrents.Filter = ListFilter.GetFilter(Filter.All);

            if (_cancelToken != null)
            {
                if (!_cancelToken.IsCancellationRequested)
                {
                    _cancelToken.Cancel();
                }

                _cancelToken.Dispose();
            }

            if (_torrentClient != null)
            {
                // TODO: What? Why do I have to cast to IDisposable?
                // The object clearly implements IDisposable...
                (_torrentClient as IDisposable).Dispose();
            }
        }