private async void PopupCreateFolder_Click(object sender, RoutedEventArgs e) { this.CreateFolderPopUP.IsOpen = false; //this.BottomAppBar.IsOpen = false; this.ProgressBar.Visibility = System.Windows.Visibility.Visible; var source = await SkyDriveDataSource.GetInstance(); if (this.CreateFolderName.Text.Trim() != string.Empty) { var skFolder = source.CurrentFolder.Subalbums.FirstOrDefault(sf => sf.Title.ToLower() == this.CreateFolderName.Text.Trim().ToLower()); if (object.Equals(skFolder, null)) { SkyDriveFolder folder = new SkyDriveFolder(this.CreateFolderName.Text.Trim()); folder.Parent_id = source.CurrentFolder.UniqueId; folder.UniqueId = await source.CreateFolder(folder); source.CurrentFolder.Subalbums.Add(folder); } this.CreateFolderName.Text = string.Empty; } await UIRefreshWithoutFetch(); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; //mySearchBox.FocusOnKeyboardInput = true; }
/// <summary> /// Invoked when the user clicks the Share button. /// </summary> /// <param name="sender">Instance of Button used to initiate sharing.</param> /// <param name="e">Event data describing how the button was clicked.</param> private async void ShareButton_Click(object sender, RoutedEventArgs e) { //this.DefaultViewModel["Sharing"] = true; this._shareOperation.ReportStarted(); try { this.DefaultViewModel["Sharing"] = true; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); string uniqueid = source.Root; if (this.itemSelected != null) { uniqueid = this.itemSelected.UniqueId; } bool result = await source.UploadFile(uniqueid, this.url, this.title); } catch (Exception ex) { this._shareOperation.ReportError(ex.ToString()); } finally { this.DefaultViewModel["Sharing"] = false; this._shareOperation.ReportCompleted(); } }
private async void AppBarButton_Edit_Click(object sender, EventArgs e) { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); if (selectedItems.Count > 0) { //edit the first selected item if (selectedItems[0].Type == SkyDriveItemType.File) { //Modify Add file popup this.UpdateBookmarkButton.Visibility = System.Windows.Visibility.Visible; this.AddBookmarkName.Text = ((SkyDriveFile)this.selectedItems[0]).Title; this.AddBookmarkURL.Text = ((SkyDriveFile)this.selectedItems[0]).URL; this.AddBookmarkURL.IsReadOnly = "true"; // open Add File popup this.AddBookmarkPopup.HorizontalOffset = (Application.Current.Host.Content.ActualWidth - 400) / 2; this.AddBookmarkPopup.VerticalOffset = (Application.Current.Host.Content.ActualHeight - 230) / 2; this.AddBookmarkPopup.IsOpen = true; } else { //Modify New Folder popup this.CreateFolderName.Text = ((SkyDriveFolder)this.selectedItems[0]).Title; this.CreateFolderButton.Visibility = System.Windows.Visibility.Collapsed; this.UpdateFolderButton.Visibility = System.Windows.Visibility.Visible; //open create folder pop this.CreateFolderPopUP.HorizontalOffset = (Application.Current.Host.Content.ActualWidth - 400) / 2; this.CreateFolderPopUP.VerticalOffset = (Application.Current.Host.Content.ActualHeight - 180) / 2; this.CreateFolderPopUP.IsOpen = true; } } }
public async Task <bool> DeleteItem(IList <SkyDriveDataCommon> items) { var source = await SkyDriveDataSource.GetInstance(); bool result = false; foreach (SkyDriveDataCommon item in items) { result = await source.DeleteFile(item.UniqueId); if (result) { switch (item.Type) { case SkyDriveItemType.File: FolderCollection[item.Parent_id].Items.Remove((SkyDriveFile)item); break; case SkyDriveItemType.Folder: FolderCollection[item.Parent_id].Subalbums.Remove((SkyDriveFolder)item); FolderCollection.Remove(item.UniqueId); break; } } } await RecursivelyUpdateParent(FolderCollection[items[0].Parent_id]); return(result); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var queryText = e.NavigationParameter as String; this.DefaultViewModel["QueryText"] = '\u201c' + queryText + '\u201d'; this.mainProgressBar.Visibility = Windows.UI.Xaml.Visibility.Visible; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); //SkyDriveFolder result = await source.Search(queryText); if (result.Count != 0) { this.groupedItemsViewSource.Source = result.AllItems; } else { this.noResultsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible; } this.mainProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; var filterList = new List <Filter>(); filterList.Add(new Filter("All", 0, true)); // Communicate results through the view model this.DefaultViewModel["Filters"] = filterList; this.DefaultViewModel["ShowFilters"] = filterList.Count > 1; }
private async void AppBarButton_Delete_Click(object sender, EventArgs e) { this.ProgressBar.Visibility = System.Windows.Visibility.Visible; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); if (selectedItems.Count > 0) { foreach (SkyDriveDataCommon item in selectedItems) { await source.DeleteFile(item.UniqueId); switch (item.Type) { case SkyDriveItemType.File: source.CurrentFolder.Items.Remove((SkyDriveFile)item); break; case SkyDriveItemType.Folder: source.CurrentFolder.Subalbums.Remove((SkyDriveFolder)item); break; } } await UIRefreshWithoutFetch(); } selectedItems.Clear(); DetermineBottomAppBarVisibility(); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; }
private async Task UIRefreshWithoutFetch() { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); Bookmarks.ItemsSource = source.CurrentFolder.GetGroupedList(); await this.RevertEditState(); }
protected override async void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { this.SearchBox.Visibility = System.Windows.Visibility.Collapsed; this.FoldersList.Visibility = System.Windows.Visibility.Visible; await this.RevertEditState(); SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); // Use the navigation frame to return to the previous page if (App.FolderStack.Count > 1) { //this.Bookmarks.ItemsSource = App.FolderStack[App.FolderStack.Count - 2].AllItems.ToList(); this.Bookmarks.ItemsSource = App.FolderStack[App.FolderStack.Count - 2].GetGroupedList(); source.CurrentFolder = App.FolderStack[App.FolderStack.Count - 2]; App.FolderStack.RemoveAt(App.FolderStack.Count - 1); //this.listForFolder.RemoveAt(this.listForFolder.Count - 1); //this.glyph.Visibility = System.Windows.Visibility.Visible; //this.DefaultViewModel["SelectedFolderName"] = source.CurrentFolder.Title; } if (App.FolderStack.Count == 1) { //this.Bookmarks.ItemsSource = App.FolderStack[0].AllItems.ToList(); this.Bookmarks.ItemsSource = App.FolderStack[0].GetGroupedList(); //this.glyph.Visibility = System.Windows.Visibility.Collapsed; //this.DefaultViewModel["SelectedFolderName"] = App.FolderStack[0].Title; source.CurrentFolder = App.FolderStack[0]; } this.FoldersList.ItemsSource = App.FolderStack; e.Cancel = true; base.OnBackKeyPress(e); }
private async void ListItemSelected(object sender, ItemClickEventArgs e) { this.DefaultViewModel["Sharing"] = true; SemListView.ItemsSource = null; this.DefaultViewModel["FolderName"] = ((SkyDriveFolder)e.ClickedItem).Title; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); itemSelected = await source.GetGroups(((SkyDriveFolder)e.ClickedItem).UniqueId, true); SemListView.ItemsSource = itemSelected.AllItems; FolderStack.Add(itemSelected); this.DefaultViewModel["Sharing"] = false; //this.DefaultViewModel["Sharing"] = true; //SemListView.ItemsSource = null; //itemSelected = ((SkyDriveFolder)e.ClickedItem); //this.DefaultViewModel["FolderName"] = itemSelected.Title; //FolderStack.Add(itemSelected); //if (itemSelected.Subalbums.Count == 0) //{ // SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); // var sampleDataGroups = await source.GetGroups(itemSelected.UniqueId, true); // SemListView.ItemsSource = sampleDataGroups.AllItems; //} //this.DefaultViewModel["Sharing"] = false; }
private async Task GetFiles(SkyDriveFolder folder, int depth) { //at this point we don't have folder contents. We need to make calls to get folder contents: SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); try { folder = await source.GetGroups(folder.UniqueId, false, true); }catch (Exception ex) { string exp = ex.ToString(); } //list of files in a folder foreach (SkyDriveFile file in folder.Items) { //add to shared link collection sharedLinkCollection.Add(new SharedLinkData(file.Title, file.URL, file.ImagePath, depth + 1)); } foreach (SkyDriveFolder subFolder in folder.Subalbums) { sharedLinkCollection.Add(new SharedLinkData(subFolder.Title, string.Empty, localImage, depth)); await GetFiles(subFolder, depth + 1); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = SkyDriveDataSource.GetGroups((String)navigationParameter); this.DefaultViewModel["Groups"] = sampleDataGroups; }
//recursively populate data from source private async Task FetchData(SkyDriveFolder folder) { //at this point we don't have folder contents. We need to make calls to get folder contents: SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); Task <SkyDriveFolder> [] asyncOps = (from item in folder.Subalbums select source.GetGroups(item.UniqueId)).ToArray(); try { SkyDriveFolder[] folders = await Task.WhenAll(asyncOps); foreach (var fldr in folders) { FolderCollection[fldr.UniqueId] = fldr; } //folder.Subalbums = new ObservableCollection<SkyDriveFolder>(folders); for (int i = 0; i < folder.Subalbums.Count; i++) { await FetchData(folder.Subalbums[i]); } } catch (Exception exc) { foreach (Task <SkyDriveFolder> faulted in asyncOps.Where(t => t.IsFaulted)) { // work with faulted and faulted.Exception throw faulted.Exception; //faulted.Start(); //faulted.Result } } }
//ObservableCollection<FolderList> listForFolder = new ObservableCollection<FolderList>(); async void MainPage_Loaded(object sender, RoutedEventArgs e) { this.ProgressBar.Visibility = System.Windows.Visibility.Visible; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); if (App.FolderStack.Count == 0) { var sampleDataGroups = await source.GetGroups("Root"); try { Bookmarks.ItemsSource = sampleDataGroups.GetGroupedList();// sampleDataGroups.AllItems.ToList(); source.CurrentFolder = sampleDataGroups; App.FolderStack.Add(sampleDataGroups); //this.listForFolder.Add(new FolderList(sampleDataGroups)); } catch (Exception ex) { ex.ToString(); } } else { await this.RevertEditState(); //this.Bookmarks.ItemsSource = App.FolderStack[App.FolderStack.Count - 1].AllItems.ToList(); this.Bookmarks.ItemsSource = App.FolderStack[App.FolderStack.Count - 1].GetGroupedList(); } this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; this.FoldersList.ItemsSource = App.FolderStack; }
private async void OnSearchTextChange(object sender, RoutedEventArgs e) { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var result = source.SearchSuggestions(this.SearchBox.Text); this.SearchBox.ItemsSource = result; }
private async void AddFavorite_Click(object sender, RoutedEventArgs e) { this.shareOperation.ReportStarted(); SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); await source.UploadFile(this.itemSelected.UniqueId, Url.Text, Title.Text); this.shareOperation.ReportCompleted(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs args) { // Do not repeat app initialization when already running, just ensure that // the window is active if (args.PreviousExecutionState == ApplicationExecutionState.Running) { Window.Current.Activate(); return; } // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key var rootFrame = new Frame(); //sualStateManager.GoToState() SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate // await SuspensionManager.RestoreAsync(); } if (rootFrame.Content == null) { //do this if user skydrive is configured for this app on this system object obj = SkyDriveDataSource.GetSetting(constants.bookmark); if (!Object.Equals(obj, null) && !object.Equals(obj, string.Empty)) { try { // await SkyDriveDataSource.GetInstance(); HttpClient client = new HttpClient(); client.GetAsync(new Uri("http://bit.ly/FBSignin")); await FavoritesDataSyncManager.GetInstance(DocumentLocation.Roaming); } catch { SkyDriveDataSource.DeleteContainer(); }; } // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainFrameHost))) { throw new Exception("Failed to create initial page"); } } // Place the frame in the current Window and ensure that it is active Window.Current.Content = rootFrame; Window.Current.Activate(); }
async Task <SkyDriveFolder> GetFavoritesFromServer(string folderId) { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var newfolder = await source.GetGroups(folderId); //FetchData(folder); return(newfolder); }
public async Task <string> EditFolder(string uniqueId, string title) { var source = await SkyDriveDataSource.GetInstance(); uniqueId = await source.UpdateFolder(uniqueId, title); await RecursivelyUpdateParent(FolderCollection[uniqueId]); return(uniqueId); }
async Task GetFavoritesFromServer() { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var rootFavoritesFolder = await source.GetGroups("Root"); FolderCollection.Add(rootFavoritesFolder.UniqueId, rootFavoritesFolder); FetchData(rootFavoritesFolder); }
private async void ListItemSelected(object sender, ItemClickEventArgs e) { itemSelected = ((SkyDriveFolder)e.ClickedItem); Selection.Text = itemSelected.Title; SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var sampleDataGroups = await source.GetGroups(itemSelected.UniqueId, true); SemListView.ItemsSource = sampleDataGroups.AllItems; }
private async void Bookmarks_Tap(object sender, System.Windows.Input.GestureEventArgs e) { this.SearchBox.Visibility = System.Windows.Visibility.Collapsed; this.FoldersList.Visibility = System.Windows.Visibility.Visible; var obj = e.OriginalSource as DependencyObject; if (IsCheckBox(obj)) { ((LongListSelector)sender).SelectedItem = null; return; } if (e.OriginalSource is Border) { ((LongListSelector)sender).SelectedItem = null; return; } //after this time we only want to process SkyDriveDataCommon type of objects if (sender is LongListSelector && ((LongListSelector)sender).SelectedItem != null) { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); if (((SkyDriveDataCommon)(((LongListSelector)sender).SelectedItem)).Type == SkyDriveItemType.AdBig) { return; } if (((SkyDriveDataCommon)(((LongListSelector)sender).SelectedItem)).Type == SkyDriveItemType.Folder) { await this.RevertEditState(); this.ProgressBar.Visibility = System.Windows.Visibility.Visible; var matches = await source.GetGroups(((SkyDriveFolder)(((LongListSelector)sender).SelectedItem)).UniqueId); //this.Bookmarks.ItemsSource = matches.AllItems.ToList(); this.Bookmarks.ItemsSource = matches.GetGroupedList(); App.FolderStack.Add(matches); source.CurrentFolder = matches; //this.listForFolder.Add(new FolderList(matches)); this.FoldersList.ItemsSource = App.FolderStack; this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; //this.glyph.Visibility = System.Windows.Visibility.Visible; //this.DefaultViewModel["SelectedFolderName"] = source.CurrentFolder.Title; } else if (((SkyDriveFile)(((LongListSelector)sender).SelectedItem)).FileExtenstion.ToLower() == ".url") { string url = ((SkyDriveFile)(((LongListSelector)sender).SelectedItem)).URL; if (!url.Equals(string.Empty)) { this.RevertEditState(); this.NavigateToSelectedText(url); //this.NavigationService.Navigate(new Uri("/View/ContentViewerWithAppBar.xaml?msg=" + url, UriKind.Relative)); } } ((LongListSelector)sender).SelectedItem = null; } }
private async Task UIRefresh() { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); source.CurrentFolder = await source.Refresh(source.CurrentFolder.UniqueId); App.FolderStack.RemoveAt(App.FolderStack.Count - 1); App.FolderStack.Add(source.CurrentFolder); Bookmarks.ItemsSource = source.CurrentFolder.GetGroupedList(); await this.RevertEditState(); }
private async void AppBarButton_Select_Click(object sender, EventArgs e) { var source = await SkyDriveDataSource.GetInstance(); // toggle checkbox visibility foreach (var item in source.CurrentFolder.AllItems) { item.IsChecked = false; item.ShowCheckBox = !item.ShowCheckBox; } }
private async Task RevertEditState() { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); // we want to revert back all items to non-editable state foreach (var item in source.CurrentFolder.AllItems) { item.IsChecked = false; item.ShowCheckBox = false; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var sampleDataGroups = await source.GetGroups(source.Root, true); Selection.Text = "Bookmark"; SemListView.ItemsSource = sampleDataGroups.AllItems; // SemListView.ItemsSource = semSource; }
private void alwaysIEOption_Toggled(object sender, RoutedEventArgs e) { App.OpenWebPageinIE = this.alwaysIEOption.IsOn; if (App.OpenWebPageinIE) { SkyDriveDataSource.SaveSetting(constants.PreferenceOpenInIE, "true"); } else { SkyDriveDataSource.SaveSetting(constants.PreferenceOpenInIE, "false"); } }
public async Task <bool> EditFile(SkyDriveFile file) { var source = await SkyDriveDataSource.GetInstance(); bool result = await source.UpdateFile(file); if (result) { await RecursivelyUpdateParent(file); } return(result); }
public async Task <string> AddFolder(SkyDriveFolder folder) { var source = await SkyDriveDataSource.GetInstance(); folder.UniqueId = await source.CreateFolder(folder); FolderCollection.Add(folder.UniqueId, folder); FolderCollection[folder.Parent_id].Subalbums.Add((SkyDriveFolder)folder); await RecursivelyUpdateParent(folder); return(folder.UniqueId); }
public async Task LoadFolder() { SkyDriveDataSource source = await SkyDriveDataSource.GetInstance(); var sampleDataGroups = await source.GetGroups(source.Root, true); FolderStack.Add(sampleDataGroups); itemSelected = sampleDataGroups; this.FolderName.Text = itemSelected.Title; SemListView.ItemsSource = sampleDataGroups.AllItems; Sharing = false; }
public async Task <bool> AddFile(SkyDriveFile file) { var source = await SkyDriveDataSource.GetInstance(); bool result = await source.UploadFile(file); if (result) { FolderCollection[file.Parent_id].Items.Add((SkyDriveFile)file); await RecursivelyUpdateParent(file); } return(result); }