C#/data_binding-contract #42

Merged
antoine.perederii merged 8 commits from C#/data_binding-contract into master 2 years ago

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

@ -15,12 +15,13 @@ public partial class App : Application
MyManager.DataLoad();
MyManager.Persistence = new DataContractPersistance.DataContractPers();
MyManager.DataSave();
InitializeComponent();
MainPage = new AppShell();
//MyManager.DataSave();
}
}
}

@ -4,23 +4,25 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Banquale.Views"
xmlns:balance="clr-namespace:Banquale.Views.Balance"
xmlns:transfer="clr-namespace:Banquale.Views.Transfer"
Shell.FlyoutBehavior="Disabled">
<ShellContent ContentTemplate="{DataTemplate views:ConnectionPage}"
Route="connection"/>
<!--<ShellContent ContentTemplate="{DataTemplate views:ConnectionPage}"
Route="connection"/>-->
<TabBar>
<ShellContent
Title="Solde"
ContentTemplate="{DataTemplate views:BalancePage}"
ContentTemplate="{DataTemplate balance:BalancePage}"
Route="balance"
Icon="home.png"/>
<ShellContent
Title="Transactions"
ContentTemplate="{DataTemplate views:MenuTransferPage}"
ContentTemplate="{DataTemplate transfer:MenuTransferPage}"
Route="menu"
Icon="transactions.png"/>

@ -1,5 +1,6 @@
using Banquale.Views;
using Banquale.Views.Category;
using Banquale.Views.Transfer;
namespace Banquale;
public partial class AppShell : Shell
@ -8,7 +9,7 @@ public partial class AppShell : Shell
{
InitializeComponent();
Routing.RegisterRoute("balance/categorydetails", typeof(CategoryPage));
Routing.RegisterRoute("newpagedetails", typeof(NewPage1));
Routing.RegisterRoute("balance/newpagedetails", typeof(NewPage1));
Routing.RegisterRoute("menu/requestdetails", typeof(RequestPage));
Routing.RegisterRoute("menu/ribdetails", typeof(RibPage));
Routing.RegisterRoute("menu/transferdetails", typeof(TransferPage));

@ -66,6 +66,8 @@
<None Remove="Resources\Images\helpIcon.svg" />
<None Remove="Stub\" />
<None Remove="DataContractPersistance\" />
<None Remove="Views\Balance\" />
<None Remove="Views\Category\" />
</ItemGroup>
<ItemGroup>
<MauiXaml Remove="Resources\Images\Images.xaml" />
@ -78,5 +80,7 @@
<Folder Include="Persistances\" />
<Folder Include="Stub\" />
<Folder Include="DataContractPersistance\" />
<Folder Include="Views\Balance\" />
<Folder Include="Views\Category\" />
</ItemGroup>
</Project>

@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Banquale.Model
{
[DataContract]
public class Account : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
@ -17,9 +19,10 @@ namespace Banquale.Model
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
[DataMember]
public double Balance
{
get => Balance;
get => balance;
set
{
if (balance == value)
@ -30,8 +33,8 @@ namespace Banquale.Model
}
private double balance;
[DataMember]
public string Name
{
get => name;
@ -45,6 +48,8 @@ namespace Banquale.Model
}
private string name;
[DataMember]
public string IBAN
{
get => iban;
@ -66,15 +71,24 @@ namespace Banquale.Model
IBAN = iban;
}
public List<Transactions> TransactionsList { get; set; }
[DataMember]
public List<Transactions> TransactionsList { get; set; } = new List<Transactions>();
//public bool DoTransactions(string name, string IBAN, float sum)
//{
// List<Transactions> transactions.add(sum);
// if ()
// if()
// return true;
//}
internal static void DoTransactions(Entry name, Entry iban, Entry sum)
{
Debug.WriteLine(name);
Debug.WriteLine(iban);
Debug.WriteLine(sum);
Debug.WriteLine("Transaction successed !");
}
//public bool DoRequest(string name, string IBAN, float sum)
//{
// List<Transactions> transactions.add(sum);
@ -84,8 +98,21 @@ namespace Banquale.Model
//public void AskForHelp(string type, string type2, string message)
//{
// Console.WriteLine("Help button pressed !");
//}
internal static void AskForHelp(Entry request, Entry subject, Editor message)
{
Debug.WriteLine(request.Text);
Debug.WriteLine(subject);
Debug.WriteLine(message);
Debug.WriteLine("Help button pressed !");
//throw new NotImplementedException();
}
internal static void DoRequest(Entry name, Entry iBAN, Entry sum)
{
throw new NotImplementedException();
}
}
}

@ -12,9 +12,9 @@ namespace Banquale.Model
public class Customer : Person
{
[DataMember]
public List<Account> AccountsList { get; private set; }
public List<Account> AccountsList { get; private set; } = new List<Account>();
//private unsigned int NbAccounts { get; private set; }
//private uint NbAccounts { get; set; } = AccountsList.Count;
public Customer(string name, string firstName, string password) : base(name, firstName, password)

@ -12,6 +12,8 @@ namespace Banquale.Model
[DataMember]
public List<Transactions> TransactionsList { get; private set; }
public List<Account> AccountList { get; private set; }
public IPersistenceManager Persistence { get; set; }
public Manager(IPersistenceManager persistence) {

@ -1,7 +1,9 @@
using System.ComponentModel;
using System.Runtime.Serialization;
namespace Banquale.Model
{
[DataContract]
public class Transactions : INotifyPropertyChanged
{
@ -9,7 +11,9 @@ namespace Banquale.Model
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Type
[DataMember]
public int Type
{
get => type;
set
@ -20,9 +24,11 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Type));
}
}
[DataMember]
private int type;
[DataMember]
public Double Sum
{
get => sum;
@ -34,8 +40,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Sum));
}
}
[DataMember]
private Double sum;
[DataMember]
public Account InvolvedAccounts
{
get => involvedAccounts;
@ -47,8 +55,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(InvolvedAccounts));
}
}
[DataMember]
private Account involvedAccounts;
[DataMember]
public string Category
{
get => category;
@ -60,8 +70,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Category));
}
}
[DataMember]
private string category;
[DataMember]
public DateTime Date
{
get => date;
@ -73,6 +85,7 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Date));
}
}
[DataMember]
private DateTime date;
public Transactions(int type, Double sum, Account involvedAccounts, string category, DateTime date)

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using Banquale.Model;
namespace Banquale.Stub
@ -21,18 +22,29 @@ namespace Banquale.Stub
Transactions Transactions2 = new Transactions(1, 54.99, Account2, "Test", new DateTime(2022, 8, 15));
Transactions Transactions3 = new Transactions(0, 1000, Account3, "Test", new DateTime(2020, 9, 1));
Console.WriteLine(Customer1);
List<Customer> ListeCustomers = new List<Customer>();
List<Transactions> ListeTransactions = new List<Transactions>();
//List<Account> ListeAccount = new List<Account>();
//ListeAccount.Add( Account1 );
//ListeAccount.Add(Account2);
//ListeAccount.Add(Account3);
ListeCustomers.Add(Customer1);
ListeCustomers.Add(Customer2);
ListeCustomers.Add(Customer3);
return (ListeCustomers, ListeTransactions /*, ListeAccount*/);
Debug.WriteLine(Customer1.Name, Customer1.Password);
List<Customer> CustomersList = new List<Customer>();
List<Transactions> TransactionsList= new List<Transactions>();
List<Account> AccountsList = new List<Account>();
Account1.TransactionsList.Add(Transactions1);
Account2.TransactionsList.Add(Transactions2);
//AccountsList.Add(Account1);
//AccountsList.Add(Account2);
//AccountsList.Add(Account3);
Customer1.AccountsList.Add(Account1);
Customer1.AccountsList.Add(Account2);
CustomersList.Add(Customer1);
CustomersList.Add(Customer2);
CustomersList.Add(Customer3);
return (CustomersList, TransactionsList /*, AccountsList*/);
}
public void DataSave(List<Customer> c, List<Transactions> t)

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Banquale.Views"
xmlns:local="clr-namespace:Banquale.Views.Balance"
xmlns:model="clr-namespace:Banquale.Model"
x:Class="Banquale.Views.BalancePage"
x:Class="Banquale.Views.Balance.BalancePage"
Title="BalancePage"
Shell.NavBarIsVisible="False"
>
Shell.NavBarIsVisible="False">
<Grid RowDefinitions="auto, *">
<Grid BackgroundColor="Beige"
@ -17,41 +16,49 @@
RowDefinitions="auto, 35, *"
ColumnDefinitions="250, auto"
Grid.Row="0"
Margin="30"
>
<Button Clicked="OnButtonClicked" />
Margin="30">
<Label
Text="Compte Professionnel"
HorizontalOptions="Center"
BackgroundColor="AliceBlue"
Margin="0, 15, 0, 0"/>
<Label
Text="{Binding Name}"
<HorizontalStackLayout
Grid.Row="1"
Grid.ColumnSpan="2"
HorizontalOptions="Center"
TextColor="Black"
BackgroundColor="SaddleBrown"/> <!-- colspan permet de redefinir la taille de la colonne -->
<Grid ColumnDefinitions="*, *" Grid.Row="2" >
HorizontalOptions="Center">
<Label
Text="{Binding CustomersList[0].Name}"
Margin="0, 0, 5, 0"/>
<Label
Text="{Binding CustomersList[0].FirstName}"
Margin="5, 0, 0, 0"/>
</HorizontalStackLayout>
<Grid ColumnDefinitions="auto, auto, auto"
Grid.Row="2"
HorizontalOptions="Center">
<Label
Text="Solde"
WidthRequest="75"
TextColor="Black"
HorizontalOptions="Center"/>
<Label
Text="{Binding Balance}"
Text="{Binding CustomersList[0].AccountsList[0].Balance} "
Grid.Column="1"
MinimumWidthRequest="70"
TextColor="Black"
HorizontalOptions="Center"/>
Margin="0, 0, 5, 0"/>
<Label Text="€"
Grid.Column="2"/>
</Grid>
</Grid>
<ScrollView
Grid.Row="1">
<FlexLayout JustifyContent="Center"
@ -60,6 +67,10 @@
Direction="Row"
Wrap="Wrap">
<Button Text="NewPage1"
Clicked="OnButtonClicked"
MinimumWidthRequest="250"/>
<local:BalanceView/>
<local:BalanceView/>
<local:BalanceView/>

@ -0,0 +1,21 @@
using Banquale.Model;
namespace Banquale.Views.Balance;
public partial class BalancePage : ContentPage
{
public Manager Mgr => (App.Current as App).MyManager;
public BalancePage()
{
InitializeComponent();
BindingContext = Mgr;
//BindingContext = new Account(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004");
}
public async void OnButtonClicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new NewPage1());
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.BalanceView">
x:Class="Banquale.Views.Balance.BalanceView">
<VerticalStackLayout>
<BoxView BackgroundColor="Black"
HorizontalOptions="FillAndExpand"

@ -1,4 +1,4 @@
namespace Banquale.Views;
namespace Banquale.Views.Balance;
public partial class BalanceView : ContentView
{

@ -1,20 +0,0 @@
using Banquale.Model;
namespace Banquale.Views;
public partial class BalancePage : ContentPage
{
//public Manager Mgr { get; private set; } = new Manager();
public BalancePage()
{
InitializeComponent();
BindingContext = new Account(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004"); ;
}
public async void OnButtonClicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new NewPage1());
}
}

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.CategoryPage"
xmlns:local="clr-namespace:Banquale.Views"
x:Class="Banquale.Views.Category.CategoryPage"
xmlns:local="clr-namespace:Banquale.Views.Category"
Title="CategoryPage"
BackgroundColor="White">

@ -1,4 +1,4 @@
namespace Banquale.Views;
namespace Banquale.Views.Category;
public partial class CategoryPage : ContentPage
{

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.CategoryView">
x:Class="Banquale.Views.Category.CategoryView">
<VerticalStackLayout>
<BoxView HorizontalOptions="FillAndExpand"

@ -1,4 +1,4 @@
namespace Banquale.Views;
namespace Banquale.Views.Category;
public partial class CategoryView : ContentView
{

@ -13,7 +13,8 @@
<Entry Placeholder="Quel est votre demande ?"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="Request"/>
</Frame>
@ -25,7 +26,8 @@
<Entry Placeholder="Quel est le sujet de votre demande ?"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="Subject"/>
</Frame>
@ -35,7 +37,8 @@
Margin="0, 0, 0, 10"
Padding="15, 5, 15, 5">
<Editor Placeholder="Decrivez votre demande ici." />
<Editor Placeholder="Decrivez votre demande ici."
x:Name="Message"/>
</Frame>

@ -1,4 +1,5 @@
namespace Banquale.Views;
using Banquale.Model;
namespace Banquale.Views;
public partial class HelpPage : ContentPage
{
@ -9,6 +10,7 @@ public partial class HelpPage : ContentPage
public async void Send_Clicked(Object sender, EventArgs e)
{
Account.AskForHelp(Request, Subject, Message);
await Shell.Current.GoToAsync("//balance");
}

@ -26,7 +26,7 @@ public partial class NewPage1 : ContentPage
public async void ArrowBack(object sender, EventArgs e)
{
await Navigation.PopAsync();
await Shell.Current.GoToAsync("//balance");
}
}

@ -1,18 +0,0 @@
using Banquale.Model;
namespace Banquale.Views;
public partial class RequestPage : ContentPage
{
public RequestPage()
{
InitializeComponent();
}
//public async void Send_Clicked(Object sender, EventArgs e)
//{
// await Shell.Current.GoToAsync("//balance");
//}
//Client.DoRequest(this.name, this.IBAN, )
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.MenuTransferPage"
x:Class="Banquale.Views.Transfer.MenuTransferPage"
Shell.NavBarIsVisible="False">
<Grid RowDefinitions="auto, auto"

@ -1,4 +1,4 @@
namespace Banquale.Views;
namespace Banquale.Views.Transfer;
public partial class MenuTransferPage : ContentPage
{

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.RequestPage">
x:Class="Banquale.Views.Transfer.RequestPage">
<VerticalStackLayout VerticalOptions="Center">
@ -26,7 +26,8 @@
<Entry Placeholder="IBAN"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="IBAN"/>
</Frame>
@ -38,7 +39,8 @@
<Entry Placeholder="Montant"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="Sum"/>
</Frame>

@ -0,0 +1,17 @@
using Banquale.Model;
namespace Banquale.Views.Transfer;
public partial class RequestPage : ContentPage
{
public RequestPage()
{
InitializeComponent();
}
public async void Send_Clicked(Object sender, EventArgs e)
{
Account.DoRequest(Name, IBAN, Sum);
await Shell.Current.GoToAsync("//balance");
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.RibPage">
x:Class="Banquale.Views.Transfer.RibPage">
<VerticalStackLayout>

@ -1,4 +1,4 @@
namespace Banquale.Views;
namespace Banquale.Views.Transfer;
public partial class RibPage : ContentPage
{

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.TransferPage">
x:Class="Banquale.Views.Transfer.TransferPage">
<VerticalStackLayout VerticalOptions="Center">
@ -13,7 +13,8 @@
<Entry Placeholder="Destinataire"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="Name"/>
</Frame>
@ -25,7 +26,8 @@
<Entry Placeholder="IBAN"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="IBAN"/>
</Frame>
@ -37,7 +39,8 @@
<Entry Placeholder="Montant"
HorizontalOptions="Center"
WidthRequest="280"/>
WidthRequest="280"
x:Name="Sum"/>
</Frame>

@ -1,4 +1,5 @@
namespace Banquale.Views;
using Banquale.Model;
namespace Banquale.Views.Transfer;
public partial class TransferPage : ContentPage
{
@ -9,6 +10,7 @@ public partial class TransferPage : ContentPage
public async void Send_Clicked(Object sender, EventArgs e)
{
Account.DoTransactions(Name, IBAN, Sum);
await Shell.Current.GoToAsync("//balance");
}
Loading…
Cancel
Save