Exemplo n.º 1
0
 public void SetSelectedPathOrNavigate(PathNavigationEventArgs e)
 {
     if (ColumnHost.ActiveBlades?.Count > 1)
     {
         foreach (var item in ColumnHost.ActiveBlades)
         {
             if ((item.Content as Frame)?.Content is ColumnShellPage s &&
                 PathNormalization.NormalizePath(s.FilesystemViewModel.WorkingDirectory) ==
                 PathNormalization.NormalizePath(e.ItemPath))
             {
                 DismissOtherBlades(item);
                 return;
             }
         }
     }
     if (PathNormalization.NormalizePath(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory) !=
         PathNormalization.NormalizePath(e.ItemPath))
     {
         ParentShellPageInstance.NavigateToPath(e.ItemPath);
     }
     else
     {
         DismissOtherBlades(ColumnHost.ActiveBlades[0]);
     }
 }
Exemplo n.º 2
0
        protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            // Add item jumping handler
            AppSettings.LayoutModeChangeRequested       += AppSettings_LayoutModeChangeRequested;
            Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
            var parameters = (NavigationArguments)eventArgs.Parameter;

            isSearchResultPage      = parameters.IsSearchResultPage;
            ParentShellPageInstance = parameters.AssociatedTabInstance;
            IsItemSelected          = false;
            ParentShellPageInstance.FilesystemViewModel.IsFolderEmptyTextDisplayed = false;

            if (!isSearchResultPage)
            {
                ParentShellPageInstance.NavigationToolbar.CanRefresh        = true;
                ParentShellPageInstance.NavigationToolbar.CanCopyPathInPage = true;
                string previousDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory;
                await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(parameters.NavPathParam);

                // pathRoot will be empty on recycle bin path
                var    workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory;
                string pathRoot   = Path.GetPathRoot(workingDir);
                if (string.IsNullOrEmpty(pathRoot) || workingDir == pathRoot)
                {
                    ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = false;
                }
                else
                {
                    ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = true;
                }
                ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = workingDir.StartsWith(App.AppSettings.RecycleBinPath);
                ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice  = workingDir.StartsWith("\\\\?\\");

                MainPage.MultitaskingControl?.UpdateSelectedTab(new DirectoryInfo(workingDir).Name, workingDir, false);
                ParentShellPageInstance.FilesystemViewModel.RefreshItems(previousDir);
                ParentShellPageInstance.NavigationToolbar.PathControlDisplayText  = parameters.NavPathParam;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = false;
            }
            else
            {
                ParentShellPageInstance.NavigationToolbar.CanRefresh              = false;
                ParentShellPageInstance.NavigationToolbar.CanCopyPathInPage       = false;
                ParentShellPageInstance.NavigationToolbar.CanNavigateToParent     = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin    = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice     = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = true;

                MainPage.MultitaskingControl?.UpdateSelectedTab(null, null, true);
                ParentShellPageInstance.FilesystemViewModel.AddSearchResultsToCollection(parameters.SearchResults, parameters.SearchPathParam);
            }

            ParentShellPageInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page
            ParentShellPageInstance.Clipboard_ContentChanged(null, null);

            cachedNewContextMenuEntries = await RegistryHelper.GetNewContextMenuEntries();

            FocusFileList(); // Set focus on layout specific file list control
        }
Exemplo n.º 3
0
        private void AppSettings_GridViewSizeChangeRequested(object sender, EventArgs e)
        {
            var requestedIconSize = GetIconSize(); // Get new icon size

            // Prevents reloading icons when the icon size hasn't changed
            if (requestedIconSize != currentIconSize)
            {
                currentIconSize = requestedIconSize;     // Update icon size before refreshing
                ParentShellPageInstance.Refresh_Click(); // Refresh icons
            }
        }
Exemplo n.º 4
0
        private void AppSettings_GridViewSizeChangeRequested(object sender, EventArgs e)
        {
            var iconSize = UpdateThumbnailSize(); // Get new icon size

            // Prevents reloading icons when the icon size hasn't changed
            if (iconSize != _iconSize)
            {
                _iconSize = iconSize;                    // Update icon size before refreshing
                ParentShellPageInstance.Refresh_Click(); // Refresh icons
            }
            else
            {
                _iconSize = iconSize; // Update icon size
            }
        }
Exemplo n.º 5
0
        protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            // Add item jumping handler
            AppSettings.LayoutModeChangeRequested       += AppSettings_LayoutModeChangeRequested;
            Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
            var parameters = (NavigationArguments)eventArgs.Parameter;

            ParentShellPageInstance = parameters.AssociatedTabInstance;
            ParentShellPageInstance.NavigationToolbar.CanRefresh = true;
            IsItemSelected = false;
            ParentShellPageInstance.FilesystemViewModel.IsFolderEmptyTextDisplayed = false;
            await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectory(parameters.NavPathParam);

            // pathRoot will be empty on recycle bin path
            var    workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory;
            string pathRoot   = Path.GetPathRoot(workingDir);

            if (string.IsNullOrEmpty(pathRoot) || workingDir == pathRoot)
            {
                ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = false;
            }
            else
            {
                ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = true;
            }

            ParentShellPageInstance.InstanceViewModel.IsPageTypeNotHome    = true; // show controls that were hidden on the home page
            ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = workingDir.StartsWith(App.AppSettings.RecycleBinPath);
            ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice  = workingDir.StartsWith("\\\\?\\");

            MainPage.MultitaskingControl?.UpdateSelectedTab(new DirectoryInfo(workingDir).Name, workingDir);
            ParentShellPageInstance.FilesystemViewModel.RefreshItems();

            ParentShellPageInstance.Clipboard_ContentChanged(null, null);
            ParentShellPageInstance.NavigationToolbar.PathControlDisplayText = parameters.NavPathParam;
        }
Exemplo n.º 6
0
        private void FolderSettings_LayoutModeChangeRequested(object sender, LayoutModeEventArgs e)
        {
            if (ParentShellPageInstance.ContentPage != null)
            {
                var layoutType = FolderSettings.GetLayoutType(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory);

                if (layoutType != ParentShellPageInstance.CurrentPageType)
                {
                    FolderSettings.IsLayoutModeChanging = true;
                    ParentShellPageInstance.NavigateWithArguments(layoutType, new NavigationArguments()
                    {
                        NavPathParam          = navigationArguments.NavPathParam,
                        IsSearchResultPage    = navigationArguments.IsSearchResultPage,
                        SearchPathParam       = navigationArguments.SearchPathParam,
                        SearchResults         = navigationArguments.SearchResults,
                        IsLayoutSwitch        = true,
                        AssociatedTabInstance = ParentShellPageInstance
                    });

                    // Remove old layout from back stack
                    ParentShellPageInstance.RemoveLastPageFromBackStack();
                }
            }
        }
Exemplo n.º 7
0
        public void SetSelectedPathOrNavigate(string navigationPath, Type sourcePageType, NavigationArguments navArgs = null)
        {
            var destPath        = navArgs != null ? (navArgs.IsSearchResultPage ? navArgs.SearchPathParam : navArgs.NavPathParam) : navigationPath;
            var columnPath      = ((ColumnHost.ActiveBlades.Last().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;
            var columnFirstPath = ((ColumnHost.ActiveBlades.First().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;

            if (string.IsNullOrEmpty(destPath) || string.IsNullOrEmpty(destPath) || string.IsNullOrEmpty(destPath))
            {
                ParentShellPageInstance.NavigateToPath(navigationPath, sourcePageType, navArgs);
                return;
            }

            var destComponents        = StorageFileExtensions.GetDirectoryPathComponents(destPath);
            var columnComponents      = StorageFileExtensions.GetDirectoryPathComponents(columnPath);
            var columnFirstComponents = StorageFileExtensions.GetDirectoryPathComponents(columnFirstPath);

            var lastCommonItemIndex = columnComponents
                                      .Select((value, index) => new { value, index })
                                      .LastOrDefault(x => x.index < destComponents.Count && x.value.Path == destComponents[x.index].Path)?.index ?? -1;

            var relativeIndex = lastCommonItemIndex - (columnFirstComponents.Count - 1);

            if (relativeIndex < 0 || destComponents.Count - (lastCommonItemIndex + 1) > 1) // Going above parent or too deep down
            {
                ParentShellPageInstance.NavigateToPath(navigationPath, sourcePageType, navArgs);
            }
            else
            {
                DismissOtherBlades(relativeIndex);

                for (int ii = lastCommonItemIndex + 1; ii < destComponents.Count; ii++)
                {
                    var frame = new Frame();
                    frame.Navigated += Frame_Navigated;
                    var newblade = new BladeItem();
                    newblade.Content = frame;
                    ColumnHost.Items.Add(newblade);

                    if (navArgs != null)
                    {
                        frame.Navigate(typeof(ColumnShellPage), new ColumnParam
                        {
                            Column               = ColumnHost.ActiveBlades.IndexOf(newblade),
                            IsSearchResultPage   = navArgs.IsSearchResultPage,
                            SearchQuery          = navArgs.SearchQuery,
                            NavPathParam         = destComponents[ii].Path,
                            SearchUnindexedItems = navArgs.SearchUnindexedItems,
                            SearchPathParam      = navArgs.SearchPathParam
                        });
                    }
                    else
                    {
                        frame.Navigate(typeof(ColumnShellPage), new ColumnParam
                        {
                            Column       = ColumnHost.ActiveBlades.IndexOf(newblade),
                            NavPathParam = destComponents[ii].Path
                        });
                    }
                }
            }
        }
Exemplo n.º 8
0
        protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            // Add item jumping handler
            Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
            navigationArguments     = (NavigationArguments)eventArgs.Parameter;
            ParentShellPageInstance = navigationArguments.AssociatedTabInstance;
            IsItemSelected          = false;
            FolderSettings.LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested;
            ParentShellPageInstance.FilesystemViewModel.IsFolderEmptyTextDisplayed = false;
            FolderSettings.SetLayoutInformation();

            if (!navigationArguments.IsSearchResultPage)
            {
                ParentShellPageInstance.NavigationToolbar.CanRefresh = true;
                string previousDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory;
                await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(navigationArguments.NavPathParam);

                // pathRoot will be empty on recycle bin path
                var    workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory;
                string pathRoot   = GetPathRoot(workingDir);
                if (string.IsNullOrEmpty(pathRoot) || NormalizePath(workingDir) == NormalizePath(pathRoot) ||
                    workingDir.StartsWith(AppSettings.RecycleBinPath))    // Can't go up from recycle bin
                {
                    ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = false;
                }
                else
                {
                    ParentShellPageInstance.NavigationToolbar.CanNavigateToParent = true;
                }

                ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin    = workingDir.StartsWith(App.AppSettings.RecycleBinPath);
                ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice     = workingDir.StartsWith("\\\\?\\");
                ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = false;
                ParentShellPageInstance.NavigationToolbar.PathControlDisplayText  = navigationArguments.NavPathParam;
                if (!navigationArguments.IsLayoutSwitch)
                {
                    ParentShellPageInstance.FilesystemViewModel.RefreshItems(previousDir);
                }
                else
                {
                    ParentShellPageInstance.NavigationToolbar.CanGoForward = false;
                }
            }
            else
            {
                ParentShellPageInstance.NavigationToolbar.CanRefresh              = false;
                ParentShellPageInstance.NavigationToolbar.CanGoForward            = false;
                ParentShellPageInstance.NavigationToolbar.CanGoBack               = true; // Impose no artificial restrictions on back navigation. Even in a search results page.
                ParentShellPageInstance.NavigationToolbar.CanNavigateToParent     = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin    = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice     = false;
                ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = true;
                if (!navigationArguments.IsLayoutSwitch)
                {
                    await ParentShellPageInstance.FilesystemViewModel.AddSearchResultsToCollection(navigationArguments.SearchResults, navigationArguments.SearchPathParam);

                    ParentShellPageInstance.UpdatePathUIToWorkingDirectory(null, $"{"SearchPagePathBoxOverrideText".GetLocalized()} {navigationArguments.SearchPathParam}");
                }
            }

            ParentShellPageInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page

            FolderSettings.IsLayoutModeChanging = false;

            cachedNewContextMenuEntries = await RegistryHelper.GetNewContextMenuEntries();

            FocusFileList(); // Set focus on layout specific file list control

            try
            {
                if (navigationArguments.SelectItems != null && navigationArguments.SelectItems.Count() > 0)
                {
                    List <ListedItem> liItemsToSelect = new List <ListedItem>();
                    foreach (string item in navigationArguments.SelectItems)
                    {
                        liItemsToSelect.Add(ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.Where((li) => li.ItemName == item).First());
                    }

                    SetSelectedItemsOnUi(liItemsToSelect);
                }
            }
            catch (Exception e)
            {
            }
        }