public void ShowNewDownloadDialog(Message message) { var url = message.Url; if (NewDownloadPromptTracker.IsPromptAlreadyOpen(url)) { return; } ApplicationContext.MainWindow.RunOnUIThread(() => { NewDownloadPromptTracker.PromptOpen(url); NewDownloadDialogUIController.CreateAndShowDialog(this.CreateNewDownloadDialog(false), message, () => NewDownloadPromptTracker.PromptClosed(url)); }); }
private void AttachedEventHandler() { ApplicationContext.MainWindow.NewDownloadClicked += (s, e) => { ApplicationContext.MainWindow.RunOnUIThread(() => { NewDownloadDialogUIController.CreateAndShowDialog(CreateNewDownloadDialog(true)); }); }; ApplicationContext.MainWindow.YoutubeDLDownloadClicked += (s, e) => { ApplicationContext.PlatformUIService.ShowYoutubeDLDialog(); }; ApplicationContext.MainWindow.BatchDownloadClicked += (s, e) => { ApplicationContext.PlatformUIService.ShowBatchDownloadWindow(); }; ApplicationContext.MainWindow.SelectionChanged += (s, e) => { UpdateToolbarButtonState(); }; ApplicationContext.MainWindow.CategoryChanged += (s, e) => { UpdateToolbarButtonState(); }; ApplicationContext.MainWindow.NewButton.Clicked += (s, e) => { ApplicationContext.MainWindow.OpenNewDownloadMenu(); }; ApplicationContext.MainWindow.DeleteButton.Clicked += (a, b) => { DeleteDownloads(); }; ApplicationContext.MainWindow.DownloadListDoubleClicked += (a, b) => UIActions.OnDblClick(); ApplicationContext.MainWindow.OpenFolderButton.Clicked += (a, b) => UIActions.OpenSelectedFolder(); ApplicationContext.MainWindow.OpenFileButton.Clicked += (a, b) => { UIActions.OpenSelectedFile(); }; ApplicationContext.MainWindow.PauseButton.Clicked += (a, b) => { if (ApplicationContext.MainWindow.IsInProgressViewSelected) { UIActions.StopSelectedDownloads(); } }; ApplicationContext.MainWindow.ResumeButton.Clicked += (a, b) => { if (ApplicationContext.MainWindow.IsInProgressViewSelected) { UIActions.ResumeDownloads(); } }; ApplicationContext.MainWindow.SettingsClicked += (s, e) => { ApplicationContext.PlatformUIService.ShowSettingsDialog(1); }; ApplicationContext.MainWindow.BrowserMonitoringSettingsClicked += (s, e) => { ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog(); }; ApplicationContext.MainWindow.ClearAllFinishedClicked += (s, e) => { ApplicationContext.MainWindow.DeleteAllFinishedDownloads(); AppDB.Instance.Downloads.RemoveAllFinished(); //SaveFinishedList(); }; ApplicationContext.MainWindow.ImportClicked += (s, e) => { var file = ApplicationContext.PlatformUIService.OpenFileDialog(null, "zip", null); if (!string.IsNullOrEmpty(file) && File.Exists(file)) { Log.Debug("Exporting to: " + file); ApplicationContext.CoreService.Import(file !); } LoadDownloadList(); }; ApplicationContext.MainWindow.ExportClicked += (s, e) => { var file = ApplicationContext.PlatformUIService.SaveFileDialog("xdm-download-list.zip", "zip", "All files (*.*)|*.*"); if (!string.IsNullOrEmpty(file)) { Log.Debug("Exporting to: " + file); ApplicationContext.CoreService.Export(file !); } }; ApplicationContext.MainWindow.HelpClicked += (s, e) => { PlatformHelper.OpenBrowser(Links.SupportUrl); }; ApplicationContext.MainWindow.UpdateClicked += (s, e) => { if (AppUpdater.IsAppUpdateAvailable) { PlatformHelper.OpenBrowser(AppUpdater.UpdatePage); return; } if (AppUpdater.IsComponentUpdateAvailable) { if (ApplicationContext.MainWindow.Confirm(ApplicationContext.MainWindow, AppUpdater.ComponentUpdateText)) { LaunchUpdater(UpdateMode.FFmpegUpdateOnly | UpdateMode.YoutubeDLUpdateOnly); return; } else { return; } } ApplicationContext.PlatformUIService.ShowMessageBox(ApplicationContext.MainWindow, TextResource.GetText("MSG_NO_UPDATE")); }; ApplicationContext.MainWindow.BrowserMonitoringButtonClicked += (s, e) => { if (Config.Instance.IsBrowserMonitoringEnabled) { Config.Instance.IsBrowserMonitoringEnabled = false; } else { Config.Instance.IsBrowserMonitoringEnabled = true; } Config.SaveConfig(); ApplicationContext.BroadcastConfigChange(); ApplicationContext.MainWindow.UpdateBrowserMonitorButton(); }; ApplicationContext.MainWindow.SupportPageClicked += (s, e) => { PlatformHelper.OpenBrowser(Links.SupportUrl); }; ApplicationContext.MainWindow.BugReportClicked += (s, e) => { PlatformHelper.OpenBrowser(Links.IssueUrl); }; ApplicationContext.MainWindow.CheckForUpdateClicked += (s, e) => { PlatformHelper.OpenBrowser(AppUpdater.UpdatePage); }; ApplicationContext.MainWindow.SchedulerClicked += (s, e) => { ShowQueueWindow(ApplicationContext.MainWindow); }; ApplicationContext.MainWindow.WindowCreated += (s, e) => { this.WindowLoaded?.Invoke(this, EventArgs.Empty); }; AttachContextMenuEvents(); ApplicationContext.MainWindow.InProgressContextMenuOpening += (_, _) => InProgressContextMenuOpening(); ApplicationContext.MainWindow.FinishedContextMenuOpening += (_, _) => FinishedContextMenuOpening(); }