/// <summary> /// Called when the dialog is opened. /// </summary> /// <param name="parameters">The parameters passed to the dialog.</param> public override void OnDialogOpened(IDialogParameters parameters) { base.OnDialogOpened(parameters); // Subscribe event this.eventAggregator.GetEvent <FileSelectionEvent>().Subscribe(this.OnFileSelection); this.eventAggregator.GetEvent <MoveCurrentFolderEvent>().Subscribe(this.OnMoveCurrentFolder); this.eventAggregator.GetEvent <FileEnterEvent>().Subscribe(this.OnFileEnter); // Configure parameters if (parameters.TryGetValue(DialogParameterNames.FileNamePrefixText, out string fileNamePrefixText)) { this.FileNamePrefixText = fileNamePrefixText; } if (parameters.TryGetValue(DialogParameterNames.SelectButtonText, out string selectButtonText)) { this.SelectButtonText = selectButtonText; } if (parameters.TryGetValue(DialogParameterNames.CancelButtonText, out string cancelButtonText)) { this.CancelButtonText = cancelButtonText; } this.filters.Clear(); if (parameters.TryGetValue(DialogParameterNames.Filters, out IEnumerable <FileFilter> filters)) { this.filters.AddRange(filters); } else { var filter = parameters.TryGetValue(DialogParameterNames.DefaultAllFilesFilterText, out string filterText) ? new FileFilter(filterText) : FileFilter.CreateDefault(); this.filters.Add(filter); } this.selectedFilter = this.Filters.First(); var regionContext = ExplorerBaseRegionContext.CreateForSingleFileSelect(); if (parameters.TryGetValue(DialogParameterNames.TextResource, out ExplorerBaseTextResource textResource)) { regionContext.TextResource = textResource; } if (parameters.TryGetValue(DialogParameterNames.CanMultiSelect, out bool canMultiSelect)) { regionContext.CanMultiSelect = canMultiSelect; } if (parameters.TryGetValue(DialogParameterNames.RootFolders, out IEnumerable <string> rootFolders)) { regionContext.RootFolders = rootFolders; } regionContext.FileExtensions = this.Filters.First().Extensions; this.RegionContext = regionContext; }
/// <summary> /// Called when the dialog is opened. /// </summary> /// <param name="parameters">The parameters passed to the dialog.</param> public override void OnDialogOpened(IDialogParameters parameters) { base.OnDialogOpened(parameters); // Subscribe event this.eventAggregator.GetEvent <FileSelectionEvent>().Subscribe(this.OnFileSelection); this.eventAggregator.GetEvent <MoveCurrentFolderEvent>().Subscribe(this.OnMoveDisplayFolder); this.eventAggregator.GetEvent <FileEnterEvent>().Subscribe(this.OnFileEnter); // Configure parameters if (parameters.TryGetValue(DialogParameterNames.FileNamePrefixText, out string fileNamePrefixText)) { this.FileNamePrefixText = fileNamePrefixText; } if (parameters.TryGetValue(DialogParameterNames.FileTypePrefixText, out string fileTypePrefixText)) { this.FileTypePrefixText = fileTypePrefixText; } if (parameters.TryGetValue(DialogParameterNames.SaveButtonText, out string saveButtonText)) { this.SaveButtonText = saveButtonText; } if (parameters.TryGetValue(DialogParameterNames.CancelButtonText, out string cancelButtonText)) { this.CancelButtonText = cancelButtonText; } if (parameters.TryGetValue(DialogParameterNames.DefaultSaveFileName, out string defaultSaveFileName)) { this.SaveFileName = defaultSaveFileName; } this.filters.Clear(); if (parameters.TryGetValue(DialogParameterNames.Filters, out IEnumerable <FileFilter> filters)) { this.filters.AddRange(filters); } else { var filter = parameters.TryGetValue(DialogParameterNames.DefaultAllFilesFilterText, out string filterText) ? new FileFilter(filterText) : FileFilter.CreateDefault(); this.filters.Add(filter); } this.selectedFilter = this.Filters.First(); if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationTitle, out string overwriteConfirmationTitle)) { this.OverwriteConfirmationTitle = overwriteConfirmationTitle; } if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationMessageFunc, out Func <string, string> overwriteConfirmationMessageFunc)) { this.OverwriteConfirmationMessageFunc = overwriteConfirmationMessageFunc; } if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationOKButtonText, out string overwriteConfirmationOKButtonText)) { this.OverwriteConfirmationOKButtonText = overwriteConfirmationOKButtonText; } if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationCancelButtonText, out string overwriteConfirmationCancelButtonText)) { this.OverwriteConfirmationCancelButtonText = overwriteConfirmationCancelButtonText; } var regionContext = ExplorerBaseRegionContext.CreateForSingleFileSelect(); if (parameters.TryGetValue(DialogParameterNames.TextResource, out ExplorerBaseTextResource textResource)) { regionContext.TextResource = textResource; } if (parameters.TryGetValue(DialogParameterNames.RootFolders, out IEnumerable <string> rootFolders)) { regionContext.RootFolders = rootFolders; } regionContext.FileExtensions = this.Filters.First().Extensions; this.RegionContext = regionContext; }