public MainPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator,
                                 SettingsHelper settingsHelper, SettingsViewModel settingsViewModel,
                                 SettingsPaneViewModel settingsPaneViewModel, FilterListViewModel filterListViewModel,
                                 ListFilterViewModel listFilterViewModel, TorrentWindowViewModel torrentWindowViewModel,
                                 ErrorTracker errorTracker)
        {
            _errorTracker = errorTracker;
            _uriQueue = new List<string>();
            _torrentsQueue = new List<TorrentFileData>();

            _settingsHelper = settingsHelper;
            _eventAggregator = eventAggregator;
            _navigationService = navigationService;

            FilterList = filterListViewModel;
            ListFilter = listFilterViewModel;
            SettingsPane = settingsPaneViewModel;
            Settings = settingsViewModel;
            TorrentWindow = torrentWindowViewModel;

            backingTorrents = new ObservableCollection<TorrentViewModel>();
            Torrents = new ListCollectionView(backingTorrents);
            SelectedItems = new ObservableCollection<TorrentViewModel>();

            ChangeOrder(settingsHelper.GetSetting<bool>(SettingType.OrderByQueue));
            Torrents.Filter = ListFilter.GetFilter(Filter.All);

            ClearCommand = new DelegateCommand(() => ClearSelection());
            SelectAllCommand = new DelegateCommand(() => SelectAll());
            ForceStartCommand = new DelegateCommand(() => ChangeTorrentState(StateType.ForceStart));
            PauseCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Stop));
            StartCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Start));
            VerifyCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Verify));
            ShowAddTorrentCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Add, Server.DefaultDownloadLocation));
            ShowMoveTorrentsCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Move, Server.DefaultDownloadLocation, SelectedItems));
            ShowConfirmDeleteCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Delete, Server.DefaultDownloadLocation, SelectedItems));

            _eventAggregator.GetEvent<AddTorrent>().Subscribe(AddTorrents);
            _eventAggregator.GetEvent<DeleteTorrents>().Subscribe(Delete);
            _eventAggregator.GetEvent<MoveTorrents>().Subscribe(MoveTorrents);
            _eventAggregator.GetEvent<SearchChanged>().Subscribe(query => Torrents.Refresh());
            _eventAggregator.GetEvent<SearchCleared>().Subscribe(_ => Torrents.Refresh());
            _eventAggregator.GetEvent<PriorityChanged>().Subscribe(PriorityChanged);
            _eventAggregator.GetEvent<WantedChanged>().Subscribe(WantedChanged);
            _eventAggregator.GetEvent<FilterChanged>().Subscribe(FilterChanged);
            _eventAggregator.GetEvent<OrderByQueueSettingChanged>().Subscribe(orderByQueue => ChangeOrder(orderByQueue));
            _eventAggregator.GetEvent<FileActivated>().Subscribe(FileActivated);
            _eventAggregator.GetEvent<URIActivated>().Subscribe(URIActivated);
            _eventAggregator.GetEvent<ServerLoaded>().Subscribe(ProcessQueues);

            SelectedItems.CollectionChanged += (s, e) =>
            {
                SelectionChange();
            };
        }
Exemple #2
0
 public Settings(SettingsViewModel settingsVM)
 {
     InitializeComponent();
     DataContext = settingsVM;
 }