예제 #1
0
파일: AppCommands.cs 프로젝트: RyanFu/MLib
        /// <summary>
        /// Open a file persistence with dialog and user interaction.
        /// </summary>
        public void OnOpen(string typeOfDocument
                           , string defaultPath
                           , string defaultFallbackPath
                           , IFileManager docManager
                           , IExplorer explorer
                           , IList <IFileItem> pathCollection
                           )
        {
            try
            {
                IFileFilterEntries fileEntries = null;

                // Get filter strings for document specific filters or all filters
                // depending on whether type of document is set to a key or not.
                fileEntries = docManager.GetFileFilterEntries(typeOfDocument);

                var pathColl = explorer.FileOpenMultipleFiles(fileEntries.GetFilterString()
                                                              , defaultPath
                                                              , defaultFallbackPath);

                if (pathColl != null)
                {
                    foreach (string fileName in pathColl)
                    {
                        pathCollection.Add(docManager.GetFileItem(fileName));
                    }
                }
            }
            catch (Exception exp)
            {
                var msg = GetService <IContentDialogService>().MsgBox;

                //logger.Error(exp.Message, exp);
                msg.Show(exp, "Unexpected Error",
                         MsgBoxButtons.OK, MsgBoxImage.Error, MsgBoxResult.NoDefaultButton);
            }
        }