コード例 #1
0
        /// <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));
        }
コード例 #2
0
ファイル: FileController.cs プロジェクト: zwq00000/waf
        private void SaveAs(IDocument document)
        {
            var fileTypes = (from d in documentTypes
                             where d.CanSave(document)
                             select new FileType(d.Description, d.FileExtension)
                             ).ToArray();

            if (!fileTypes.Any())
            {
                throw new InvalidOperationException("No DocumentType is registered that supports the Save operation.");
            }

            FileType selectedFileType;

            if (File.Exists(document.FileName))
            {
                var           saveTypes    = documentTypes.Where(d => d.CanSave(document)).ToArray();
                IDocumentType documentType = saveTypes.First(d => d.FileExtension == Path.GetExtension(document.FileName));
                selectedFileType = fileTypes.First(
                    f => f.Description == documentType.Description && f.FileExtension == documentType.FileExtension);
            }
            else
            {
                selectedFileType = fileTypes.First();
            }
            string fileName = Path.GetFileNameWithoutExtension(document.FileName);

            FileDialogResult result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, fileTypes, selectedFileType, fileName);

            if (result.IsValid)
            {
                IDocumentType documentType = GetDocumentType(result.SelectedFileType);
                SaveCore(documentType, document, result.FileName);
            }
        }
コード例 #3
0
        private void SaveList()
        {
            var result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, saveQueuelistFileType);

            if (!result.IsValid)
            {
                return;
            }

            var queueList = new List <string>();

            foreach (var item in QueueManager.Items)
            {
                queueList.Add(item.Blog.Name);
            }

            try
            {
                var targetFolder = Path.GetDirectoryName(result.FileName);
                var name         = Path.GetFileNameWithoutExtension(result.FileName);

                using (FileStream stream = new FileStream(Path.Combine(targetFolder, name) + ".que", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    IFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, queueList);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("SaveList SaveAs: {0}", ex);
                shellService.ShowError(ex, Resources.CouldNotSaveQueueList);
            }
        }
コード例 #4
0
        /// <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="fileTypes">The supported file types.</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">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, object owner, IEnumerable <FileType> fileTypes)
        {
            Preconditions.NotNull(service, "service");
            Preconditions.NotNull(owner, "owner");

            return(service.ShowSaveFileDialog(owner, fileTypes, null, null));
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
 /// <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="fileTypes">The supported file types.</param>
 /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
 /// <exception cref="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileTypes must not be null.</exception>
 /// <exception cref="ArgumentException">fileTypes must contain at least one item.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, object owner, IEnumerable <FileType> fileTypes)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     return(service.ShowSaveFileDialog(owner, fileTypes, null, null));
 }
コード例 #7
0
        /// <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="_fileTypes">The supported file types.</param>
        /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
        /// <exception cref="ArgumentNullException">service must not be null.</exception>
        /// <exception cref="ArgumentNullException">fileTypes must not be null.</exception>
        /// <exception cref="ArgumentException">fileTypes must contain at least one item.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService _service, object _owner, IEnumerable <FileType> _fileTypes)
        {
            if (null == _service)
            {
                throw new ArgumentNullException(nameof(_service));
            }

            return(_service.ShowSaveFileDialog(_owner, _fileTypes, null, null));
        }
コード例 #8
0
        /// <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));
        }
コード例 #9
0
 /// <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="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileTypes must not be null.</exception>
 /// <exception cref="ArgumentException">fileTypes must contain at least one item.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, IEnumerable <FileType> fileTypes,
                                                   FileType defaultFileType, string defaultFileName)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     return(service.ShowSaveFileDialog(null, fileTypes, defaultFileType, defaultFileName));
 }
コード例 #10
0
 private void SaveAttachmentRequest()
 {
     IEnumerable <System.Waf.Applications.Services.FileType> fileTypes = new System.Waf.Applications.Services.FileType[] {
         new System.Waf.Applications.Services.FileType("all files", ".*"),
         new System.Waf.Applications.Services.FileType("jpg image", ".jpg"),
         new System.Waf.Applications.Services.FileType("bmp image", ".bmp"),
         new System.Waf.Applications.Services.FileType("png image", ".png")
     };
     FileDialogResult result = fileDialogService.ShowSaveFileDialog(fileTypes);
 }
コード例 #11
0
        /// <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="ArgumentNullException">service must not be null.</exception>
        /// <exception cref="ArgumentNullException">fileTypes must not be null.</exception>
        /// <exception cref="ArgumentException">fileTypes must contain at least one item.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService _service, IEnumerable <FileType> _fileTypes
                                                          , FileType _defaultFileType, string _defaultFileName)
        {
            if (null == _service)
            {
                throw new ArgumentNullException(nameof(_service));
            }

            return(_service.ShowSaveFileDialog(null, _fileTypes, _defaultFileType, _defaultFileName));
        }
コード例 #12
0
        private void BrowseExportLocation()
        {
            FileDialogResult result = fileDialogService.ShowSaveFileDialog(ShellService.ShellView, bloglistExportFileType, ExportLocation);

            if (!result.IsValid)
            {
                return;
            }

            ExportLocation = result.FileName;
        }
コード例 #13
0
 /// <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="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, object owner, FileType fileType, string defaultFileName)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     if (fileType == null)
     {
         throw new ArgumentNullException("fileType");
     }
     return(service.ShowSaveFileDialog(owner, new FileType[] { fileType }, fileType, defaultFileName));
 }
コード例 #14
0
 /// <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="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, FileType fileType)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     if (fileType == null)
     {
         throw new ArgumentNullException("fileType");
     }
     return(service.ShowSaveFileDialog(null, new FileType[] { fileType }, fileType, null));
 }
コード例 #15
0
        private void SaveAs(DocumentFile document)
        {
            FileType fileType = document.DocumentType == DocumentType.CSharp ? cSharpFileType : visualBasicFileType;
            string   fileName = Path.GetFileNameWithoutExtension(document.FileName);

            FileDialogResult result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, fileType, fileName);

            if (result.IsValid)
            {
                SaveCore(document, result.FileName);
            }
        }
コード例 #16
0
 /// <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>
 /// <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="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, FileType fileType, string?defaultFileName)
 {
     if (service == null)
     {
         throw new ArgumentNullException(nameof(service));
     }
     if (fileType == null)
     {
         throw new ArgumentNullException(nameof(fileType));
     }
     return(service.ShowSaveFileDialog(null, new[] { fileType }, fileType, defaultFileName));
 }
コード例 #17
0
 /// <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>
 /// <returns>A FileDialogResult object which contains the filename entered by the user.</returns>
 /// <exception cref="ArgumentNullException">service must not be null.</exception>
 /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
 public static FileDialogResult ShowSaveFileDialog(this IFileDialogService service, object?owner, FileType fileType)
 {
     if (service == null)
     {
         throw new ArgumentNullException(nameof(service));
     }
     if (fileType == null)
     {
         throw new ArgumentNullException(nameof(fileType));
     }
     return(service.ShowSaveFileDialog(owner, new[] { fileType }, fileType, null));
 }
コード例 #18
0
        /// <summary>
        /// Saves a bulk file in a new file path
        /// </summary>
        public void FileSaveAs()
        {
            fileDialogService.Title            = "Sačuvajte datoteku";
            fileDialogService.Filter           = "Rasuta datoteka (*.bf)|*.bf";
            fileDialogService.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            if (fileDialogService.ShowSaveFileDialog() == true)
            {
                FileName = fileDialogService.FileName;
                BusinessContext.WriteToBinaryFile(FileName, BulkFile);
                Messages.Enqueue("Uspešno ste sačuvali datoteku");
            }
        }
コード例 #19
0
        /// <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="ArgumentNullException">service must not be null.</exception>
        /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService _service, FileType _fileType)
        {
            if (null == _service)
            {
                throw new ArgumentNullException(nameof(_service));
            }
            if (null == _fileType)
            {
                throw new ArgumentNullException(nameof(_fileType));
            }

            return(_service.ShowSaveFileDialog(null, new FileType[] { _fileType }, _fileType, null));
        }
コード例 #20
0
        /// <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="ArgumentNullException">service must not be null.</exception>
        /// <exception cref="ArgumentNullException">fileType must not be null.</exception>
        public static FileDialogResult ShowSaveFileDialog(this IFileDialogService _service, object _owner, FileType _fileType, string _defaultFileName)
        {
            if (null == _service)
            {
                throw new ArgumentNullException(nameof(_service));
            }
            if (null == _fileType)
            {
                throw new ArgumentNullException(nameof(_fileType));
            }

            return(_service.ShowSaveFileDialog(_owner, new FileType[] { _fileType }, _fileType, _defaultFileName));
        }
コード例 #21
0
        private void SaveFile()
        {
            var options = new FileDialogOptions()
            {
                Filter = Filter
            };

            var result = _fileDialogService.ShowSaveFileDialog(options);

            if (result != null)
            {
                FileName = result.FileName;
            }
        }
コード例 #22
0
ファイル: MainViewModel.cs プロジェクト: sk8tz/Cas.Common.WPF
        private bool SaveAs()
        {
            var options = new FileDialogOptions()
            {
                Filter = Filter
            };

            var result = _fileDialogService.ShowSaveFileDialog(options);

            if (result == null)
            {
                return(false);
            }

            File.WriteAllText(result.FileName, Text);
            Path = result.FileName;
            _dirtyService.MarkClean();

            return(true);
        }
コード例 #23
0
        private bool SaveAs()
        {
            var options = new FileDialogOptions()
            {
                Filter = FileFilter
            };

            var result = _fileDialogService.ShowSaveFileDialog(options);

            if (result != null)
            {
                Filename = result.FileName;

                SaveInner();

                return(true);
            }

            return(false);
        }
        private void SaveList()
        {
            var result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, savePlaylistFileType);

            if (!result.IsValid)
            {
                return;
            }

            var playlist = new Playlist();

            try
            {
                foreach (var item in PlaylistManager.Items)
                {
                    var file = StorageFile.GetFileFromPathAsync(item.MusicFile.FileName).GetResult();
                    playlist.Files.Add(file);
                }
            }
            catch (Exception ex)
            {
                Log.Default.Error(ex, "SaveList GetStorageFiles");
                shellService.ShowError(ex, Resources.CouldNotSavePlaylistBecauseMissingFiles);
                return;
            }

            try
            {
                var targetFolder = StorageFolder.GetFolderFromPathAsync(Path.GetDirectoryName(result.FileName)).GetResult();
                var name         = Path.GetFileNameWithoutExtension(result.FileName);
                playlist.SaveAsAsync(targetFolder, name, NameCollisionOption.ReplaceExisting, PlaylistFormat.M3u).Wait();
            }
            catch (Exception ex)
            {
                Log.Default.Error(ex, "SaveList SaveAs");
                shellService.ShowError(ex, Resources.CouldNotSavePlaylist);
            }
        }
コード例 #25
0
        private async void Download()
        {
            var layer = SelectedLayer;

            if (layer == null)
            {
                return;
            }

            GetBlobResponse response = null;

            var ex = await Executor.ExecuteAsync(async() =>
            {
                response = await _registryClient.Blobs.GetBlobAsync(_parent.Repository, layer.Digest);
            });

            if (ex != null)
            {
                _messageBoxService.Show(ex.Message);
            }
            else
            {
                using (var stream = response.Stream)
                {
                    var result = _fileDialogService.ShowSaveFileDialog();

                    if (result != null)
                    {
                        using (var targetStream = File.Create(result.FileName))
                        {
                            stream.CopyTo(targetStream);
                        }
                    }
                }

                _messageBoxService.Show("Layer saved", "Complete");
            }
        }
コード例 #26
0
ファイル: QueueController.cs プロジェクト: yl9345/TumblThree
        private void SaveList()
        {
            FileDialogResult result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, saveQueuelistFileType);

            if (!result.IsValid)
            {
                return;
            }

            var queueList = new QueueSettings();

            queueList.ReplaceAll(QueueManager.Items.Select(item => item.Blog.Name).ToList(),
                                 QueueManager.Items.Select(item => item.Blog.BlogType).ToList());

            try
            {
                string targetFolder = Path.GetDirectoryName(result.FileName);
                string name         = Path.GetFileNameWithoutExtension(result.FileName);

                using (
                    var stream = new FileStream(Path.Combine(targetFolder, name) + ".que", FileMode.Create, FileAccess.Write,
                                                FileShare.None))
                {
                    using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
                               stream, Encoding.UTF8, true, true, "  "))
                    {
                        var serializer = new DataContractJsonSerializer(typeof(QueueSettings));
                        serializer.WriteObject(writer, queueList);
                        writer.Flush();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("QueueController:SaveList: {0}", ex);
                shellService.ShowError(ex, Resources.CouldNotSaveQueueList);
            }
        }