Ejemplo n.º 1
0
        public PhotoAlbum()
        {
            this.InitializeComponent();
            EmptyTextPA = EmptyText;
            PAPageName  = PhotoAlbumViewer;
            gv          = FileList;
            progressBar = ProgBar;
            gridContext = GridRightClickContextMenu;
            Clipboard.ContentChanged += Clipboard_ContentChanged;
            Frame            rootFrame        = Window.Current.Content as Frame;
            InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;

            instanceTabsView.TabStrip_SelectionChanged(null, null);
            tabInstance = App.selectedTabInstance;
            if (tabInstance.instanceViewModel == null && tabInstance.instanceInteraction == null)
            {
                tabInstance.instanceViewModel   = new ItemViewModel();
                tabInstance.instanceInteraction = new Interaction();
            }
            viewModelInstance          = tabInstance.instanceViewModel;
            FileList.DoubleTapped     += tabInstance.instanceInteraction.List_ItemClick;
            SidebarPinItem.Click      += tabInstance.instanceInteraction.PinItem_Click;
            OpenTerminal.Click        += tabInstance.instanceInteraction.OpenDirectoryInTerminal;
            OpenInNewWindowItem.Click += tabInstance.instanceInteraction.OpenInNewWindowItem_Click;
            OpenInNewTab.Click        += tabInstance.instanceInteraction.OpenDirectoryInNewTab_Click;
            NewFolder.Click           += tabInstance.instanceInteraction.NewFolder_Click;
            NewBitmapImage.Click      += tabInstance.instanceInteraction.NewBitmapImage_Click;
            NewTextDocument.Click     += tabInstance.instanceInteraction.NewTextDocument_Click;
            UnzipItem.Click           += tabInstance.instanceInteraction.ExtractItems_Click;
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            // Add item jumping handler
            App.AppSettings.LayoutModeChangeRequested   += AppSettings_LayoutModeChangeRequested;
            Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
            var parameters = (string)eventArgs.Parameter;

            if (App.AppSettings.FormFactor == Enums.FormFactorMode.Regular)
            {
                Frame            rootFrame        = Window.Current.Content as Frame;
                InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;
                instanceTabsView.TabStrip_SelectionChanged(null, null);
            }
            App.CurrentInstance.NavigationToolbar.CanRefresh = true;
            IsItemSelected = false;
            AssociatedViewModel.EmptyTextState.isVisible             = Visibility.Collapsed;
            App.CurrentInstance.ViewModel.Universal.WorkingDirectory = parameters;

            if (App.CurrentInstance.ViewModel.Universal.WorkingDirectory == Path.GetPathRoot(App.CurrentInstance.ViewModel.Universal.WorkingDirectory))
            {
                App.CurrentInstance.NavigationToolbar.CanNavigateToParent = false;
            }
            else
            {
                App.CurrentInstance.NavigationToolbar.CanNavigateToParent = true;
            }

            App.CurrentInstance.ViewModel.AddItemsToCollectionAsync(App.CurrentInstance.ViewModel.Universal.WorkingDirectory);
            App.Clipboard_ContentChanged(null, null);

            App.CurrentInstance.NavigationToolbar.PathControlDisplayText = parameters;
        }
Ejemplo n.º 3
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (AssociatedViewModel == null && AssociatedInteractions == null)
     {
         AssociatedViewModel    = App.CurrentInstance.ViewModel;
         AssociatedInteractions = App.CurrentInstance.InteractionOperations;
         if (App.CurrentInstance == null)
         {
             App.CurrentInstance = InstanceTabsView.GetCurrentSelectedTabInstance <ModernShellPage>();
         }
     }
 }
Ejemplo n.º 4
0
 private async void TabStrip_TabCloseRequested(Microsoft.UI.Xaml.Controls.TabView sender, Microsoft.UI.Xaml.Controls.TabViewTabCloseRequestedEventArgs args)
 {
     if (TabStrip.TabItems.Count == 1)
     {
         await InstanceTabsView.StartTerminateAsync();
     }
     else if (TabStrip.TabItems.Count > 1)
     {
         int tabIndexToClose = TabStrip.TabItems.IndexOf(args.Tab);
         TabStrip.TabItems.RemoveAt(tabIndexToClose);
     }
 }
Ejemplo n.º 5
0
        private async void CloseSelectedTabKeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
        {
            var InvokedTabView = (args.Element as TabView);

            // Only close the selected tab if it is closeable
            if (((TabViewItem)InvokedTabView.SelectedItem).IsClosable)
            {
                if (TabStrip.TabItems.Count == 1)
                {
                    await InstanceTabsView.StartTerminateAsync();
                }
                else
                {
                    InvokedTabView.TabItems.Remove(InvokedTabView.SelectedItem);
                }
            }
            args.Handled = true;
        }
Ejemplo n.º 6
0
        public GenericFileBrowser()
        {
            this.InitializeComponent();
            GFBPageName            = GenericItemView;
            emptyTextGFB           = EmptyText;
            progressBar            = progBar;
            progressBar.Visibility = Visibility.Collapsed;
            data                      = AllView;
            context                   = RightClickContextMenu;
            HeaderContextMenu         = HeaderRightClickMenu;
            grid                      = RootGrid;
            Clipboard.ContentChanged += Clipboard_ContentChanged;
            RefreshEmptySpace.Click  += NavigationActions.Refresh_Click;
            Frame            rootFrame        = Window.Current.Content as Frame;
            InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;

            instanceTabsView.TabStrip_SelectionChanged(null, null);
            tabInstance = App.selectedTabInstance;
            if (tabInstance.instanceViewModel == null && tabInstance.instanceInteraction == null)
            {
                tabInstance.instanceViewModel   = new ItemViewModel();
                tabInstance.instanceInteraction = new Interaction();
            }
            viewModelInstance          = tabInstance.instanceViewModel;
            PasteEmptySpace.Click     += tabInstance.instanceInteraction.PasteItem_ClickAsync;
            OpenItem.Click            += tabInstance.instanceInteraction.OpenItem_Click;
            ShareItem.Click           += tabInstance.instanceInteraction.ShareItem_Click;
            DeleteItem.Click          += tabInstance.instanceInteraction.DeleteItem_Click;
            RenameItem.Click          += tabInstance.instanceInteraction.RenameItem_Click;
            CutItem.Click             += tabInstance.instanceInteraction.CutItem_Click;
            CopyItem.Click            += tabInstance.instanceInteraction.CopyItem_ClickAsync;
            SidebarPinItem.Click      += tabInstance.instanceInteraction.PinItem_Click;
            OpenInNewTab.Click        += tabInstance.instanceInteraction.OpenDirectoryInNewTab_Click;
            AllView.RightTapped       += tabInstance.instanceInteraction.AllView_RightTapped;
            AllView.DoubleTapped      += tabInstance.instanceInteraction.List_ItemClick;
            OpenTerminal.Click        += tabInstance.instanceInteraction.OpenDirectoryInTerminal;
            NewFolder.Click           += tabInstance.instanceInteraction.NewFolder_Click;
            NewBitmapImage.Click      += tabInstance.instanceInteraction.NewBitmapImage_Click;
            NewTextDocument.Click     += tabInstance.instanceInteraction.NewTextDocument_Click;
            PropertiesItem.Click      += tabInstance.ShowPropertiesButton_Click;
            OpenInNewWindowItem.Click += tabInstance.instanceInteraction.OpenInNewWindowItem_Click;
        }
Ejemplo n.º 7
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 = (string)eventArgs.Parameter;

            if (AppSettings.FormFactor == Enums.FormFactorMode.Regular)
            {
                Frame            rootFrame        = Window.Current.Content as Frame;
                InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;
                instanceTabsView.TabStrip_SelectionChanged(null, null);
            }
            App.CurrentInstance.NavigationToolbar.CanRefresh = true;
            IsItemSelected = false;
            AssociatedViewModel.IsFolderEmptyTextDisplayed = false;
            await App.CurrentInstance.FilesystemViewModel.SetWorkingDirectory(parameters);

            // pathRoot will be empty on recycle bin path
            string pathRoot = Path.GetPathRoot(App.CurrentInstance.FilesystemViewModel.WorkingDirectory);

            if (string.IsNullOrEmpty(pathRoot) || App.CurrentInstance.FilesystemViewModel.WorkingDirectory == pathRoot)
            {
                App.CurrentInstance.NavigationToolbar.CanNavigateToParent = false;
            }
            else
            {
                App.CurrentInstance.NavigationToolbar.CanNavigateToParent = true;
            }
            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome    = true; // show controls that were hidden on the home page
            App.CurrentInstance.InstanceViewModel.IsPageTypeRecycleBin =
                App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath);
            App.CurrentInstance.InstanceViewModel.IsPageTypeMtpDevice =
                App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith("\\\\?\\");

            App.CurrentInstance.FilesystemViewModel.RefreshItems();

            App.Clipboard_ContentChanged(null, null);
            App.CurrentInstance.NavigationToolbar.PathControlDisplayText = parameters;
        }
Ejemplo n.º 8
0
        protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            base.OnNavigatedTo(eventArgs);
            // Add item jumping handler
            Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
            var parameters = (string)eventArgs.Parameter;

            if (App.FormFactor == Enums.FormFactorMode.Regular)
            {
                Frame            rootFrame        = Window.Current.Content as Frame;
                InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;
                instanceTabsView.TabStrip_SelectionChanged(null, null);
            }
            App.OccupiedInstance.RibbonArea.Refresh.IsEnabled     = true;
            App.OccupiedInstance.AlwaysPresentCommands.isEnabled  = true;
            AssociatedViewModel.EmptyTextState.isVisible          = Visibility.Collapsed;
            App.OccupiedInstance.instanceViewModel.Universal.path = parameters;

            if (App.OccupiedInstance.instanceViewModel.Universal.path == Path.GetPathRoot(App.OccupiedInstance.instanceViewModel.Universal.path))
            {
                App.OccupiedInstance.RibbonArea.Up.IsEnabled = false;
            }
            else
            {
                App.OccupiedInstance.RibbonArea.Up.IsEnabled = true;
            }

            App.OccupiedInstance.instanceViewModel.AddItemsToCollectionAsync(App.OccupiedInstance.instanceViewModel.Universal.path);
            App.Clipboard_ContentChanged(null, null);

            if (parameters.Equals(App.DesktopPath))
            {
                App.OccupiedInstance.PathText.Text = "Desktop";
            }
            else if (parameters.Equals(App.DocumentsPath))
            {
                App.OccupiedInstance.PathText.Text = "Documents";
            }
            else if (parameters.Equals(App.DownloadsPath))
            {
                App.OccupiedInstance.PathText.Text = "Downloads";
            }
            else if (parameters.Equals(App.PicturesPath))
            {
                App.OccupiedInstance.PathText.Text = "Pictures";
            }
            else if (parameters.Equals(App.MusicPath))
            {
                App.OccupiedInstance.PathText.Text = "Music";
            }
            else if (parameters.Equals(App.OneDrivePath))
            {
                App.OccupiedInstance.PathText.Text = "OneDrive";
            }
            else if (parameters.Equals(App.VideosPath))
            {
                App.OccupiedInstance.PathText.Text = "Videos";
            }
            else
            {
                if (parameters.Equals(@"C:\") || parameters.Equals(@"c:\"))
                {
                    App.OccupiedInstance.PathText.Text = @"Local Disk (C:\)";
                }
                else
                {
                    App.OccupiedInstance.PathText.Text = parameters;
                }
            }
        }
Ejemplo n.º 9
0
        public void PopulateDrivesListWithLocalDisks()
        {
            var driveLetters = DriveInfo.GetDrives().Select(x => x.RootDirectory.Root).ToList().OrderBy(x => x.Root.FullName).ToList();

            driveLetters.ForEach(async roots =>
            {
                try
                {
                    var content = string.Empty;
                    string icon = null;
                    if (!(await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.Path).ToList().Contains(roots.Name))
                    {
                        // TODO: Display Custom Names for Local Disks as well
                        if (InstanceTabsView.NormalizePath(roots.Name) != InstanceTabsView.NormalizePath("A:") &&
                            InstanceTabsView.NormalizePath(roots.Name) != InstanceTabsView.NormalizePath("B:"))
                        {
                            content = $"Local Disk ({roots.Name.TrimEnd('\\')})";
                            icon    = "\uEDA2";
                        }
                        else
                        {
                            content = $"Floppy Disk ({roots.Name.TrimEnd('\\')})";
                            icon    = "\uE74E";
                        }


                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low,
                                                                                      async() =>
                        {
                            Visibility capacityBarVis = Visibility.Visible;
                            ulong totalSpaceProg      = 0;
                            ulong freeSpaceProg       = 0;
                            string free_space_text    = "Unknown";
                            string total_space_text   = "Unknown";

                            try
                            {
                                StorageFolder drive    = await StorageFolder.GetFolderFromPathAsync(roots.Name);
                                var retrivedProperties = await drive.Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace", "System.Capacity" });

                                var sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).GigaBytes;
                                freeSpaceProg      = Convert.ToUInt64(sizeAsGBString);

                                sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).GigaBytes;
                                totalSpaceProg = Convert.ToUInt64(sizeAsGBString);

                                free_space_text  = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).ToString();
                                total_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).ToString();
                            }
                            catch (UnauthorizedAccessException)
                            {
                                capacityBarVis = Visibility.Collapsed;
                            }
                            catch (NullReferenceException)
                            {
                                capacityBarVis = Visibility.Collapsed;
                            }

                            App.foundDrives.Add(new DriveItem()
                            {
                                driveText             = content,
                                glyph                 = icon,
                                maxSpace              = totalSpaceProg,
                                spaceUsed             = totalSpaceProg - freeSpaceProg,
                                tag                   = roots.Name,
                                progressBarVisibility = capacityBarVis,
                                spaceText             = free_space_text + " free of " + total_space_text,
                            });
                        });
                    }
                }
                catch (UnauthorizedAccessException e)
                {
                    Debug.WriteLine(e.Message);
                }
            });
        }