/// <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="fileTypes">The supported file types.</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">fileTypes must not be null.</exception> /// <exception cref="System.ArgumentException">fileTypes must contain at least one item.</exception> public static FileDialogResult ShowOpenFileDialog(this IFileDialogService service, object owner, IEnumerable <FileType> fileTypes) { Preconditions.NotNull(service, "service"); Preconditions.NotNull(owner, "owner"); return(service.ShowOpenFileDialog(owner, fileTypes, null, 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> /// <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> public static FileDialogResult ShowOpenFileDialog(this IFileDialogService service, FileType fileType) { Preconditions.NotNull(service, "service"); Preconditions.NotNull(fileType, "fileType"); return(service.ShowOpenFileDialog(null, new FileType[] { fileType }, fileType, null)); }
private async void OpenFile() { var assemblyFileType = new FileType(".NET Assembly (*.dll, *.exe)", ".dll;*.exe"); var allFileType = new FileType("All files (*.*)", ".*"); var result = fileDialogService.ShowOpenFileDialog(ShellViewModel.View, new[] { assemblyFileType, allFileType }); if (!result.IsValid) { return; } try { using (ShellViewModel.SetApplicationBusy()) { var assemblyApi = await Task.Run(() => AssemblyReader.Read(result.FileName)); AddAndSelectAssemblyApi(result.FileName, assemblyApi.version, assemblyApi.api); } } catch (Exception e) { messageService.ShowError(ShellViewModel.View, "Could not read the file. Error: " + e); } }
/// <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="fileTypes">The supported file types.</param> /// <returns>A FileDialogResult object which contains the filename selected 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 ShowOpenFileDialog(this IFileDialogService service, object owner, IEnumerable <FileType> fileTypes) { if (service == null) { throw new ArgumentNullException("service"); } return(service.ShowOpenFileDialog(owner, fileTypes, null, 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="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 selected 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 ShowOpenFileDialog(this IFileDialogService service, IEnumerable <FileType> fileTypes, FileType defaultFileType, string defaultFileName) { Preconditions.NotNull(service, "service"); Preconditions.NotNull(defaultFileType, "defaultFileType"); Preconditions.NotNull(defaultFileName, "defaultFileName"); return(service.ShowOpenFileDialog(null, fileTypes, defaultFileType, 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="_fileTypes">The supported file types.</param> /// <returns>A FileDialogResult object which contains the filename selected 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 ShowOpenFileDialog(this IFileDialogService _service, IEnumerable <FileType> _fileTypes) { if (null == _service) { throw new ArgumentNullException(nameof(_service)); } return(_service.ShowOpenFileDialog(null, _fileTypes, null, 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="owner">The window that owns this OpenFileDialog.</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">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 ShowOpenFileDialog(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.ShowOpenFileDialog(owner, 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="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 selected 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 ShowOpenFileDialog(this IFileDialogService service, IEnumerable <FileType> fileTypes, FileType defaultFileType, string defaultFileName) { if (service == null) { throw new ArgumentNullException("service"); } return(service.ShowOpenFileDialog(null, fileTypes, defaultFileType, defaultFileName)); }
private void OpenList() { var result = fileDialogService.ShowOpenFileDialog(shellService.ShellView, openPlaylistFileType); if (!result.IsValid) { return; } OpenListCore(result.FileName); }
private void OpenList() { FileDialogResult result = _fileDialogService.ShowOpenFileDialog(_shellService.ShellView, _openQueuelistFileType); if (!result.IsValid) { return; } OpenListCore(result.FileName); }
/// <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> /// <returns>A FileDialogResult object which contains the filename selected 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 ShowOpenFileDialog(this IFileDialogService service, FileType fileType) { if (service == null) { throw new ArgumentNullException("service"); } if (fileType == null) { throw new ArgumentNullException("fileType"); } return(service.ShowOpenFileDialog(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="ArgumentNullException">service must not be null.</exception> /// <exception cref="ArgumentNullException">fileType must not be null.</exception> public static FileDialogResult ShowOpenFileDialog(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.ShowOpenFileDialog(null, new[] { 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="ArgumentNullException">service must not be null.</exception> /// <exception cref="ArgumentNullException">fileType must not be null.</exception> public static FileDialogResult ShowOpenFileDialog(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.ShowOpenFileDialog(owner, new[] { 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="owner">The window that owns this OpenFileDialog.</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="ArgumentNullException">service must not be null.</exception> /// <exception cref="ArgumentNullException">fileType must not be null.</exception> public static FileDialogResult ShowOpenFileDialog(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.ShowOpenFileDialog(owner, new FileType[] { fileType }, fileType, defaultFileName)); }
/// <summary> /// Opens an existing bulk file from the pc /// </summary> private void OpenFile() { fileDialogService.Title = "Izaberite fajl"; fileDialogService.Filter = "Rasuta datoteka (*.bf)|*.bf"; fileDialogService.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (fileDialogService.ShowOpenFileDialog() == true) { FileName = fileDialogService.FileName; BulkFile = BusinessContext.ReadFromBinaryFile(FileName); Messages.Enqueue("Uspešno ste učitali datoteku"); } }
/// <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> /// <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="ArgumentNullException">service must not be null.</exception> /// <exception cref="ArgumentNullException">fileType must not be null.</exception> public static FileDialogResult ShowOpenFileDialog(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.ShowOpenFileDialog(_owner, 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="_fileType">The supported file type.</param> /// <returns>A FileDialogResult object which contains the filename selected 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 ShowOpenFileDialog(this IFileDialogService _service, FileType _fileType) { if (null == _service) { throw new ArgumentNullException(nameof(_service)); } if (null == _fileType) { throw new ArgumentNullException(nameof(_fileType)); } return(_service.ShowOpenFileDialog(null, new FileType[] { _fileType }, _fileType, null)); }
private void OpenFile() { var options = new FileDialogOptions() { Filter = Filter }; var result = _fileDialogService.ShowOpenFileDialog(options); if (result != null) { FileName = result.FileName; } }
private void AddAttachmentRequest() { CommunicationAttachment attachment = null; 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.ShowOpenFileDialog(this, fileTypes); if (result.IsValid) { try { /* ShowLoadingAnimation = true; * * Action addFolderItemAction = () => * { * ReadFileContent(item, item.FileSystemPath); * ShowLoadingAnimation = false; * }; * addFolderItemAction.BeginInvoke(null, null);*/ FileInfo fInfo = new FileInfo(result.FileName); if (fInfo != null) { attachment = new CommunicationAttachment() { FileUrl = fInfo.Name, Url = result.FileName, State = CommunicationItemState.Appended }; } } catch { ShowLoadingAnimation = false; throw; } if (attachment != null) { OnUIThread(() => { Attachments.Add(attachment); AttacmentsCollection.Refresh(); State = CommunicationItemState.Modified; }); } } }
private void OnGolemOpenModClicked() { FileDialogResult showOpenFileDialog = _fileDialogService.ShowOpenFileDialog(View, new FileType("Golem MOD Information", "*.gmi")); if (!showOpenFileDialog.IsValid) { return; } var golemModFilePath = showOpenFileDialog.FileName; var openGolemModCommand = new OpenGolemModCommand(golemModFilePath, _mainViewActorRef); _mainViewActorRef.Tell(openGolemModCommand); }
private void BrowseSoundFileCommand() { List <FileType> FileTypes = new List <FileType> { new FileType(string.Format(CultureInfo.CurrentCulture, Resources.MP3MusicFile), ".mp3"), new FileType(string.Format(CultureInfo.CurrentCulture, Resources.SoundWaveFile), ".wav") }; FileDialogResult result = fileDialogService.ShowOpenFileDialog(FileTypes); if (!string.IsNullOrWhiteSpace(result.FileName)) { SoundPath = result.FileName; } }
private void AddImage() { IEnumerable <System.Waf.Applications.Services.FileType> fileTypes = new[] { 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") }; var result = _fileDialogService.ShowOpenFileDialog(this, fileTypes); if (result.IsValid) { InnerItem.ImgUrl = result.FileName; } }
private void ChangeContactImage() { IEnumerable <System.Waf.Applications.Services.FileType> fileTypes = new System.Waf.Applications.Services.FileType[] { 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.ShowOpenFileDialog(this, fileTypes); if (result.IsValid) { try { string fileName = result.FileName; if (fileName == null || !IsImageFileValid(fileName)) { return; } byte[] buff = null; buff = File.ReadAllBytes(fileName); if (buff.Length > 20000) { NotificationInteractionRequest.Raise(new ConditionalConfirmation() { Title = "Error file selection".Localize(), Content = "Image must be less than 20 kilobytes".Localize() }, x => { }); } else { InnerItem.Photo = buff; } } catch (Exception) { } } }
private DocumentFile OpenCore(string fileName = null, bool setActiveDocument = true) { if (string.IsNullOrEmpty(fileName)) { FileDialogResult result = fileDialogService.ShowOpenFileDialog(shellService.ShellView, allFilesType); if (result.IsValid) { fileName = result.FileName; } } if (string.IsNullOrEmpty(fileName)) { return(null); } // Check if document is already opened DocumentFile document = fileService.DocumentFiles.SingleOrDefault(d => d.FileName == fileName); if (document == null) { string fileExtension = Path.GetExtension(fileName); if (!new[] { ".cs", ".vb" }.Contains(fileExtension)) { Trace.TraceError(string.Format(CultureInfo.InvariantCulture, "The extension of the file '{0}' is not supported.", fileName)); messageService.ShowError(shellService.ShellView, string.Format(CultureInfo.CurrentCulture, Resources.OpenFileUnsupportedExtension, fileName)); return(null); } var documentType = fileExtension == ".cs" ? DocumentType.CSharp : DocumentType.VisualBasic; document = new DocumentFile(documentType, LoadDocumentContent) { FileName = fileName }; fileService.AddDocument(document); } if (setActiveDocument) { ActiveDocumentFile = document; } return(document); }
private void Open() { var options = new FileDialogOptions() { Filter = FileFilter }; var result = _fileDialogService.ShowOpenFileDialog(options); if (result != null) { var metadata = HostPersistor.LoadFromFile(result.FileName); Filename = result.FileName; Program = new ProgramViewModel(metadata.Functions); } }
private IDocument Open() { var fileTypes = (from d in documentTypes where d.CanOpen() select new FileType(d.Description, d.FileExtension) ).ToArray(); if (!fileTypes.Any()) { throw new InvalidOperationException("No DocumentType is registered that supports the Open operation."); } var result = fileDialogService.ShowOpenFileDialog(shellService.ShellView, fileTypes); if (result.IsValid) { return(OpenCore(result.FileName, result.SelectedFileType)); } return(null); }
private void Open() { if (!SaveIfDirty()) { return; } var options = new FileDialogOptions() { Filter = Filter }; var result = _fileDialogService.ShowOpenFileDialog(options); if (result != null) { Path = result.FileName; Text = File.ReadAllText(result.FileName); _dirtyService.MarkClean(); } }
private static void ExecuteOpenFileDialog(IFileDialogService fileDialogService) { fileDialogService.ShowOpenFileDialog(new OpenFileDialogOptions()); }
private void RaiseUploadRequest() { if (ParentItem.Parent == null) { CommonNotifyRequest.Raise(new Notification { Content = "Can not upload files to the root. Please select a folder first.".Localize(), Title = "Error".Localize(null, LocalizationScope.DefaultCategory) }); return; } IEnumerable <FileType> fileTypes = new[] { new FileType("all files".Localize(), ".*"), new FileType("jpg image".Localize(), ".jpg"), new FileType("bmp image".Localize(), ".bmp"), new FileType("png image".Localize(), ".png"), new FileType("Report".Localize(), ".rld"), new FileType("Report".Localize(), ".rldc") }; if (fileDialogService == null) { fileDialogService = new System.Waf.VirtoCommerce.ManagementClient.Services.FileDialogService(); } var result = fileDialogService.ShowOpenFileDialog(this, fileTypes); if (result.IsValid) { var delimiter = !string.IsNullOrEmpty(ParentItem.InnerItemID) && !ParentItem.InnerItemID.EndsWith(NamePathDelimiter) ? NamePathDelimiter : string.Empty; // construct new FolderItemId var fileInfo = new FileInfo(result.FileName); var fileName = string.Format("{0}{1}{2}", ParentItem.InnerItemID, delimiter, fileInfo.Name); var canUpload = true; var fileExists = SelectedFolderItems.OfType <IFileSearchViewModel>().Any(x => x.InnerItem.FolderItemId.EndsWith(NamePathDelimiter + fileInfo.Name, StringComparison.OrdinalIgnoreCase)); if (fileExists) { CommonConfirmRequest.Raise(new ConditionalConfirmation { Title = "Upload file".Localize(), Content = string.Format("There is already a file with the same name in this location.\nDo you want to overwrite and replace the existing file '{0}'?".Localize(), fileInfo.Name) }, (x) => { canUpload = x.Confirmed; }); } if (canUpload) { ShowLoadingAnimation = true; var worker = new BackgroundWorker(); worker.DoWork += (o, ea) => { var id = o.GetHashCode().ToString(); var item = new StatusMessage { ShortText = "File upload in progress".Localize(), StatusMessageId = id }; EventSystem.Publish(item); using (var info = new UploadStreamInfo()) using (var fileStream = new FileStream(result.FileName, FileMode.Open, FileAccess.Read)) { info.FileName = fileName; info.FileByteStream = fileStream; info.Length = fileStream.Length; _assetRepository.Upload(info); } }; worker.RunWorkerCompleted += (o, ea) => { ShowLoadingAnimation = false; var item = new StatusMessage { StatusMessageId = o.GetHashCode().ToString() }; if (ea.Cancelled) { item.ShortText = "File upload was canceled!".Localize(); item.State = StatusMessageState.Warning; } else if (ea.Error != null) { item.ShortText = string.Format("Failed to upload file: {0}".Localize(), ea.Error.Message); item.Details = ea.Error.ToString(); item.State = StatusMessageState.Error; } else { item.ShortText = "File uploaded".Localize(); item.State = StatusMessageState.Success; RefreshCommand.Execute(); } EventSystem.Publish(item); }; worker.RunWorkerAsync(); } } }