Пример #1
0
 /// <summary>
 /// Create a dropdown viewmodel object that can be used to manage a dropdown view
 /// that contains a browser naviagtion (directory picker) control.
 /// </summary>
 /// <param name="treeBrowser"></param>
 /// <param name="recentLocations"></param>
 /// <param name="resultCallback"></param>
 /// <returns></returns>
 public static IDropDownViewModel CreateDropDownViewModel(
     IBrowserViewModel treeBrowser,
     IBookmarksViewModel recentLocations,
     DropDownClosedResult resultCallback)
 {
     return(new DropDownViewModel(treeBrowser, recentLocations, resultCallback));
 }
Пример #2
0
 /// <summary>
 /// Class constructor
 /// </summary>
 public DropDownViewModel(
     IBrowserViewModel treeBrowser,
     IBookmarksViewModel recentLocations,
     DropDownClosedResult resultCallback)
     : base(treeBrowser, recentLocations)
 {
     ResultCallback = resultCallback;
 }
Пример #3
0
        /// <summary>
        /// Method is invoked to copy the given bookmarks into the local
        /// bookmark locations object (typically called up close of browser dialog).
        /// </summary>
        /// <param name="bookmarkedLocations"></param>
        private void CloneBookMarks(IBookmarksViewModel bookmarkedLocations)
        {
            if (bookmarkedLocations == null)
            {
                return;
            }

            this.BookmarkedLocations = bookmarkedLocations.CloneBookmark();
        }
Пример #4
0
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="initialPath"></param>
        /// <param name="bookmarks"></param>
        /// <param name="specialFolderVisibility"></param>
        public FolderBrowserControler(string initialPath
                                      , IBookmarksViewModel bookmarks
                                      , bool specialFolderVisibility = true)
            : this()
        {
            _SpecialFolderVisibility = specialFolderVisibility;
            _InitialPath             = initialPath;

            BookmarkedLocations = bookmarks;
        }
Пример #5
0
        /// <summary>
        /// Constructs a few initial entries for
        /// the recent folder collection that implements folder bookmarks.
        /// </summary>
        /// <returns></returns>
        private IBookmarksViewModel ConstructBookmarks()
        {
            IBookmarksViewModel ret = FileSystemModels.Factory.CreateBookmarksViewModel();

            ret.AddFolder(@"C:\Windows");
            ret.AddFolder(@"C:\Users");
            ret.AddFolder(@"C:\Program Files");

            ret.SelectedItem = ret.DropDownItems.First();

            return(ret);
        }
Пример #6
0
        /// <summary>
        /// Copies all of the given bookmars into the destionations bookmarks collection.
        /// </summary>
        /// <param name="srcRecentFolders"></param>
        /// <param name="dstRecentFolders"></param>
        public void CloneBookmarks(IBookmarksViewModel srcRecentFolders,
                                   IBookmarksViewModel dstRecentFolders)
        {
            if (srcRecentFolders == null || dstRecentFolders == null)
                return;

            dstRecentFolders.ClearFolderCollection();

            // Set collection of recent folder locations
            foreach (var item in srcRecentFolders.DropDownItems)
                dstRecentFolders.AddFolder(item.ItemPath);
        }
Пример #7
0
        /// <summary>
        /// Method is invoked to copy the given bookmarks into the local
        /// bookmark locations object (typically called up close of browser dialog).
        /// </summary>
        /// <param name="bookmarkedLocations"></param>
        private void CloneBookMarks(IBookmarksViewModel bookmarkedLocations)
        {
            if (bookmarkedLocations == null)
            {
                return;
            }

            BookmarkedLocations.BrowseEvent -= BookmarkedLocations_RequestChangeOfDirectory;

            this.BookmarkedLocations = bookmarkedLocations.CloneBookmark();

            BookmarkedLocations.BrowseEvent += BookmarkedLocations_RequestChangeOfDirectory;
        }
Пример #8
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public DialogBaseViewModel(IBrowserViewModel treeBrowser       = null,
                                   IBookmarksViewModel recentLocations = null)
        {
            if (treeBrowser == null)
            {
                TreeBrowser = new BrowserViewModel();
            }
            else
            {
                TreeBrowser = treeBrowser;
            }

            ResetBookmarks(recentLocations);
        }
Пример #9
0
        /// <summary>
        /// Method is invoked when drop element is closed.
        /// </summary>
        /// <param name="bookmarks"></param>
        /// <param name="selectedPath"></param>
        /// <param name="result"></param>
        private void DropDownClosedResult(IBookmarksViewModel bookmarks,
                                          string selectedPath,
                                          FolderBrowser.Dialogs.Interfaces.Result result)
        {
            if (result == FolderBrowser.Dialogs.Interfaces.Result.OK)
            {
                CloneBookMarks(bookmarks);

                if (string.IsNullOrEmpty(selectedPath) == false)
                {
                    this.Path = selectedPath;
                }
                else
                {
                    this.Path = PathFactory.SysDefault.Path;
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Shows a sample progress dialog that was invoked via a bound viewmodel.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="progressIsFinite"></param>
        internal async Task <string> ShowContentDialogFromVM(
            object context
            , bool progressIsFinite
            )
        {
            // See Loaded event in FolderBrowserTreeView_Loaded method to understand initial load
            var treeBrowserVM = FolderBrowserFactory.CreateBrowserViewModel(_SpecialFolderVisibility
                                                                            , _InitialPath);

            // Switch updates to view of by default to speed up load of view
            // Loading the view will kick-off the browsing via View.Loaded Event
            // and that in turn will switch on view updates ...
            treeBrowserVM.UpdateView = false;

            var fsDlg = FolderBrowserFactory.CreateDialogViewModel(treeBrowserVM, BookmarkedLocations);

            var customDialog = CreateFolderBrowserDialog(new FolderBrowserContentDialogViewModel(fsDlg));

            var coord   = GetService <IContentDialogService>().Coordinator;
            var manager = GetService <IContentDialogService>().Manager;

            string returnPath = null;

            // Show a progress dialog to initialize the viewmodel - in case file system is slow...
            await coord.ShowMetroDialogAsync(context, customDialog).ContinueWith
            (
                (t) =>
            {
                if (t.Result == DialogIntResults.OK)
                {
                    returnPath = treeBrowserVM.SelectedFolder;
                }
            }
            );

            if (fsDlg.BookmarkedLocations != null)
            {
                this.BookmarkedLocations = fsDlg.BookmarkedLocations.CloneBookmark();
            }

            return(returnPath);
        }
Пример #11
0
        /// <summary>
        /// (Re-)Connects the Bookmark ViewModel with the
        /// <seealso cref="IBrowserViewModel"/>.BrowsePath(string, bool) method via private method.
        /// to enable user's path selection being input to folder browser.
        /// </summary>
        /// <param name="recentLocations"></param>
        protected void ResetBookmarks(IBookmarksViewModel recentLocations)
        {
            if (BookmarkedLocations != null)
            {
                //BookmarkedLocations.BrowseEvent -= RecentLocations_RequestChangeOfDirectory;
                WeakEventManager <ICanNavigate, BrowsingEventArgs>
                .RemoveHandler(BookmarkedLocations, "BrowseEvent", RecentLocations_RequestChangeOfDirectory);

                if (TreeBrowser != null)
                {
                    //TreeBrowser.BookmarkFolder.RequestEditBookmarkedFolders -= BookmarkFolder_RequestEditBookmarkedFolders;
                    WeakEventManager <IEditBookmarks, EditBookmarkEvent>
                    .RemoveHandler(TreeBrowser.BookmarkFolder, "RequestEditBookmarkedFolders", BookmarkFolder_RequestEditBookmarkedFolders);
                }
            }

            if (recentLocations != null)
            {
                // The recentlocations drop down is optionanl
                // Its component and add/remove context menu accessibility in the treeview
                // is only shown if caller supplied this object
                BookmarkedLocations = recentLocations.CloneBookmark();
            }
            else
            {
                BookmarkedLocations = FileSystemModels.Factory.CreateBookmarksViewModel();
            }

            if (BookmarkedLocations != null)
            {
                //BookmarkedLocations.BrowseEvent += RecentLocations_RequestChangeOfDirectory;
                WeakEventManager <ICanNavigate, BrowsingEventArgs>
                .AddHandler(BookmarkedLocations, "BrowseEvent", RecentLocations_RequestChangeOfDirectory);
            }

            //TreeBrowser.BookmarkFolder.RequestEditBookmarkedFolders += BookmarkFolder_RequestEditBookmarkedFolders;
            WeakEventManager <IEditBookmarks, EditBookmarkEvent>
            .AddHandler(TreeBrowser.BookmarkFolder, "RequestEditBookmarkedFolders", BookmarkFolder_RequestEditBookmarkedFolders);
        }
Пример #12
0
 /// <summary>
 /// Default Class Constructor
 /// </summary>
 protected FolderBrowserControler()
 {
     _SpecialFolderVisibility = true;
     _InitialPath             = string.Empty;
     _BookmarkedLocations     = null;
 }
Пример #13
0
 /// <summary>
 /// Create a dialog viewmodel object that can be used to manage a dialog
 /// that contains a browser naviagtion (directory picker) control.
 /// </summary>
 /// <param name="treeBrowser"></param>
 /// <param name="recentLocations"></param>
 /// <returns></returns>
 public static IDialogViewModel CreateDialogViewModel(
     IBrowserViewModel treeBrowser       = null,
     IBookmarksViewModel recentLocations = null)
 {
     return(new DialogViewModel(treeBrowser, recentLocations));
 }
Пример #14
0
 /// <summary>
 /// Class constructor
 /// </summary>
 public DialogViewModel(IBrowserViewModel treeBrowser       = null,
                        IBookmarksViewModel recentLocations = null)
     : base(treeBrowser, recentLocations)
 {
 }