/// <summary> /// Invokes the action related to this class. /// </summary> /// <param name="m"><see cref="FolderSelectionMessage" /> specified to <see cref="InteractionMessenger" /> in the client.</param> protected override void InvokeAction(InteractionMessage m) { // ReSharper disable once InvertIf if (m is FolderSelectionMessage folderSelectionMessage) { var hostWindow = Window.GetWindow(AssociatedObject ?? throw new InvalidOperationException()); if (hostWindow == null) { return; } using (var dialog = FolderSelectionDialogFactory.CreateDialog(folderSelectionMessage.DialogPreference)) { if (dialog == null) { throw new InvalidOperationException(); } dialog.Title = folderSelectionMessage.Title; dialog.Description = folderSelectionMessage.Description; dialog.SelectedPath = folderSelectionMessage.SelectedPath; dialog.Multiselect = folderSelectionMessage.Multiselect; if (dialog.ShowDialog(hostWindow).GetValueOrDefault()) { folderSelectionMessage.SelectedPaths = dialog.SelectedPaths; folderSelectionMessage.Response = folderSelectionMessage.SelectedPaths.FirstOrDefault(); } else { folderSelectionMessage.Response = null; } } } }
/// <summary> /// Invokes the action related to this class. /// </summary> /// <param name="m"><see cref="FolderSelectionMessage"/> specified to <see cref="InteractionMessenger"/> in the client.</param> protected override void InvokeAction(InteractionMessage m) { var folderSelectionMessage = m as FolderSelectionMessage; if (folderSelectionMessage != null) { Window hostWindow = Window.GetWindow(AssociatedObject); if (hostWindow == null) { return; } using (var dialog = FolderSelectionDialogFactory.CreateDialog(folderSelectionMessage.DialogPreference) ) { dialog.Title = folderSelectionMessage.Title; dialog.Description = folderSelectionMessage.Description; dialog.SelectedPath = folderSelectionMessage.SelectedPath; if (dialog.ShowDialog(hostWindow).GetValueOrDefault()) { folderSelectionMessage.Response = dialog.SelectedPath; } else { folderSelectionMessage.Response = null; } } } }