예제 #1
0
        /// <summary>
        /// One of the controls has changed its location in the filesystem.
        /// This method is invoked to synchronize this change with all other controls.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FolderTextPath_BrowseEvent(object sender,
                                                FileSystemModels.Browse.BrowsingEventArgs e)
        {
            var location = e.Location;

            SelectedFolder = location.Path;

            if (e.IsBrowsing == false && e.Result == BrowseResult.Complete)
            {
                NavigateToFolder(location);
            }
            else
            {
                if (e.IsBrowsing == true)
                {
                    // The sender has messaged: "I am chnaging location..."
                    // So, we set this property to tell the others:
                    // 1) Don't change your location now (eg.: Disable UI)
                    // 2) We'll be back to tell you the location when we know it
                    if (TreeBrowser != sender)
                    {
                        TreeBrowser.SetExternalBrowsingState(true);
                    }

                    if (FolderTextPath != sender)
                    {
                        FolderTextPath.SetExternalBrowsingState(true);
                    }

                    if (FolderItemsView != sender)
                    {
                        FolderItemsView.SetExternalBrowsingState(true);
                    }
                }
            }
        }
예제 #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();
            }
        }