School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
namespace District_3_App.ExtraInfo
{
public class Account
{
private string cardNumber;
private string holderName;
private string expirationDate;
private string cvv;
// public UserExtraInfo UserExtraInfo { get; private set; }
public User User { get; private set; }
public string CardNumber
{
get => cardNumber;
set
{
/*if (!IsNumeric(value) || value.Length != 16)
{
throw new ArgumentException("Card Number must be a string of 16 digits (numeric input only).");
}*/
cardNumber = value;
}
}
public string HolderName
{
get => holderName;
set
{
/*if (!IsAlphabetic(value))
{
throw new ArgumentException("Holder Name must contain alphabetic characters only.");
}*/
holderName = value;
}
}
public string ExpirationDate
{
get => expirationDate;
set
{
/*if (!IsValidExpirationDate(value))
{
throw new ArgumentException("Expiration Date must be in MM/YY format (numeric input only).");
}*/
expirationDate = value;
}
}
public string CVV
{
get => cvv;
set
{
/*if (!IsNumeric(value) || value.Length != 3)
{
throw new ArgumentException("CVV must be a three-digit code (numeric input only).");
}*/
cvv = value;
}
}
public Account(User user, string cardNumber, string holderName, string expirationDate, string cvv)
{
User = user;
CardNumber = cardNumber;
HolderName = holderName;
ExpirationDate = expirationDate;
CVV = cvv;
}
private bool IsNumeric(string value)
{
return long.TryParse(value, out _);
}
private bool IsAlphabetic(string value)
{
return !string.IsNullOrWhiteSpace(value) && value.All(c => char.IsLetter(c) || char.IsWhiteSpace(c));
}
private bool IsValidExpirationDate(string value)
{
if (value.Length != 5 || value[2] != '/')
{
return false;
}
string[] parts = value.Split('/');
if (parts.Length != 2)
{
return false;
}
if (!int.TryParse(parts[0], out int month) || !int.TryParse(parts[1], out int year))
{
return false;
}
if (month < 1 || month > 12 || year < DateTime.Now.Year % 100 || year > (DateTime.Now.Year % 100) + 10)
{
return false;
}
return true;
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace District_3_App.ExtraInfo
{
public class EncryptionModule
{
}
}
@@ -0,0 +1,159 @@
<UserControl x:Class="District_3_App.ExtraInfo.ExtraInfo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:District_3_App.ExtraInfo"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="extraInfoGrid" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220.573"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" x:Name="EditProfileButton" Height="50" Margin="4,46,4,10" Click="EditProfileButton_Click" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderThickness="0" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<Image Source="\images\userExtraInfo.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Edit Profile" FontSize="20"/>
</StackPanel>
</Button>
<Button Grid.Column="0" x:Name="SettingsPrivacyButton" Click="SettingsPrivacyButton_Click" Height="49" Margin="4,87,579,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.ColumnSpan="2">
<StackPanel Orientation="Horizontal" Height="70" Width="204">
<Image Source="\images\settings.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Settings and Privacy" FontSize="20" Width="182" Height="31"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="StatisticsButton" Click="StatisticsButton_Click" Height="50" Margin="7,132,10,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<Image Source="\images\statistics.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Statistics" FontSize="20"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="FancierProfileButton" Click="FancierProfileButton_Click" Height="50" Margin="4,171,5,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<Image Source="\images\fancierProfile.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Fancier Profile" FontSize="20" TextAlignment="Left"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="SavedPostsButton" Click="SavedPostsButton_Click" Height="50" Margin="5,211,5,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<Image Source="\images\saved.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Saved" FontSize="20" TextAlignment="Left"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="CloseFriendsButton" Click="CloseFriendsButton_Click" Height="50" Margin="2,257,10,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal" Width="170">
<Image Source="\images\closeFriends.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Close Friends" FontSize="20" Width="150"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="VerifiedAccountButton" Height="50" Margin="2,307,2,0" Click="VerifiedAccountButton_Click" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal" Width="170">
<Image Source="\images\verify.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Verified Account" FontSize="19"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="FriendsSettingsButton" Click="FriendsSettingsButton_Click" Height="43" Margin="2,357,6,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal" Width="168">
<Image Source="\images\friends.png" Width="16" Height="16" Margin="0,0,4,0"/>
<TextBlock Text="Friends Settings" FontSize="20"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Button x:Name="LikedPostsButton" Height="50" Click="LikedPostsButton_Click" Margin="5,400,8,0" VerticalAlignment="Top" Background="White" Foreground="#47525E" BorderBrush="DarkGray" BorderThickness="0" HorizontalContentAlignment="Left" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<Image Source="\images\likedPosts.png" Width="16" Height="16" Margin="0,0,4,0" />
<TextBlock Text="Liked Posts" FontSize="20"/>
</StackPanel>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<!--<StackPanel Orientation="Vertical" Margin="0,0,10,0" Grid.Column="0">
<TextBlock Text="District 3" FontWeight="Bold" FontSize="25" Foreground="#47525E" Width="269"/>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\home.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Home" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Home" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\search-interface-symbol.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Search" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Search" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\explore.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Explore" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Explore" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\reel.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Reels" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Reels" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\send.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Messages" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Messages" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\bell.png" Width="30" Height="30" Margin="3,0,10,0"/>
<Button x:Name="Notifications" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Notifications" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,15,0,20">
<Image Source="\images\user.png" Width="30" Height="30" Margin="0,0,10,0"/>
<Button x:Name="Profile" Background="Transparent" BorderBrush="Transparent">
<TextBlock Text="Profile" Margin="5,0,0,0" FontSize="20"/>
</Button>
</StackPanel>
</StackPanel>-->
<StackPanel HorizontalAlignment="Left" Width="180" Grid.Column="0">
<TextBlock Text="Extra Info" Foreground="#343B42" FontWeight="Bold" FontSize="25"/>
<Line X1="200" Y1="-35" X2="200" Y2="800" Stroke="#8492A6" StrokeThickness="1" />
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,269 @@
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 District_3_App.CloseFriends_GUI;
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
using District_3_App.Settings_Privacy_GUI;
using Statistics;
namespace District_3_App.ExtraInfo
{
/// <summary>
/// Interaction logic for ExtraInfo.xaml
/// </summary>
public partial class ExtraInfo : UserControl
{
private ProfileNetworkInfoService profileNetworkInfoService;
private User currentConnectedUser;
public ExtraInfo()
{
//// HARDCODED STUFF
User user1 = new User(Guid.NewGuid(), "username1", "password1", "user1@yahoo.ro", "password1");
User user2 = new User(Guid.NewGuid(), "username2", "password2", "username2@gmail.ro", "password2");
User user3 = new User(Guid.NewGuid(), "username3", "password3", "user3@yahoo.com", "password3");
User user4 = new User(Guid.NewGuid(), "username4", "password4", "username4@stud.ubbcluj.ro", "password4");
User user5 = new User(Guid.NewGuid(), "username5", "password5", "username4@gmail.es", "password5");
List<User> usersList = new List<User>();
usersList.Add(user1);
usersList.Add(user2);
usersList.Add(user3);
usersList.Add(user4);
usersList.Add(user5);
UsersRepository usersRepo = new UsersRepository(usersList);
BlockedProfile blockedProfile1 = new BlockedProfile(user5, new DateTime(2023, 12, 02, 18, 40, 10));
BlockedProfile blockedProfile2 = new BlockedProfile(user2, new DateTime(2023, 12, 02, 17, 50, 10));
BlockedProfile blockedProfile3 = new BlockedProfile(user3, new DateTime(2023, 12, 02, 17, 50, 15));
BlockedProfile blockedProfile4 = new BlockedProfile(user4, new DateTime(2022, 11, 02, 17, 50, 15));
CloseFriendProfile closeFriendProfile1 = new CloseFriendProfile(user3, new DateTime(2023, 12, 02, 18, 40, 10));
CloseFriendProfile closeFriendProfile2 = new CloseFriendProfile(user4, new DateTime(2023, 12, 02, 18, 40, 10));
CloseFriendProfile closeFriendProfile3 = new CloseFriendProfile(user5, new DateTime(2023, 12, 02, 18, 40, 10));
CloseFriendProfile closeFriendProfile4 = new CloseFriendProfile(user2, new DateTime(2023, 12, 02, 18, 40, 10));
List<User> group1Members = new List<User>();
group1Members.Add(user2);
group1Members.Add(user3);
group1Members.Add(user1);
List<User> group2Members = new List<User>();
group2Members.Add(user1);
group2Members.Add(user5);
group2Members.Add(user4);
List<User> group3Members = new List<User>();
group3Members.Add(user1);
group3Members.Add(user5);
group3Members.Add(user2);
List<User> anotherGroupMembers = new List<User>();
anotherGroupMembers.Add(user5);
anotherGroupMembers.Add(user3);
Group group1 = new Group(Guid.NewGuid(), "group 1", group1Members);
Group group2 = new Group(Guid.NewGuid(), "group 3", group2Members);
Group group3 = new Group(Guid.NewGuid(), "group 2", group3Members);
Group group4 = new Group(Guid.NewGuid(), "another group", anotherGroupMembers);
List<Group> groups = new List<Group>();
groups.Add(group1);
groups.Add(group2);
groups.Add(group3);
groups.Add(group4);
// some hardocded profile perspective examples
UserProfileSocialNetworkInfo profileUser1 = new UserProfileSocialNetworkInfo(user1, new List<BlockedProfile> { blockedProfile2, blockedProfile3 }, new List<CloseFriendProfile> { closeFriendProfile4, closeFriendProfile3 }, new List<Group> { group1, group2, group3 }, new List<User> { user2, user3 }, new List<User> { user2, user3 });
UserProfileSocialNetworkInfo profileUser2 = new UserProfileSocialNetworkInfo(user2, new List<BlockedProfile> { blockedProfile1, blockedProfile3 }, new List<CloseFriendProfile> { closeFriendProfile4 }, new List<Group> { group1, group3 }, new List<User>(), new List<User>());
UserProfileSocialNetworkInfo profileUser3 = new UserProfileSocialNetworkInfo(user3, new List<BlockedProfile>(), new List<CloseFriendProfile>(), new List<Group> { group1, group3 }, new List<User>(), new List<User>());
UserProfileSocialNetworkInfo profileUser5 = new UserProfileSocialNetworkInfo(user5, new List<BlockedProfile>(), new List<CloseFriendProfile>(), new List<Group> { group2, group3, group4 }, new List<User>(), new List<User>());
List<UserProfileSocialNetworkInfo> userProfileSocialNetworkInfos = new List<UserProfileSocialNetworkInfo>();
userProfileSocialNetworkInfos.Add(profileUser1);
userProfileSocialNetworkInfos.Add(profileUser2);
userProfileSocialNetworkInfos.Add(profileUser3);
userProfileSocialNetworkInfos.Add(profileUser5);
// init repos with profiles list and groups list
GroupsRepository groupsRepository = new GroupsRepository();
ProfileNetworkInfoRepository<UserProfileSocialNetworkInfo> userProfileNetowrkRepository = new ProfileNetworkInfoRepository<UserProfileSocialNetworkInfo>();
// init profile info service with profile list
ProfileNetworkInfoService profileNetworkInfoService = new ProfileNetworkInfoService(groupsRepository, userProfileNetowrkRepository, usersRepo);
// profileNetworkInfoService.CreateGroupToRepository("group 1", group1Members);
// profileNetworkInfoService.CreateGroupToRepository("group 3", group3Members);
// profileNetworkInfoService.CreateGroupToRepository("group 2", group2Members);
// profileNetworkInfoService.CreateGroupToRepository("another group", anotherGroupMembers);
this.currentConnectedUser = user1;
this.profileNetworkInfoService = profileNetworkInfoService;
//// ADD DATA TO THE SERVICE
profileNetworkInfoService.AddProfileSocialNetworkInfo(profileUser1);
profileNetworkInfoService.AddProfileSocialNetworkInfo(profileUser2);
profileNetworkInfoService.AddProfileSocialNetworkInfo(profileUser5);
profileNetworkInfoService.AddBlockedProfileToCurrentUser(profileUser1, blockedProfile2);
profileNetworkInfoService.AddBlockedProfileToCurrentUser(profileUser1, blockedProfile4);
profileNetworkInfoService.AddCloseFriendToCurrentUser(profileUser1, closeFriendProfile2);
profileNetworkInfoService.AddGroupToCurrentUser(profileUser1, group1);
profileNetworkInfoService.AddGroupToCurrentUser(profileUser1, group3);
profileNetworkInfoService.AddGroupToCurrentUser(profileUser1, group2);
profileNetworkInfoService.AddRestrictedPostsAudienceUserToCurrentUser(profileUser1, user3);
profileNetworkInfoService.AddRestrictedStoriesAudienceUserToCurrentUser(profileUser1, user3);
profileNetworkInfoService.AddRestrictedPostsAudienceUserToCurrentUser(profileUser1, user2);
profileNetworkInfoService.AddRestrictedStoriesAudienceUserToCurrentUser(profileUser1, user2);
profileNetworkInfoService.AddRestrictedPostsAudienceUserToCurrentUser(profileUser1, user4);
profileNetworkInfoService.AddRestrictedStoriesAudienceUserToCurrentUser(profileUser1, user4);
profileNetworkInfoService.AddBlockedProfileToCurrentUser(profileUser2, blockedProfile3);
profileNetworkInfoService.AddBlockedProfileToCurrentUser(profileUser2, blockedProfile1);
profileNetworkInfoService.AddCloseFriendToCurrentUser(profileUser2, closeFriendProfile4);
profileNetworkInfoService.AddGroupToCurrentUser(profileUser2, group2);
profileNetworkInfoService.AddGroupToCurrentUser(profileUser2, group3);
InitializeComponent();
}
private void EditProfileButton_Click(object sender, RoutedEventArgs e)
{
List<UIElement> elementsToRemove = new List<UIElement>();
foreach (UIElement child in extraInfoGrid.Children)
{
int columnIndex = Grid.GetColumn(child);
if (columnIndex == 1)
{
elementsToRemove.Add(child);
}
}
foreach (UIElement element in elementsToRemove)
{
extraInfoGrid.Children.Remove(element);
}
var profileInfo = new ProfileInfo_GUI.ProfileInfoDisplay();
Grid.SetColumn(profileInfo, 1);
Grid.SetRow(profileInfo, 1);
Grid.SetRowSpan(profileInfo, 4);
// .Children.Clear();
extraInfoGrid.Children.Add(profileInfo);
}
private void SettingsPrivacyButton_Click(object sender, RoutedEventArgs e)
{
var settingsPrivacyUserControl = new SettingsPrivacy_UserControl(currentConnectedUser, profileNetworkInfoService);
Grid.SetColumn(settingsPrivacyUserControl, 1);
Grid.SetRow(settingsPrivacyUserControl, 1);
Grid.SetRowSpan(settingsPrivacyUserControl, 4);
// extraInfoGrid.Children.Clear();
extraInfoGrid.Children.Add(settingsPrivacyUserControl);
}
private void FancierProfileButton_Click(object sender, RoutedEventArgs e)
{
var paymentForm = new FancierProfilePage();
Grid.SetColumn(paymentForm, 1);
Grid.SetRow(paymentForm, 1);
Grid.SetRowSpan(paymentForm, 4);
// .Children.Clear();
extraInfoGrid.Children.Add(paymentForm);
}
private void SavedPostsButton_Click(object sender, RoutedEventArgs e)
{
}
private void CloseFriendsButton_Click(object sender, RoutedEventArgs e)
{
var closeFriendsUserControl = new CloseFriendsSection_UserControl(currentConnectedUser, profileNetworkInfoService);
Grid.SetColumn(closeFriendsUserControl, 1);
Grid.SetRow(closeFriendsUserControl, 1);
Grid.SetRowSpan(closeFriendsUserControl, 4);
// .Children.Clear();
extraInfoGrid.Children.Add(closeFriendsUserControl);
}
private void VerifiedAccountButton_Click(object sender, RoutedEventArgs e)
{
var newContent = new VerifiedAccount(profileNetworkInfoService);
// extraInfoGrid.Children.Clear();
extraInfoGrid.Children.Add(newContent);
Grid.SetColumn(newContent, 1);
Grid.SetRow(newContent, 1);
Grid.SetRowSpan(newContent, 4);
}
private void FriendsSettingsButton_Click(object sender, RoutedEventArgs e)
{
/*var friends = new FriendsSettings.Friends();
//extraInfoGrid.Children.Clear();
Grid.SetColumn(friends, 1);
Grid.SetRow(friends, 1);
Grid.SetRowSpan(friends, 4);
extraInfoGrid.Children.Add(friends);*/
// Collect the controls that need to be removed from the specified column
List<UIElement> elementsToRemove = new List<UIElement>();
// Iterate through the children of the extraInfoGrid
foreach (UIElement child in extraInfoGrid.Children)
{
// Get the column index of the current child
int columnIndex = Grid.GetColumn(child);
// Check if the child is located in the target column (column 1 in this case)
if (columnIndex == 1)
{
// Add the child to the list of elements to remove
elementsToRemove.Add(child);
}
}
// Remove all elements collected in the elementsToRemove list from the grid
foreach (UIElement element in elementsToRemove)
{
extraInfoGrid.Children.Remove(element);
}
// Create and add the new FriendsSettings.Friends control to the specified column
var friends = new FriendsSettings.Friends();
Grid.SetColumn(friends, 1);
Grid.SetRow(friends, 1);
Grid.SetRowSpan(friends, 4);
extraInfoGrid.Children.Add(friends);
}
private void LikedPostsButton_Click(object sender, RoutedEventArgs e)
{
var likedPosts = new LikedPosts();
Grid.SetColumn(likedPosts, 1);
Grid.SetRow(likedPosts, 1);
Grid.SetRowSpan(likedPosts, 4);
// extraInfoGrid.Children.Clear();
extraInfoGrid.Children.Add(likedPosts);
}
private void StatisticsButton_Click(object sender, RoutedEventArgs e)
{
var statistics = new Statistics.Statistics();
Grid.SetColumn(statistics, 1);
Grid.SetRow(statistics, 1);
Grid.SetRowSpan(statistics, 4);
// extraInfoGrid.Children.Clear();
extraInfoGrid.Children.Add(statistics);
}
}
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
using District_3_App.Statistics;
namespace District_3_App.ExtraInfo
{
public class ExtraInfoService
{
private StatisticsService statisticsService;
private ProfileNetworkInfoService profileNetworkInfoService;
public ExtraInfoService(StatisticsService statisticsService, ProfileNetworkInfoService profileNetworkInfoService)
{
this.statisticsService = statisticsService;
this.profileNetworkInfoService = profileNetworkInfoService;
}
public StatisticsService GetStatisticsService()
{
return this.statisticsService;
}
public ProfileNetworkInfoService GetProfileNetworkInfoService()
{
return this.profileNetworkInfoService;
}
}
}
@@ -0,0 +1,33 @@
<UserControl x:Class="District_3_App.ExtraInfo.PaymentConfirmed"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:District_3_App.ExtraInfo"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="ConfirmationGrid" Background="White" Margin="0,0,0,0">
<Image Source="E:\facultate\Sem4\software engineering\lab4\paymentConfirmation.png" Height="100" Width="100" Margin="350,42,350,292"/>
<StackPanel Height="30" Width="200" Orientation="Horizontal" Margin="10 150 10 200" HorizontalAlignment="Center">
<TextBlock Text="Payment successful" TextAlignment="Center" FontSize="20" Foreground="#47525E" FontWeight="Bold" Width="199"/>
</StackPanel>
<Line X1="-700" Y1="60" X2="2000" Y2="60" Stroke="#969FAA" StrokeThickness="2" Margin="0,174,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="909"/>
<StackPanel Height="30" Width="200" Orientation="Horizontal" Margin="10 260 0 130" HorizontalAlignment="Center">
<TextBlock Text="Amount paid: 200$" TextAlignment="Center" FontSize="15" Foreground="#47525E" FontWeight="Bold" Width="199"/>
</StackPanel>
<Button Click="Button_Click" Height="30" Width="140" HorizontalAlignment="Center" Margin="0,320,0,0" Background="#47525E" Foreground="White" BorderBrush="DarkGray">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Back to profile page" Grid.Column="0"/>
</Grid>
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
</Grid>
</UserControl>
@@ -0,0 +1,36 @@
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;
namespace District_3_App.ExtraInfo
{
/// <summary>
/// Interaction logic for PaymentConfirmed.xaml
/// </summary>
public partial class PaymentConfirmed : UserControl
{
public PaymentConfirmed()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var newContent = new ProfileInfo_GUI.ProfileInfoDisplay();
ConfirmationGrid.Children.Clear();
ConfirmationGrid.Children.Add(newContent);
}
}
}
@@ -0,0 +1,63 @@
<UserControl x:Class="District_3_App.ExtraInfo.PaymentForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:District_3_App.ExtraInfo"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="CompleteGrid" Background="White">
<Grid Height="20" Width="500" Margin="100,52,100,362">
<Border BorderThickness="1" CornerRadius="10" Background="#2A2838" Margin="-48,0,-50,0"/>
</Grid>
<Grid Height="290" VerticalAlignment="Center" Width="600" Background="White" HorizontalAlignment="Center" >
<StackPanel Orientation="Vertical" >
<StackPanel Width="500" Height="50" Orientation="Vertical" Background="White" Margin="30 10 0 0" HorizontalAlignment="Left">
<TextBlock Text="CARD NUMBER" Foreground="#8190A5"></TextBlock>
<Grid Height="22" Width="500" Margin="0 10 0 0">
<TextBox x:Name="CardNumberTextBox" Text="{Binding Account.CardNumber, UpdateSourceTrigger=PropertyChanged}"/>
<Border BorderBrush="#343F4B" BorderThickness="2" CornerRadius="5"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<StackPanel Width="100" Height="20" Orientation="Horizontal" Background="White" Margin="30 0 0 0">
<TextBlock Text="EXPIRATION DATE" Foreground="#8190A5"></TextBlock>
</StackPanel>
<StackPanel Width="100" Height="20" Orientation="Horizontal" Background="White" Margin="315 10 10 10" >
<TextBlock Text="CVV" Foreground="#8190A5"></TextBlock>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5 0 0 0">
<Grid Height="22" Width="90" Margin="25 0 0 0">
<TextBox x:Name="ExpirationDateTextBox" Text="{Binding Account.ExpirationDate, UpdateSourceTrigger=PropertyChanged}"/>
<Border BorderBrush="#343F4B" BorderThickness="2" CornerRadius="5"/>
</Grid>
<Grid Height="22" Width="90" Margin="315 0 0 0">
<TextBox x:Name="CVVTextBox" Text="{Binding Account.CVV, UpdateSourceTrigger=PropertyChanged}"/>
<Border BorderBrush="#343F4B" BorderThickness="2" CornerRadius="5"/>
</Grid>
</StackPanel>
<StackPanel Width="500" Height="50" Orientation="Vertical" Background="White" Margin="30" HorizontalAlignment="Left">
<TextBlock Text="CARDHOLDER NAME" Foreground="#8190A5"></TextBlock>
<Grid Height="22" Width="500" Margin="0 10 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="231*"/>
<ColumnDefinition Width="269*"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="HolderNameTextBox" Text="{Binding Account.HolderName, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" Grid.ColumnSpan="2"/>
<Border BorderBrush="#343F4B" BorderThickness="2" CornerRadius="5" Grid.ColumnSpan="2"/>
</Grid>
</StackPanel>
</StackPanel>
<Button Content="Confirm" Click="Button_Click" Height="30" Width="70" HorizontalAlignment="Center" Margin="0,250,0,0" VerticalAlignment="Top" Background="#47525E" Foreground="White" BorderBrush="DarkGray">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
<Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="10"/>
</Grid>
<ContentControl x:Name="PaymentConfirmedControl"></ContentControl>
</Grid>
</UserControl>
@@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
using System.IO;
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 System.Xml.Linq;
using District_3_App.LogIn;
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
namespace District_3_App.ExtraInfo
{
/// <summary>
/// Interaction logic for PaymentForm.xaml
/// </summary>
public partial class PaymentForm : UserControl
{
public Account Account { get; set; }
private ProfileNetworkInfoService profileNetworkInfoService;
private UserManager userManager;
private XDocument xmlDoc;
public PaymentForm(ProfileNetworkInfoService profileNetworkInfoService)
{
this.profileNetworkInfoService = profileNetworkInfoService;
InitializeComponent();
try
{
string xmlFilePath = "./Users.xml";
xmlDoc = XDocument.Load(xmlFilePath);
userManager = new UserManager(xmlFilePath);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load XML file: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
/*var users = xmlDoc.Descendants("User");
Guid id = Guid.NewGuid();
string username = "test_1";
string email = "testines@gmail.com";
string password = "Test-1";
string confirmationPassword = "Test-1";
var user = FindUserByUsernameAndPassword(username, password);*/
/*if (user != null)
{
Account = new Account(new User(id,username, password,email,confirmationPassword), "", "", "", "");
DataContext = this;
}*/
string username = "test_1";
string password = "Test-1";
// Authenticate user
if (userManager.AuthenticateUser(username, password))
{
bool isLoggedIn = userManager.IsUserLoggedIn();
if (isLoggedIn)
{
User currentUser = userManager.GetUsers().FirstOrDefault(u => u.Username == username);
if (currentUser != null)
{
Account = new Account(currentUser, string.Empty, string.Empty, string.Empty, string.Empty);
DataContext = this;
}
else
{
MessageBox.Show("User details not found.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
else
{
MessageBox.Show("No user is currently logged in.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
else
{
MessageBox.Show("User not found or authentication failed.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
/*else
{
MessageBox.Show("User not found in XML.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}*/
private XElement FindUserByUsernameAndPassword(string username, string password)
{
/*foreach (var userElement in xmlDoc.Root.Elements("User"))
{
User currUser = new User
{
id = Guid.Parse(userElement.Attribute("id").Value),
username = userElement.Attribute("Username").Value,
email = userElement.Attribute("Email").Value,
password = userElement.Attribute("Password").Value,
confirmationPassword = userElement.Attribute("ConfirmationPassword").Value,
};
}
var user = xmlDoc.Descendants("User")
.FirstOrDefault(u => (string)u.Element("Username") == username &&
(string)u.Element("Password") == password);
return user;*/
foreach (var userElement in xmlDoc.Root.Elements("User"))
{
string xmlUsername = userElement.Attribute("Username")?.Value;
string xmlPassword = userElement.Attribute("Password")?.Value;
if (xmlUsername == username && xmlPassword == password)
{
return userElement;
}
}
return null;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
bool isValid = true;
if (!ValidateCardNumber(CardNumberTextBox.Text))
{
MessageBox.Show("Card Number must be a string of 16 digits (numeric input only).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
isValid = false;
}
if (!ValidateExpirationDate(ExpirationDateTextBox.Text))
{
MessageBox.Show("Expiration Date must be in MM/YY format (numeric input only).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
isValid = false;
}
if (!ValidateCVV(CVVTextBox.Text))
{
MessageBox.Show("CVV must be a three-digit code (numeric input only).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
isValid = false;
}
if (!ValidateHolderName(HolderNameTextBox.Text))
{
MessageBox.Show("Holder Name must contain alphabetic characters only.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
isValid = false;
}
if (isValid)
{
Account.CardNumber = CardNumberTextBox.Text;
Account.ExpirationDate = ExpirationDateTextBox.Text;
Account.CVV = CVVTextBox.Text;
Account.HolderName = HolderNameTextBox.Text;
var newContent = new PaymentConfirmed();
CompleteGrid.Children.Clear();
Grid.SetColumn(newContent, 1);
CompleteGrid.Children.Add(newContent);
}
}
private bool ValidateCardNumber(string cardNumber)
{
return !string.IsNullOrWhiteSpace(cardNumber) && (cardNumber.Length == 16 && IsNumeric(cardNumber));
}
private bool ValidateExpirationDate(string expirationDate)
{
if (string.IsNullOrWhiteSpace(expirationDate) || expirationDate.Length != 5)
{
return false;
}
string[] parts = expirationDate.Split('/');
if (parts.Length != 2)
{
return false;
}
if (!int.TryParse(parts[0], out int month) || !int.TryParse(parts[1], out int year))
{
return false;
}
int currentYear = DateTime.Now.Year % 100;
return month >= 1 && month <= 12 && year >= currentYear && year <= currentYear + 10;
}
private bool ValidateCVV(string cvv)
{
return !string.IsNullOrWhiteSpace(cvv) && (cvv.Length == 3 && IsNumeric(cvv));
}
private bool ValidateHolderName(string holderName)
{
return !string.IsNullOrWhiteSpace(holderName) && IsAlphabetic(holderName);
}
private bool IsNumeric(string value)
{
return long.TryParse(value, out _);
}
private bool IsAlphabetic(string value)
{
return value.All(c => char.IsLetter(c) || char.IsWhiteSpace(c));
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace District_3_App.ExtraInfo
{
public class UserExtraInfo
{
private string username;
private string password;
public string Username
{
get { return username; }
set { username = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public UserExtraInfo(string name, string passwd)
{
username = name;
password = passwd;
}
}
}
@@ -0,0 +1,60 @@
<UserControl x:Class="District_3_App.ExtraInfo.VerifiedAccount"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:District_3_App.ExtraInfo"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="VerifiedAccountGrid" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Margin="10,0,0,-30" HorizontalAlignment="Left" Width="619" Grid.Column="0">
<TextBlock Text="Verified Account" Foreground="#47525E" FontSize="25" FontWeight="Bold"/>
<Grid Height="335" HorizontalAlignment="Left" Width="565" Background="White" Margin="15 40 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Pricing" Foreground="#47525E" FontSize="25" Margin="15 10 0 0" FontWeight="Bold" TextAlignment="Center"/>
<Grid Height="201" Width="376" HorizontalAlignment="Left" Margin="105,82,0,0" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="20*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0" Orientation="Vertical">
<TextBlock Text="Classic" Foreground="#47525E" FontSize="20" Margin="0 10 0 0" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="FREE" Foreground="#47525E" FontSize="18" Margin="0 0 0 0" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="Edit Profile" Foreground="#8190A5" FontSize="10" Margin="0 10 0 0" TextAlignment="Center"/>
<TextBlock Text="Make Connections" Foreground="#8190A5" FontSize="10" Margin="0 10 0 0" TextAlignment="Center"/>
<Button x:Name="ChooseFreeButton" Click="ChooseFreeButton_Click" Content="Choose" FontSize="8" Height="20" Width="40" HorizontalAlignment="Center" Margin="0,5,0,0" VerticalAlignment="Top" Background="#47525E" Foreground="White" BorderBrush="DarkGray">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
</StackPanel>
<Line Grid.Column="0" X1="180" Y1="0" X2="180" Y2="800" Stroke="#8492A6" StrokeThickness="1" />
<StackPanel Grid.Column="1" Margin="0" Orientation="Vertical">
<TextBlock Text="Business" Foreground="#47525E" FontSize="20" Margin="0 10 0 0" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="$ 200.0" Foreground="#47525E" FontSize="18" Margin="0 0 0 0" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="Verified Account" Foreground="#8190A5" FontSize="10" Margin="0 10 0 0" TextAlignment="Center"/>
<TextBlock Text="See who viewed your profile" Foreground="#8190A5" FontSize="10" Margin="0 10 0 0" TextAlignment="Center"/>
<Button x:Name="ChooseBusinessButton" Click="ChooseBusinessButton_Click" Content="Choose" FontSize="8" Height="20" Width="40" HorizontalAlignment="Center" Margin="0,5,0,0" VerticalAlignment="Top" Background="#47525E" Foreground="White" BorderBrush="DarkGray">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</Button.Resources>
</Button>
</StackPanel>
<Border Grid.ColumnSpan="2" BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5"/>
</Grid>
<Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="10"/>
<ContentControl x:Name="FreeAccountControl"/>
<ContentControl x:Name="BusinessAccountControl"/>
</Grid>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,55 @@
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 District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
using District_3_App.Statistics;
using Statistics;
namespace District_3_App.ExtraInfo
{
/// <summary>
/// Interaction logic for VerifiedAccount.xaml
/// </summary>
public partial class VerifiedAccount : UserControl
{
private ProfileNetworkInfoService profileNetworkInfoService;
public VerifiedAccount(ProfileNetworkInfoService profileNetworkInfoService)
{
this.profileNetworkInfoService = profileNetworkInfoService;
InitializeComponent();
}
private void ChooseBusinessButton_Click(object sender, RoutedEventArgs e)
{
var paymentForm = new PaymentForm(profileNetworkInfoService);
// VerifiedAccountGrid.Children.Clear();
/*Grid.SetColumn(paymentForm, 0);
Grid.SetRow(paymentForm, 1);
Grid.SetRowSpan(paymentForm, 4);*/
VerifiedAccountGrid.Children.Add(paymentForm);
}
private void ChooseFreeButton_Click(object sender, RoutedEventArgs e)
{
var newContent = new VerifiedAccount(profileNetworkInfoService);
VerifiedAccountGrid.Children.Clear();
Grid.SetColumn(newContent, 0);
Grid.SetRow(newContent, 1);
Grid.SetRowSpan(newContent, 4);
VerifiedAccountGrid.Children.Add(newContent);
}
}
}