예제 #1
0
        private async void TreeUp()
        {
            try
            {
                // Wait Sync work
                await TaskHelper.WaitTask(TaskHelper.STORAGE_EXPLORER_SYNC + Switcher.GetCurrentStorage().GetStorageName());

                // If message is visible, set collapsed.
                if (uiPinFileMessage.Visibility == Visibility.Visible && !uiPinFileMessage.Text.Equals(AppResources.Refreshing))
                {
                    uiPinFileMessage.Visibility = Visibility.Collapsed;
                }

                // Do tree up work and set items to list
                List <FileObject> fileList = StorageExplorer.TreeUp();
                this.CurrentFileObjectList = fileList;
                this.PinFileObjectViewModel.SetItems(this.CurrentFileObjectList, true);
                uiPinFileCurrentPath.Text = StorageExplorer.GetCurrentPath();

                // Clear trees.
                //this.PinFileAppBarButton.IsEnabled = false;
                this.PinSelectedFileList.Clear();
            }
            catch
            {
                return;
            }
        }
예제 #2
0
        private async void SetPinFileListAsync(IStorageManager iStorageManager, string message, FileObjectViewItem folder)
        {
            // Set Mutex true and Show Process Indicator
            // Clear selected file and set pin button false.
            base.SetProgressRing(uiFileListProgressRing, true);
            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                uiPinFileListGridView.Visibility = Visibility.Collapsed;
                uiPinFileMessage.Text            = message;
                uiPinFileMessage.Visibility      = Visibility.Visible;
            });

            this.PinSelectedFileList.Clear();

            try
            {
                // Wait Signin and Sync task
                await TaskHelper.WaitSignInTask(iStorageManager.GetStorageName());

                await TaskHelper.WaitTask(TaskHelper.STORAGE_EXPLORER_SYNC + Switcher.GetCurrentStorage().GetStorageName());

                // Get files from current folder in the cloud.
                // If it is not null, set items.
                // Otherwise, show message
                if (folder == null)
                {
                    this.CurrentFileObjectList = StorageExplorer.GetFilesFromRootFolder();
                }
                else
                {
                    this.CurrentFileObjectList = StorageExplorer.GetTreeForFolder(this.GetCloudStorageFileObjectById(folder.Id));
                }
                if (this.CurrentFileObjectList != null)
                {
                    // If didn't change cloud mode while loading, set it to list.
                    // Set file list visible and current path.
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        this.PinFileObjectViewModel.IsDataLoaded = true;
                        uiPinFileListGridView.Visibility         = Visibility.Visible;
                        uiPinFileCurrentPath.Text = StorageExplorer.GetCurrentPath();
                        this.PinFileObjectViewModel.SetItems(this.CurrentFileObjectList, true);
                    });


                    // If there exists file, show it.
                    // Otherwise, show no file message.
                    if (this.CurrentFileObjectList.Count > 0)
                    {
                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            uiPinFileMessage.Visibility = Visibility.Collapsed;
                        });
                    }
                    else
                    {
                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            uiPinFileMessage.Text = AppResources.NoFileInFolderMessage;
                        });
                    }
                }
                else
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        uiPinFileListGridView.Visibility = Visibility.Collapsed;
                        uiPinFileMessage.Text            = AppResources.BadLoadingFileMessage;
                        uiPinFileMessage.Visibility      = Visibility.Visible;
                    });
                }
            }
            catch
            {
                uiPinFileListGridView.Visibility = Visibility.Collapsed;
                uiPinFileMessage.Text            = AppResources.BadLoadingFileMessage;
                uiPinFileMessage.Visibility      = Visibility.Visible;
            }
            base.SetProgressRing(uiFileListProgressRing, false);
        }