private async void Scan <T>(Func <string, Progress <object>, Task> scanFunction) where T : LibgenObject { SelectFolderDialogParameters selectFolderDialogParameters = new SelectFolderDialogParameters { DialogTitle = Localization.BrowseDirectoryDialogTitle }; SelectFolderDialogResult selectFolderDialogResult = WindowManager.ShowSelectFolderDialog(selectFolderDialogParameters); if (selectFolderDialogResult.DialogResult) { mode = Mode.SCANNING; FoundItems = new ObservableCollection <ScanResultItemViewModel>(); NotFoundItems = new ObservableCollection <string>(); UpdateResultTabHeaders(); UpdateAddAllFilesToLibraryButton(); IsScanLogTabSelected = true; AreScanButtonsVisible = false; IsResultsPanelVisible = true; scanDirectory = selectFolderDialogResult.SelectedFolderPath; ScanLogs.Add(Localization.GetScanStartedString(scanDirectory)); Progress <object> scanProgressHandler = new Progress <object>(HandleScanProgress <T>); await scanFunction(scanDirectory, scanProgressHandler); mode = Mode.SCAN_COMPLETE; hasFilesToAdd = foundItems.Any(foundItem => !foundItem.ExistsInLibrary); UpdateAddAllFilesToLibraryButton(); } }
public static SelectFolderDialogResult GetBrowseDialogPath(string title = "Select Folder", bool selectMultiple = false, string initialDirectory = "", bool IsWin7Style = false) { SelectFolderDialogResult folderDialogResult = new SelectFolderDialogResult(); FileChooserAdapter fileChooserAdapter = new FileChooserAdapter(FileAction.SelectFolder, title, selectMultiple, initialDirectory); if (!fileChooserAdapter.Run(IsWin7Style)) { return(folderDialogResult); } folderDialogResult.Folder = fileChooserAdapter.Path; folderDialogResult.Folders = fileChooserAdapter.Paths; return(folderDialogResult); }
private void DownloadSelectDirectory() { SelectFolderDialogParameters selectFolderDialogParameters = new SelectFolderDialogParameters { DialogTitle = Localization.DownloadBrowseDirectoryDialogTitle, InitialDirectory = DownloadDirectory }; SelectFolderDialogResult selectFolderDialogResult = WindowManager.ShowSelectFolderDialog(selectFolderDialogParameters); if (selectFolderDialogResult.DialogResult) { DownloadDirectory = selectFolderDialogResult.SelectedFolderPath; } }
private async void Scan() { SelectFolderDialogParameters selectFolderDialogParameters = new SelectFolderDialogParameters { DialogTitle = Localization.BrowseDirectoryDialogTitle }; SelectFolderDialogResult selectFolderDialogResult = WindowManager.ShowSelectFolderDialog(selectFolderDialogParameters); if (selectFolderDialogResult.DialogResult) { FoundItems = new ObservableCollection <ScanResultItemViewModel>(); NotFoundItems = new ObservableCollection <string>(); UpdateResultTabHeaders(); IsScanLogTabSelected = true; IsScanButtonVisible = false; IsResultsPanelVisible = true; string scanDirectory = selectFolderDialogResult.SelectedFolderPath; ScanLogs.Add(Localization.GetScanStartedString(scanDirectory)); Progress <object> scanProgressHandler = new Progress <object>(HandleScanProgress); await MainModel.ScanAsync(scanDirectory, scanProgressHandler); } }