Ejemplo n.º 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is Tuple <FileControl, StorageItemQueryResult> Parameters)
            {
                FileControlInstance = Parameters.Item1;
                ItemQuery           = Parameters.Item2;

                CommonAccessCollection.Register(FileControlInstance, this);

                await Initialize().ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 private async void DeviceExpander_Expanded(object sender, EventArgs e)
 {
     SettingControl.DeviceExpanderIsExpand = true;
     await CommonAccessCollection.LoadDeviceAsync();
 }
        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);
                    });
                }
Ejemplo n.º 4
0
 private async void LibraryExpander_Expanded(object sender, EventArgs e)
 {
     SettingControl.LibraryExpanderIsExpand = true;
     await CommonAccessCollection.LoadLibraryFoldersAsync();
 }
Ejemplo n.º 5
0
 public async void Refresh_Click(object sender, RoutedEventArgs e)
 {
     await CommonAccessCollection.LoadDriveAsync(true);
 }