/// <summary>
        /// Shows the save file dialog box that allows a user to specify a filename to save a file as.
        /// </summary>
        /// <param name="service">The file dialog service.</param>
        /// <param name="fileType">The supported file type.</param>
        /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
        /// <exception cref="System.ArgumentNullException">service must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">fileType must not be null.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, FileType fileType)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(fileType, "fileType");

            return service.ShowSaveFileDialog(null, new FileType[] { fileType }, fileType, null);
        }
        /// <summary>
        /// Shows the open file dialog box that allows a user to specify a file that should be opened.
        /// </summary>
        /// <param name="service">The file dialog service.</param>
        /// <param name="fileType">The supported file type.</param>
        /// <param name="defaultFileName">Default filename. The directory name is used as initial directory when it is specified.</param>
        /// <returns>A FileDialogResult object which contains the filename selected by the user.</returns>
        /// <exception cref="System.ArgumentNullException">service must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">fileType must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">defaultFileName must not be null.</exception>
        public static FileDialogResult ShowOpenFileDialog(this IFileDialogService service, FileType fileType, string defaultFileName)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(fileType, "fileType");
            Preconditions.NotNull(defaultFileName, "defaultFileName");

            return service.ShowOpenFileDialog(null, new FileType[] { fileType }, fileType, defaultFileName);
        }
        /// <summary>
        /// Shows the open file dialog box that allows a user to specify a file that should be opened.
        /// </summary>
        /// <param name="service">The file dialog service.</param>
        /// <param name="owner">The window that owns this OpenFileDialog.</param>
        /// <param name="fileType">The supported file type.</param>
        /// <returns>A FileDialogResult object which contains the filename selected by the user.</returns>
        /// <exception cref="System.ArgumentNullException">service must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">owner must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">fileType must not be null.</exception>
        public static FileDialogResult ShowOpenFileDialog(this IFileDialogService service, object owner, FileType fileType)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(owner, "owner");
            Preconditions.NotNull(fileType, "fileType");

            return service.ShowOpenFileDialog(owner, new FileType[] { fileType }, fileType, null);
        }
Beispiel #4
0
        public void CreateFilterTest()
        {
            FileType rtfFileType = new FileType("RichText Document", ".rtf");
            FileType xpsFileType = new FileType("XPS Document", ".xps");

            Assert.AreEqual("RichText Document|*.rtf", InvokeCreateFilter(new FileType[] { rtfFileType }));
            Assert.AreEqual("RichText Document|*.rtf|XPS Document|*.xps",
                InvokeCreateFilter(new FileType[] { rtfFileType, xpsFileType }));
        }
        /// <summary>
        /// Shows the save file dialog box that allows a user to specify a filename to save a file as.
        /// </summary>
        /// <param name="service">The file dialog service.</param>
        /// <param name="owner">The window that owns this SaveFileDialog.</param>
        /// <param name="fileType">The supported file type.</param>
        /// <param name="defaultFileName">Default filename. The directory name is used as initial directory when it is specified.</param>
        /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
        /// <exception cref="System.ArgumentNullException">service must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">owner must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">fileType must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">defaultFileName must not be null.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, object owner, FileType fileType, string defaultFileName)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(owner, "owner");
            Preconditions.NotNull(fileType, "fileType");
            Preconditions.NotNull(defaultFileName, "defaultFileName");

            return service.ShowSaveFileDialog(owner, new FileType[] { fileType }, fileType, defaultFileName);
        }
Beispiel #6
0
 public FileDialogResult ShowSaveFileDialog(object owner, IEnumerable<FileType> fileTypes, FileType defaultFileType, string defaultFileName)
 {
     FileDialogType = FileDialogType.SaveFileDialog;
     Owner = owner;
     FileTypes = fileTypes;
     DefaultFileType = defaultFileType;
     DefaultFileName = defaultFileName;
     return Result;
 }
Beispiel #7
0
        public void GeneralTest()
        {
            var fileType = new FileType("Bitmap Image (*.bmp)", ".bmp");
            var result = new FileDialogResult(@"C:\image.bmp", fileType);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(@"C:\image.bmp", result.FileName);
            Assert.AreEqual(fileType, result.SelectedFileType);
            Assert.AreEqual(@"C:\image.bmp", result.GetFullFileName());
        }
Beispiel #8
0
        public void GetFullFileNameTest()
        {
            var fileType = new FileType("Bitmap Image (*.bmp)", ".bmp");

            var result = new FileDialogResult(@"C:\image.bmp", fileType);
            Assert.AreEqual(@"C:\image.bmp", result.GetFullFileName());

            result = new FileDialogResult(@"C:\image", fileType);
            Assert.AreEqual(@"C:\image.bmp", result.GetFullFileName());

            result = new FileDialogResult(@"C:\image.txt", fileType);
            Assert.AreEqual(@"C:\image.txt.bmp", result.GetFullFileName());

            result = new FileDialogResult(@"C:\image.txt", fileType);
            Assert.AreEqual(@"C:\image.txt.bmp", result.GetFullFileName());
        }
        /// <summary>
        /// Shows the save file dialog box that allows a user to specify a filename to save a file as.
        /// </summary>
        /// <param name="service">The file dialog service.</param>
        /// <param name="fileTypes">The supported file types.</param>
        /// <param name="defaultFileType">Default file type.</param>
        /// <param name="defaultFileName">Default filename. The directory name is used as initial directory when it is specified.</param>
        /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
        /// <exception cref="System.ArgumentNullException">service must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">defaultFileType must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">defaultFileName must not be null.</exception>
        /// <exception cref="System.ArgumentNullException">fileTypes must not be null.</exception>
        /// <exception cref="System.ArgumentException">fileTypes must contain at least one item.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, IEnumerable<FileType> fileTypes, FileType defaultFileType, string defaultFileName)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(defaultFileType, "defaultFileType");
            Preconditions.NotNull(defaultFileName, "defaultFileName");

            return service.ShowSaveFileDialog(null, fileTypes, defaultFileType, defaultFileName);
        }
Beispiel #10
0
 public void GeneralTest()
 {
     var fileType = new FileType("Bitmap Image (*.bmp)", ".bmp");
     Assert.AreEqual("Bitmap Image (*.bmp)", fileType.Description);
     Assert.AreEqual(".bmp", fileType.FileExtension);
 }