/// <summary> /// Creates the appropriate <see cref="FolderSelectionDialog" /> for running platform. /// </summary> /// <param name="preference">Folder selection dialog implementation preference.</param> /// <returns> /// The appropriate <see cref="FolderSelectionDialog" /> for running platform. /// </returns> /// <remarks> /// The return value is determined with running platform and <paramref name="preference" />. /// </remarks> public static FolderSelectionDialog CreateDialog(FolderSelectionDialogPreference preference) { switch (preference) { case FolderSelectionDialogPreference.None: { if (CanUseCommonItemDialog) { return(new CommonOpenFileFolderSelectionDialog()); } return(new FolderBrowserFolderSelectionDialog()); } case FolderSelectionDialogPreference.FolderBrowser: { return(new FolderBrowserFolderSelectionDialog()); } case FolderSelectionDialogPreference.CommonItemDialog: { if (!CanUseCommonItemDialog) { throw new PlatformNotSupportedException(Resources .FolderSelectionDialogFactory_CommonItemDialogIsSupportedFromWindowsNT6); } return(new CommonOpenFileFolderSelectionDialog()); } default: { throw new ArgumentException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedEnumValue ?? string.Empty, typeof(FolderSelectionDialogPreference), preference, (int)preference), nameof(preference) ); } } }
/// <summary> /// Creates the appropriate <see cref="FolderSelectionDialog"/> for running platform. /// </summary> /// <param name="preference">Folder selection dialog impementation preference.</param> /// <returns> /// The appropriate <see cref="FolderSelectionDialog"/> for running platform. /// </returns> /// <remarks> /// The return value is determined with running platform and <paramref name="preference"/>. /// </remarks> public static FolderSelectionDialog CreateDialog( FolderSelectionDialogPreference preference ) { switch ( preference ) { case FolderSelectionDialogPreference.None: { if ( CanUseCommonItemDialog ) { return new CommonOpenFileFolderSelectionDialog(); } else { return new FolderBrowserFolderSelectionDialog(); } } case FolderSelectionDialogPreference.FolderBrowser: { return new FolderBrowserFolderSelectionDialog(); } case FolderSelectionDialogPreference.CommonItemDialog: { if ( !CanUseCommonItemDialog ) { throw new PlatformNotSupportedException( Resources.FolderSelectionDialogFactory_CommonItemDialogIsSupportedFromWindowsNT6 ); } return new CommonOpenFileFolderSelectionDialog(); } default: { throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Resources.UnsupportedEnumValue, typeof( FolderSelectionDialogPreference ), preference, ( int )preference ), "preference" ); } } }