Ejemplo n.º 1
0
 private void RecentLocations_RequestChangeOfDirectory(object sender,
                                                       BrowsingEventArgs e)
 {
     if (e.IsBrowsing == false && e.Result == BrowseResult.Complete)
     {
         // XXX Todo Keep task reference, support cancel, and remove on end?
         var t = TreeBrowser.NavigateToAsync(new BrowseRequest(e.Location));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Master controler interface method to navigate all views
        /// to the folder indicated in <paramref name="folder"/>
        /// - updates all related viewmodels.
        /// </summary>
        /// <param name="request"></param>
        private async Task <FinalBrowseResult> NavigateToFolderAsync(BrowseRequest request,
                                                                     object sender)
        {
            // Make sure the task always processes the last input but is not started twice
            await _SlowStuffSemaphore.WaitAsync();

            try
            {
                var newPath = request.NewLocation;
                var cancel  = request.CancelTok;

                if (cancel != null)
                {
                    cancel.ThrowIfCancellationRequested();
                }

                TreeBrowser.SetExternalBrowsingState(true);
                FolderItemsView.SetExternalBrowsingState(true);
                FolderTextPath.SetExternalBrowsingState(true);

                FinalBrowseResult browseResult = null;

                // Navigate TreeView to this file system location
                if (TreeBrowser != sender)
                {
                    browseResult = await TreeBrowser.NavigateToAsync(request);

                    if (cancel != null)
                    {
                        cancel.ThrowIfCancellationRequested();
                    }

                    if (browseResult.Result != BrowseResult.Complete)
                    {
                        return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
                    }
                }

                // Navigate Folder ComboBox to this folder
                if (FolderTextPath != sender)
                {
                    browseResult = await FolderTextPath.NavigateToAsync(request);

                    if (cancel != null)
                    {
                        cancel.ThrowIfCancellationRequested();
                    }

                    if (browseResult.Result != BrowseResult.Complete)
                    {
                        return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
                    }
                }

                if (cancel != null)
                {
                    cancel.ThrowIfCancellationRequested();
                }

                // Navigate Folder/File ListView to this folder
                if (FolderItemsView != sender)
                {
                    browseResult = await FolderItemsView.NavigateToAsync(request);

                    if (cancel != null)
                    {
                        cancel.ThrowIfCancellationRequested();
                    }

                    if (browseResult.Result != BrowseResult.Complete)
                    {
                        return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
                    }
                }

                if (browseResult != null)
                {
                    if (browseResult.Result == BrowseResult.Complete)
                    {
                        SelectedFolder = newPath.Path;

                        // Log location into history of recent locations
                        NaviHistory.Forward(newPath);
                    }
                }

                return(browseResult);
            }
            catch (Exception exp)
            {
                var result = FinalBrowseResult.FromRequest(request, BrowseResult.InComplete);
                result.UnexpectedError = exp;
                return(result);
            }
            finally
            {
                TreeBrowser.SetExternalBrowsingState(true);
                FolderItemsView.SetExternalBrowsingState(false);
                FolderTextPath.SetExternalBrowsingState(false);

                _SlowStuffSemaphore.Release();
            }
        }