/// <summary> /// folderListClient event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void FolderListClient_GetCompleted(LiveOperationResult e, SkydriveAlbum album) { album.Photos.Clear(); List <object> data = (List <object>)e.Result["data"]; NumberOfImages = data.Count; if (NumberOfImages == 0) { HideProgressBar(); return; } foreach (IDictionary <string, object> photo in data) { var item = new SkydrivePhoto(); item.Title = (string)photo["name"]; item.Subtitle = (string)photo["name"]; item.PhotoUrl = (string)photo["source"]; item.Description = (string)photo["description"]; item.ID = (string)photo["id"]; if (album != null) { album.Photos.Add(item); } } }
/// <summary> /// LiveConnectClient event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DeleteFile_Completed(SkydrivePhoto selectedFile, LiveOperationResult e) { if (e.Result != null) { App.CurrentAlbum.Photos.Remove(selectedFile); } else { string downFaild = SkyPhoto.Resources.Resources.downFaild; MessageBox.Show(downFaild); } }
/// <summary> /// LiveConnectClient event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DeleteFile_Completed(object sender, LiveOperationCompletedEventArgs e) { SkydrivePhoto selectedFile = e.UserState as SkydrivePhoto; if (e.Error == null) { App.CurrentAlbum.Photos.Remove(selectedFile); } else { string downFaild = SkyPhoto.Resources.Resources.downFaild; MessageBox.Show(downFaild); } }
/// <summary> /// ContextMenu delete button tergar MenuDelte_Click and delete the picture from sky drive /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuDelte_Click(object sender, RoutedEventArgs e) { var Menu = sender as MenuItem; SkydrivePhoto selectedFile = Menu.DataContext as SkydrivePhoto; string msgDelPic = SkyPhoto.Resources.Resources.msgDelPic; string msgDelPicTitel = SkyPhoto.Resources.Resources.msgDelPicTitle; MessageBoxResult m = MessageBox.Show(msgDelPic + selectedFile.Title + "?", msgDelPicTitel, MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { LiveConnectClient client = new LiveConnectClient(App.Session); client.DeleteCompleted += new EventHandler <LiveOperationCompletedEventArgs>(DeleteFile_Completed); client.DeleteAsync(selectedFile.ID, selectedFile); } else { return; } }
/// <summary> /// ContextMenu download button tergar MenuDownload_Click and download the picture from sky drive to gallery /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuDownload_Click(object sender, RoutedEventArgs e) { var Menu = sender as MenuItem; SkydrivePhoto selectedPhoto = Menu.DataContext as SkydrivePhoto; WebClient client = new WebClient(); CurrentPhoto = selectedPhoto; client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted); string progMsgDownPic = SkyPhoto.Resources.Resources.progMsgDownPic; ShowProgressBar(progMsgDownPic); try { client.OpenReadAsync(new Uri(selectedPhoto.PhotoUrl), client); } catch (Exception) { string downFaild = SkyPhoto.Resources.Resources.downFaild; MessageBox.Show(downFaild); HideProgressBar(); } }
/// <summary> /// folderListClient event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void FolderListClient_GetCompleted(LiveOperationResult e, SkydriveAlbum album) { album.Photos.Clear(); List<object> data = (List<object>)e.Result["data"]; NumberOfImages = data.Count; if (NumberOfImages == 0) { HideProgressBar(); return; } foreach (IDictionary<string, object> photo in data) { var item = new SkydrivePhoto(); item.Title = (string)photo["name"]; item.Subtitle = (string)photo["name"]; item.PhotoUrl = (string)photo["source"]; item.Description = (string)photo["description"]; item.ID = (string)photo["id"]; if (album != null) { album.Photos.Add(item); } } }
/// <summary> /// double tab event downlaod the picture from skydirve and save it to gallery /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DoubleTapped(object sender, Microsoft.Phone.Controls.GestureEventArgs e) { SkydrivePhoto selectedPhoto = App.CurrentAlbum.Photos[photoListBox.SelectedIndex]; NavigationService.Navigate(new Uri("/FullPhotoPage.xaml?phtoUrl=" + selectedPhoto.PhotoUrl, UriKind.Relative)); }