private void StartApplication(StartupEventArgs e) { SetupAutomapper(); // TODO: Add IOC Container / Service locator var userRequestsHelper = new UserRequestsHelper(); var persistenceService = new PersistenceService(AppDataFolder); var torrentSessionService = new TorrentSessionService(DownloadsFolder); var torrentsSessionViewModel = new TransferListViewModel(userRequestsHelper, persistenceService, torrentSessionService); var mainWindowViewModel = new MainWindowViewModel(torrentsSessionViewModel); var window = new MainWindow(mainWindowViewModel); window.Show(); _notifyIconIconHelper = new SytemTrayIconHelper(window); // TODO: Add a message broker Current.Exit += (sender, args) => { torrentsSessionViewModel.OnAplicationExit(); torrentSessionService.OnApplicationExit(); }; if (e.Args.Any()) { torrentsSessionViewModel.AddNewTorrent(e.Args[0]); } _singleHelper.StartNewProcessListener(torrentsSessionViewModel, window); }
public void AddNewTorrent(string filePath) { try { _transferListViewModel.AddNewTorrent(filePath); } catch (OperationException e) { MessageBox.Show(e.Reason, "Error", MessageBoxButton.OK, MessageBoxImage.Information); } }