示例#1
0
        protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            var parameters = eventArgs.Parameter as NavigationArguments;

            AppInstance = parameters.AssociatedTabInstance;
            AppInstance.InstanceViewModel.IsPageTypeNotHome       = false;
            AppInstance.InstanceViewModel.IsPageTypeSearchResults = false;
            AppInstance.InstanceViewModel.IsPageTypeMtpDevice     = false;
            AppInstance.InstanceViewModel.IsPageTypeRecycleBin    = false;
            AppInstance.InstanceViewModel.IsPageTypeCloudDrive    = false;
            AppInstance.NavigationToolbar.CanRefresh          = false;
            AppInstance.NavigationToolbar.CanGoBack           = AppInstance.CanNavigateBackward;
            AppInstance.NavigationToolbar.CanGoForward        = AppInstance.CanNavigateForward;
            AppInstance.NavigationToolbar.CanNavigateToParent = false;

            // Set path of working directory empty
            await AppInstance.FilesystemViewModel.SetWorkingDirectoryAsync("Home");

            // Clear the path UI and replace with Favorites
            AppInstance.NavigationToolbar.PathComponents.Clear();
            string      componentLabel = parameters.NavPathParam;
            string      tag            = parameters.NavPathParam;
            PathBoxItem item           = new PathBoxItem()
            {
                Title = componentLabel,
                Path  = tag,
            };

            AppInstance.NavigationToolbar.PathComponents.Add(item);
        }
示例#2
0
        /*
         * Ensure that the path bar gets updated for user interaction
         * whenever the path changes. We will get the individual directories from
         * the updated, most-current path and add them to the UI.
         */

        private void Universal_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            // Clear the path UI
            App.selectedTabInstance.pathBoxItems.Clear();
            // Style tabStyleFixed = App.selectedTabInstance.accessiblePathTabView.Resources["PathSectionTabStyle"] as Style;
            FontWeight weight = new FontWeight()
            {
                Weight = FontWeights.SemiBold.Weight
            };
            List <string> pathComponents = new List <string>();

            if (e.PropertyName == "path")
            {
                // If path is a library, simplify it

                // If path is found to not be a library
                pathComponents = Universal.path.Split("\\", StringSplitOptions.RemoveEmptyEntries).ToList();
                int index = 0;
                foreach (string s in pathComponents)
                {
                    string componentLabel = null;
                    string tag            = "";
                    if (s.Contains(":"))
                    {
                        if (s == @"C:" || s == @"c:")
                        {
                            componentLabel = @"Local Disk (C:\)";
                        }
                        else
                        {
                            componentLabel = @"Drive (" + s + @"\)";
                        }
                        tag = s + @"\";

                        PathBoxItem item = new PathBoxItem()
                        {
                            Title = componentLabel,
                            Path  = tag,
                        };
                        App.selectedTabInstance.pathBoxItems.Add(item);
                    }
                    else
                    {
                        componentLabel = s;
                        foreach (string part in pathComponents.GetRange(0, index + 1))
                        {
                            tag = tag + part + @"\";
                        }

                        PathBoxItem item = new PathBoxItem()
                        {
                            Title = componentLabel,
                            Path  = tag,
                        };
                        App.selectedTabInstance.pathBoxItems.Add(item);
                    }
                    index++;
                }
            }
        }
示例#3
0
        private async Task SetPathBoxDropDownFlyout(MenuFlyout flyout, PathBoxItem pathItem)
        {
            var nextPathItemTitle = App.CurrentInstance.NavigationToolbar.PathComponents
                                    [App.CurrentInstance.NavigationToolbar.PathComponents.IndexOf(pathItem) + 1].Title;
            IList <StorageFolderWithPath> childFolders = new List <StorageFolderWithPath>();

            try
            {
                var folder = await ItemViewModel.GetFolderWithPathFromPathAsync(pathItem.Path);

                childFolders = await folder.GetFoldersWithPathAsync(string.Empty);
            }
            catch
            {
                // Do nothing.
            }
            finally
            {
                flyout.Items?.Clear();
            }

            if (childFolders.Count == 0)
            {
                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon {
                        FontFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily, Glyph = "\uEC17"
                    },
                    Text = ResourceController.GetTranslation("SubDirectoryAccessDenied"),
                    //Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"],
                    FontSize = 12
                };
                flyout.Items.Add(flyoutItem);
                return;
            }

            var boldFontWeight = new FontWeight {
                Weight = 800
            };
            var normalFontWeight = new FontWeight {
                Weight = 400
            };
            var customGlyphFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily;

            var workingPath = App.CurrentInstance.NavigationToolbar.PathComponents
                              [App.CurrentInstance.NavigationToolbar.PathComponents.Count - 1].
                              Path.TrimEnd(Path.DirectorySeparatorChar);

            foreach (var childFolder in childFolders)
            {
                var isPathItemFocused = childFolder.Item.Name == nextPathItemTitle;

                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon
                    {
                        FontFamily = customGlyphFamily,
                        Glyph      = "\uEA5A",
                        FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                    },
                    Text       = childFolder.Item.Name,
                    FontSize   = 12,
                    FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                };

                if (workingPath != childFolder.Path)
                {
                    flyoutItem.Click += (sender, args) => App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), childFolder.Path);
                }

                flyout.Items.Add(flyoutItem);
            }
        }
        public static List <PathBoxItem> GetDirectoryPathComponents(string value)
        {
            List <string>      pathComponents = new List <string>();
            List <PathBoxItem> pathBoxItems   = new List <PathBoxItem>();

            // If path is a library, simplify it
            // If path is found to not be a library
            if (value.StartsWith("\\\\?\\"))
            {
                pathComponents = value.Replace("\\\\?\\", "").Split("\\", StringSplitOptions.RemoveEmptyEntries).ToList();
            }
            else
            {
                pathComponents = value.Split("\\", StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            int index = 0;

            foreach (string s in pathComponents)
            {
                string componentLabel = null;
                string tag            = "";
                if (s.StartsWith(App.AppSettings.RecycleBinPath))
                {
                    // Handle the recycle bin: use the localized folder name
                    PathBoxItem item = new PathBoxItem()
                    {
                        Title = ApplicationData.Current.LocalSettings.Values.Get("RecycleBin_Title", "Recycle Bin"),
                        Path  = tag,
                    };
                    App.CurrentInstance.NavigationToolbar.PathComponents.Add(item);
                }
                else if (s.Contains(":"))
                {
                    if (MainPage.sideBarItems.FirstOrDefault(x => x.ItemType == NavigationControlItemType.Drive && x.Path.Contains(s, StringComparison.OrdinalIgnoreCase)) != null)
                    {
                        componentLabel = MainPage.sideBarItems.FirstOrDefault(x => x.ItemType == NavigationControlItemType.Drive && x.Path.Contains(s, StringComparison.OrdinalIgnoreCase)).Text;
                    }
                    else
                    {
                        componentLabel = @"Drive (" + s + @"\)";
                    }
                    tag = s + @"\";

                    PathBoxItem item = new PathBoxItem()
                    {
                        Title = componentLabel,
                        Path  = tag,
                    };
                    pathBoxItems.Add(item);
                }
                else
                {
                    componentLabel = s;
                    foreach (string part in pathComponents.GetRange(0, index + 1))
                    {
                        tag = tag + part + @"\";
                    }
                    if (value.StartsWith("\\\\?\\"))
                    {
                        tag = "\\\\?\\" + tag;
                    }
                    else if (index == 0)
                    {
                        tag = "\\\\" + tag;
                    }

                    PathBoxItem item = new PathBoxItem()
                    {
                        Title = componentLabel,
                        Path  = tag,
                    };
                    pathBoxItems.Add(item);
                }
                index++;
            }
            return(pathBoxItems);
        }