public virtual void AskForFileName(ExpressionOpenFileDialog dialog) { bool?nullable = dialog.ShowDialog(); if (!nullable.HasValue || !nullable.Value) { return; } this.FileName = dialog.FileName; }
protected string SelectProject(string dialogTitle) { string str; string defaultOpenProjectPath = this.ProjectManager().DefaultOpenProjectPath; if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(defaultOpenProjectPath)) { defaultOpenProjectPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(defaultOpenProjectPath)) { defaultOpenProjectPath = Path.GetPathRoot(Environment.CurrentDirectory); } ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog() { Title = dialogTitle, RestoreDirectory = true, InitialDirectory = defaultOpenProjectPath }; IEnumerable <string> projectExtensions = this.ProjectExtensions; expressionOpenFileDialog.Filter = this.GenerateFilterString(projectExtensions); bool?nullable = expressionOpenFileDialog.ShowDialog(); Application.Current.MainWindow.Dispatcher.Invoke(DispatcherPriority.Input, new TimeSpan(0, 0, 3), new DispatcherOperationCallback((object arg) => null), null); if (nullable.HasValue && nullable.Value) { string fileName = expressionOpenFileDialog.FileName; string extension = Path.GetExtension(fileName); if (extension.Length > 0) { using (IEnumerator <string> enumerator = projectExtensions.GetEnumerator()) { while (enumerator.MoveNext()) { if (!enumerator.Current.EndsWith(extension, StringComparison.OrdinalIgnoreCase)) { continue; } str = fileName; return(str); } goto Label0; } return(str); } Label0: CultureInfo currentCulture = CultureInfo.CurrentCulture; string extensionNotOpenableMessage = StringTable.ExtensionNotOpenableMessage; object[] objArray = new object[] { extension }; this.DisplayCommandFailedMessage(string.Format(currentCulture, extensionNotOpenableMessage, objArray)); } return(null); }
private void BrowseForNewImage() { ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog(); expressionOpenFileDialog.Title = StringTable.SampleDataConfigurationImageBrowserDialog; expressionOpenFileDialog.Filter = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}({1})|{1}|{2}|{3}|{4}|{5}|{6}({7})|{7}", (object)StringTable.AllImageFilesDescription, (object)"*.jpg;*.png", (object)StringTable.JpgImageDocumentTypeDescription, (object)"*.jpg", (object)StringTable.PngImageDocumentTypeDescription, (object)"*.png", (object)StringTable.SampleDataAllFilesDescription, (object)"*.*"); bool?nullable = expressionOpenFileDialog.ShowDialog(); if (!nullable.HasValue || !nullable.Value) { return; } this.editingRow.GetCell(this.sampleDataProperty).Value = (object)expressionOpenFileDialog.FileName; }
public static string GetFolderPath(string dialogDescription, string vistaDialogTitle, string initialDirectory) { string selectedPath; if (!ExpressionFileDialog.CanPickFolders) { using (ModalDialogHelper modalDialogHelper = new ModalDialogHelper()) { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog() { Description = dialogDescription, SelectedPath = initialDirectory }; if (folderBrowserDialog.ShowDialog() != DialogResult.OK) { return(null); } else { selectedPath = folderBrowserDialog.SelectedPath; } } return(selectedPath); } else { ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog() { Title = vistaDialogTitle, InitialDirectory = initialDirectory, PickFolders = true }; bool?nullable = expressionOpenFileDialog.ShowDialog(); if (nullable.HasValue && nullable.Value) { return(expressionOpenFileDialog.FileName); } } return(null); }
protected virtual string[] GetFilesToImport(string defaultImportFolder) { ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog() { RestoreDirectory = true, InitialDirectory = defaultImportFolder, Title = this.DisplayName, Multiselect = true }; AddProjectItemCommand.FileTypeDescription[] fileTypeFilter = this.GetFileTypeFilter(); StringBuilder stringBuilder = new StringBuilder(); bool flag = true; AddProjectItemCommand.FileTypeDescription[] fileTypeDescriptionArray = fileTypeFilter; for (int i = 0; i < (int)fileTypeDescriptionArray.Length; i++) { AddProjectItemCommand.FileTypeDescription fileTypeDescription = fileTypeDescriptionArray[i]; if (!flag) { stringBuilder.Append("|"); } else { flag = false; } stringBuilder.Append(fileTypeDescription.Description); stringBuilder.Append("|"); stringBuilder.Append(fileTypeDescription.Extensions); } expressionOpenFileDialog.Filter = stringBuilder.ToString(); bool?nullable = expressionOpenFileDialog.ShowDialog(); if (!nullable.HasValue || !nullable.Value) { return(null); } return(expressionOpenFileDialog.FileNames); }
private void BrowseForFolder() { bool flag = false; string path = this.DirectoryDisplayText; string folderBrowserDialog1 = StringTable.SampleDataConfigurationImageFolderBrowserDialog; if (ExpressionFileDialog.CanPickFolders) { ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog(); expressionOpenFileDialog.Title = folderBrowserDialog1; expressionOpenFileDialog.InitialDirectory = path; expressionOpenFileDialog.PickFolders = true; bool?nullable = expressionOpenFileDialog.ShowDialog(); if (nullable.HasValue && nullable.Value) { flag = true; path = expressionOpenFileDialog.FileName; } } else { using (new ModalDialogHelper()) { FolderBrowserDialog folderBrowserDialog2 = new FolderBrowserDialog(); folderBrowserDialog2.Description = folderBrowserDialog1; folderBrowserDialog2.SelectedPath = path; if (folderBrowserDialog2.ShowDialog() == DialogResult.OK) { flag = true; path = folderBrowserDialog2.SelectedPath; } } } if (!flag) { return; } this.SetNewFolder(path); }
public static string BrowseForXmlFile(string dialogTitle, ref string initialDirectory) { string str = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.XmlFileTypeDescription, new object[1] { (object)"*.xml" }) + "|*.xml" + "|" + (string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.AllFilesTypeDescription, new object[1] { (object)"*.*" }) + "|*.*"); ExpressionOpenFileDialog expressionOpenFileDialog = new ExpressionOpenFileDialog(); expressionOpenFileDialog.Title = dialogTitle; expressionOpenFileDialog.RestoreDirectory = true; expressionOpenFileDialog.InitialDirectory = initialDirectory; expressionOpenFileDialog.Filter = str; bool?nullable = expressionOpenFileDialog.ShowDialog(); if (!nullable.HasValue || !nullable.Value) { return((string)null); } initialDirectory = Path.GetDirectoryName(expressionOpenFileDialog.FileName); return(expressionOpenFileDialog.FileName); }
private IImporter PromptUserForAnImporter(string[] filterImportersID) { ExpressionOpenFileDialog dialog = new ExpressionOpenFileDialog(); dialog.RestoreDirectory = true; dialog.Multiselect = false; IEnumerable <string> registeredImporters = this.importService.RegisteredImporters; StringBuilder stringBuilder1 = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); int num = 0; string str1 = (string)null; foreach (string identifier in registeredImporters) { if (filterImportersID == null || Enumerable.Contains <string>((IEnumerable <string>)filterImportersID, identifier)) { string str2 = (string)this.importService.GetProperty(identifier, "Filter"); if (stringBuilder1.Length != 0) { stringBuilder1.Append("|"); } stringBuilder1.AppendFormat((string)this.importService.GetProperty(identifier, "FileTypeDescription"), (object)(string)this.importService.GetProperty(identifier, "Filter")); stringBuilder1.AppendFormat("|{0}", (object)str2); ++num; if (stringBuilder2.Length != 0) { stringBuilder2.AppendFormat((IFormatProvider)CultureInfo.CurrentCulture, ";{0}", new object[1] { (object)str2 }); } else { stringBuilder2.Append(str2); } str1 = (string)this.importService.GetProperty(identifier, "ImportFileOpenDialogTitle"); } } if (num > 1) { StringBuilder stringBuilder3 = new StringBuilder(); stringBuilder3.Append(StringTable.ImportAllSupportedFiles); stringBuilder3.AppendFormat("|{0}|", (object)stringBuilder2); stringBuilder3.Append((object)stringBuilder1); dialog.Title = StringTable.ImportFileOpenDialogTitle; dialog.Filter = stringBuilder3.ToString(); } else { dialog.Filter = stringBuilder1.ToString(); dialog.Title = str1 ?? StringTable.ImportFileOpenDialogTitle; } if (string.IsNullOrEmpty(this.ImportContext.FileName)) { this.ImportContext.AskForFileName(dialog); } if (string.IsNullOrEmpty(this.ImportContext.FileName)) { return((IImporter)null); } string extension = Path.GetExtension(this.importContext.FileName); if (extension.Length > 0) { foreach (string identifier in registeredImporters) { string str2 = (string)this.importService.GetProperty(identifier, "Filter"); char[] chArray = new char[1] { ';' }; foreach (string str3 in str2.Split(chArray)) { if (str3.EndsWith(extension, StringComparison.OrdinalIgnoreCase)) { return(this.importService[identifier]); } } } } return((IImporter)null); }