class build avec dico, data binding pour l'acceuil

master
Clement LESME 1 year ago
parent f2b2cc8403
commit e89abf6fbf

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<DataToPersist xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CanYouBuildIt.DataContractPersistance"> <DataToPersist xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CanYouBuildIt.DataContractPersistance">
<lb xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model" /> <lb xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model">
<d2p1:Build>
<d2p1:dComp xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:id>0</d2p1:id>
<d2p1:image>pc1.png</d2p1:image>
<d2p1:prix>1294.6599</d2p1:prix>
</d2p1:Build>
<d2p1:Build>
<d2p1:dComp xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:id>1</d2p1:id>
<d2p1:image>pc2.png</d2p1:image>
<d2p1:prix>1288.0999</d2p1:prix>
</d2p1:Build>
</lb>
<lc xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model"> <lc xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model">
<d2p1:Composant> <d2p1:Composant>
<d2p1:id>Zalman Z10 Plus</d2p1:id> <d2p1:id>Zalman Z10 Plus</d2p1:id>
@ -56,6 +69,30 @@
<d2p1:prix>62.95</d2p1:prix> <d2p1:prix>62.95</d2p1:prix>
<d2p1:type>HDD</d2p1:type> <d2p1:type>HDD</d2p1:type>
</d2p1:Composant> </d2p1:Composant>
<d2p1:Composant>
<d2p1:id>Corsair Vengeance RGB RS 16 Go (2 x 8 Go) DDR4 3200 MHz CL16</d2p1:id>
<d2p1:lien>https://www.cdiscount.com/informatique/memoire-ram/memoire-ram-corsair-vengeance-rgb-rs-ddr4/f-10716-cor0840006649007.html?idOffre</d2p1:lien>
<d2p1:prix>60.7</d2p1:prix>
<d2p1:type>RAM</d2p1:type>
</d2p1:Composant>
<d2p1:Composant>
<d2p1:id>Samsung SSD 980 M.2 PCIe NVMe 1 To</d2p1:id>
<d2p1:lien>https://www.amazon.fr/s?k=samsung+ssd+980+m.2+pcie+nvme+1to&amp;ref=nb_sb_noss</d2p1:lien>
<d2p1:prix>57.37</d2p1:prix>
<d2p1:type>SSD</d2p1:type>
</d2p1:Composant>
<d2p1:Composant>
<d2p1:id>NZXT H5 Flow Noir</d2p1:id>
<d2p1:lien>https://www.ldlc.com/fiche/PB00532181.html</d2p1:lien>
<d2p1:prix>109.36</d2p1:prix>
<d2p1:type>Boitier</d2p1:type>
</d2p1:Composant>
<d2p1:Composant>
<d2p1:id>MARSGAMING MF-Duo</d2p1:id>
<d2p1:lien>https://www.amazon.fr/MARSGAMING-Ventilateurs-Rainbow-Ultra-Silencieux-Connexion/dp/B0BGY9M3ZG/</d2p1:lien>
<d2p1:prix>10.9</d2p1:prix>
<d2p1:type>Ventilateur</d2p1:type>
</d2p1:Composant>
</lc> </lc>
<lu xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model"> <lu xmlns:d2p1="http://schemas.datacontract.org/2004/07/CanYouBuildIt.Model">
<d2p1:Utilisateur> <d2p1:Utilisateur>
@ -83,8 +120,8 @@
<d2p1:Builds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /> <d2p1:Builds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:listBuild i:nil="true" /> <d2p1:listBuild i:nil="true" />
<d2p1:listFav xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /> <d2p1:listFav xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:password>0123</d2p1:password> <d2p1:password>nouna</d2p1:password>
<d2p1:username>tt</d2p1:username> <d2p1:username>nouna</d2p1:username>
</d2p1:Utilisateur> </d2p1:Utilisateur>
</lu> </lu>
</DataToPersist> </DataToPersist>

@ -0,0 +1,29 @@
<Frame>
<VerticalStackLayout>
<Image Source="{Binding manager.listBuild[0].image}"
Grid.Row="0" Grid.Column="0"
HeightRequest="200"/>
<Label Text="{Binding manager.listBuild[0].prix}"/>
</VerticalStackLayout>
</Frame>
<Image Source="pc3.png"
Grid.Row="0" Grid.Column="2"
HeightRequest="200"
/>
<Image Source="pc3.png"
Grid.Row="0" Grid.Column="4"
HeightRequest="200"
/>
<Image Source="pc2.png"
Grid.Row="1" Grid.Column="1"
HeightRequest="200"
/>
<Image Source="pc4.png"
Grid.Row="1" Grid.Column="3"
HeightRequest="200"
/>
<Image Source="pc2.png"
Grid.Row="1" Grid.Column="5"
HeightRequest="200"
/>

@ -16,9 +16,6 @@ namespace CanYouBuildIt.DataContractPersistance
public string FileName { get; set; } = "UserData.xml"; public string FileName { get; set; } = "UserData.xml";
public DataContractPers()
{ }
public DataToPersist chargeDonnee() public DataToPersist chargeDonnee()
{ {
//-- Chemin de sauvegarde --// //-- Chemin de sauvegarde --//

@ -1,71 +1,70 @@
using System; using System.Diagnostics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace CanYouBuildIt.Model namespace CanYouBuildIt.Model
{ {
[DataContract]
public class Build public class Build
{ {
[DataMember]
public static int nbId = 0; public static int nbId = 0;
[DataMember]
public int id { get; private set; } public int id { get; private set; }
[DataMember]
public float prix { get; private set; } public float prix { get; private set; }
[DataMember]
public string image { get; private set; } public string image { get; private set; }
public Composant boitier { get; private set; } [DataMember]
public Composant processeur { get; private set; } public Dictionary<TypeComposant, Composant> dComp { get; private set;}
public Composant ventirad { get; private set; }
public Composant cartemere { get; private set; }
public Composant memoirevive { get; private set; }
public Composant cartegraphique { get; private set; }
public Composant alimentation { get; private set; }
public Composant ventilateur { get; private set; }
public Composant SSD { get; private set; }
public Composant HDD { get; private set; }
//public List<Composant> listComp { get; private set; }
public Build(string image,Composant v1, Composant v2, Composant v3, Composant v4, Composant v5, Composant v6, Composant v7, Composant v8 = null, Composant v9 = null, Composant v10 = null)
public Build(string image,Composant boitier, Composant processeur, Composant ventirad, Composant cartemere, Composant memoirevive, Composant cartegraphique, Composant alimentation, Composant ventilateur = null, Composant ssd = null, Composant hdd = null)
{ {
id = nbId; id = nbId;
nbId = nbId +1; nbId = nbId +1;
this.image = image; this.image = image;
//-- ajoue de chaque élément + calcule du prix total Dictionary<TypeComposant, Composant> dComp = new Dictionary<TypeComposant, Composant>();
this.boitier = boitier;
prix = boitier.prix;
this.processeur = processeur;
prix = prix + processeur.prix;
this.ventirad = ventirad;
prix = prix + ventirad.prix;
this.cartemere = cartemere;
prix = prix + cartemere.prix;
this.memoirevive = memoirevive;
prix = prix + memoirevive.prix;
this.cartegraphique = cartegraphique;
prix = prix + cartegraphique.prix;
this.alimentation = alimentation;
prix = prix + alimentation.prix;
//-- element non obligatoire d'un build --// //-- ajoue de chaque élément + calcule du prix total
if (ventilateur != null) dComp.Add(v1.type,v1);
{ prix = prix + v1.prix;
this.ventilateur = ventilateur; dComp.Add(v2.type,v2);
prix = prix + ventilateur.prix; prix = prix + v2.prix;
} dComp.Add(v3.type,v3);
if (ssd != null) prix = prix + v3.prix;
{ dComp.Add(v4.type,v4);
this.SSD = ssd; prix = prix + v4.prix;
prix = prix + ssd.prix; dComp.Add(v5.type,v5);
} prix = prix + v5.prix;
if (hdd != null) dComp.Add(v6.type,v6);
prix = prix + v6.prix;
dComp.Add(v7.type,v7);
prix = prix + v7.prix;
if (v8 != null)
{ {
this.HDD = hdd; dComp.Add(v8.type, v8);
prix = prix + hdd.prix; prix = prix + v8.prix;
}
if (v9 != null)
{
dComp.Add(v9.type,v9);
prix = prix + v9.prix;
if (v10 != null)
{
dComp.Add(v10.type, v10);
prix = prix + v10.prix;
}
}
}
} }

@ -36,13 +36,20 @@ namespace CanYouBuildIt.Model
lc.Add(new Composant("Crucial BX500 1 To",TypeComposant.SSD,(float)74.95, "https://www.ldlc.com/fiche/PB00281733.html")); lc.Add(new Composant("Crucial BX500 1 To",TypeComposant.SSD,(float)74.95, "https://www.ldlc.com/fiche/PB00281733.html"));
lc.Add(new Composant("Seagate BarraCuda 2 To (ST2000DM005) ", TypeComposant.HDD,(float)62.95, "https://www.ldlc.com/fiche/PB00254339.html")); lc.Add(new Composant("Seagate BarraCuda 2 To (ST2000DM005) ", TypeComposant.HDD,(float)62.95, "https://www.ldlc.com/fiche/PB00254339.html"));
lc.Add(new Composant("Corsair Vengeance RGB RS 16 Go (2 x 8 Go) DDR4 3200 MHz CL16", TypeComposant.RAM, (float)60.70, "https://www.cdiscount.com/informatique/memoire-ram/memoire-ram-corsair-vengeance-rgb-rs-ddr4/f-10716-cor0840006649007.html?idOffre"));
lc.Add(new Composant("Samsung SSD 980 M.2 PCIe NVMe 1 To", TypeComposant.SSD, (float)57.37, "https://www.amazon.fr/s?k=samsung+ssd+980+m.2+pcie+nvme+1to&ref=nb_sb_noss"));
lc.Add(new Composant("NZXT H5 Flow Noir", TypeComposant.Boitier, (float)109.36, "https://www.ldlc.com/fiche/PB00532181.html"));
lc.Add(new Composant("MARSGAMING MF-Duo", TypeComposant.Ventilateur, (float)10.90, "https://www.amazon.fr/MARSGAMING-Ventilateurs-Rainbow-Ultra-Silencieux-Connexion/dp/B0BGY9M3ZG/"));
DataToPersist data = new DataToPersist(); DataToPersist data = new DataToPersist();
data.lu.AddRange(lu); data.lu.AddRange(lu);
data.lc.AddRange(lc); data.lc.AddRange(lc);
data.lb.Add(new Build("pc1.png",lc[0], lc[1], lc[2], lc[3], lc[6], lc[5], lc[4], null, lc[7], lc[8])); data.lb.Add(new Build("pc1.png", lc[0], lc[1], lc[2], lc[3], lc[4], lc[5], lc[6], lc[7], lc[8]));
data.lb.Add(new Build("pc2.png", lc[11], lc[1], lc[2], lc[3], lc[4], lc[5], lc[9], lc[8], lc[10], lc[12]));
return data; return data;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

@ -34,9 +34,13 @@
x:Name="Log"/> x:Name="Log"/>
</Grid> </Grid>
<Grid Margin="0,50,0,0">
<Grid
Margin="10,50,10,0"
BindingContext="{Binding manager.listBuild}"
x:Name="gridacc">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
<RowDefinition Height="1"/> <RowDefinition Height="1"/>
@ -50,40 +54,12 @@
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Frame>
<VerticalStackLayout>
<Image Source="{Binding listBuild[0].image}"
Grid.Row="0" Grid.Column="0"
HeightRequest="200"/>
<Label Text="{Binding listBuild[0].prix}"/>
</VerticalStackLayout>
</Frame>
<Image Source="pc3.png"
Grid.Row="0" Grid.Column="2"
HeightRequest="200"
/>
<Image Source="pc3.png"
Grid.Row="0" Grid.Column="4"
HeightRequest="200"
/>
<Image Source="pc2.png"
Grid.Row="1" Grid.Column="1"
HeightRequest="200"
/>
<Image Source="pc4.png"
Grid.Row="1" Grid.Column="3"
HeightRequest="200"
/>
<Image Source="pc2.png"
Grid.Row="1" Grid.Column="5"
HeightRequest="200"
/>
</Grid> </Grid>
<Grid Margin="0,250"> <Grid Margin="0,150">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />

@ -1,4 +1,5 @@
using CanYouBuildIt.Model; using CanYouBuildIt.Model;
using Microsoft.Maui.Controls;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
@ -6,16 +7,15 @@ namespace CanYouBuildIt.Views;
public partial class Acceuil : ContentPage public partial class Acceuil : ContentPage
{ {
public Manager manager=> (App.Current as App).manager; public Manager manager => (App.Current as App).manager;
bool connecte = false; bool connecte = false;
int user; int user;
public Acceuil() public Acceuil()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = manager; BindingContext = manager;
if (connecte) showGrid();
Log.Text = "{Binding ListUtil[user].username}";
} }
public Acceuil(int iduser) public Acceuil(int iduser)
@ -24,16 +24,20 @@ public partial class Acceuil : ContentPage
BindingContext = manager; BindingContext = manager;
connecte = true; connecte = true;
user = iduser; user = iduser;
string userN = manager.listUtil[user].username;
Log.Text = userN;
showGrid();
} }
//Ancien test //Ancien test
/*private void AddUtilisater(object sender, EventArgs e) /*public void AddUtilisater(object sender, EventArgs e)
{ {
Utilisateur utilisateur = new Utilisateur("Util1","pdm1"); Utilisateur utilisateur = new Utilisateur("Util1","pdm1");
Debug.WriteLine("Utilisateur créé"); Debug.WriteLine("Utilisateur créé");
}*/ }*/
private async void NavFav(object sender, EventArgs e) public async void NavFav(object sender, EventArgs e)
{ {
if (connecte) if (connecte)
await Navigation.PushAsync(new Favoris(user)); await Navigation.PushAsync(new Favoris(user));
@ -45,18 +49,46 @@ public partial class Acceuil : ContentPage
} }
} }
private async void NavCreds(object sender, EventArgs e) public async void NavCreds(object sender, EventArgs e)
{ {
await Navigation.PushAsync(new Credits()); await Navigation.PushAsync(new Credits());
} }
private async void NavLogin(object sender, EventArgs e) public async void NavLogin(object sender, EventArgs e)
{ {
await Navigation.PushAsync(new Login()); await Navigation.PushAsync(new Login());
} }
private void ToQuit(object sender, EventArgs e) public void ToQuit(object sender, EventArgs e)
{ {
App.Current.Quit(); App.Current.Quit();
} }
public void showGrid()
{
int row = 0;
for (int i = 0; i < 7 && i < manager.listBuild.Count(); ++i)
{
if (i % 2 == 0)
row = 0;
else
row = 1;
ImageButton imagebtn = new ImageButton()
{
Source = manager.listBuild[i].image,
HeightRequest = 200
};
Debug.WriteLine("position :");
Debug.WriteLine(i);
Debug.WriteLine(row);
Grid.SetRow(imagebtn, row);
Grid.SetColumn(imagebtn, i);
gridacc.Children.Add(imagebtn);
}
}
} }

@ -7,24 +7,24 @@ public partial class Credits : ContentPage
InitializeComponent(); InitializeComponent();
} }
private async void BackHome(object sender, EventArgs e) public async void BackHome(object sender, EventArgs e)
{ {
await Navigation.PopAsync(); await Navigation.PopAsync();
} }
private async void lienLDLC(object sender, EventArgs e) public async void lienLDLC(object sender, EventArgs e)
{ {
await Launcher.OpenAsync(new Uri("https://www.ldlc.com/configurateur/")); await Launcher.OpenAsync(new Uri("https://www.ldlc.com/configurateur/"));
} }
private async void lienCanYou(object sender, EventArgs e) public async void lienCanYou(object sender, EventArgs e)
{ {
await Launcher.OpenAsync(new Uri("https://www.systemrequirementslab.com/cyri")); await Launcher.OpenAsync(new Uri("https://www.systemrequirementslab.com/cyri"));
} }
private async void lienDenicheur(object sender, EventArgs e) public async void lienDenicheur(object sender, EventArgs e)
{ {
await Launcher.OpenAsync(new Uri("https://ledenicheur.fr/")); await Launcher.OpenAsync(new Uri("https://ledenicheur.fr/"));
} }

@ -12,7 +12,7 @@ public partial class Favoris : ContentPage
user = iduser; user = iduser;
} }
private async void BackHome(object sender, EventArgs e) public async void BackHome(object sender, EventArgs e)
{ {
await Navigation.PopAsync(); await Navigation.PopAsync();
} }

@ -4,6 +4,7 @@ using CanYouBuildIt.Model;
public partial class Login : ContentPage public partial class Login : ContentPage
{ {
public Manager manager => (App.Current as App).manager; public Manager manager => (App.Current as App).manager;
public Login() public Login()
{ {
InitializeComponent(); InitializeComponent();
@ -26,6 +27,8 @@ public partial class Login : ContentPage
if (idname == -1 && idmdp == -1) if (idname == -1 && idmdp == -1)
wrong.IsVisible = true; wrong.IsVisible = true;
else if(idname != idmdp)
wrong.IsVisible = true;
else if (idname != -1 && idmdp != -1) else if (idname != -1 && idmdp != -1)
{ {
valide.IsVisible = true; valide.IsVisible = true;

@ -77,6 +77,7 @@
Margin="0,30,0,0" Margin="0,30,0,0"
HorizontalOptions="Center" HorizontalOptions="Center"
WidthRequest="500"/> WidthRequest="500"/>
<!-- the cat : fcgvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv--> <!-- the cat : fcgvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv-->
<Label Text="Le mot de passe doit être composé d'au moins 4 caractères." <Label Text="Le mot de passe doit être composé d'au moins 4 caractères."
IsVisible="false" IsVisible="false"

@ -9,7 +9,7 @@ public partial class SignIn : ContentPage
InitializeComponent(); InitializeComponent();
} }
private async void BtValider(object sender, EventArgs e) public async void BtValider(object sender, EventArgs e)
{ {
vide.IsVisible = false; vide.IsVisible = false;
wrong.IsVisible = false; wrong.IsVisible = false;
@ -40,7 +40,7 @@ public partial class SignIn : ContentPage
} }
} }
private async void BackLogin(object sender, EventArgs e) public async void BackLogin(object sender, EventArgs e)
{ {
await Navigation.PopAsync(); await Navigation.PopAsync();
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save