public async void SetPinInfoListAsync(FileObjectViewItem folder, string message, IStorageManager iStorageManager, int currentPlatformIndex)
        {
            // Set Mutex true and Show Process Indicator
            this.FileObjectViewModel.IsDataLoaded = true;
            this.FileObjectViewModel.IsDataLoading = true;
            this.SetListUnableAndShowMessage(uiPinInfoList, message, uiPinInfoMessage);
            this.SetProgressIndicator(true);

            // Wait tasks
            await App.TaskManager.WaitSignInTask(currentPlatformIndex);
            await App.TaskManager.WaitSignOutTask(currentPlatformIndex);


            // If it haven't signed out before working below code, do it.
            if (iStorageManager.GetAccount() != null)
            {
                // Delete selected file and If folder null, set root.
                this.SelectedFile.Clear();
                if (folder == null)
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        uiPinInfoCurrentPath.Text = "";
                    });

                    this.FolderRootTree.Clear();
                    this.FoldersTree.Clear();

                    FileObject rootFolder = await iStorageManager.GetRootFolderAsync();
                    folder = new FileObjectViewItem();
                    folder.Id = rootFolder.Id;
                }

                // Get files and push to stack tree.
                List<FileObject> files = await iStorageManager.GetFilesFromFolderAsync(folder.Id);
                if (!message.Equals(AppResources.Refreshing))
                {
                    this.FolderRootTree.Push(folder);
                    this.FoldersTree.Push(files);
                }

                // Set file list visible and current path.
                base.Dispatcher.BeginInvoke(() =>
                {
                    // Set file tree to list.
                    uiPinInfoList.Visibility = Visibility.Visible;
                    uiPinInfoCurrentPath.Text = this.GetCurrentPath();
                    this.FileObjectViewModel.SetItems(files, true);
                });

                // If there exists file, show it.
                // Otherwise, show no file message.
                if (files.Count > 0)
                {
                    base.Dispatcher.BeginInvoke(() =>
                    {
                        uiPinInfoMessage.Visibility = Visibility.Collapsed;
                    });
                }
                else
                {
                    base.Dispatcher.BeginInvoke(() =>
                    {
                        uiPinInfoMessage.Text = AppResources.NoFileInFolderMessage;
                    });
                }
            }
            else
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    uiPinInfoListGrid.Visibility = Visibility.Collapsed;
                    uiPinInfoSignInGrid.Visibility = Visibility.Visible;
                });
            }


            // Set Mutex false and Hide Process Indicator
            this.SetProgressIndicator(false);
            this.FileObjectViewModel.IsDataLoading = false;
        }
Ejemplo n.º 2
0
        protected async void SetPinInfoListAsync(IStorageManager iStorageManager, LongListSelector list, TextBlock messageTextBlock, string message,
            TextBlock pathTextBlock, Grid listGrid, StackPanel signInPanel, ApplicationBarIconButton pinInfoAppBarButton,
            FileObjectViewModel viewModel, List<FileObjectViewItem> selectedFile, FileObjectViewItem folder, bool load)
        {
            // Set Mutex true and Show Process Indicator
            viewModel.IsDataLoaded = true;
            base.SetListUnableAndShowMessage(list, messageTextBlock, message);
            base.SetProgressIndicator(true);

            // Clear selected file and set pin button false.
            selectedFile.Clear();
            base.Dispatcher.BeginInvoke(() =>
            {
                pinInfoAppBarButton.IsEnabled = false;
            });

            // Wait task
            await TaskHelper.WaitSignInTask(iStorageManager.GetStorageName());
            await TaskHelper.WaitSignOutTask(iStorageManager.GetStorageName());

            // If it wasn't signed out, set list.
            // Othersie, show sign in grid.
            if (iStorageManager.GetStorageAccount() != null)  // Wasn't signed out.
            {
                // If it has to load, load new files.
                // Otherwise, set existing files to list.
                List<FileObject> fileObjects = new List<FileObject>();
                if (load)  // Load from server
                {
                    // If folder null, set root.
                    if (folder == null)
                    {
                        iStorageManager.GetFolderRootTree().Clear();
                        iStorageManager.GetFoldersTree().Clear();

                        FileObject rootFolder = await iStorageManager.GetRootFolderAsync();
                        folder = new FileObjectViewItem();
                        folder.Id = rootFolder.Id;
                    }

                    // Get files and push to stack tree.
                    fileObjects = await iStorageManager.GetFilesFromFolderAsync(folder.Id);
                    if (!message.Equals(AppResources.Refreshing))
                    {
                        iStorageManager.GetFoldersTree().Push(fileObjects);
                        if (!iStorageManager.GetFolderRootTree().Contains(folder))
                            iStorageManager.GetFolderRootTree().Push(folder);
                    }
                }
                else  // Set existed file to list
                {
                    fileObjects = iStorageManager.GetFoldersTree().First();
                }


                // If didn't change cloud mode while loading, set it to list.
                if (iStorageManager.GetStorageName().Equals(iStorageManager.GetStorageName()))
                {
                    // Set file list visible and current path.
                    base.Dispatcher.BeginInvoke(() =>
                    {
                        list.Visibility = Visibility.Visible;
                        this.SetCurrentPath(iStorageManager, pathTextBlock);
                        viewModel.SetItems(fileObjects, true);
                    });

                    // If there exists file, show it.
                    // Otherwise, show no file message.
                    if (fileObjects.Count > 0)
                    {
                        base.Dispatcher.BeginInvoke(() =>
                        {
                            messageTextBlock.Visibility = Visibility.Collapsed;
                        });
                    }
                    else
                    {
                        base.Dispatcher.BeginInvoke(() =>
                        {
                            messageTextBlock.Text = AppResources.NoFileInFolderMessage;
                        });
                    }
                }
            }
            else  // Was signed out.
            {
                base.Dispatcher.BeginInvoke(() =>
                {
                    listGrid.Visibility = Visibility.Collapsed;
                    signInPanel.Visibility = Visibility.Visible;
                });
            }

            // Set Mutex false and Hide Process Indicator
            base.SetProgressIndicator(false);
        }