public static FileDialog GetDialog(InstancedIFormat2 ThisOne, ApplicationState CurrentState, FileDialogMode Mode) { if (StringResources == null) { StringResources = new ResourceManager(typeof(StringResources.Localized_GenericDialog)); } FileDialog ret = null; if (CurrentState == null) { throw new ArgumentNullException(nameof(CurrentState)); } if (ThisOne == null) { throw new ArgumentNullException(nameof(ThisOne)); } else { if (Mode.HasFlag(FileDialogMode.UseOpenDialog)) { ret = new OpenFileDialog { Title = StringResources.GetString("WindowFilePlugin_OpenFragment", CultureInfo.CurrentUICulture) }; } else { if (Mode.HasFlag(FileDialogMode.UseSaveDialog)) { ret = new SaveFileDialog { Title = StringResources.GetString("WindowFilePlugin_SaveFragment", CultureInfo.CurrentUICulture) }; } } if (ret == null) { throw new NotImplementedException(StringResources.GetString("WindowFilePlugin_UnsupportedMode", CultureInfo.CurrentUICulture)); } ret.InitialDirectory = CurrentState.UserDocumentLocation; ret.Title += ThisOne.GetFriendlyName(); ret.Filter = ThisOne.GetDialogBoxExt(); if (ret.Filter.EndsWith("|", StringComparison.InvariantCultureIgnoreCase)) { ret.Filter += "All Files (*.*)|*.*"; } else { ret.Filter += "|All Files (*.*)|*.*"; } return(ret); } }