diff --git a/Business/Manager.cs b/Business/Manager.cs index 09c27b0..ef92997 100644 --- a/Business/Manager.cs +++ b/Business/Manager.cs @@ -54,8 +54,6 @@ namespace Business { RequinsEdit.Add(rE); } - - SelectedRequin = null; } public void SaveRequins() diff --git a/Business/ManagerUsers.cs b/Business/ManagerUsers.cs index 59e3b1f..cca518a 100644 --- a/Business/ManagerUsers.cs +++ b/Business/ManagerUsers.cs @@ -48,7 +48,6 @@ namespace Business Experts.Add(e); } - SelectedUser = null; } diff --git a/Modèle/Modèle.csproj b/Modèle/Modèle.csproj index f208d30..4b3854b 100644 --- a/Modèle/Modèle.csproj +++ b/Modèle/Modèle.csproj @@ -4,4 +4,8 @@ net5.0 + + + + diff --git a/Persistance/DataContractPersistance.cs b/Persistance/DataContractPersistance.cs index 684b86e..afe34c8 100644 --- a/Persistance/DataContractPersistance.cs +++ b/Persistance/DataContractPersistance.cs @@ -77,7 +77,8 @@ namespace Persistance { Directory.CreateDirectory(FileUsers); } - + data.Users.Clear(); + data.Experts.Clear(); data.Users.AddRange(users); data.Experts.AddRange(experts); @@ -117,6 +118,10 @@ namespace Persistance Directory.CreateDirectory(FilePath); } + + dataReq.Requins.Clear(); + dataReq.RequinsAdd.Clear(); + dataReq.RequinsEdit.Clear(); dataReq.Requins.AddRange(reqs); dataReq.RequinsAdd.AddRange(reqsAdd); dataReq.RequinsEdit.AddRange(reqsEdit); diff --git a/WpfApp1/AddAShark.xaml.cs b/WpfApp1/AddAShark.xaml.cs index e93e022..d44bdab 100644 --- a/WpfApp1/AddAShark.xaml.cs +++ b/WpfApp1/AddAShark.xaml.cs @@ -89,6 +89,12 @@ namespace WpfApp1 loopEnd: + if (!video.Contains("Videos/")) + { + MessageBox.Show("Les vidéos doivent venir obligatoirement du répertoire Videos"); + return; + } + if (Arct.IsChecked == true) { diff --git a/WpfApp1/DescriptionAdd.xaml.cs b/WpfApp1/DescriptionAdd.xaml.cs index 0ffde4d..d3340cd 100644 --- a/WpfApp1/DescriptionAdd.xaml.cs +++ b/WpfApp1/DescriptionAdd.xaml.cs @@ -44,7 +44,15 @@ namespace WpfApp1 } } - + private BitmapImage urlEnBitmap(string url) + { + var path = @url; + BitmapImage bitmap = new BitmapImage(); + bitmap.BeginInit(); + bitmap.UriSource = new Uri(path, UriKind.Absolute); + bitmap.EndInit(); + return bitmap; + } public void uptadeUi(Requin requin) { @@ -56,20 +64,29 @@ namespace WpfApp1 funFact.Text = requin.FunFact; consPic.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute)); - - var pathPhoto = @requin.Photo; - BitmapImage bitmap = new BitmapImage(); - bitmap.BeginInit(); - bitmap.UriSource = new Uri(pathPhoto, UriKind.Absolute); - bitmap.EndInit(); - photo.Source = bitmap; - - var pathCarte = @requin.PhotoCarte; - BitmapImage bitmapMap = new BitmapImage(); - bitmapMap.BeginInit(); - bitmapMap.UriSource = new Uri(pathCarte, UriKind.Absolute); - bitmapMap.EndInit(); - cartePic.Source = bitmapMap; + + if (requin.Photo.Contains("Images/")) //Vérifie si la photo vient d'internet ou du dossier + { + photo.Source = new BitmapImage(new Uri(requin.Photo, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.Photo); + photo.Source = bitmap; + } + + + if (requin.PhotoCarte.Contains("Images/")) + { + cartePic.Source = new BitmapImage(new Uri(requin.PhotoCarte, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.PhotoCarte); + cartePic.Source = bitmap; + } } private void exit_Click(object sender, RoutedEventArgs e) diff --git a/WpfApp1/DescriptionEdit.xaml.cs b/WpfApp1/DescriptionEdit.xaml.cs index a821c91..0592827 100644 --- a/WpfApp1/DescriptionEdit.xaml.cs +++ b/WpfApp1/DescriptionEdit.xaml.cs @@ -52,6 +52,16 @@ namespace WpfApp1 } } + private BitmapImage urlEnBitmap(string url) + { + var path = @url; + BitmapImage bitmap = new BitmapImage(); + bitmap.BeginInit(); + bitmap.UriSource = new Uri(path, UriKind.Absolute); + bitmap.EndInit(); + return bitmap; + } + public void uptadeUi(Requin requin) { @@ -62,15 +72,27 @@ namespace WpfApp1 vid.Source = new Uri(requin.Video, UriKind.RelativeOrAbsolute); funFact.Text = requin.FunFact; consPic.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute)); - cartePic.Source = new BitmapImage(new Uri(requin.PhotoCarte, UriKind.RelativeOrAbsolute)); - var urlPhoto = "@" + requin.Photo; - if (requin.Photo.Contains("Images/")) + if (requin.Photo.Contains("Images/")) //Vérifie si la photo vient d'internet ou du dossier { photo.Source = new BitmapImage(new Uri(requin.Photo, UriKind.RelativeOrAbsolute)); } else { - photo.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute)); + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.Photo); + photo.Source = bitmap; + } + + + if (requin.PhotoCarte.Contains("Images/")) + { + cartePic.Source = new BitmapImage(new Uri(requin.PhotoCarte, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.PhotoCarte); + cartePic.Source = bitmap; } } @@ -82,10 +104,30 @@ namespace WpfApp1 sciNameOld.Text = oldRequin.NomSci; descOld.Text = oldRequin.Description; vidOld.Source = new Uri(oldRequin.Video, UriKind.Relative); - photoOld.Source = new BitmapImage(new Uri(oldRequin.Photo, UriKind.Relative)); funFactOld.Text = oldRequin.FunFact; consPicOld.Source = new BitmapImage(new Uri(url, UriKind.Relative)); - cartePicOld.Source = new BitmapImage(new Uri(oldRequin.PhotoCarte, UriKind.Relative)); + if (requin.Photo.Contains("Images/")) //Vérifie si la photo vient d'internet ou du dossier + { + photoOld.Source = new BitmapImage(new Uri(requinOld.Photo, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requinOld.Photo); + photoOld.Source = bitmap; + } + + + if (requin.PhotoCarte.Contains("Images/")) + { + cartePicOld.Source = new BitmapImage(new Uri(requinOld.PhotoCarte, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requinOld.PhotoCarte); + cartePicOld.Source = bitmap; + } } private void remplacer_Click(object sender, RoutedEventArgs e) diff --git a/WpfApp1/Images/carteArctique.png b/WpfApp1/Images/carteArctique.png new file mode 100644 index 0000000..fb4c98c Binary files /dev/null and b/WpfApp1/Images/carteArctique.png differ diff --git a/WpfApp1/Images/carteAtlantique.png b/WpfApp1/Images/carteAtlantique.png new file mode 100644 index 0000000..916f671 Binary files /dev/null and b/WpfApp1/Images/carteAtlantique.png differ diff --git a/WpfApp1/Images/carteIndien.png b/WpfApp1/Images/carteIndien.png new file mode 100644 index 0000000..65a5904 Binary files /dev/null and b/WpfApp1/Images/carteIndien.png differ diff --git a/WpfApp1/Images/cartePacifique.png b/WpfApp1/Images/cartePacifique.png new file mode 100644 index 0000000..e2ac639 Binary files /dev/null and b/WpfApp1/Images/cartePacifique.png differ diff --git a/WpfApp1/Images/cartemaismieuxman.png b/WpfApp1/Images/cartemaismieuxman.png index fdbe650..30a011c 100644 Binary files a/WpfApp1/Images/cartemaismieuxman.png and b/WpfApp1/Images/cartemaismieuxman.png differ diff --git a/WpfApp1/MainWindow.xaml b/WpfApp1/MainWindow.xaml index a254281..507374a 100644 --- a/WpfApp1/MainWindow.xaml +++ b/WpfApp1/MainWindow.xaml @@ -20,7 +20,7 @@ - + diff --git a/WpfApp1/MainWindow.xaml.cs b/WpfApp1/MainWindow.xaml.cs index 46d6471..58c7ecc 100644 --- a/WpfApp1/MainWindow.xaml.cs +++ b/WpfApp1/MainWindow.xaml.cs @@ -32,6 +32,8 @@ namespace WpfApp1 Nullable zonePage{ get; set; } + public bool aChanger = false; + public MainWindow() { @@ -56,38 +58,64 @@ namespace WpfApp1 } - public void ChangeRegion() + private void ChangeRegion() { if (Region.SelectedIndex == 0) { zonePage = null; - chargerUC(); } else if (Region.SelectedIndex == 1) { zonePage = Zone.ARCTIQUE; - viderListBox(); - changerListBox(Zone.ARCTIQUE); + aChanger = true; } else if (Region.SelectedIndex == 2) { zonePage = Zone.ATLANTIQUE; - viderListBox(); - changerListBox(Zone.ATLANTIQUE); + aChanger = true; } else if (Region.SelectedIndex == 3) { zonePage = Zone.INDIEN; - viderListBox(); - changerListBox(Zone.INDIEN); + aChanger = true; } else if (Region.SelectedIndex == 4) { zonePage = Zone.PACIFIQUE; - viderListBox(); - changerListBox(Zone.PACIFIQUE); + aChanger = true; + } + if (aChanger == true) + { + ChangerAffichage(zonePage); + } + } + + + public void ChangeRegionAvecMap(Nullable z) + { + if (z == null) + { + Region.SelectedIndex = 0; + } + else if (z == Zone.ARCTIQUE) + { + Region.SelectedIndex = 1; + } + else if (z == Zone.ATLANTIQUE) + { + Region.SelectedIndex = 2; } + else if (z == Zone.INDIEN) + { + Region.SelectedIndex = 3; + } + else if (z == Zone.PACIFIQUE) + { + Region.SelectedIndex = 4; + } + zonePage = z; + ChangerAffichage(z); } @@ -127,10 +155,14 @@ namespace WpfApp1 } } - public void changerListBox(Zone zone) + private void ChangerAffichage(Nullable zone) { int test = 0; viderListBox(); + if (zone == null) + { + chargerUC(); + } foreach (Requin req in Mgr.Requins) { foreach (Zone z in req.Repartition) @@ -142,10 +174,11 @@ namespace WpfApp1 } if (test > 0) { - laListe.Items.Add((new UserControlRequin { requin = req })); + laListe.Items.Add(new UserControlRequin { requin = req }); } test = 0; } + contentControl.Content = new userControlAcceuil { zone = zone }; } public void viderListBox() @@ -181,7 +214,7 @@ namespace WpfApp1 } if (rech == "Shrek" || rech=="shrek") { - laListe.Items.Add((new UserControlRequin { requin = new Requin("Shrek", "Ogre", "I see you are a person of culture as well.\n\nFais ton grrrrr", "Images/shrekin.png", "Videos/shrekin.mp4", "Images/shrekMap.png", Conservation.EW, null, "GET OUT OF MY SEA") })); + laListe.Items.Add(new UserControlRequin { requin = new Requin("Shrek", "Ogre", "I see you are a person of culture as well.\n\nFais ton grrrrr", "Images/shrekin.png", "Videos/shrekin.mp4", "Images/shrekMap.png", Conservation.EW, null, "GET OUT OF MY SEA") }); } } } diff --git a/WpfApp1/Persistance/ficReqs b/WpfApp1/Persistance/ficReqs index 69c09b9..cbef1d0 100644 --- a/WpfApp1/Persistance/ficReqs +++ b/WpfApp1/Persistance/ficReqs @@ -1,19 +1,6 @@ - - wow il est trop bo - (C'est pas un vrai requin) - mon requin adoré - trop cool ce requin - Images/Dormeur-Mexicain.png - Images/rep_Heterodontus_mexicanus.png - - ATLANTIQUE - - EW - Videos/Vid-dormeur-mexicain.mp4 - C'est un requin pas ultra banal Il est vraiment pas banal @@ -54,7 +41,7 @@ Videos/Vid-Requin-Blanc.mp4 - wow il est trop bo + wow il est trop joli (C'est pas un vrai requin) mon requin adoré trop cool ce requin @@ -64,63 +51,36 @@ ATLANTIQUE EW - Videos/Vid-dormeur-mexicain.mp4 - - - C'est un requin pas ultra banal - Il est vraiment pas banal - Req1 - Le requin pas banal - Images/White_shark.png - Images/rep_Heterodontus_mexicanus.png - - PACIFIQUE - - EX - Videos/Vid-dormeur-mexicain.mp4 - - - C'est un requin pas ultra banal - Il est vraiment pas banal - leRequinAjouté - Le requin pas banal - Images/White_shark.png - Images/rep_Heterodontus_mexicanus.png - - PACIFIQUE - - EX - Videos/Vid-dormeur-mexicain.mp4 + Videos/Vid-Requin-Blanc.mp4 - C'est un requin ultra banal - En fait il est giga banal - Banane - Le requin banal + le vrai requin + zfz + fzf + flpzeflk Images/White_shark.png - Images/rep_Heterodontus_mexicanus.png + Images/White_shark.png - ATLANTIQUE + ARCTIQUE + INDIEN - EW + VU Videos/Vid-Requin-Blanc.mp4 - wow il est joli + C'est un requin pas ultra banal Il est vraiment pas banal Req1 Le requin pas banal Images/White_shark.png Images/rep_Heterodontus_mexicanus.png - ATLANTIQUE - INDIEN PACIFIQUE - CR + EX Videos/Vid-dormeur-mexicain.mp4 diff --git a/WpfApp1/Persistance/ficUsers b/WpfApp1/Persistance/ficUsers index 742e0a1..850435a 100644 --- a/WpfApp1/Persistance/ficUsers +++ b/WpfApp1/Persistance/ficUsers @@ -7,22 +7,21 @@ 2022-06-09T14:59:29.3884138+02:00 bob - - salut - hey - 2022-06-09T14:59:29.3884138+02:00 - bob - - a + salut 3 - a - salut + bernard@gmail.com + bernie + 1 + + + bernard + lol 0 diff --git a/WpfApp1/UserControlEdit.xaml.cs b/WpfApp1/UserControlEdit.xaml.cs index 81177ed..7593bc3 100644 --- a/WpfApp1/UserControlEdit.xaml.cs +++ b/WpfApp1/UserControlEdit.xaml.cs @@ -151,6 +151,13 @@ namespace WpfApp1 } loopEnd: + + if (!video.Contains("Videos/")) + { + MessageBox.Show("Les vidéos doivent venir obligatoirement du répertoire Videos"); + return; + } + if (Arct.IsChecked == true) { test++; diff --git a/WpfApp1/Videos/GrandRequinBlanc.mp4 b/WpfApp1/Videos/GrandRequinBlanc.mp4 new file mode 100644 index 0000000..b2f5769 Binary files /dev/null and b/WpfApp1/Videos/GrandRequinBlanc.mp4 differ diff --git a/WpfApp1/Videos/Le requin Renard.mp4 b/WpfApp1/Videos/Le requin Renard.mp4 new file mode 100644 index 0000000..66b326f Binary files /dev/null and b/WpfApp1/Videos/Le requin Renard.mp4 differ diff --git a/WpfApp1/Videos/Le requin-bouledogue.mp4 b/WpfApp1/Videos/Le requin-bouledogue.mp4 new file mode 100644 index 0000000..f4d53ed Binary files /dev/null and b/WpfApp1/Videos/Le requin-bouledogue.mp4 differ diff --git a/WpfApp1/WpfApp1.csproj b/WpfApp1/WpfApp1.csproj index 45d9a05..ada4f23 100644 --- a/WpfApp1/WpfApp1.csproj +++ b/WpfApp1/WpfApp1.csproj @@ -8,8 +8,12 @@ + + + + @@ -44,12 +48,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/WpfApp1/userControlAcceuil.xaml b/WpfApp1/userControlAcceuil.xaml index e089a0c..b9e8a56 100644 --- a/WpfApp1/userControlAcceuil.xaml +++ b/WpfApp1/userControlAcceuil.xaml @@ -20,7 +20,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WpfApp1/userControlAcceuil.xaml.cs b/WpfApp1/userControlAcceuil.xaml.cs index 9a9c443..f6f1951 100644 --- a/WpfApp1/userControlAcceuil.xaml.cs +++ b/WpfApp1/userControlAcceuil.xaml.cs @@ -37,11 +37,25 @@ namespace WpfApp1 } } + + private Nullable _zone; + public Nullable zone + { + get { return _zone; } + set + { + _zone = value; + choixCarte(_zone); + } + } + + + + + + private void add_Click(object sender, RoutedEventArgs e) - {/* - var addSharkWindow = new AddAShark(); - addSharkWindow.ShowDialog(); - */ + { if (MgrUser.SelectedUser == null) { MessageBox.Show("Vous avez besoin d'être connecté pour accéder à cette fonctionnalité"); @@ -75,5 +89,49 @@ namespace WpfApp1 infoUser.ShowDialog(); } } + + + + + private void Arctique_MouseDown(object sender, MouseButtonEventArgs e) + { + ((MainWindow)System.Windows.Application.Current.MainWindow).ChangeRegionAvecMap(Zone.ARCTIQUE); + } + private void Atlantique_MouseDown(object sender, MouseButtonEventArgs e) + { + ((MainWindow)System.Windows.Application.Current.MainWindow).ChangeRegionAvecMap(Zone.ATLANTIQUE); + } + private void Indien_MouseDown(object sender, MouseButtonEventArgs e) + { + ((MainWindow)System.Windows.Application.Current.MainWindow).ChangeRegionAvecMap(Zone.INDIEN); + } + private void Pacifique_MouseDown(object sender, MouseButtonEventArgs e) + { + ((MainWindow)System.Windows.Application.Current.MainWindow).ChangeRegionAvecMap(Zone.PACIFIQUE); + } + + private void choixCarte(Nullable zone) + { + if (zone == null) + { + Carte = "Images/cartemaismieuxman.png"; + } + else if (zone == Zone.ATLANTIQUE) + { + Carte = "Images/carteAtlantique.png"; + } + else if(zone == Zone.ARCTIQUE) + { + Carte = "Images/carteArctique.png"; + } + else if(zone == Zone.INDIEN) + { + Carte = "Images/carteIndien.png"; + } + else if(zone == Zone.PACIFIQUE) + { + Carte = "Images/cartePacifique.png"; + } + } } } diff --git a/WpfApp1/userControlDescription.xaml.cs b/WpfApp1/userControlDescription.xaml.cs index a760740..a726d86 100644 --- a/WpfApp1/userControlDescription.xaml.cs +++ b/WpfApp1/userControlDescription.xaml.cs @@ -2,7 +2,9 @@ using Modèle; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -14,6 +16,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using VideoLibrary; + namespace WpfApp1 { @@ -45,7 +49,6 @@ namespace WpfApp1 private void exit_Click(object sender, RoutedEventArgs e) { ((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapAcc(); - Mgr.SelectedRequin = null; } private void edit_Click(object sender, RoutedEventArgs e) @@ -63,31 +66,54 @@ namespace WpfApp1 } + + private BitmapImage urlEnBitmap(string url) + { + var path = @url; + BitmapImage bitmap = new BitmapImage(); + bitmap.BeginInit(); + bitmap.UriSource = new Uri(path, UriKind.Absolute); + bitmap.EndInit(); + return bitmap; + } + public void UptadeUi(Requin requin) { string url = "Images/" + requin.StatutCons.ToString() + ".png"; nameReq.Text = requin.Nom; sciName.Text = requin.NomSci; desc.Text = requin.Description; - vid.Source = new Uri(requin.Video, UriKind.Relative); + funFact.Text = requin.FunFact; consPic.Source = new BitmapImage(new Uri(url, UriKind.Relative)); - if (requin.Photo.Contains("Images/")) + //La source des vidéos ne peut pas venir d'internet ou de youtube avec plus de temps nous aurions rajouté cette fonctionnalité + vid.Source = new Uri(requin.Video, UriKind.Relative); + + //La source des photos peuvent venir d'internet + if (requin.Photo.Contains("Images/")) //Vérifie si la photo vient d'internet ou du dossier { photo.Source = new BitmapImage(new Uri(requin.Photo, UriKind.RelativeOrAbsolute)); } else { - photo.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute)); + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.Photo); + photo.Source = bitmap; + } + + + if (requin.PhotoCarte.Contains("Images/")) + { + cartePic.Source = new BitmapImage(new Uri(requin.PhotoCarte, UriKind.RelativeOrAbsolute)); + } + else + { + BitmapImage bitmap = new BitmapImage(); + bitmap = urlEnBitmap(requin.PhotoCarte); + cartePic.Source = bitmap; } - var pathCarte = @requin.PhotoCarte; - BitmapImage bitmapMap = new BitmapImage(); - bitmapMap.BeginInit(); - bitmapMap.UriSource = new Uri(pathCarte, UriKind.Absolute); - bitmapMap.EndInit(); - cartePic.Source = bitmapMap; } private void vid_MouseDown(object sender, MouseButtonEventArgs e)