Пример #1
0
        private async Task LoadSyncStatusAsync()
        {
            if (SpecialPath.IsPathIncluded(Path, SpecialPath.SpecialPathEnum.OneDrive))
            {
                switch (await GetStorageItemAsync())
                {
                case StorageFile File:
                {
                    IDictionary <string, object> Properties = await File.Properties.RetrievePropertiesAsync(new string[] { "System.FilePlaceholderStatus", "System.FileOfflineAvailabilityStatus" });

                    if (!Properties.TryGetValue("System.FilePlaceholderStatus", out object StatusIndex))
                    {
                        if (!Properties.TryGetValue("System.FileOfflineAvailabilityStatus", out StatusIndex))
                        {
                            SyncStatus = SyncStatus.Unknown;
                            break;
                        }
                    }

                    switch (Convert.ToUInt32(StatusIndex))
                    {
                    case 0:
                    case 1:
                    case 8:
                    {
                        SyncStatus = SyncStatus.AvailableOnline;
                        break;
                    }

                    case 2:
                    case 3:
                    case 14:
                    case 15:
                    {
                        SyncStatus = SyncStatus.AvailableOffline;
                        break;
                    }

                    case 9:
                    {
                        SyncStatus = SyncStatus.Sync;
                        break;
                    }

                    case 4:
                    {
                        SyncStatus = SyncStatus.Excluded;
                        break;
                    }

                    default:
                    {
                        SyncStatus = SyncStatus.Unknown;
                        break;
                    }
                    }

                    break;
                }

                case StorageFolder Folder:
                {
                    IDictionary <string, object> Properties = await Folder.Properties.RetrievePropertiesAsync(new string[] { "System.FilePlaceholderStatus", "System.FileOfflineAvailabilityStatus" });


                    if (!Properties.TryGetValue("System.FileOfflineAvailabilityStatus", out object StatusIndex))
                    {
                        if (!Properties.TryGetValue("System.FilePlaceholderStatus", out StatusIndex))
                        {
                            SyncStatus = SyncStatus.Unknown;
                            break;
                        }
                    }

                    switch (Convert.ToUInt32(StatusIndex))
                    {
                    case 0:
                    case 1:
                    case 8:
                    {
                        SyncStatus = SyncStatus.AvailableOnline;
                        break;
                    }

                    case 2:
                    case 3:
                    case 14:
                    case 15:
                    {
                        SyncStatus = SyncStatus.AvailableOffline;
                        break;
                    }

                    case 9:
                    {
                        SyncStatus = SyncStatus.Sync;
                        break;
                    }

                    case 4:
                    {
                        SyncStatus = SyncStatus.Excluded;
                        break;
                    }

                    default:
                    {
                        SyncStatus = SyncStatus.Unknown;
                        break;
                    }
                    }

                    break;
                }

                default:
                {
                    SyncStatus = SyncStatus.Unknown;
                    break;
                }
                }
            }
            else
            {
                SyncStatus = SyncStatus.Unknown;
            }

            OnPropertyChanged(nameof(SyncStatus));
        }
 protected override bool CheckIfNeedLoadThumbnailOverlay()
 {
     return(SpecialPath.IsPathIncluded(Path, SpecialPath.SpecialPathEnum.OneDrive));
 }