Exemple #1
0
 private void AttachContextMenuEvents()
 {
     try
     {
         ApplicationContext.MainWindow.MenuItemMap["pause"].Clicked           += (_, _) => UIActions.StopSelectedDownloads();
         ApplicationContext.MainWindow.MenuItemMap["resume"].Clicked          += (_, _) => UIActions.ResumeDownloads();
         ApplicationContext.MainWindow.MenuItemMap["delete"].Clicked          += (_, _) => DeleteDownloads();
         ApplicationContext.MainWindow.MenuItemMap["saveAs"].Clicked          += (_, _) => UIActions.SaveAs();
         ApplicationContext.MainWindow.MenuItemMap["refresh"].Clicked         += (_, _) => UIActions.RefreshLink();
         ApplicationContext.MainWindow.MenuItemMap["moveToQueue"].Clicked     += (_, _) => UIActions.MoveToQueue();
         ApplicationContext.MainWindow.MenuItemMap["showProgress"].Clicked    += (_, _) => UIActions.ShowProgressWindow();
         ApplicationContext.MainWindow.MenuItemMap["copyURL"].Clicked         += (_, _) => UIActions.CopyURL1();
         ApplicationContext.MainWindow.MenuItemMap["copyURL1"].Clicked        += (_, _) => UIActions.CopyURL2();
         ApplicationContext.MainWindow.MenuItemMap["properties"].Clicked      += (_, _) => UIActions.ShowSeletectedItemProperties();
         ApplicationContext.MainWindow.MenuItemMap["open"].Clicked            += (_, _) => UIActions.OpenSelectedFile();
         ApplicationContext.MainWindow.MenuItemMap["openFolder"].Clicked      += (_, _) => UIActions.OpenSelectedFolder();
         ApplicationContext.MainWindow.MenuItemMap["deleteDownloads"].Clicked += (_, _) => DeleteDownloads();
         ApplicationContext.MainWindow.MenuItemMap["copyFile"].Clicked        += (_, _) => UIActions.CopyFile();
         ApplicationContext.MainWindow.MenuItemMap["properties1"].Clicked     += (_, _) => UIActions.ShowSeletectedItemProperties();
         ApplicationContext.MainWindow.MenuItemMap["downloadAgain"].Clicked   += (_, _) => UIActions.RestartDownload();
         ApplicationContext.MainWindow.MenuItemMap["restart"].Clicked         += (_, _) => UIActions.RestartDownload();
     }
     catch (Exception ex)
     {
         Log.Debug(ex, ex.Message);
     }
 }
Exemple #2
0
        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();
        }