public void SetModel(DownloadListModel model) { DetachModel(); _Model = model ?? throw (new ArgumentNullException(nameof(model))); _Model.CollectionChanged -= Model_CollectionChanged; _Model.CollectionChanged += Model_CollectionChanged; _Model.RowPropertiesChanged -= Model_RowPropertiesChanged; _Model.RowPropertiesChanged += Model_RowPropertiesChanged; Model_CollectionChanged(_CollectionChangedTypeEnum_.Add); }
public MainVM(MainWindow mainWindow) { SettingsController = new SettingsPropertyChangeController(); DownloadListModel = new DownloadListModel(); DownloadController = new DownloadController(DownloadListModel, SettingsController); AddCommand = new AddCommand(this); ParallelismCommand = new ParallelismCommand(this); SettingsCommand = new SettingsCommand(this); AboutCommand = new AboutCommand(); FileNameExcludesWordsEditorCommand = new FileNameExcludesWordsEditorCommand(this); }
public DownloadController(DownloadListModel model, SettingsPropertyChangeController sc) { _Model = model ?? throw (new ArgumentNullException(nameof(model))); _SettingsController = sc ?? throw (new ArgumentNullException(nameof(sc))); _SettingsController.SettingsPropertyChanged += SettingsController_PropertyChanged; _Dict = new ConcurrentDictionary <DownloadRow, tuple>(); _CrossDownloadInstanceRestriction = new cross_download_instance_restriction(_SettingsController.MaxCrossDownloadInstance); _DownloadThreadsSemaphoreFactory = new download_threads_semaphore_factory(_SettingsController.UseCrossDownloadInstanceParallelism, _SettingsController.MaxDegreeOfParallelism); _DefaultConnectionLimitSaver = DefaultConnectionLimitSaver.Create(_SettingsController.MaxDegreeOfParallelism); }
public AddNewDownloadForm(DownloadController dc, SettingsPropertyChangeController sc, string m3u8FileUrl, string additionalTitle = null) : this() { _Settings = sc.Settings; _DownloadListModel = dc?.Model; this.M3u8FileUrl = m3u8FileUrl; this.OutputDirectory = _Settings.OutputFileDirectory; _Model = new LogListModel(); logUC.SetModel(_Model); logUC.SetSettingsController(sc); statusBarUC.SetDownloadController(dc); statusBarUC.SetSettingsController(sc); this.Text += additionalTitle; }
private void DetachModel() { if (_Model != null) { _Model.CollectionChanged -= Model_CollectionChanged; _Model.RowPropertiesChanged -= Model_RowPropertiesChanged; _Model = null; DGV.CellValueNeeded -= DGV_CellValueNeeded; DGV.CellFormatting -= DGV_CellFormatting; try { DGV.RowCount = 0; } finally { DGV.CellValueNeeded += DGV_CellValueNeeded; DGV.CellFormatting += DGV_CellFormatting; } } }