private void button_Supprimer_Click(object sender, RoutedEventArgs e) { CustomPicture item = listView_fichier.SelectedItem as CustomPicture; if (System.IO.File.Exists(item.path)) { System.IO.File.Delete(item.path); } List <CustomPicture> poet = listView_fichier.ItemsSource as List <CustomPicture>; poet.Remove(item); listView_fichier.ItemsSource = poet; listView_fichier.Items.Refresh(); }
private void button_Tablette_Click(object sender, RoutedEventArgs e) { CustomPicture item = listView_fichier.SelectedItem as CustomPicture; if (button_Tablette.Content.Equals("Supprimer du Dossier Tablette")) { System.IO.File.Delete(item.path); } else if (button_Tablette.Content.Equals("Ajouter au Dossier Tablette")) { System.IO.File.Copy(item.path, string.Concat(dossierPhotosTablette + "\\" + item.nomfichier), true); } SetTreeView(); setFileListBox(item); }
private void listView_fichier_SelectionChanged(object sender, SelectionChangedEventArgs e) { CustomPicture pic = listView_fichier.SelectedItem as CustomPicture; if (pic != null) { BitmapImage image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnLoad; if (pic.parent != null) { image.UriSource = new Uri(dossierImage + "\\" + pic.parent + "\\" + pic.nomdossier + "\\" + pic.nomfichier); } else { image.UriSource = new Uri(dossierImage + "\\" + pic.nomdossier + "\\" + pic.nomfichier); } image.EndInit(); image_fichier.Source = image; string tmp = null; if (pic.nomdossier != null && !(pic.nomdossier.Equals("Photos Tablette")) && !(pic.nomdossier.Equals("Photos Perso"))) { tmp = string.Concat(dossierPhotosTablette, "\\", pic.nomdossier, "\\", pic.nomfichier); } else { tmp = string.Concat(dossierPhotosTablette, "\\", pic.nomfichier); } if (System.IO.File.Exists(tmp)) { button_Tablette.Content = "Supprimer du Dossier Tablette"; } else { button_Tablette.Content = "Ajouter au Dossier Tablette"; } } }
private void setFileListBox(CustomPicture item) { string[] files = null; if (item.parent != null) { files = Directory.GetFiles(dossierImage + "\\" + item.parent + "\\" + item.nomdossier + "\\"); } else { files = Directory.GetFiles(dossierImage + "\\" + item.nomdossier + "\\"); } List <CustomPicture> tutu = new List <CustomPicture>(); foreach (string file in files) { tutu.Add(new CustomPicture() { path = file, nomfichier = System.IO.Path.GetFileName(file), nomdossier = item.nomdossier, parent = item.parent }); } listView_fichier.ItemsSource = tutu; }