Exemplo n.º 1
0
        public virtual void AskForFileName(ExpressionOpenFileDialog dialog)
        {
            bool?nullable = dialog.ShowDialog();

            if (!nullable.HasValue || !nullable.Value)
            {
                return;
            }
            this.FileName = dialog.FileName;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }