You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
5.0 KiB
192 lines
5.0 KiB
using Modèle;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using Persistance;
|
|
using Business;
|
|
|
|
namespace WpfApp1
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
///
|
|
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
{
|
|
public Manager Mgr => (Application.Current as App).LeManager;
|
|
public ManagerUsers MgrUser => (Application.Current as App).LeManagerUsers;
|
|
|
|
Nullable<Zone> zonePage{ get; set; }
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Mgr.LoadRequins();
|
|
|
|
MgrUser.LoadUsers();
|
|
|
|
DataContext = Mgr;
|
|
|
|
chargerUC();
|
|
|
|
Mgr.Requins.CollectionChanged += Requins_CollectionChanged;
|
|
|
|
}
|
|
|
|
private void Requins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
{
|
|
chargerUC();
|
|
}
|
|
|
|
private void Region_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
ChangeRegion();
|
|
}
|
|
|
|
|
|
public void ChangeRegion()
|
|
{
|
|
if (Region.SelectedIndex == 0)
|
|
{
|
|
zonePage = null;
|
|
chargerUC();
|
|
}
|
|
|
|
else if (Region.SelectedIndex == 1)
|
|
{
|
|
zonePage = Zone.ARCTIQUE;
|
|
viderListBox();
|
|
changerListBox(Zone.ARCTIQUE);
|
|
}
|
|
else if (Region.SelectedIndex == 2)
|
|
{
|
|
zonePage = Zone.ATLANTIQUE;
|
|
viderListBox();
|
|
changerListBox(Zone.ATLANTIQUE);
|
|
}
|
|
else if (Region.SelectedIndex == 3)
|
|
{
|
|
zonePage = Zone.INDIEN;
|
|
viderListBox();
|
|
changerListBox(Zone.INDIEN);
|
|
}
|
|
else if (Region.SelectedIndex == 4)
|
|
{
|
|
zonePage = Zone.PACIFIQUE;
|
|
viderListBox();
|
|
changerListBox(Zone.PACIFIQUE);
|
|
}
|
|
}
|
|
|
|
|
|
public void ContentControlSwapDes(Requin req)
|
|
{
|
|
contentControl.Content = new userControlDescription { requin = req };
|
|
}
|
|
|
|
|
|
|
|
public void ContentControlSwapAcc()
|
|
{
|
|
|
|
contentControl.Content = new userControlAcceuil();
|
|
}
|
|
|
|
|
|
public void ContentControlSwapEdit(Requin req)
|
|
{
|
|
contentControl.Content = new UserControlEdit { requin = req };
|
|
}
|
|
|
|
private void TextBox_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (Rechercher.Text == "Rechercher")
|
|
{
|
|
Rechercher.Text = "";
|
|
}
|
|
}
|
|
|
|
public void chargerUC()
|
|
{
|
|
viderListBox();
|
|
foreach (Requin req in Mgr.Requins)
|
|
{
|
|
laListe.Items.Add(new UserControlRequin { requin = req , type = UCrequinType.normal }) ;
|
|
}
|
|
}
|
|
|
|
public void changerListBox(Zone zone)
|
|
{
|
|
int test = 0;
|
|
viderListBox();
|
|
foreach (Requin req in Mgr.Requins)
|
|
{
|
|
foreach (Zone z in req.Repartition)
|
|
{
|
|
if (z == zone)
|
|
{
|
|
test++;
|
|
}
|
|
}
|
|
if (test > 0)
|
|
{
|
|
laListe.Items.Add((new UserControlRequin { requin = req }));
|
|
}
|
|
test = 0;
|
|
}
|
|
}
|
|
|
|
public void viderListBox()
|
|
{
|
|
if (laListe != null)
|
|
{
|
|
while (laListe.Items.Count > 0)
|
|
{
|
|
laListe.Items.RemoveAt(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Rechercher_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
viderListBox();
|
|
List<Requin> nvReq = new List<Requin>();
|
|
string rech = Rechercher.Text;
|
|
if (!string.IsNullOrWhiteSpace(rech))
|
|
{
|
|
nvReq = Mgr.rechercherRequins(Mgr.Requins, zonePage, rech);
|
|
foreach(Requin req in nvReq)
|
|
{
|
|
laListe.Items.Add(new UserControlRequin { requin = req });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ChangeRegion();
|
|
}
|
|
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") }));
|
|
}
|
|
}
|
|
}
|
|
}
|