Compare commits
127 Commits
Author | SHA1 | Date |
---|---|---|
|
5d4ed6dd06 | 2 years ago |
|
dae95895be | 2 years ago |
|
c321a864d2 | 2 years ago |
|
7af8f8cb0d | 2 years ago |
|
ab50893242 | 2 years ago |
|
365742508e | 2 years ago |
|
9b2afcc6b2 | 2 years ago |
![]() |
b113d34ecc | 2 years ago |
![]() |
13f9923f6c | 2 years ago |
![]() |
c60fc07efc | 2 years ago |
![]() |
9d40742045 | 2 years ago |
|
3ec2199411 | 2 years ago |
|
d1875e97eb | 2 years ago |
|
b6fc6871ab | 2 years ago |
|
1f568ba29f | 2 years ago |
|
975b5fbde7 | 2 years ago |
|
2eb4330263 | 2 years ago |
![]() |
87533de711 | 2 years ago |
![]() |
091b016244 | 2 years ago |
![]() |
46d86bc107 | 2 years ago |
![]() |
76eece9089 | 2 years ago |
![]() |
1478707057 | 2 years ago |
![]() |
d2688b2d92 | 2 years ago |
|
b1d05eabfe | 2 years ago |
|
2d177dc028 | 2 years ago |
|
2071f8ba32 | 2 years ago |
|
9bbd0f3e4f | 2 years ago |
![]() |
1b4352e22b | 2 years ago |
![]() |
6ce50be142 | 2 years ago |
|
6005c16a35 | 2 years ago |
|
72aa47ee35 | 2 years ago |
![]() |
67245868b2 | 2 years ago |
|
ff86a3943d | 2 years ago |
![]() |
97b249813c | 2 years ago |
![]() |
4291785f79 | 2 years ago |
![]() |
f82b7bb9d7 | 2 years ago |
![]() |
f054b6c75d | 2 years ago |
![]() |
dbac7bb6b6 | 2 years ago |
![]() |
4129d5399f | 2 years ago |
|
f2796ec0a8 | 2 years ago |
|
836bea188f | 2 years ago |
|
ce37c078d4 | 2 years ago |
|
2520531195 | 2 years ago |
|
b77d0486d9 | 2 years ago |
|
68dd5302af | 2 years ago |
|
c75bac0219 | 2 years ago |
|
9a79b6a8b2 | 2 years ago |
|
f6a86d2d14 | 2 years ago |
|
5a6ae644be | 2 years ago |
|
dee2f48a41 | 2 years ago |
|
f9a50c300c | 2 years ago |
|
a8fdaa1bb6 | 2 years ago |
|
0c6def9fe7 | 2 years ago |
|
9b78f3ceca | 2 years ago |
|
61c1e92469 | 2 years ago |
|
8fcb08ed63 | 2 years ago |
|
cff31cec4f | 2 years ago |
![]() |
56262c4b9d | 2 years ago |
![]() |
575bd32287 | 2 years ago |
![]() |
a764c8283d | 2 years ago |
![]() |
12a3bf0896 | 2 years ago |
![]() |
75226d8bb4 | 2 years ago |
![]() |
6af577e2f2 | 2 years ago |
![]() |
2104545171 | 2 years ago |
![]() |
196b73c81a | 2 years ago |
![]() |
4c77db58fa | 2 years ago |
![]() |
296926684e | 2 years ago |
![]() |
efaa4b878b | 2 years ago |
![]() |
7a89f4cff5 | 2 years ago |
![]() |
7304a8e6da | 2 years ago |
![]() |
6d567c9058 | 2 years ago |
![]() |
554431190d | 2 years ago |
![]() |
2fffa70ff3 | 2 years ago |
![]() |
22f2bb4469 | 2 years ago |
|
5ed6a9b8d1 | 2 years ago |
|
0e7f6e2f4a | 2 years ago |
|
d3b0e7b0a6 | 2 years ago |
|
96c7a0c679 | 2 years ago |
|
b44a761253 | 2 years ago |
|
b44545a134 | 2 years ago |
|
7b262d20c7 | 2 years ago |
![]() |
5d4ae8b029 | 2 years ago |
![]() |
3ba8819ee5 | 2 years ago |
![]() |
5dca89b57b | 2 years ago |
![]() |
a2c7b26e11 | 2 years ago |
|
f534e27179 | 2 years ago |
|
cfaf17f08a | 2 years ago |
![]() |
3245980afa | 2 years ago |
|
b16da74e57 | 2 years ago |
|
2b3b0dba3a | 2 years ago |
![]() |
a0f039ed25 | 2 years ago |
![]() |
c7a06eefa9 | 2 years ago |
![]() |
ed360da803 | 2 years ago |
![]() |
7bcef40dbf | 2 years ago |
![]() |
f2358887da | 2 years ago |
![]() |
81c4405a0d | 2 years ago |
![]() |
b1b08636cf | 2 years ago |
![]() |
e868ef7317 | 2 years ago |
![]() |
23c03d38e7 | 2 years ago |
![]() |
aae9370bca | 2 years ago |
|
a68a1e8812 | 2 years ago |
|
f68ceba900 | 2 years ago |
|
0f995e1684 | 2 years ago |
|
40c88de727 | 2 years ago |
![]() |
a390297d33 | 2 years ago |
![]() |
d34d420121 | 2 years ago |
![]() |
09029d2090 | 2 years ago |
![]() |
0e0cee204d | 2 years ago |
![]() |
90c24358fd | 2 years ago |
![]() |
5c8b68b4ac | 2 years ago |
![]() |
8c66398569 | 2 years ago |
![]() |
08403ec39a | 2 years ago |
|
8a92b3aad6 | 2 years ago |
|
306d15b635 | 2 years ago |
|
bd25a436e1 | 2 years ago |
|
f3b1db2903 | 2 years ago |
|
5f10a4b94d | 2 years ago |
|
0ccdeda909 | 2 years ago |
|
5f68d68a9a | 2 years ago |
|
cb2cd438f1 | 2 years ago |
|
0a8ca83e9c | 2 years ago |
|
d115e27b67 | 2 years ago |
|
e00886d710 | 2 years ago |
|
1a1f50230c | 2 years ago |
|
83f1ab948d | 2 years ago |
|
373b91eee8 | 2 years ago |
|
d72054b9d7 | 2 years ago |
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
||||
using Biblioteque_de_Class;
|
||||
|
||||
namespace Notus_UnitTest_Database
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetLogoLinksTests
|
||||
{
|
||||
private Database database;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
database = new Database();
|
||||
database.GetDefaultLogoList().Add(new Logo("Logo1", "link1"));
|
||||
database.GetDefaultLogoList().Add(new Logo("Logo2", "link2"));
|
||||
database.GetDefaultLogoList().Add(new Logo("Logo3", "link3"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLogoLink_LogoExists_ReturnsLogoLink()
|
||||
{
|
||||
string logoName = "Logo2";
|
||||
string logoLink = database.GetLogoLink(logoName);
|
||||
Assert.That(logoLink, Is.EqualTo("link2"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLogoLink_LogoDoesNotExist_ThrowsException()
|
||||
{
|
||||
string logoName = "Logo4";
|
||||
Assert.Throws<Exception>(() => database.GetLogoLink(logoName));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,223 @@
|
||||
using Biblioteque_de_Class;
|
||||
namespace UnitTests_Model
|
||||
{
|
||||
[TestFixture]
|
||||
public class Database_Tests
|
||||
{
|
||||
private Database database;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
database = new Database();
|
||||
database.UserList.Add(new User("John", "john@example.com", "password123"));
|
||||
database.UserList.Add(new User("Jane", "jane@example.com", "choco"));
|
||||
database.UserList.Add(new User("Alice", "alice@example.com", "choco"));
|
||||
database.DefaultLogoList.Add(new Logo("Logo1", "link1"));
|
||||
database.DefaultLogoList.Add(new Logo("Logo2", "link2"));
|
||||
database.DefaultLogoList.Add(new Logo("Logo3", "link3"));
|
||||
}
|
||||
|
||||
// SearchUser tests
|
||||
|
||||
[Test]
|
||||
public void SearchUser_UserDoesNotExist_ThrowsException()
|
||||
{
|
||||
string searchName = "Bob";
|
||||
Assert.Throws<NotFoundException>(() => database.SearchUser(searchName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchUser_CaseInsensitiveSearch_ReturnsMatchingUsers()
|
||||
{
|
||||
string searchName = "Alice";
|
||||
User searchedUser = database.SearchUser(searchName);
|
||||
Assert.That(searchedUser.Username, Is.EqualTo("Alice"));
|
||||
}
|
||||
|
||||
// GetLogoLink tests
|
||||
[Test]
|
||||
public void GetLogoLink_LogoExists_ReturnsLogoLink()
|
||||
{
|
||||
Assert.That(database.GetLogoLink("Logo2"), Is.EqualTo("link2"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLogoLink_LogoDoesNotExist_ThrowsException()
|
||||
{
|
||||
string logoName = "Logo4";
|
||||
Assert.Throws<NotFoundException>(() => database.GetLogoLink(logoName));
|
||||
}
|
||||
|
||||
// GetUser tests
|
||||
[Test]
|
||||
public void GetUser_UserExists_ReturnsUser()
|
||||
{
|
||||
string userName = "Alice";
|
||||
User user = database.GetUser(userName);
|
||||
Assert.IsNotNull(user);
|
||||
Assert.That(user.Username, Is.EqualTo(userName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUser_UserDoesNotExist_ThrowsException()
|
||||
{
|
||||
string userName = "Eve";
|
||||
Assert.Throws<NotFoundException>(() => database.GetUser(userName));
|
||||
}
|
||||
|
||||
// ComparePassword tests
|
||||
[Test]
|
||||
public void ComparePassword_CorrectPassword_ReturnsTrue()
|
||||
{
|
||||
User user = database.UserList[0];
|
||||
string password = "password123";
|
||||
bool result = Database.ComparePassword(user, password);
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ComparePassword_IncorrectPassword_ReturnsFalse()
|
||||
{
|
||||
User user = database.UserList[0];
|
||||
string password = "incorrectPassword";
|
||||
bool result = Database.ComparePassword(user, password);
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
// FindEmail tests
|
||||
[Test]
|
||||
public void FindEmail_ExistingEmail_ReturnsTrue()
|
||||
{
|
||||
string email = "john@example.com";
|
||||
bool result = database.FindEmail(email);
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindEmail_NonExistingEmail_ReturnsFalse()
|
||||
{
|
||||
string email = "olivedecarglass@example.com";
|
||||
bool result = database.FindEmail(email);
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
// AddUser tests
|
||||
[Test]
|
||||
public void AddUser_ValidUser_AddsUserToList()
|
||||
{
|
||||
User user = new User("Bob", "bob@example.com", "password123");
|
||||
database.AddUser(user);
|
||||
Assert.That(database.UserList, Contains.Item(user));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddUser_DuplicateUserName_ThrowsException()
|
||||
{
|
||||
User user = new User("John", "johnDae@example.com", "password123");
|
||||
Assert.Throws<AlreadyUsedException>(() => database.AddUser(user));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddUser_DuplicateUserEmail_ThrowsException()
|
||||
{
|
||||
User user = new User("Bob", "john@example.com", "password123");
|
||||
Assert.Throws<AlreadyUsedException>(() => database.AddUser(user));
|
||||
}
|
||||
|
||||
// removeUser tests
|
||||
[Test]
|
||||
public void RemoveUser_ExistingUser_RemovesUserFromList()
|
||||
{
|
||||
User user = database.UserList[0];
|
||||
database.RemoveUser(user);
|
||||
Assert.That(database.UserList, !Contains.Item(user));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveUser_NotExistingUser_ThrowsException()
|
||||
{
|
||||
User user = new User("Bob", "bob@example.com", "password123");
|
||||
Assert.Throws<NotFoundException>(() => database.RemoveUser(user));
|
||||
}
|
||||
|
||||
// AddTheme tests
|
||||
[Test]
|
||||
public void AddTheme_ValidTheme_AddsThemeToList()
|
||||
{
|
||||
Theme theme = new Theme("Theme1", ",,,".Split().ToList());
|
||||
database.AddTheme(theme);
|
||||
Assert.That(database.ThemeList, Contains.Item(theme));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTheme_DuplicateTheme_ThrowsException()
|
||||
{
|
||||
Theme theme = new Theme("Theme1", ",,,".Split().ToList());
|
||||
database.ThemeList.Add(theme);
|
||||
Assert.Throws<AlreadyExistException>(() => database.AddTheme(theme));
|
||||
}
|
||||
|
||||
// GetTheme tests
|
||||
[Test]
|
||||
public void GetTheme_ExistingTheme_ReturnsTheme()
|
||||
{
|
||||
Theme expectedTheme = new Theme("Theme1", ",,,".Split().ToList());
|
||||
database.ThemeList.Add(expectedTheme);
|
||||
|
||||
Theme theme = database.GetTheme("Theme1");
|
||||
Assert.IsNotNull(theme);
|
||||
Assert.That(theme, Is.EqualTo(expectedTheme));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTheme_NonExistingTheme_ReturnsNull()
|
||||
{
|
||||
Theme expectedTheme = new Theme("Theme1", ",,,".Split().ToList());
|
||||
database.ThemeList.Add(expectedTheme);
|
||||
Assert.Throws<NotFoundException>(() => database.GetTheme("NonExistingTheme"));
|
||||
}
|
||||
|
||||
// ChangeUsername tests
|
||||
[Test]
|
||||
public void ChangeUsername_CorrectReplaceName_ChangesUsername()
|
||||
{
|
||||
User userSelected = database.UserList[0];
|
||||
string newUsername = "duberlute";
|
||||
|
||||
database.ChangeUsername(userSelected, newUsername);
|
||||
|
||||
User updatedUser = database.UserList.Where(u => u.Username == newUsername).First();
|
||||
Assert.IsNotNull(updatedUser);
|
||||
Assert.That(updatedUser.Username, Is.EqualTo(newUsername));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChangeUsername_UsernameAlreadyUsed_ThrowsException()
|
||||
{
|
||||
User userNotSelected = database.UserList[2];
|
||||
string newUsername = "Jane";
|
||||
|
||||
Assert.Throws<AlreadyUsedException>(() => database.ChangeUsername(userNotSelected, newUsername));
|
||||
}
|
||||
|
||||
// VerifThemeNameNotTaken tests
|
||||
[Test]
|
||||
public void VerifThemeNameNotTaken_NameNotTaken_ReturnsTrue()
|
||||
{
|
||||
string themeName = "NewTheme";
|
||||
bool result = database.VerifThemeNameNotTaken(themeName);
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VerifThemeNameNotTaken_NameAlreadyTaken_ReturnsFalse()
|
||||
{
|
||||
Theme expectedTheme = new Theme("Theme1", ",,,".Split().ToList());
|
||||
database.ThemeList.Add(expectedTheme);
|
||||
string themeName = "Theme1";
|
||||
bool result = database.VerifThemeNameNotTaken(themeName);
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Biblioteque_de_Class\Biblioteque_de_Class.csproj" />
|
||||
<ProjectReference Include="..\..\Notus_Persistence\Notus_Persistance.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1 @@
|
||||
global using NUnit.Framework;
|
@ -1,9 +1,46 @@
|
||||
namespace notus;
|
||||
|
||||
public partial class ConnecPage : ContentPage
|
||||
{
|
||||
public ConnecPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
using Biblioteque_de_Class;
|
||||
using Windows.UI.Core;
|
||||
|
||||
namespace notus;
|
||||
public partial class ConnecPage : ContentPage
|
||||
{
|
||||
User selectUser = (Application.Current as App).SelectedUser;
|
||||
Database db = (Application.Current as App).db;
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
public ConnecPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
private void Connec_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
selectUser = db.GetUser(Username);
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
DisplayAlert("Erreur", "Cet utilisateur n'existe pas" , "OK");
|
||||
return;
|
||||
}
|
||||
if (Database.ComparePassword(selectUser, HashCodeModel.GetSHA256Hash(Password).ToString()))
|
||||
{
|
||||
selectUser.IsConnected = true;
|
||||
(Application.Current as App).SelectedUser = selectUser;
|
||||
Navigation.PushAsync(new RecherPage());
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayAlert("Erreur", "Le mot de passe est incorrect", "OK");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Back_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
Navigation.PopAsync();
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
<?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:toolkit="http://schemas.microsoft.com/dodnet/2022/maui/toolkit"
|
||||
x:Class="notus.InscrPage"
|
||||
Title="InscrPage"
|
||||
BackgroundColor="#1C1C1C">
|
||||
<Shell.BackButtonBehavior>
|
||||
<BackButtonBehavior
|
||||
IsVisible="False"
|
||||
IsEnabled="False"/>
|
||||
</Shell.BackButtonBehavior>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="1.8*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1.8*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1.8*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1.6*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
<ColumnDefinition Width="0.9*"/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ImageButton
|
||||
Source="return.png"
|
||||
Aspect="AspectFit"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
HorizontalOptions="Start"
|
||||
VerticalOptions="Start"
|
||||
WidthRequest="50"
|
||||
HeightRequest="50"
|
||||
BackgroundColor="#4A4A4A"
|
||||
Margin="10,10,0,0"
|
||||
CornerRadius="50"
|
||||
Clicked="Back_Clicked"
|
||||
/>
|
||||
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="1"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center"
|
||||
Text="Inscription"
|
||||
TextColor="#74fabd"
|
||||
FontSize="80"
|
||||
FontFamily="strong"
|
||||
/>
|
||||
|
||||
<Entry
|
||||
Placeholder="Pseudo"
|
||||
FontSize="22"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="3"
|
||||
TextColor="#74fabd"
|
||||
BackgroundColor="#4A4A4A"
|
||||
PlaceholderColor="#74fabd"
|
||||
Text="{Binding Username}"
|
||||
/>
|
||||
|
||||
<Entry
|
||||
Placeholder="Mot de passe"
|
||||
FontSize="22"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="5"
|
||||
IsPassword="true"
|
||||
TextColor="#74fabd"
|
||||
BackgroundColor="#4A4A4A"
|
||||
PlaceholderColor="#74fabd"
|
||||
Text="{Binding Password}"
|
||||
/>
|
||||
|
||||
<Entry
|
||||
Placeholder ="Verif mot de passe"
|
||||
FontSize="22"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="7"
|
||||
IsPassword="true"
|
||||
TextColor="#74fabd"
|
||||
BackgroundColor="#4A4A4A"
|
||||
PlaceholderColor="#74fabd"
|
||||
Text="{Binding RePassword}"
|
||||
/>
|
||||
|
||||
<Button
|
||||
WidthRequest="80"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="1"
|
||||
Grid.Row="9"
|
||||
Text="Valider"
|
||||
TextColor="Black"
|
||||
BackgroundColor="#74fabd"
|
||||
Clicked="Inscription_Clicked"
|
||||
/>
|
||||
|
||||
<Label
|
||||
x:Name="userUser"
|
||||
Text="User Already exist."
|
||||
IsVisible="false"
|
||||
Grid.Column="1"
|
||||
Grid.Row="4"
|
||||
TextColor="Red"
|
||||
/>
|
||||
|
||||
<Label
|
||||
x:Name="shortPassword"
|
||||
Text="Password to short."
|
||||
IsVisible="false"
|
||||
Grid.Column="1"
|
||||
Grid.Row="6"
|
||||
TextColor="Red"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
</ContentPage>
|
||||
|
@ -0,0 +1,179 @@
|
||||
<?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:toolkit="http://schemas.microsoft.com/dodnet/2022/maui/toolkit"
|
||||
x:Class="notus.ProfilPage"
|
||||
Title="ProfilPage"
|
||||
BackgroundColor="#1C1C1C">
|
||||
|
||||
<Shell.BackButtonBehavior>
|
||||
<BackButtonBehavior
|
||||
IsVisible="False"
|
||||
IsEnabled="False"/>
|
||||
</Shell.BackButtonBehavior>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
<ColumnDefinition Width="6*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ImageButton
|
||||
Source="return.png"
|
||||
Aspect="AspectFit"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
HorizontalOptions="Start"
|
||||
VerticalOptions="Start"
|
||||
WidthRequest="50"
|
||||
HeightRequest="50"
|
||||
BackgroundColor="#4A4A4A"
|
||||
Margin="10,10,0,0"
|
||||
CornerRadius="50"
|
||||
Clicked="Back_Clicked"
|
||||
/>
|
||||
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="250"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Image Source="{Binding ProfilPicture}"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center"
|
||||
Grid.Row="1"
|
||||
BackgroundColor="#4A4A4A"
|
||||
WidthRequest="250"
|
||||
HeightRequest="250"
|
||||
Margin="0,0,0,30"
|
||||
/>
|
||||
|
||||
<Label Text="{Binding Username}" VerticalOptions="Center"
|
||||
Grid.Row="2"
|
||||
BackgroundColor="#4A4A4A"
|
||||
WidthRequest="260"
|
||||
HeightRequest="60"
|
||||
TextColor="#74fabd"/>
|
||||
|
||||
<Button
|
||||
VerticalOptions="End"
|
||||
Text="Modifier Profil"
|
||||
TextColor="#74fabd"
|
||||
WidthRequest="300"
|
||||
BackgroundColor="#4A4A4A"
|
||||
Grid.Row="4"
|
||||
HeightRequest="80"
|
||||
FontSize="30"
|
||||
Margin="0,20,0,0"
|
||||
Clicked="Modify_Profil"
|
||||
/>
|
||||
|
||||
<Button
|
||||
VerticalOptions="Center"
|
||||
Text="Modifier Theme"
|
||||
TextColor="#74fabd"
|
||||
WidthRequest="300"
|
||||
BackgroundColor="#4A4A4A"
|
||||
Grid.Row="5"
|
||||
HeightRequest="80"
|
||||
FontSize="30"
|
||||
Margin="0,20,0,0"
|
||||
Clicked="Modify_Theme"
|
||||
/>
|
||||
|
||||
<Button
|
||||
VerticalOptions="Start"
|
||||
Text="se déconnecter"
|
||||
FontSize="30"
|
||||
TextColor="#74fabd"
|
||||
WidthRequest="300"
|
||||
BackgroundColor="#4A4A4A"
|
||||
Grid.Row="6"
|
||||
HeightRequest="80"
|
||||
Margin="0,20,0,0"
|
||||
Clicked="Disconnect_Clicked"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="TagsZone" Grid.Column="1" Margin="40" BackgroundColor="#4A4A4A" IsVisible="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="250"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollView Grid.Row="1" VerticalScrollBarVisibility="Always" HorizontalScrollBarVisibility="Never">
|
||||
<StackLayout x:Name="TagListContainer" Padding="10" Spacing="5">
|
||||
<ListView x:Name="TagListView" SeparatorVisibility="None" BackgroundColor="Transparent">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<BoxView Grid.Column="0" BackgroundColor="{Binding Color}" WidthRequest="40" />
|
||||
<Label Grid.Column="1" Text="{Binding Name}" VerticalTextAlignment="Center" />
|
||||
<Button Grid.Column="2" Text="Modify" Clicked="Modify_Clicked"/>
|
||||
<Button Grid.Column="3" Text="Delete" Clicked="Delete_Clicked" VerticalOptions="End"/>
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
<Grid Grid.Row="2" HorizontalOptions="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="0" Text="Add" Command="{Binding AddTagCommand}" HorizontalOptions="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="ProfilZone" Grid.Column="1" Margin="40" BackgroundColor="#4A4A4A" IsVisible="false">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="250"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
<Grid x:Name="ThemeZone" Grid.Column="1" Margin="40" BackgroundColor="#4A4A4A" IsVisible="false">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="250"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -0,0 +1,101 @@
|
||||
using Microsoft.Maui.Controls;
|
||||
using Biblioteque_de_Class;
|
||||
using Notus_Persistance;
|
||||
using NHibernate.Mapping;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace notus;
|
||||
|
||||
public partial class ProfilPage : ContentPage
|
||||
{
|
||||
|
||||
public User SelectedUser = (Application.Current as App).SelectedUser;
|
||||
private string username;
|
||||
public string Username
|
||||
{
|
||||
get => username;
|
||||
set
|
||||
{
|
||||
username = value;
|
||||
OnPropertyChanged(nameof(Username));
|
||||
(Application.Current as App).SelectedUser.Username = username;
|
||||
}
|
||||
}
|
||||
private string password;
|
||||
public string Password
|
||||
{
|
||||
get => password;
|
||||
set
|
||||
{
|
||||
password = value;
|
||||
OnPropertyChanged(nameof(Password));
|
||||
(Application.Current as App).SelectedUser.Password = password;
|
||||
}
|
||||
}
|
||||
private string profilPicture;
|
||||
public string ProfilPicture
|
||||
{
|
||||
get => profilPicture;
|
||||
set
|
||||
{
|
||||
profilPicture = value;
|
||||
OnPropertyChanged(nameof(ProfilPicture));
|
||||
(Application.Current as App).SelectedUser.Picture = profilPicture;
|
||||
}
|
||||
}
|
||||
|
||||
public ProfilPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
Username = SelectedUser.Username;
|
||||
Password = SelectedUser.Password;
|
||||
ProfilPicture = SelectedUser.Picture;
|
||||
BindingContext = this;
|
||||
|
||||
|
||||
}
|
||||
private void Back_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
Navigation.PopAsync();
|
||||
}
|
||||
|
||||
private void Disconnect_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
(Application.Current as App).SelectedUser.IsConnected = false;
|
||||
Navigation.PopAsync();
|
||||
Navigation.PopAsync();
|
||||
Navigation.PopAsync();
|
||||
(Application.Current as App).SelectedUser = null;
|
||||
}
|
||||
|
||||
private void AddTag_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
// Handle add tag action
|
||||
// Show color picker and name input dialog
|
||||
// Create a new Tag object and add it to the Tags collection
|
||||
}
|
||||
|
||||
private void Modify_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
// Handle modify action for the tag
|
||||
}
|
||||
|
||||
private void Delete_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
// Handle delete action for the tag
|
||||
}
|
||||
|
||||
private void Modify_Profil(object sender, EventArgs e)
|
||||
{
|
||||
if (ProfilZone.IsVisible == true) { ProfilZone.IsVisible = false; return; }
|
||||
ThemeZone.IsVisible = false;
|
||||
ProfilZone.IsVisible = true;
|
||||
}
|
||||
|
||||
private void Modify_Theme(object sender, EventArgs e)
|
||||
{
|
||||
if (ThemeZone.IsVisible == true) { ThemeZone.IsVisible = false; return;}
|
||||
ProfilZone.IsVisible = false;
|
||||
ThemeZone.IsVisible = true;
|
||||
}
|
||||
}
|
@ -1,17 +1,152 @@
|
||||
<?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:toolkit="http://schemas.microsoft.com/dodnet/2022/maui/toolkit"
|
||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2021/maui/toolkit"
|
||||
xmlns:muxc = "using:Microsoft.UI.Xaml.Controls"
|
||||
x:Class="notus.RecherPage"
|
||||
Title="RecherPage"
|
||||
Title="Main Page"
|
||||
BackgroundColor="#1C1C1C">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Shell.BackButtonBehavior>
|
||||
<BackButtonBehavior
|
||||
IsVisible="False"
|
||||
IsEnabled="False"/>
|
||||
</Shell.BackButtonBehavior>
|
||||
<ContentPage.Content>
|
||||
<Grid>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="MasterColumn" Width="320" />
|
||||
<ColumnDefinition x:Name="DetailColumn" Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Background="#6E6E6E" Grid.Column="0" Grid.RowSpan="3" />
|
||||
<Grid Margin="0,11,0,13" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<SearchBar Placeholder="Search Note" Text="{Binding SearchNoteText}" HorizontalOptions="Start" Margin="10" VerticalOptions="Center" WidthRequest="300" HeightRequest="50" FontSize="25" TextColor="#74fabd" BackgroundColor="#4A4A4A" PlaceholderColor="#74fabd" TextChanged="OnSearchNoteTextChanged" />
|
||||
<CheckBox x:Name="FavoritesCheckBox" CheckedChanged="FavoritesFilter_CheckedChanged" WidthRequest="50" HeightRequest="50" Margin="40,0,0,0" HorizontalOptions="Start" VerticalOptions="Center" Grid.Row="1" />
|
||||
<ImageButton Source="tagsfilter.png" BackgroundColor="#4A4A4A" Clicked="TagsFilter_Clicked" WidthRequest="50" HeightRequest="50" CornerRadius="50" Margin="20" HorizontalOptions="Center" VerticalOptions="Center" Grid.Row="1"/>
|
||||
<ImageButton Source="Datefilter.png" BackgroundColor="#4A4A4A" Clicked="DatesFilter_Clicked" WidthRequest="50" HeightRequest="50" CornerRadius="50" Margin="20" HorizontalOptions="End" VerticalOptions="Center" Grid.Row="1"/>
|
||||
<ScrollView x:Name="TheScrollView" Grid.Row="2" Grid.Column="0" VerticalOptions="Start" Margin="5,5,5,5">
|
||||
<ContentView>
|
||||
<ListView ItemsSource="{Binding NoteList, Mode=TwoWay}" ItemSelected="NoteListView_ItemSelected" VerticalOptions="StartAndExpand">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Orientation="Horizontal" HeightRequest="40" Padding="3" Margin="3" BackgroundColor="#4A4A4A" MinimumWidthRequest="400" MaximumWidthRequest="400">
|
||||
<CheckBox IsChecked="{Binding IsFavorite, Mode=TwoWay}" CheckedChanged="FavoriteCheckBox_CheckedChanged" HeightRequest="20" HorizontalOptions="End" VerticalOptions="Center"/>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Image Source="{Binding LogoPath}" HorizontalOptions="Start" VerticalOptions="Center"/>
|
||||
<Label Text="{Binding Name}" TextColor="#74fabd" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ContentView>
|
||||
</ScrollView>
|
||||
</Grid>
|
||||
<ImageButton Source="create.png" BackgroundColor="#4A4A4A" Clicked="CreateNote_Clicked" WidthRequest="50" HeightRequest="50" CornerRadius="50" Margin="20" HorizontalOptions="Start" VerticalOptions="End" />
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="350" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ImageButton Source="{Binding LogoPath}" Aspect="AspectFit" Grid.Column="0" Grid.Row="0" Margin="20" HorizontalOptions="Start" VerticalOptions="Start" WidthRequest="50" HeightRequest="50" BackgroundColor="#4A4A4A" CornerRadius="50" />
|
||||
<Entry Text="{Binding Name}" Grid.Column="0" Grid.Row="0" TextColor="#74fabd" Margin="20" FontSize="21" BackgroundColor="#4A4A4A" WidthRequest="250" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Start" />
|
||||
<ImageButton Source="supp.png" Clicked="Delete_Note" Aspect="AspectFill" Grid.Column="2" Grid.Row="0" Margin="20" HorizontalOptions="Start" VerticalOptions="Start" WidthRequest="50" HeightRequest="50" BackgroundColor="#4A4A4A" CornerRadius="50" />
|
||||
<ImageButton Source="AddUser.png" Clicked="AddUser_Clicked" Grid.Column="2" Grid.Row="0" BackgroundColor="#4A4A4A" Margin="120,20,20,20" HorizontalOptions="Start" VerticalOptions="Start" WidthRequest="50" HeightRequest="50" CornerRadius="50"/>
|
||||
<ImageButton Source="{Binding ProfilPicture}" Clicked="Profil_Clicked" Aspect="AspectFit" Grid.Column="2" Grid.Row="0" HorizontalOptions="End" VerticalOptions="Start" WidthRequest="200" HeightRequest="120" BackgroundColor="#6E6E6E"/>
|
||||
|
||||
<Editor
|
||||
x:Name="textZone"
|
||||
Placeholder="Text"
|
||||
FontSize="18"
|
||||
Text="{Binding Text, Mode=TwoWay}"
|
||||
TextColor="#74fabd" BackgroundColor="#4A4A4A"
|
||||
PlaceholderColor="#74fabd"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalTextAlignment="Start"
|
||||
Margin="20"
|
||||
TextChanged="OnEditorTextChanged"
|
||||
Completed="OnEditorCompleted"/>
|
||||
|
||||
<Grid
|
||||
x:Name="AddUser_Zone"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
BackgroundColor="#6E6E6E"
|
||||
IsVisible="false"
|
||||
Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<SearchBar Placeholder="Search User" Text="{Binding SearchNoteText}" HorizontalOptions="Start" Margin="20" VerticalOptions="Center" WidthRequest="400" HeightRequest="50" FontSize="25" TextColor="#74fabd" BackgroundColor="#4A4A4A" PlaceholderColor="#74fabd" TextChanged="OnSearchNoteTextChanged" />
|
||||
<ScrollView x:Name="UserListScrollView" Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="3" VerticalOptions="Start" HorizontalOptions="Start" Margin="20,90,0,0" BackgroundColor="#4A4A4A" MinimumWidthRequest="600" MaximumWidthRequest="600">
|
||||
<ContentView>
|
||||
<ListView ItemsSource="{Binding UserList, Mode=TwoWay}" ItemSelected="NoteListView_ItemSelected" VerticalOptions="StartAndExpand">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Orientation="Horizontal" HeightRequest="40" Padding="3" Margin="3" BackgroundColor="#4A4A4A" MinimumWidthRequest="300" MaximumWidthRequest="300">
|
||||
<CheckBox IsChecked="{Binding AJouter, Mode=TwoWay}" CheckedChanged="AddUserCheckBox_CheckedChanged" HeightRequest="20" HorizontalOptions="End" VerticalOptions="Center"/>
|
||||
<Image Source="{Binding ProfilPictureUser}" HorizontalOptions="Start" VerticalOptions="Center"/>
|
||||
<Label Text="{Binding UserNameUser}" TextColor="#74fabd" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ContentView>
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
x:Name="Valid"
|
||||
Text="Valid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="3"
|
||||
TextColor="#74fabd"
|
||||
WidthRequest="70"
|
||||
HeightRequest="50"
|
||||
HorizontalOptions="End"
|
||||
VerticalOptions="End"
|
||||
Margin="0,0,20,20"
|
||||
Clicked="Valid_Clicked"
|
||||
BackgroundColor="#4A4A4A"/>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage.Content>
|
||||
|
||||
</ContentPage>
|
@ -1,9 +1,361 @@
|
||||
namespace notus;
|
||||
|
||||
public partial class RecherPage : ContentPage
|
||||
{
|
||||
public RecherPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
using Microsoft.Maui.Controls;
|
||||
using Biblioteque_de_Class;
|
||||
using Notus_Persistance;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Maui;
|
||||
using System.Globalization;
|
||||
using System.Drawing;
|
||||
|
||||
namespace notus
|
||||
{
|
||||
public partial class RecherPage : ContentPage, INotifyPropertyChanged
|
||||
{
|
||||
private ObservableCollection<Note> noteList;
|
||||
public ObservableCollection<Note> NoteList
|
||||
{
|
||||
get { return noteList; }
|
||||
set
|
||||
{
|
||||
noteList = value;
|
||||
OnPropertyChanged(nameof(NoteList));
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<Note> allNotes; // Store all notes initially
|
||||
private Database db = (Application.Current as App).db;
|
||||
public User SelectedUser = (Application.Current as App).SelectedUser;
|
||||
public Note SelectedNote
|
||||
{
|
||||
get => (Application.Current as App).SelectedNote;
|
||||
set
|
||||
{
|
||||
if ((Application.Current as App).SelectedNote != value)
|
||||
{
|
||||
(Application.Current as App).SelectedNote = value;
|
||||
OnPropertyChanged(nameof(SelectedNote));
|
||||
NoteList = new ObservableCollection<Note>(SelectedUser.NoteList);
|
||||
allNotes = new ObservableCollection<Note>(NoteList);
|
||||
Name = SelectedNote.Name;
|
||||
Text = SelectedNote.Text;
|
||||
LogoPath = SelectedNote.LogoPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
if (name != value)
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SelectedNote.ChangeName(SelectedUser, value);
|
||||
}
|
||||
catch (NotAllowedException)
|
||||
{
|
||||
Name = SelectedNote.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string text;
|
||||
public string Text
|
||||
{
|
||||
get { return text; }
|
||||
set
|
||||
{
|
||||
if (text != value)
|
||||
{
|
||||
text = value;
|
||||
OnPropertyChanged(nameof(Text));
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SelectedNote.VerifyPrivilege(SelectedUser);
|
||||
}
|
||||
catch (NotAllowedException)
|
||||
{
|
||||
Text = SelectedNote.Text;
|
||||
return;
|
||||
}
|
||||
SelectedNote.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string logoPath;
|
||||
public string LogoPath
|
||||
{
|
||||
get { return logoPath; }
|
||||
set
|
||||
{
|
||||
if (logoPath != value)
|
||||
{
|
||||
logoPath = value;
|
||||
OnPropertyChanged(nameof(LogoPath));
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SelectedNote.ChangeLogo(SelectedUser, value);
|
||||
}
|
||||
catch (NotAllowedException)
|
||||
{
|
||||
LogoPath = SelectedNote.LogoPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public string SearchNoteText { get; set; }
|
||||
public string ProfilPicture { get; set; }
|
||||
public RecherPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
allNotes = new ObservableCollection<Note>(SelectedUser.NoteList);
|
||||
NoteList = allNotes;
|
||||
|
||||
SelectedNote = SelectedUser.NoteList
|
||||
.OrderByDescending(note => note.ModificationDate)
|
||||
.FirstOrDefault();
|
||||
|
||||
(Application.Current as App).SelectedNote = SelectedNote;
|
||||
Name = SelectedNote.Name;
|
||||
Text = SelectedNote.Text;
|
||||
LogoPath = SelectedNote.LogoPath;
|
||||
ProfilPicture = SelectedUser.Picture;
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
private void CreateNote_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
SelectedUser.CreateNote("", "");
|
||||
SelectedNote = SelectedUser.NoteList[SelectedUser.NoteList.Count - 1];
|
||||
}
|
||||
|
||||
private async void Profil_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
(Application.Current as App).SelectedUser = SelectedUser;
|
||||
await Navigation.PushAsync(new ProfilPage());
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
void OnEditorTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string newText = e.NewTextValue;
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
SelectedNote.Text = newText;
|
||||
(Application.Current as App).SelectedNote = SelectedNote;
|
||||
}
|
||||
Text = SelectedNote.Text;
|
||||
}
|
||||
|
||||
void OnEditorCompleted(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
SelectedNote.Text = ((Editor)sender).Text;
|
||||
(Application.Current as App).SelectedNote = SelectedNote;
|
||||
}
|
||||
}
|
||||
|
||||
private void NoteListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
if (e.SelectedItem is Note selectedNote)
|
||||
{
|
||||
SelectedNote = selectedNote;
|
||||
(Application.Current as App).SelectedNote = SelectedNote;
|
||||
Name = SelectedNote.Name;
|
||||
Text = SelectedNote.Text;
|
||||
LogoPath = SelectedNote.LogoPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddUser_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (AddUser_Zone.IsVisible)
|
||||
AddUser_Zone.IsVisible = false;
|
||||
else
|
||||
AddUser_Zone.IsVisible = true;
|
||||
}
|
||||
|
||||
private void Valid_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
AddUser_Zone.IsVisible = false;
|
||||
}
|
||||
|
||||
private void AddUserCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public void Delete_Note(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedNote != null)
|
||||
{
|
||||
SelectedUser.NoteList.Remove(SelectedNote);
|
||||
if (SelectedUser.NoteList.Count == 0)
|
||||
{
|
||||
SelectedUser.CreateNote("","");
|
||||
}
|
||||
SelectedNote = SelectedUser.NoteList.FirstOrDefault(); // Select the first note in the list (or null if empty)
|
||||
}
|
||||
}
|
||||
|
||||
private int windowHeight;
|
||||
public int WindowHeight
|
||||
{
|
||||
get { return windowHeight; }
|
||||
set
|
||||
{
|
||||
if (windowHeight != value)
|
||||
{
|
||||
windowHeight = value - 300;
|
||||
OnPropertyChanged(nameof(WindowHeight));
|
||||
UpdateScrollViewHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSizeAllocated(double width, double height)
|
||||
{
|
||||
base.OnSizeAllocated(width, height);
|
||||
|
||||
if (WindowHeight != (int)height)
|
||||
{
|
||||
WindowHeight = (int)height;
|
||||
UpdateScrollViewHeight();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScrollViewHeight()
|
||||
{
|
||||
double availableHeight = WindowHeight;
|
||||
TheScrollView.MaximumHeightRequest = availableHeight;
|
||||
UserListScrollView.MinimumHeightRequest = availableHeight;
|
||||
UserListScrollView.MaximumHeightRequest = availableHeight;
|
||||
}
|
||||
|
||||
private bool isFavoritesFilterChecked = false;
|
||||
private List<Tags> selectedTags = new List<Tags>();
|
||||
private DateOnly startDate;
|
||||
private DateOnly endDate;
|
||||
private bool isfavorite;
|
||||
public bool IsFavorite
|
||||
{
|
||||
get => isfavorite;
|
||||
set
|
||||
{
|
||||
if (IsFavorite != value)
|
||||
{
|
||||
IsFavorite = value;
|
||||
OnPropertyChanged(nameof(IsFavorite));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchNoteTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string searchText = e.NewTextValue;
|
||||
if (string.IsNullOrEmpty(searchText))
|
||||
{
|
||||
ApplyFilters();
|
||||
}
|
||||
else
|
||||
{
|
||||
var filteredNotes = NoteList.Where(note => note.Name.Contains(searchText));
|
||||
NoteList = new ObservableCollection<Note>(filteredNotes);
|
||||
}
|
||||
}
|
||||
|
||||
private void FavoritesFilter_CheckedChanged(object sender, CheckedChangedEventArgs e)
|
||||
{
|
||||
isFavoritesFilterChecked = e.Value;
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void TagsFilter_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void DatesFilter_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void ApplyFilters()
|
||||
{
|
||||
|
||||
var filteredNotes = allNotes;
|
||||
|
||||
if (isFavoritesFilterChecked)
|
||||
{
|
||||
var FavfilteredNotes = allNotes.Where(note => SelectedUser.FavList.Contains(note));
|
||||
NoteList = new ObservableCollection<Note>(FavfilteredNotes);
|
||||
filteredNotes = NoteList;
|
||||
}
|
||||
|
||||
if (selectedTags.Count > 0)
|
||||
{
|
||||
filteredNotes = (ObservableCollection<Note>)filteredNotes.Where(note => SelectedUser.NoteTagged[note].Any(tag => selectedTags.Contains(tag)));
|
||||
}
|
||||
|
||||
if (startDate != default && endDate != default)
|
||||
{
|
||||
filteredNotes = (ObservableCollection<Note>)filteredNotes.Where(note => note.CreationDate >= startDate && note.CreationDate <= endDate || note.ModificationDate >= startDate && note.ModificationDate <= endDate);
|
||||
}
|
||||
|
||||
foreach (var note in filteredNotes)
|
||||
{
|
||||
note.IsFavorite = SelectedUser.FavList.Contains(note);
|
||||
IsFavorite = note.IsFavorite;
|
||||
}
|
||||
|
||||
NoteList = new ObservableCollection<Note>(filteredNotes);
|
||||
}
|
||||
|
||||
private void FavoriteCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
Note note = checkBox.BindingContext as Note;
|
||||
|
||||
if (note != null)
|
||||
{
|
||||
if (e.Value)
|
||||
{
|
||||
if(note.IsFavorite == false)
|
||||
SelectedUser.AddFavorite(note);
|
||||
(Application.Current as App).SelectedUser = SelectedUser;
|
||||
allNotes = new ObservableCollection<Note>(SelectedUser.NoteList);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (note.IsFavorite == true)
|
||||
SelectedUser.RemoveFavorite(note);
|
||||
(Application.Current as App).SelectedUser = SelectedUser;
|
||||
allNotes = new ObservableCollection<Note>(SelectedUser.NoteList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in new issue