Esempio n. 1
0
        /// <summary>
        /// A control has send an event that it has (been) browsing to a new location.
        /// Lets sync this with all other controls.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Control_BrowseEvent(object sender,
                                         FileSystemModels.Browse.BrowsingEventArgs e)
        {
            if (e.IsBrowsing == false && e.Result == BrowseResult.Complete)
            {
                var request = new BrowseRequest(e.Location);
                FinalBrowseResult browseResult = null;

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

                    if (browseResult.Result != BrowseResult.Complete)
                    {
                        return;
                    }
                }

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

                    if (browseResult.Result != BrowseResult.Complete)
                    {
                        return;
                    }
                }

                if (browseResult != null) // There should be at least one succesfull browse
                {                         // to change selection and log history
                    if (browseResult.Result == BrowseResult.Complete)
                    {
                        // Log location into history of recent locations
                        SelectedFolder = request.NewLocation.Path;
                        NaviHistory.Forward(request.NewLocation);
                    }
                }
            }
            else
            {
                if (e.IsBrowsing == true)
                {
                    if (FolderTextPath != sender)
                    {
                        // Navigate Folder ComboBox to this folder
                        FolderTextPath.SetExternalBrowsingState(true);
                    }

                    if (FolderItemsView != sender)
                    {
                        // Navigate Folder/File ListView to this folder
                        FolderItemsView.SetExternalBrowsingState(true);
                    }
                }
            }
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
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)
            {
                // XXX Todo Keep task reference, support cancel, and remove on end?
                try
                {
                    var timeout    = TimeSpan.FromSeconds(5);
                    var actualTask = new Task(() =>
                    {
                        var request = new BrowseRequest(location, _CancelTokenSourc.Token);

                        var t = Task.Factory.StartNew(() => NavigateToFolderAsync(request, sender),
                                                      request.CancelTok,
                                                      TaskCreationOptions.LongRunning,
                                                      _OneTaskScheduler);

                        if (t.Wait(timeout) == true)
                        {
                            return;
                        }

                        _CancelTokenSourc.Cancel();     // Task timed out so lets abort it
                        return;                         // Signal timeout here...
                    });

                    actualTask.Start();
                    actualTask.Wait();
                }
                catch (System.AggregateException ex)
                {
                    Logger.Error(ex);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
            else
            {
                if (e.IsBrowsing == true)
                {
                    // The sender has messaged: "I am changing 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);
                    }
                }
            }
        }