public static void GoBack() { if (CurrentTabNavigation.Content is FileControl Control) { if (Control.Nav.CanGoBack) { Control.Nav.GoBack(); } else if (CurrentTabNavigation.CanGoBack) { CurrentTabNavigation.GoBack(); } } else if (CurrentTabNavigation.CanGoBack) { CurrentTabNavigation.GoBack(); } }
private async void TabViewContainer_KeyDown(CoreWindow sender, KeyEventArgs args) { if (!QueueContentDialog.IsRunningOrWaiting && CurrentTabNavigation?.Content is ThisPC PC) { args.Handled = true; switch (args.VirtualKey) { case VirtualKey.Space when SettingControl.IsQuicklookAvailable && SettingControl.IsQuicklookEnable: { if (PC.DeviceGrid.SelectedItem is HardDeviceInfo Device) { await FullTrustProcessController.Current.ViewWithQuicklookAsync(Device.Folder.Path).ConfigureAwait(false); } else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library) { await FullTrustProcessController.Current.ViewWithQuicklookAsync(Library.Folder.Path).ConfigureAwait(false); } break; } case VirtualKey.Enter: { if (PC.DeviceGrid.SelectedItem is HardDeviceInfo Device) { if (string.IsNullOrEmpty(Device.Folder.Path)) { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_TipTitle"), Content = Globalization.GetString("QueueDialog_MTP_CouldNotAccess_Content"), PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"), CloseButtonText = Globalization.GetString("Common_Dialog_CancelButton") }; if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary) { await Launcher.LaunchFolderAsync(Device.Folder); } } else { if (AnimationController.Current.IsEnableAnimation) { CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Device.Folder), new DrillInNavigationTransitionInfo()); } else { CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Device.Folder), new SuppressNavigationTransitionInfo()); } } } else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library) { if (AnimationController.Current.IsEnableAnimation) { CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Library.Folder), new DrillInNavigationTransitionInfo()); } else { CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Library.Folder), new SuppressNavigationTransitionInfo()); } } break; } case VirtualKey.F5: { PC.Refresh_Click(null, null); break; } } } }
private async void PortalDeviceWatcher_Removed(DeviceWatcher sender, DeviceInformationUpdate args) { try { List <string> AllBaseDevice = DriveInfo.GetDrives().Where((Drives) => Drives.DriveType == DriveType.Fixed || Drives.DriveType == DriveType.Network) .Select((Info) => Info.RootDirectory.FullName).ToList(); List <StorageFolder> PortableDevice = new List <StorageFolder>(); foreach (DeviceInformation Device in await DeviceInformation.FindAllAsync(StorageDevice.GetDeviceSelector())) { try { PortableDevice.Add(StorageDevice.FromId(Device.Id)); } catch { Debug.WriteLine($"Error happened when get storagefolder from {Device.Name}"); } } foreach (string PortDevice in AllBaseDevice.Where((Path) => PortableDevice.Any((Item) => Item.Path == Path))) { AllBaseDevice.Remove(PortDevice); } List <HardDeviceInfo> OneStepDeviceList = CommonAccessCollection.HardDeviceList.Where((Item) => !AllBaseDevice.Contains(Item.Folder.Path)).ToList(); List <HardDeviceInfo> TwoStepDeviceList = OneStepDeviceList.Where((RemoveItem) => PortableDevice.All((Item) => Item.Name != RemoveItem.Folder.Name)).ToList(); foreach (HardDeviceInfo Device in TwoStepDeviceList) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { for (int j = 0; j < TabViewControl.TabItems.Count; j++) { if (((TabViewControl.TabItems[j] as TabViewItem)?.Content as Frame)?.Content is FileControl Control && Path.GetPathRoot(Control.CurrentFolder.Path) == Device.Folder.Path) { if (TabViewControl.TabItems.Count == 1) { while (CurrentTabNavigation.CanGoBack) { CurrentTabNavigation.GoBack(); } } else { CommonAccessCollection.UnRegister(Control); Control.Dispose(); TabViewControl.TabItems.RemoveAt(j); if (TabViewControl.TabItems.Count == 1) { (TabViewControl.TabItems.First() as TabViewItem).IsClosable = false; } } } } CommonAccessCollection.HardDeviceList.Remove(Device); }); }