public void AddItemsByFolder() { SelectFolderDialogCreationArgs args = new SelectFolderDialogCreationArgs(); args.AllowCreateNewFolder = false; args.Path = _lastFolder; args.Prompt = SR.MessageSelectAddFilesFolder; FileDialogResult result = base.Context.DesktopWindow.ShowSelectFolderDialogBox(args); if (result.Action == DialogBoxAction.Ok) { _lastFolder = result.FileName; base.Context.BulkOperationsMode = true; try { base.Load(false, result.FileName); base.RefreshTable(); } finally { base.Context.BulkOperationsMode = false; } } }
public void OpenFile(FileDialogResult result) { if (result.UserApproved) { this.OpenFile(result.FilePath); } }
public bool ExportNetworkGraph(object ownerViewModel, SimilarityMetric similarityMetric, double scoreFilter) { FileDialogResult result = _dialogService.ShowSaveFileDialog("Export Network Graph", this, new FileType("PNG image", ".png")); if (result.IsValid) { IBidirectionalGraph <NetworkGraphVertex, NetworkGraphEdge> graph = _graphService.GenerateNetworkGraph(similarityMetric); var graphLayout = new NetworkGraphLayout { IsAnimationEnabled = false, CreationTransition = null, DestructionTransition = null, LayoutAlgorithmType = "StressMajorization", LayoutParameters = new StressMajorizationLayoutParameters { WeightAdjustment = 1.0 }, OverlapRemovalAlgorithmType = "FSA", OverlapRemovalParameters = new OverlapRemovalParameters { HorizontalGap = 2, VerticalGap = 2 }, Graph = graph, Background = Brushes.White, WeightFilter = scoreFilter }; SaveElement(graphLayout, result.FileName, null); return(true); } return(false); }
Optional <FileDialogResult> OpenFileSync(FileDialogOptions options) { var ofd = new Microsoft.Win32.OpenFileDialog { Title = options.Caption, Filter = options.Filters.CreateFilterString(), CheckPathExists = true, CheckFileExists = true, }; FilterString.Parse(ofd.Filter).Each(f => Console.WriteLine(f)); if (options.Directory != null) { ofd.InitialDirectory = options.Directory.NativePath; } var success = _window == null?ofd.ShowDialog() : ofd.ShowDialog(_window); var filename = ofd.FileName; var result = new FileDialogResult(); if (success.Value) { result.Path = AbsoluteFilePath.Parse(ofd.FileName); result.Filter = FilterAtIndex(ofd.Filter, ofd.FilterIndex); } Focus(); return(success.Value ? Optional.Some(result) : Optional.None <FileDialogResult>()); }
public void ShowSaveFileDialogExtensionTest() { FileType rtfFileType = new FileType("RichText Document", ".rtf"); FileType xpsFileType = new FileType("XPS Document", ".xps"); IEnumerable <FileType> fileTypes = new FileType[] { rtfFileType, xpsFileType }; string defaultFileName = "Document 1.rtf"; FileDialogResult result = new FileDialogResult("Document 2.rtf", rtfFileType); MockFileDialogService service = new MockFileDialogService(); service.Result = result; Assert.AreEqual(result, service.ShowSaveFileDialog(rtfFileType)); Assert.AreEqual(rtfFileType, service.FileTypes.Single()); AssertHelper.ExpectedException <ArgumentNullException>(() => FileDialogServiceExtensions.ShowSaveFileDialog(null, rtfFileType)); AssertHelper.ExpectedException <ArgumentNullException>(() => service.ShowSaveFileDialog((FileType)null)); Assert.AreEqual(result, service.ShowSaveFileDialog(rtfFileType, defaultFileName)); Assert.AreEqual(rtfFileType, service.FileTypes.Single()); Assert.AreEqual(defaultFileName, service.DefaultFileName); AssertHelper.ExpectedException <ArgumentNullException>(() => FileDialogServiceExtensions.ShowSaveFileDialog(null, rtfFileType, defaultFileName)); AssertHelper.ExpectedException <ArgumentNullException>(() => service.ShowSaveFileDialog((FileType)null, defaultFileName)); Assert.AreEqual(result, service.ShowSaveFileDialog(fileTypes)); Assert.IsTrue(service.FileTypes.SequenceEqual(new FileType[] { rtfFileType, xpsFileType })); AssertHelper.ExpectedException <ArgumentNullException>(() => FileDialogServiceExtensions.ShowSaveFileDialog(null, fileTypes)); }
Optional <FileDialogResult> SaveFileSync(FileDialogOptions options) { var ofd = new Microsoft.Win32.SaveFileDialog { Title = options.Caption, Filter = options.Filters.CreateFilterString(), OverwritePrompt = true, }; if (options.Directory != null) { ofd.InitialDirectory = options.Directory.NativePath; } var success = _window == null?ofd.ShowDialog() : ofd.ShowDialog(_window); var filename = ofd.FileName; var result = new FileDialogResult(); if (success.Value) { result.Path = AbsoluteFilePath.Parse(ofd.FileName); result.Filter = FilterAtIndex(ofd.Filter, ofd.FilterIndex); } Focus(); return(success.Value ? Optional.Some(result) : Optional.None <FileDialogResult>()); }
Optional <FileDialogResult> OpenFileSync(FileDialogOptions options) { var dialog = new OpenDialog(options.Filters) { Title = options.Caption, Multiselect = false }; if (options.Directory != null) { dialog.Directory = options.Directory; } var success = dialog.Run(); FileDialogResult result = new FileDialogResult(); if (success) { result = new FileDialogResult(dialog.FilePath, dialog.CurrentFilter); } return(success ? Optional.Some(result) : Optional.None <FileDialogResult>()); }
private void SaveList() { FileDialogResult result = fileDialogService.ShowSaveFileDialog(shellService.ShellView, saveQueuelistFileType); if (!result.IsValid) { return; } List <string> queueList = QueueManager.Items.Select(item => item.Blog.Name).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)) { IFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, queueList); } } catch (Exception ex) { Logger.Error("SaveList SaveAs: {0}", ex); shellService.ShowError(ex, Resources.CouldNotSaveQueueList); } }
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); } }
Optional <FileDialogResult> SaveFileSync(FileDialogOptions options) { var dialog = new SaveDialog(options.Filters) { Title = options.Caption, }; if (options.Directory != null) { dialog.Directory = options.Directory; } var success = dialog.Run(_window); FileDialogResult result = new FileDialogResult(); if (success) { result = new FileDialogResult(dialog.FilePath, dialog.CurrentFilter); } return(success ? Optional.Some(result) : Optional.None <FileDialogResult>()); }
public bool ExportGlobalCorrespondencesChart(object ownerViewModel, SyllablePosition syllablePosition, int frequencyFilter) { FileDialogResult result = _dialogService.ShowSaveFileDialog("Export Global Correspondences Chart", this, new FileType("PNG image", ".png")); if (result.IsValid) { IBidirectionalGraph <GlobalCorrespondencesGraphVertex, GlobalCorrespondencesGraphEdge> graph = _graphService.GenerateGlobalCorrespondencesGraph(syllablePosition); var graphLayout = new GlobalCorrespondencesGraphLayout { IsAnimationEnabled = false, CreationTransition = null, DestructionTransition = null, LayoutAlgorithmType = "Grid", EdgeRoutingAlgorithmType = "Bundle", EdgeRoutingParameters = new BundleEdgeRoutingParameters { InkCoefficient = 0, LengthCoefficient = 1, VertexMargin = 2 }, Graph = graph, Background = Brushes.White, WeightFilter = frequencyFilter, SyllablePosition = syllablePosition }; graphLayout.Resources[typeof(EdgeControl)] = System.Windows.Application.Current.Resources["GlobalCorrespondenceEdgeControlStyle"]; SaveElement(graphLayout, result.FileName, null); return(true); } return(false); }
public bool ExportCurrentHierarchicalGraph(object ownerViewModel, HierarchicalGraphType type) { FileDialogResult result = _dialogService.ShowSaveFileDialog("Export Hierarchical Graph", ownerViewModel, new FileType("PNG image", ".png")); if (result.IsValid) { FrameworkElement graphLayout = null; switch (type) { case HierarchicalGraphType.Tree: graphLayout = System.Windows.Application.Current.MainWindow.FindVisualChild <HierarchicalGraphLayout>(); break; case HierarchicalGraphType.Dendrogram: graphLayout = System.Windows.Application.Current.MainWindow.FindVisualChild <DendrogramLayout>(); break; } if (graphLayout == null) { throw new InvalidOperationException(); } SaveElement(graphLayout, result.FileName, null); return(true); } return(false); }
public void Open() { SelectFolderDialogCreationArgs args = new SelectFolderDialogCreationArgs(); args.AllowCreateNewFolder = false; args.Path = _lastFolder; args.Prompt = SR.MessageSelectFolderToFilter; FileDialogResult result = base.Context.DesktopWindow.ShowSelectFolderDialogBox(args); if (result.Action == DialogBoxAction.Ok) { _lastFolder = result.FileName; StudyFilterComponent component = new StudyFilterComponent(); component.BulkOperationsMode = true; if (component.Load(base.Context.DesktopWindow, true, result.FileName)) { component.Refresh(true); base.Context.DesktopWindow.Workspaces.AddNew(component, SR.StudyFilters); } component.BulkOperationsMode = false; } }
protected override bool ConfirmClose(IDocument document) { GameDocument gameDcument = document as GameDocument; if (gameDcument == null) { return(base.ConfirmClose(document)); } bool closeConfirmed = true; if (gameDcument.AnyDirty) { string message = "One or more level and/or external resource is dirty" + Environment.NewLine + "Save Changes?"; FileDialogResult result = FileDialogService.ConfirmFileClose(message); if (result == FileDialogResult.Yes) { closeConfirmed = Save(document); } else if (result == FileDialogResult.Cancel) { closeConfirmed = false; } } return(closeConfirmed); }
public IEnumerable <IResult> Execute() { FileDialogResult fds = new FileDialogResult("This was executed from a custom IResult, FileDialogResult.", "All files (*.*)|*.*"); yield return(fds); yield return(new MessageDialogResult($"The selected file is {fds.SelectedFile}", "IResult Coroutines")); }
public void CancelResultTest() { var result = FileDialogResult.CancelResult(); Assert.IsFalse(result.IsValid); Assert.IsNull(result.FileName); Assert.IsNull(result.GetFullFileName()); }
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); }
private void OpenList() { FileDialogResult result = fileDialogService.ShowOpenFileDialog(shellService.ShellView, openQueuelistFileType); if (!result.IsValid) { return; } OpenListCore(result.FileName); }
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()); }
private void BrowseExportLocation() { FileDialogResult result = fileDialogService.ShowSaveFileDialog(ShellService.ShellView, bloglistExportFileType, ExportLocation); if (!result.IsValid) { return; } ExportLocation = result.FileName; }
public static bool ConfirmClose(IDocument document, IFileDialogService fileDialogService) { var game = document.As <Game.GameExtensions>(); if (game == null) { return(true); } var terrain = game.Terrain; var sceneManager = game.SceneManager; if (terrain == null || sceneManager == null) { return(true); } var layerIds = terrain.GetAllLayerIds(); bool hasActiveLocks = false; foreach (var l in layerIds) { hasActiveLocks |= sceneManager.HasTerrainLock(l); } if (hasActiveLocks) { string message = "You still have active terrain locks. These are unsaved areas of terrain." + System.Environment.NewLine + "Do you want to save all active terrain locks?"; FileDialogResult result = fileDialogService.ConfirmFileClose(message); if (result == FileDialogResult.Yes) { foreach (var l in layerIds) { try { using (var progress = new ControlsLibrary.ProgressDialog.ProgressInterface()) { sceneManager.SaveTerrainLock(l, progress); } } catch (Exception ex) { ControlsLibrary.BasicControls.ExceptionReport.Show(ex, "Saving terrain lock"); } } } else if (result == FileDialogResult.Cancel) { return(false); } } return(true); }
private bool Initialize() { _synchronizationContext = SynchronizationContext.Current; _exportedInstances = new AuditedInstances(); _canceled = false; _overwrite = false; if (Anonymize) { ExportComponent component = new ExportComponent(); component.OutputPath = OutputPath; if (DialogBoxAction.Ok != DesktopWindow.ShowDialogBox(component, SR.Export)) { return(false); } OutputPath = component.OutputPath; StudyData studyData = new StudyData { PatientId = component.PatientId, PatientsNameRaw = component.PatientsName, PatientsBirthDate = component.PatientsDateOfBirth, StudyId = component.StudyId, StudyDescription = component.StudyDescription, AccessionNumber = component.AccessionNumber, StudyDate = component.StudyDate }; _anonymizer = new DicomAnonymizer(); _anonymizer.KeepPrivateTags = component.KeepPrivateTags; _anonymizer.ValidationOptions = ValidationOptions.RelaxAllChecks; _anonymizer.StudyDataPrototype = studyData; } else { SelectFolderDialogCreationArgs args = new SelectFolderDialogCreationArgs(); args.Prompt = SR.MessageSelectOutputLocation; args.Path = OutputPath; FileDialogResult result = DesktopWindow.ShowSelectFolderDialogBox(args); if (result.Action != DialogBoxAction.Ok) { return(false); } OutputPath = result.FileName; } return(true); }
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); } }
public void ResultTest() { FileDialogResult result = new FileDialogResult(); Assert.IsFalse(result.IsValid); FileType rtfFileType = new FileType("RichText Document", ".rtf"); result = new FileDialogResult(@"C:\Document 1.rtf", rtfFileType); Assert.IsTrue(result.IsValid); Assert.AreEqual(@"C:\Document 1.rtf", result.FileName); Assert.AreEqual(rtfFileType, result.SelectedFileType); }
public void ShouldShowErrorMessageWhenThereIsAnExceptionWhenLoadingProject() { projectRepository.Stub(r => r.LoadProject("")).IgnoreArguments().Throw(new Exception()); var fileDialogResult = new FileDialogResult { Accepted = true }; fileDialogCreator.Stub(c => c.ShowFileOpen("")).IgnoreArguments().Return(fileDialogResult); var presenter = CreatePresenter(); presenter.LoadEditorSettings(); messageCreator.AssertWasCalled(c => c.ShowError(""), o => o.IgnoreArguments()); }
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; }); } } }
public void Execute(object parameter) { SearchPattern[] searchPatterns = new SearchPattern[] { new SearchPattern("Jpegs (*.jpg)", "*.jpg"), new SearchPattern("All files (*.*)", "*.*") }; FileDialogResult result = FileDialog.Show("Open File...", searchPatterns, searchPatterns[0]); if (result.Result == FileDialogResultEnum.OK) { this.viewModel.LoadImage(result.SelectedFile); } }
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 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); }
public void Execute(object parameter) { SearchPattern[] searchPatterns = new SearchPattern[] { new SearchPattern("InkWriter-Dateien (*.iwd)", "*.iwd"), new SearchPattern("Alle Dateien (*.*)", "*.*") }; FileDialogResult result = FileDialog.Show("Open File...", searchPatterns, searchPatterns[0]); if (result.Result == FileDialogResultEnum.OK) { this.mainWindow.SetActiveDocument(InkWriterDocument.Load(result.SelectedFile)); } }