School Commit Init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
@@ -0,0 +1,3 @@
|
||||
bin/
|
||||
obj/
|
||||
.vs/
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="District_3_App.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:District_3_App"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace District_3_App
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
|
||||
// (used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly) // where the generic resource dictionary is located
|
||||
// (used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
]
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="District_3_App.CloseFriends_GUI.CloseFriendsSection_UserControl"
|
||||
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.CloseFriends_GUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800" Background="White">
|
||||
<Grid HorizontalAlignment="Left">
|
||||
<Label FontSize="25" Content="Close Friends" HorizontalAlignment="Left" Margin="141,34,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox SelectionChanged="SearchCloseFriendsTextBox_SelectionChanged" x:Name="searchCloseFriendsTextBox" FontSize="20" Background="LightGray" HorizontalAlignment="Left" Margin="141,82,0,0" TextWrapping="Wrap" Text="Search" VerticalAlignment="Top" Width="259"/>
|
||||
|
||||
<Button x:Name="addNewCloseFriendButton" Content="Add" HorizontalAlignment="Left" Margin="626,82,0,0" VerticalAlignment="Top" Height="29" Width="48" Click="AddNewCloseFriendButton_Click"/>
|
||||
<Button x:Name="removeCloseFriendButton" Content="Remove" HorizontalAlignment="Left" Margin="626,131,0,0" VerticalAlignment="Top" Height="30" Width="49" Click="RemoveCloseFriendButton_Click"/>
|
||||
<ListView x:Name="closeFriendsListView" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="141,131,275,130">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
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.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
|
||||
|
||||
namespace District_3_App.CloseFriends_GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CloseFriendsSection_UserControl.xaml
|
||||
/// </summary>
|
||||
public partial class CloseFriendsSection_UserControl : UserControl
|
||||
{
|
||||
private User currentConnectedUser;
|
||||
private ProfileNetworkInfoService profileNetworkInfoService;
|
||||
|
||||
public CloseFriendsSection_UserControl(User u, ProfileNetworkInfoService service)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.currentConnectedUser = u;
|
||||
this.profileNetworkInfoService = service;
|
||||
|
||||
PopulateCloseFriends();
|
||||
}
|
||||
|
||||
public void PopulateCloseFriends()
|
||||
{
|
||||
if (searchCloseFriendsTextBox.Text.Length > 0 && profileNetworkInfoService != null)
|
||||
{
|
||||
// closeFriendsListView.Items.Clear();
|
||||
|
||||
// UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
// foreach (var user in profileNetworkInfoService.GetAllUsers())
|
||||
// {
|
||||
// bool isCloseFriend = false;
|
||||
|
||||
// foreach (var closeFriend in profile.closeFriendsProfiles)
|
||||
// {
|
||||
// if (closeFriend.user.username == user.username)
|
||||
// isCloseFriend = true;
|
||||
// }
|
||||
|
||||
// if (!isCloseFriend)
|
||||
// {
|
||||
// //non close friend image
|
||||
// closeFriendsListView.Items.Add(new { Username = user.username, ImagePath = "../../images/round_checkBox.jpeg" });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //close firend image
|
||||
// closeFriendsListView.Items.Add(new { Username = user.username, ImagePath = "../../images/filled_round_checkBox.jpg" });
|
||||
// }
|
||||
// }
|
||||
closeFriendsListView.Items.Clear();
|
||||
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
foreach (var closeFriend in profile.CloseFriendsProfiles)
|
||||
{
|
||||
if (closeFriend.User.Username.Contains(searchCloseFriendsTextBox.Text))
|
||||
{
|
||||
closeFriendsListView.Items.Add(closeFriend.User.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchCloseFriendsTextBox_SelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PopulateCloseFriends();
|
||||
}
|
||||
|
||||
private void AddNewCloseFriendButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (searchCloseFriendsTextBox.Text.Length > 0 && profileNetworkInfoService != null)
|
||||
{
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
bool usernameExists = false;
|
||||
foreach (var user in profileNetworkInfoService.GetAllUsers())
|
||||
{
|
||||
if (user.Username == searchCloseFriendsTextBox.Text)
|
||||
{
|
||||
usernameExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!usernameExists)
|
||||
{
|
||||
MessageBox.Show("Error: User with this username does not exist");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool alreadyCloseFriend = false;
|
||||
foreach (var closeFriend in profile.CloseFriendsProfiles)
|
||||
{
|
||||
if (closeFriend.User.Username == searchCloseFriendsTextBox.Text)
|
||||
{
|
||||
alreadyCloseFriend = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (alreadyCloseFriend)
|
||||
{
|
||||
MessageBox.Show("Error: User is already your close friend");
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseFriendProfile closeFriendToAdd = new CloseFriendProfile(profileNetworkInfoService.GetUserByName(searchCloseFriendsTextBox.Text), DateTime.Now);
|
||||
profile.CloseFriendsProfiles.Add(closeFriendToAdd);
|
||||
profileNetworkInfoService.SaveDataIntoXML();
|
||||
|
||||
PopulateCloseFriends();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveCloseFriendButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string selectedCloseFriendUsername = closeFriendsListView.SelectedItem.ToString();
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(this.currentConnectedUser);
|
||||
|
||||
profileNetworkInfoService.RemoveCloseFriendFromCurrentUser(profile, profileNetworkInfoService.GetCloseFriendByName(profile, selectedCloseFriendUsername));
|
||||
profileNetworkInfoService.SaveDataIntoXML();
|
||||
|
||||
closeFriendsListView.Items.Clear(); // reset the list view
|
||||
|
||||
foreach (var closeFriend in profile.CloseFriendsProfiles)
|
||||
{
|
||||
closeFriendsListView.Items.Add(closeFriend.User.Username);
|
||||
// foreach (var groupMember in group.groupMembers)
|
||||
// {
|
||||
// groupMembersListView.Items.Add(groupMember.username);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<RootNamespace>District_3_App</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<CodeAnalysisRuleSet>SE.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="images\app_logo.png" />
|
||||
<None Remove="images\avatar.png" />
|
||||
<None Remove="images\bee1.jpg" />
|
||||
<None Remove="images\bee2.jpg" />
|
||||
<None Remove="images\bee3.jpg" />
|
||||
<None Remove="images\bell.png" />
|
||||
<None Remove="images\closeFriends.png" />
|
||||
<None Remove="images\explore.png" />
|
||||
<None Remove="images\fancierProfile.png" />
|
||||
<None Remove="images\friends.png" />
|
||||
<None Remove="images\hidePasswordIcon.png" />
|
||||
<None Remove="images\home.png" />
|
||||
<None Remove="images\katniss.jpg" />
|
||||
<None Remove="images\likedPosts.png" />
|
||||
<None Remove="images\menu.png" />
|
||||
<None Remove="images\more2.png" />
|
||||
<None Remove="images\peeta.jpeg" />
|
||||
<None Remove="images\plus.png" />
|
||||
<None Remove="images\poster.jpeg" />
|
||||
<None Remove="images\reel.png" />
|
||||
<None Remove="images\right-arrow.png" />
|
||||
<None Remove="images\saved.png" />
|
||||
<None Remove="images\search-interface-symbol.png" />
|
||||
<None Remove="images\send.png" />
|
||||
<None Remove="images\settings.png" />
|
||||
<None Remove="images\showPasswordIcon.png" />
|
||||
<None Remove="images\snow.jpg" />
|
||||
<None Remove="images\square.png" />
|
||||
<None Remove="images\square1.png" />
|
||||
<None Remove="images\statistics.png" />
|
||||
<None Remove="images\threedots.png" />
|
||||
<None Remove="images\user.png" />
|
||||
<None Remove="images\userExtraInfo.png" />
|
||||
<None Remove="images\verified.png" />
|
||||
<None Remove="images\verify.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="images\app_logo.png" />
|
||||
<Resource Include="images\avatar.png" />
|
||||
<Resource Include="images\bee2.jpg" />
|
||||
<Resource Include="images\bee3.jpg" />
|
||||
<Resource Include="images\bell.png" />
|
||||
<Resource Include="images\closeFriends.png" />
|
||||
<Resource Include="images\explore.png" />
|
||||
<Resource Include="images\fancierProfile.png" />
|
||||
<Resource Include="images\friends.png" />
|
||||
<Resource Include="images\hidePasswordIcon.png" />
|
||||
<Resource Include="images\home.png" />
|
||||
<Resource Include="images\katniss.jpg" />
|
||||
<Resource Include="images\likedPosts.png" />
|
||||
<Resource Include="images\menu.png" />
|
||||
<Resource Include="images\more2.png" />
|
||||
<Resource Include="images\peeta.jpeg" />
|
||||
<Resource Include="images\plus.png" />
|
||||
<Resource Include="images\poster.jpeg" />
|
||||
<Resource Include="images\reel.png" />
|
||||
<Resource Include="images\right-arrow.png" />
|
||||
<Resource Include="images\saved.png" />
|
||||
<Resource Include="images\search-interface-symbol.png" />
|
||||
<Resource Include="images\send.png" />
|
||||
<Resource Include="images\settings.png" />
|
||||
<Resource Include="images\showPasswordIcon.png" />
|
||||
<Resource Include="images\snow.jpg" />
|
||||
<Resource Include="images\square.png" />
|
||||
<Resource Include="images\square1.png" />
|
||||
<Resource Include="images\statistics.png" />
|
||||
<Resource Include="images\threedots.png" />
|
||||
<Resource Include="images\user.png" />
|
||||
<Resource Include="images\userExtraInfo.png" />
|
||||
<Resource Include="images\verified.png" />
|
||||
<Resource Include="images\verify.png" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Update="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="CloseFriends_GUI\CloseFriendsSection_UserControl.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="FancierProfilePage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="HighlightsFE\CreateNewHighlight.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="HighlightsFE\HighlightsOnMain.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="HighlightsFE\SeeHighlightPosts.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="HighlightsFE\SelectHighlight.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="HighlightsFE\SelectPostsPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="LogIn\ForgotPassword.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="LogIn\SignInPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="LogIn\SignUp.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl1.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl2.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl3.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl4.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl5.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UserControl6.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="CloseFriends_GUI\CloseFriendsSection_UserControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="FancierProfilePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="HighlightsFE\CreateNewHighlight.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="HighlightsFE\HighlightsOnMain.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="HighlightsFE\SeeHighlightPosts.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="HighlightsFE\SelectHighlight.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="HighlightsFE\SelectPostsPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="LogIn\ForgotPassword.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="LogIn\SignInPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="LogIn\SignUp.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="LogIn\Window1.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="MainWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl1.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl2.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl3.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl4.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl5.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="UserControl6.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "District 3 App", "District 3 App.csproj", "{355E9333-12C6-4227-BB49-B41AE5EB5DE6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "District 3 App Tests", "..\District 3 App Tests\District 3 App Tests.csproj", "{FCACACDE-D61C-45A0-BDC3-8D47C809F3BF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{355E9333-12C6-4227-BB49-B41AE5EB5DE6} = {355E9333-12C6-4227-BB49-B41AE5EB5DE6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{355E9333-12C6-4227-BB49-B41AE5EB5DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{355E9333-12C6-4227-BB49-B41AE5EB5DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{355E9333-12C6-4227-BB49-B41AE5EB5DE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{355E9333-12C6-4227-BB49-B41AE5EB5DE6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FCACACDE-D61C-45A0-BDC3-8D47C809F3BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FCACACDE-D61C-45A0-BDC3-8D47C809F3BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FCACACDE-D61C-45A0-BDC3-8D47C809F3BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FCACACDE-D61C-45A0-BDC3-8D47C809F3BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9FE740C1-BC80-4943-BC00-2F2490A3F040}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.Enitities
|
||||
{
|
||||
public class Highlight
|
||||
{
|
||||
private Guid highlightId;
|
||||
private Guid userId;
|
||||
private List<Guid> postsIds;
|
||||
private string name;
|
||||
private string coverFilePath;
|
||||
|
||||
public Highlight()
|
||||
{
|
||||
}
|
||||
public Highlight(string newName, string newCover)
|
||||
{
|
||||
this.highlightId = Guid.NewGuid();
|
||||
this.postsIds = new List<Guid>();
|
||||
this.name = newName;
|
||||
this.coverFilePath = newCover;
|
||||
}
|
||||
public Guid GetHighlightId()
|
||||
{
|
||||
return highlightId;
|
||||
}
|
||||
public List<Guid> GetPosts()
|
||||
{
|
||||
return postsIds;
|
||||
}
|
||||
public string GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public string GetCover()
|
||||
{
|
||||
return coverFilePath;
|
||||
}
|
||||
public bool AddPostToHighlight(Guid postId)
|
||||
{
|
||||
this.postsIds.Add(postId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemovePostFromHighlight(Guid postId)
|
||||
{
|
||||
this.postsIds.Remove(postId);
|
||||
return true;
|
||||
}
|
||||
public void SetName(string newName)
|
||||
{
|
||||
this.name = newName;
|
||||
}
|
||||
public void SetCover(string coverFilePath)
|
||||
{
|
||||
this.coverFilePath = coverFilePath;
|
||||
}
|
||||
public void SetListPosts(List<Guid> postsIds)
|
||||
{
|
||||
this.postsIds = postsIds;
|
||||
}
|
||||
public void SetGuid(Guid guid)
|
||||
{
|
||||
this.highlightId = guid;
|
||||
}
|
||||
|
||||
public void SetListPosts(List<string> list)
|
||||
{
|
||||
List<Guid> guids = new List<Guid>();
|
||||
foreach (var post in list)
|
||||
{
|
||||
guids.Add(Guid.Parse(post));
|
||||
}
|
||||
this.SetListPosts(guids);
|
||||
}
|
||||
public void SetUserId(Guid userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
public Guid GetUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.Enitities.Mocks
|
||||
{
|
||||
public class MockPhotoPost : MockPost
|
||||
{
|
||||
private string description;
|
||||
private string filePath;
|
||||
|
||||
public MockPhotoPost(object user, Dictionary<int, List<object>> reactions, List<object> mentionedUsers, string title, string description, string photo)
|
||||
: base(user, reactions, mentionedUsers, title)
|
||||
{
|
||||
this.description = description;
|
||||
this.filePath = photo;
|
||||
}
|
||||
|
||||
public string GetPhoto()
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.Enitities.Mocks
|
||||
{
|
||||
public class MockPost
|
||||
{
|
||||
private Guid postId;
|
||||
private object user;
|
||||
private Dictionary<int, List<object>> reactions;
|
||||
private List<object> mentionedUsers;
|
||||
private string title;
|
||||
|
||||
public MockPost(object user, Dictionary<int, List<object>> reactions, List<object> mentionedUsers, string title)
|
||||
{
|
||||
this.postId = Guid.NewGuid();
|
||||
this.user = user;
|
||||
this.reactions = reactions;
|
||||
this.mentionedUsers = mentionedUsers;
|
||||
this.title = title;
|
||||
}
|
||||
public Guid GetPostId()
|
||||
{
|
||||
return postId;
|
||||
}
|
||||
public void SetPostId(Guid postId)
|
||||
{
|
||||
this.postId = postId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -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>
|
||||
+36
@@ -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>
|
||||
+219
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -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>
|
||||
+55
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
<UserControl x:Class="District_3_App.FancierProfilePage"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="Fancier Profile" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" FontSize="18" FontWeight="Bold" Foreground="#FF47525E"/>
|
||||
|
||||
<Grid x:Name="MottosGrid" Grid.Row="1" Margin="10">
|
||||
<Label Content="Motto of the day" HorizontalAlignment="Left" VerticalAlignment="Top" Width="111" Foreground="#FF47525E" FontWeight="Bold"/>
|
||||
<Button x:Name="AddMottoButton" Content="Add" HorizontalAlignment="Left" Margin="357,0,0,0" VerticalAlignment="Center" Width="94" Click="AddMottoButton_Click" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<TextBox HorizontalAlignment="Left" Margin="3,25,0,0" TextWrapping="Wrap" Text="Choose a daily motto from our list or add your own!
|
||||
The perfect way to tell your friends about your day" VerticalAlignment="Top" Width="285" Height="43" Foreground="#FF8190A5" BorderBrush="#00000000" SelectionBrush="#00000000" />
|
||||
|
||||
<Popup x:Name="MottoPopUp" PlacementTarget="{Binding ElementName=AddMottoButton}" Placement="Center" StaysOpen="False">
|
||||
<Border Background="White" BorderBrush="#FF47525E" Width="250" Height="150" BorderThickness="1" CornerRadius="5">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Choose one of ours:" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Left"/>
|
||||
<Button x:Name="closePopUpButton" Grid.Row="0" Grid.Column="1" Content="X" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="ClosePopUpButton_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
|
||||
<ComboBox Name="MottosComboBox" Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
|
||||
<ComboBoxItem Content="LIVE every moment, LAUGH every day, LOVE beyond words"></ComboBoxItem>
|
||||
<ComboBoxItem Content="You know my name not my story"></ComboBoxItem>
|
||||
<ComboBoxItem Content="Let's stop wasting time, get wasted and have the time of our lives"></ComboBoxItem>
|
||||
<ComboBoxItem Content="DALE -Mr. Worldwide"></ComboBoxItem>
|
||||
<ComboBoxItem Content="This is for everybody going through tough times: been there, done that"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Content="Or make your own:" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="textInputBox" Grid.Row="3" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="5" TextChanged="TextInputBox_TextChanged"/>
|
||||
|
||||
<Button Grid.Row="4" Grid.Column="0" x:Name="SaveMottoButton" Content="Save" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="SaveMottoButton_Click" Width="100">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Button Grid.Row="4" Grid.Column="1" x:Name="cancelMottoButton" Content="Cancel" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="ClosePopUpButton_Click" Width="100">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Popup>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
<Grid x:Name="ExtraLinks" Grid.Row="2" Margin="10">
|
||||
<Label Content="Extra Links" HorizontalAlignment="Left" VerticalAlignment="Top" Width="111" Foreground="#FF47525E" FontWeight="Bold"/>
|
||||
<Button x:Name="AddExtraLinksButton" Content="Add" HorizontalAlignment="Left" Margin="357,0,0,0" VerticalAlignment="Center" Width="94" Click="AddExtraLinksButton_Click" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" >
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<TextBox HorizontalAlignment="Left" Margin="3,25,0,0" TextWrapping="Wrap" Text="Add links to your profile and promote your work!" VerticalAlignment="Top" Width="285" Height="43" Foreground="#FF8190A5" BorderBrush="#00000000" SelectionBrush="#00000000" />
|
||||
|
||||
<Popup x:Name="LinksPopUp" PlacementTarget="{Binding ElementName=AddExtraLinksButton}" Placement="Center" StaysOpen="False" >
|
||||
<Border Background="White" BorderBrush="#FF47525E" Width="250" Height="150" CornerRadius="10" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Write the links " Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" FontSize="14" />
|
||||
<Button x:Name="closeLinksPopUpButton" Grid.Row="0" Grid.Column="1" Content="X" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="CloseLinksPopUpButton_Click" Margin="5"/>
|
||||
<TextBox x:Name="link1Text" Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="10" Width="200" Height="25" BorderThickness="1" BorderBrush="#FF47525E"/>
|
||||
<TextBox x:Name="link2Text" Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="10" Width="200" Height="25" BorderThickness="1" BorderBrush="#FF47525E" />
|
||||
<Button Grid.Row="4" Grid.Column="0" x:Name="SaveLinksButton" Content="Save" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="SaveLinksButton_Click" Margin="5" Width="100">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Button Grid.Row="4" Grid.Column="1" x:Name="cancelLinksButton" Content="Cancel" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="CancelLinksButton_Click" Margin="5" Width="100">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Popup>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="FramesGrid" Grid.Row="3" Margin="5,25,15,-48">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="257*"/>
|
||||
<ColumnDefinition Width="223*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Frames" HorizontalAlignment="Left" VerticalAlignment="Top" Width="111" Foreground="#FF47525E" FontWeight="Bold" Margin="3,-29,0,0"/>
|
||||
<UniformGrid Rows="1" Columns="7" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2" >
|
||||
<Button x:Name="firstFrame" Background="White" BorderThickness="0" Height="52" Width="52" Margin="5" Click="FirstFrame_Click">
|
||||
<Rectangle Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFFF00BD"/>
|
||||
<GradientStop Color="#FF0A2CB9" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
|
||||
<Button x:Name="secondFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="SecondFrame_Click">
|
||||
<Rectangle Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="Black"/>
|
||||
<GradientStop Color="#FF80006E" Offset="1"/>
|
||||
<GradientStop Color="#FFEE47F2" Offset="0.798"/>
|
||||
<GradientStop Color="White" Offset="0.616"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
<Button x:Name="thirdFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="ThirdFrame_Click">
|
||||
<Rectangle HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6" >
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFD52D00"/>
|
||||
<GradientStop Color="#FFA30262" Offset="1"/>
|
||||
<GradientStop Color="#FFB55690" Offset="0.858"/>
|
||||
<GradientStop Color="#FFD162A4" Offset="0.629"/>
|
||||
<GradientStop Color="White" Offset="0.497"/>
|
||||
<GradientStop Color="#FFFF9A56" Offset="0.36"/>
|
||||
<GradientStop Color="#FFEF7627" Offset="0.199"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
<Button x:Name="forthFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="ForthFrame_Click">
|
||||
<Rectangle HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6" >
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFE40303"/>
|
||||
<GradientStop Color="DarkOrange" Offset="0.21"/>
|
||||
<GradientStop Color="#FFFFED00" Offset="0.401"/>
|
||||
<GradientStop Color="#FF008026" Offset="0.57"/>
|
||||
<GradientStop Color="#FF24408E" Offset="0.766"/>
|
||||
<GradientStop Color="#FF732982" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
<Button x:Name="fifthFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="FifthFrame_Click" >
|
||||
<Rectangle HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6" >
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FF5BCEFA"/>
|
||||
<GradientStop Color="#FFF5A9B8" Offset="0.272"/>
|
||||
<GradientStop Color="White" Offset="0.519"/>
|
||||
<GradientStop Color="#FFF5A9B8" Offset="0.734"/>
|
||||
<GradientStop Color="#FF5BCEFA" Offset="0.981"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
<Button x:Name="romanianFlagFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="RomanianFlagFrame_Click">
|
||||
<Rectangle HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="50" StrokeThickness="6">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0" MappingMode="RelativeToBoundingBox" SpreadMethod="Pad">
|
||||
<GradientStop Color="#0033A0" Offset="0"/>
|
||||
<GradientStop Color="#0033A0" Offset="0.333"/>
|
||||
<GradientStop Color="#FFCE1126" Offset="0.333"/>
|
||||
<GradientStop Color="#FFCE1126" Offset="0.666"/>
|
||||
<GradientStop Color="#FCD116" Offset="0.666"/>
|
||||
<GradientStop Color="#FCD116" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
</Button>
|
||||
<Button x:Name="NoneFrame" Background="White" BorderThickness="0" Height="52" Width="52" Click="NoneFrame_Click" >
|
||||
<Grid>
|
||||
<Rectangle HorizontalAlignment="Left" Height="50" Stroke="#FF8492A6" VerticalAlignment="Center" Width="50" />
|
||||
<Label Content="None" HorizontalAlignment="Center" VerticalAlignment="Center" Canvas.Left="398" Canvas.Top="264" Foreground="#FF8190A5" RenderTransformOrigin="0.742,1.183"/>
|
||||
</Grid>
|
||||
</Button>
|
||||
|
||||
|
||||
</UniformGrid>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid x:Name="HashtagsGrid" Grid.Row="3" Margin="6,84,51,-132">
|
||||
<Label Content="Hashtags" HorizontalAlignment="Left" VerticalAlignment="Top" Width="111" Foreground="#FF47525E" FontWeight="Bold"/>
|
||||
<Button Content="#Fun" HorizontalAlignment="Left" Margin="3,25,0,0" VerticalAlignment="Top" Width="39" Foreground="#FF8190A5" Click="Fun_Button_Click">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
|
||||
<Button Content="#Sad" HorizontalAlignment="Left" Margin="47,25,0,0" VerticalAlignment="Top" Width="39" Foreground="#FF8190A5" Background="White" Click="Sad_Button_Click_1">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="#OpenToWork" HorizontalAlignment="Left" Margin="90,25,0,0" VerticalAlignment="Top" Width="87" Foreground="#FF8190A5" Background="White" Click="Button_Click_Open_to_Work">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="#JustMarried" HorizontalAlignment="Left" Margin="181,25,0,0" VerticalAlignment="Top" Width="87" Foreground="#FF8190A5" Background="White" Click="Button_Click_Married">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="#Engaged" HorizontalAlignment="Left" Margin="273,25,0,0" VerticalAlignment="Top" Width="70" Foreground="#FF8190A5" Background="White" Click="Button_Click_Engaged">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="#BigPromotion" HorizontalAlignment="Left" Margin="348,25,0,0" VerticalAlignment="Top" Width="95" Foreground="#FF8190A5" Background="White" Click="Button_Click_Promotion">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="Remove Hashtag" HorizontalAlignment="Left" Margin="448,25,0,0" VerticalAlignment="Top" Width="95" Foreground="#FF8190A5" Background="White" Click="Button_Click_Remove">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,321 @@
|
||||
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.Repository;
|
||||
using District_3_App.Service;
|
||||
|
||||
namespace District_3_App
|
||||
{
|
||||
public partial class FancierProfilePage : UserControl
|
||||
{
|
||||
private ProfileInfoSettings profileInfoSettings;
|
||||
private CasualProfileService casualProfileService = new CasualProfileService();
|
||||
private string motto;
|
||||
public FancierProfilePage()
|
||||
{
|
||||
this.profileInfoSettings = casualProfileService.GetProfileInfoSettings();
|
||||
InitializeComponent();
|
||||
MottosComboBox.SelectionChanged += MottosComboBox_SelectionChanged;
|
||||
LinksPopUp.Opened += LinksPopUp_Opened;
|
||||
}
|
||||
private void AddMottoButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MottoPopUp.IsOpen = !MottoPopUp.IsOpen;
|
||||
}
|
||||
|
||||
private void ClosePopUpButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (motto != null)
|
||||
{
|
||||
profileInfoSettings.AddDailyMotto(motto);
|
||||
}
|
||||
MottoPopUp.IsOpen = false;
|
||||
}
|
||||
private void MottosComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ComboBoxItem selectedItem = (ComboBoxItem)MottosComboBox.SelectedItem;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
string selectedMotto = selectedItem.Content.ToString();
|
||||
this.motto = selectedMotto;
|
||||
}
|
||||
}
|
||||
private void SaveMottoButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (motto != null || motto != string.Empty)
|
||||
{
|
||||
profileInfoSettings.AddDailyMotto(motto);
|
||||
}
|
||||
MottoPopUp.IsOpen = false;
|
||||
}
|
||||
|
||||
private void AddExtraLinksButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LinksPopUp.IsOpen = !LinksPopUp.IsOpen;
|
||||
}
|
||||
|
||||
private void CloseLinksPopUpButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LinksPopUp.IsOpen = false;
|
||||
}
|
||||
|
||||
private void SaveLinksButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string link1 = link1Text.Text;
|
||||
string link2 = link2Text.Text;
|
||||
List<string> links = profileInfoSettings.GetLinks();
|
||||
bool? result1 = null, result2 = null;
|
||||
|
||||
if (links != null)
|
||||
{
|
||||
if (links.Count >= 1)
|
||||
{
|
||||
if (link1 != links[0])
|
||||
{
|
||||
profileInfoSettings.DeleteLink(links[0]);
|
||||
result1 = profileInfoSettings.AddLink(link1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result1 = profileInfoSettings.AddLink(link1);
|
||||
}
|
||||
|
||||
if (links.Count >= 2)
|
||||
{
|
||||
if (link2 != links[1])
|
||||
{
|
||||
profileInfoSettings.DeleteLink(links[1]);
|
||||
result2 = profileInfoSettings.AddLink(link2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = profileInfoSettings.AddLink(link2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result1 = profileInfoSettings.AddLink(link1);
|
||||
result2 = profileInfoSettings.AddLink(link2);
|
||||
}
|
||||
|
||||
if (result1 == false)
|
||||
{
|
||||
MessageBox.Show("Invalid link 1 :(");
|
||||
}
|
||||
|
||||
if (result2 == false)
|
||||
{
|
||||
MessageBox.Show("Invalid link 2 :(");
|
||||
}
|
||||
|
||||
LinksPopUp.IsOpen = false;
|
||||
}
|
||||
|
||||
private void LinksPopUp_Opened(object sender, EventArgs e)
|
||||
{
|
||||
List<string> links = profileInfoSettings.GetLinks();
|
||||
if (links != null && links.Count > 0)
|
||||
{
|
||||
if (links.Count >= 1)
|
||||
{
|
||||
link1Text.Text = links[0];
|
||||
}
|
||||
if (links.Count >= 2)
|
||||
{
|
||||
link2Text.Text = links[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelLinksButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LinksPopUp.IsOpen = false;
|
||||
}
|
||||
|
||||
private void TextInputBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
this.motto = textInputBox.Text;
|
||||
}
|
||||
|
||||
private void FirstFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(1))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void SecondFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(2))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void ThirdFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(3))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForthFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(4))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void FifthFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(5))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void RomanianFlagFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetFrameNumber(6))
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void NoneFrame_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.DeleteFrameNumber())
|
||||
{
|
||||
MessageBox.Show("New frame set :) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to set frame :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Fun_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Fun"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Sad_Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Sad"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Open_to_Work(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Open To Work"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Married(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Just Married"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Engaged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Engaged"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Promotion(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.SetHashtag("#Big Promotion"))
|
||||
{
|
||||
MessageBox.Show("New Hashtag set");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Can't set this hashtag :(");
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Remove(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (profileInfoSettings.DeleteHashtag())
|
||||
{
|
||||
MessageBox.Show("Hashtag removed");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("can't remove hashtag :(");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<contacts>
|
||||
<contact>
|
||||
<Id>fc0e19f2-114f-47f1-a25a-1245035bc7b3</Id>
|
||||
<username>@patri.stoica</username>
|
||||
<email>email1@example.com</email>
|
||||
<phoneNumber>0752111222</phoneNumber>
|
||||
<birthday>2000-01-01T00:00:00</birthday>
|
||||
</contact>
|
||||
<contact>
|
||||
<Id>68ce0f1a-b031-4c62-b2d2-f297e2f68768</Id>
|
||||
<username>@delia.gherasim</username>
|
||||
<phoneNumber>0743111222</phoneNumber>
|
||||
<birthday>1995-05-05T00:00:00</birthday>
|
||||
</contact>
|
||||
</contacts>
|
||||
@@ -0,0 +1,50 @@
|
||||
<UserControl x:Class="District_3_App.FriendsSettings.Friends"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:District_3_App.FriendsSettings"
|
||||
mc:Ignorable="d"
|
||||
Height="450" Width="800" Background="White">
|
||||
<UserControl.Resources>
|
||||
<!-- Define the loading button template -->
|
||||
<ControlTemplate x:Key="LoadingButtonTemplate" TargetType="Button">
|
||||
<Grid>
|
||||
<!-- Use an Image as the button content -->
|
||||
<Image Source="\images\button.png" Stretch="Uniform"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="LoadingButtonEyeTemplate" TargetType="Button">
|
||||
<Grid>
|
||||
<!-- Use an Image as the button content -->
|
||||
<Image Source="\images\buttonEye.png" Stretch="Uniform"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<!-- Define ComboBox item template with a button -->
|
||||
<DataTemplate x:Key="ComboBoxItemTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding}" Margin="0,0,5,0" />
|
||||
<Button Grid.Column="1" Content="follow" Click="ItemButton_Click" Background="White" Foreground="Black" BorderBrush="White" FontSize="10" FontWeight="Bold" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="White">
|
||||
<Label Content="Friends Settings" HorizontalAlignment="Left" Margin="68,51,0,0" VerticalAlignment="Top" FontSize="18" FontWeight="Bold"/>
|
||||
<Label Content="Sync Contacts" HorizontalAlignment="Left" Margin="68,107,0,0" VerticalAlignment="Top" FontSize="16"/>
|
||||
<Label Content="See who viewed your profile" HorizontalAlignment="Left" Margin="68,294,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.175,0.579" FontSize="16"/>
|
||||
<!-- Use the custom loading button template -->
|
||||
<Button Click="LoadUsernamesContacts_Click" HorizontalAlignment="Left" Margin="181,110,0,0" VerticalAlignment="Top" Width="19" Height="25" RenderTransformOrigin="0.09,0.483" ClickMode="Press"/>
|
||||
<Button HorizontalAlignment="Left" Margin="282,296,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.092,-0.076" Height="29" Width="18"/>
|
||||
<ComboBox x:Name="usernamesContactsComboBox" ItemTemplate="{StaticResource ComboBoxItemTemplate}" HorizontalContentAlignment="Stretch" HorizontalAlignment="Left" Margin="70,143,0,0" VerticalAlignment="Top" Width="221" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="81,146,0,0" TextWrapping="Wrap" Text="See contacts" VerticalAlignment="Top" RenderTransformOrigin="-0.074,-3.498"/>
|
||||
<ComboBox x:Name="usernamesViewersComboBox" HorizontalAlignment="Left" Margin="70,330,0,0" VerticalAlignment="Top" Width="221" RenderTransformOrigin="0.981,0.598"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="81,333,0,0" TextWrapping="Wrap" Text="See everyone" VerticalAlignment="Top" RenderTransformOrigin="0.456,0.425"/>
|
||||
<Image Source="/FriendsSettings/buttonEye.png" Margin="305,306,481,132" />
|
||||
<Image Source="/FriendsSettings/button.png" Margin="204,114,581,321" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
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;
|
||||
using System.Xml.Linq;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App.FriendsSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Friends.xaml
|
||||
/// </summary>
|
||||
public partial class Friends : UserControl
|
||||
{
|
||||
// Getting lists
|
||||
private static Dictionary<string, UserInfo> GetContacts()
|
||||
{
|
||||
var contacts = new Dictionary<string, UserInfo>();
|
||||
string filePath;
|
||||
|
||||
// Create User objects with usernames and add them to the dictionary
|
||||
/*contacts["0752111222"] = new User("@patri.stoica", "0752111222");
|
||||
contacts["0743111222"] = new User("@delia.gherasim", "0743111222");*/
|
||||
|
||||
// Load the XML document
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "FriendsSettings");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Contacts.xml");
|
||||
Console.WriteLine(filePath);
|
||||
/*if (!File.Exists(filePath))
|
||||
{
|
||||
XDocument xDocument1 = new XDocument(new XElement("FancierProfiles"));
|
||||
xDocument1.Save(filePath);
|
||||
}*/
|
||||
// MessageBox.Show("Reading profile info from file: " + filePath);
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
|
||||
XElement root = xDocument.Element("contacts");
|
||||
if (root != null && root.HasElements)
|
||||
{
|
||||
foreach (var userElem in root.Elements("contact"))
|
||||
{
|
||||
Guid userId;
|
||||
if (!Guid.TryParse((string)userElem.Element("Id"), out userId))
|
||||
{
|
||||
userId = Guid.NewGuid();
|
||||
}
|
||||
UserInfo user = new UserInfo();
|
||||
try
|
||||
{
|
||||
user.Id = userId;
|
||||
user.Username = (string)userElem.Element("username");
|
||||
user.Email = (string)userElem.Element("email");
|
||||
user.PhoneNumber = (string)userElem.Element("phoneNumber");
|
||||
user.Birthday = (DateTime)userElem.Element("birthday");
|
||||
|
||||
contacts[user.PhoneNumber] = user;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error parsing profile: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return contacts;
|
||||
}
|
||||
|
||||
private static Dictionary<string, UserInfo> GetViewers()
|
||||
{
|
||||
var contacts = new Dictionary<string, UserInfo>();
|
||||
string filePath;
|
||||
|
||||
// Create User objects with usernames and add them to the dictionary
|
||||
/*contacts["0752111222"] = new User("@patri.stoica", "0752111222");
|
||||
contacts["0743111222"] = new User("@delia.gherasim", "0743111222");
|
||||
contacts["0755111222"] = new User("@anita.gorog", "0755111222");*/
|
||||
|
||||
// Load the XML document
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "FriendsSettings");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Viewers.xml");
|
||||
Console.WriteLine(filePath);
|
||||
/*if (!File.Exists(filePath))
|
||||
{
|
||||
XDocument xDocument1 = new XDocument(new XElement("FancierProfiles"));
|
||||
xDocument1.Save(filePath);
|
||||
}*/
|
||||
// MessageBox.Show("Reading profile info from file: " + filePath);
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
|
||||
XElement root = xDocument.Element("viewers");
|
||||
if (root != null && root.HasElements)
|
||||
{
|
||||
foreach (var userElem in root.Elements("viewer"))
|
||||
{
|
||||
Guid userId;
|
||||
if (!Guid.TryParse((string)userElem.Element("Id"), out userId))
|
||||
{
|
||||
userId = Guid.NewGuid();
|
||||
}
|
||||
UserInfo user = new UserInfo();
|
||||
try
|
||||
{
|
||||
user.Id = userId;
|
||||
user.Username = (string)userElem.Element("username");
|
||||
user.Email = (string)userElem.Element("email");
|
||||
user.PhoneNumber = (string)userElem.Element("phoneNumber");
|
||||
user.Birthday = (DateTime)userElem.Element("birthday");
|
||||
|
||||
contacts[user.PhoneNumber] = user;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error parsing profile: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
private static Dictionary<string, UserInfo> GetFriends()
|
||||
{
|
||||
var friends = new Dictionary<string, UserInfo>();
|
||||
string filePath;
|
||||
|
||||
// Load the XML document
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "FriendsSettings");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Friends.xml");
|
||||
Console.WriteLine(filePath);
|
||||
/*if (!File.Exists(filePath))
|
||||
{
|
||||
XDocument xDocument1 = new XDocument(new XElement("FancierProfiles"));
|
||||
xDocument1.Save(filePath);
|
||||
}*/
|
||||
// MessageBox.Show("Reading profile info from file: " + filePath);
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
|
||||
XElement root = xDocument.Element("friends");
|
||||
if (root != null && root.HasElements)
|
||||
{
|
||||
foreach (var userElem in root.Elements("friend"))
|
||||
{
|
||||
Guid userId;
|
||||
if (!Guid.TryParse((string)userElem.Element("Id"), out userId))
|
||||
{
|
||||
userId = Guid.NewGuid();
|
||||
}
|
||||
UserInfo user = new UserInfo();
|
||||
try
|
||||
{
|
||||
user.Id = userId;
|
||||
user.Username = (string)userElem.Element("username");
|
||||
user.Email = (string)userElem.Element("email");
|
||||
user.PhoneNumber = (string)userElem.Element("phoneNumber");
|
||||
user.Birthday = (DateTime)userElem.Element("birthday");
|
||||
|
||||
friends[user.PhoneNumber] = user;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error parsing profile: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return friends;
|
||||
}
|
||||
|
||||
public void SaveFriendsToXml()
|
||||
{
|
||||
string filePath;
|
||||
|
||||
// Load the XML document
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currentFilePath = System.IO.Path.Combine(relativePath, "FriendsSettings");
|
||||
filePath = System.IO.Path.Combine(currentFilePath, "Friends.xml");
|
||||
|
||||
try
|
||||
{
|
||||
XDocument xDocument = new XDocument(new XElement("friends"));
|
||||
|
||||
foreach (var friend in friends.Values)
|
||||
{
|
||||
XElement friendElement = new XElement("friend",
|
||||
new XElement("Id", friend.Id),
|
||||
new XElement("username", friend.Username),
|
||||
new XElement("email", friend.Email),
|
||||
new XElement("phoneNumber", friend.PhoneNumber),
|
||||
new XElement("birthday", friend.Birthday));
|
||||
|
||||
xDocument.Root?.Add(friendElement);
|
||||
}
|
||||
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error saving friends to XML: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, UserInfo> syncContacts = GetContacts();
|
||||
|
||||
private Dictionary<string, UserInfo> usernames_viewers = GetViewers();
|
||||
|
||||
private Dictionary<string, UserInfo> friends = GetFriends();
|
||||
public Friends()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoadUsernamesContacts_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
usernamesContactsComboBox.Items.Clear();
|
||||
|
||||
foreach (UserInfo user in syncContacts.Values)
|
||||
{
|
||||
usernamesContactsComboBox.Items.Add(user.Username);
|
||||
}
|
||||
}
|
||||
|
||||
private bool AddSyncContact(UserInfo contactToAdd, string key)
|
||||
{
|
||||
if (friends.ContainsKey(key))
|
||||
{
|
||||
Console.WriteLine("User already added.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
friends[key] = contactToAdd;
|
||||
|
||||
Console.WriteLine($"User added: {contactToAdd.Username}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool RemoveSyncContact(string key)
|
||||
{
|
||||
friends.Remove(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ItemButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button clickedButton = (Button)sender;
|
||||
Grid grid = (Grid)VisualTreeHelper.GetParent(clickedButton);
|
||||
TextBlock textBlock = (TextBlock)grid.Children[0];
|
||||
string username = textBlock.Text;
|
||||
bool added = false;
|
||||
foreach (UserInfo user in syncContacts.Values)
|
||||
{
|
||||
if (user.Username == username)
|
||||
{
|
||||
string phoneNumber = user.PhoneNumber;
|
||||
added = AddSyncContact(user, phoneNumber);
|
||||
if (added)
|
||||
{
|
||||
MessageBox.Show($"Username added to friends: {username}");
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSyncContact(user.PhoneNumber);
|
||||
MessageBox.Show($"Username removed from friends: {username}");
|
||||
}
|
||||
SaveFriendsToXml();
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (UserInfo friend in friends.Values)
|
||||
{
|
||||
stringBuilder.AppendLine(friend.Username + ',' + friend.PhoneNumber);
|
||||
}
|
||||
string friendsList = stringBuilder.ToString();
|
||||
MessageBox.Show("Friends List:\n\n" + friendsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<friends>
|
||||
<friend>
|
||||
<Id>68ce0f1a-b031-4c62-b2d2-f297e2f68768</Id>
|
||||
<username>@delia.gherasim</username>
|
||||
<email></email>
|
||||
<phoneNumber>0743111222</phoneNumber>
|
||||
<birthday>1995-05-05T00:00:00</birthday>
|
||||
</friend>
|
||||
</friends>
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.FriendsSettings
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public DateTime? Birthday { get; set; }
|
||||
|
||||
public User(string newUsername, string newPhoneNumber)
|
||||
{
|
||||
Username = newUsername;
|
||||
PhoneNumber = newPhoneNumber;
|
||||
}
|
||||
|
||||
public User()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.FriendsSettings
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public DateTime? Birthday { get; set; }
|
||||
|
||||
public UserInfo(string newUsername, string newPhoneNumber)
|
||||
{
|
||||
Username = newUsername;
|
||||
PhoneNumber = newPhoneNumber;
|
||||
}
|
||||
|
||||
public UserInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<viewers>
|
||||
<viewer>
|
||||
<Id>fc0e19f2-114f-47f1-a25a-1245035bc7b3</Id>
|
||||
<username>@patri.stoica</username>
|
||||
<email>email1@example.com</email>
|
||||
<phoneNumber>0752111222</phoneNumber>
|
||||
<birthday>2000-01-01T00:00:00</birthday>
|
||||
</viewer>
|
||||
<viewer>
|
||||
<Id>68ce0f1a-b031-4c62-b2d2-f297e2f68768</Id>
|
||||
<username>@delia.gherasim</username>
|
||||
<phoneNumber>0743111222</phoneNumber>
|
||||
<birthday>1995-05-05T00:00:00</birthday>
|
||||
</viewer>
|
||||
<viewer>
|
||||
<Id>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxz</Id>
|
||||
<username>@anita.gorog</username>
|
||||
<phoneNumber>0755111222</phoneNumber>
|
||||
<birthday>1995-08-05T00:00:00</birthday>
|
||||
</viewer>
|
||||
</viewers>
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
+56
@@ -0,0 +1,56 @@
|
||||
<Window x:Class="District_3_App.FriendsWindow.CustomWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:District_3_App"
|
||||
mc:Ignorable="d"
|
||||
Title="CustomWindow" Height="337" Width="419">
|
||||
<Window.Resources>
|
||||
<ControlTemplate x:Key="LoadingButtonTemplate" TargetType="Button">
|
||||
<Grid>
|
||||
<Image Source="imageSearch.png" Stretch="Uniform"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="RoundCheckBoxStyle" TargetType="CheckBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="CheckBox">
|
||||
<Grid>
|
||||
<Ellipse x:Name="OuterCircle" Width="20" Height="20" Fill="Transparent" Stroke="Black" StrokeThickness="2"/>
|
||||
<Path x:Name="TickSymbol" Data="M5,10 L9,14 L15,6" Stroke="Black" StrokeThickness="2" Visibility="Visible"/>
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="TickSymbol" Property="Stroke" Value="White"/>
|
||||
<Setter TargetName="OuterCircle" Property="Fill" Value="Black"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="ListBoxItemTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<CheckBox Grid.Column="0" Style="{StaticResource RoundCheckBoxStyle}" Checked="CheckedFunction" Unchecked="UnCheckedFunction" IsChecked="False"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding}" Margin="0,0,5,0" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Label Content="Custom:" HorizontalAlignment="Left" Margin="30,25,0,0" VerticalAlignment="Top" FontSize="16" FontWeight="Bold"/>
|
||||
<Button Template="{StaticResource LoadingButtonTemplate}" Click="SearchButton_Clicked" HorizontalAlignment="Left" Margin="48,61,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.092,-0.076" Height="36" Width="27"/>
|
||||
<TextBox x:Name="textBox" PreviewMouseDown="TextBox_PreviewMouseDown" HorizontalAlignment="Left" Margin="73,69,0,0" TextWrapping="Wrap" Text="Search" VerticalAlignment="Top" Width="280" Height="20"/>
|
||||
<ListBox x:Name="listBox" ItemTemplate="{StaticResource ListBoxItemTemplate}" Margin="66,102,83,68"/>
|
||||
<Button Content="Save" Click="SaveButton_Clicked" HorizontalAlignment="Left" Margin="184,258,0,0" VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace District_3_App.FriendsWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CustomWindow.xaml
|
||||
/// </summary>
|
||||
public partial class CustomWindow : Window
|
||||
{
|
||||
// Mock friends list
|
||||
private static Dictionary<string, UserInfo> GetFriends()
|
||||
{
|
||||
var contacts = new Dictionary<string, UserInfo>();
|
||||
|
||||
// Create User objects with usernames and add them to the dictionary
|
||||
contacts["0752111222"] = new UserInfo("@patri.stoica", "0752111222");
|
||||
contacts["0743111222"] = new UserInfo("@delia.gherasim", "0743111222");
|
||||
contacts["0755111222"] = new UserInfo("@anita.gorog", "0755111222");
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
// Mock posts
|
||||
private static List<Post> GetPosts()
|
||||
{
|
||||
List<Post> posts = new List<Post>();
|
||||
Post post = new Post(9);
|
||||
posts.Add(post);
|
||||
return posts;
|
||||
}
|
||||
private static Dictionary<Post, List<UserInfo>> MakePostDictionary()
|
||||
{
|
||||
Dictionary<Post, List<UserInfo>> posts = new Dictionary<Post, List<UserInfo>>();
|
||||
foreach (Post post in GetPosts())
|
||||
{
|
||||
posts[post] = new List<UserInfo>();
|
||||
}
|
||||
return posts;
|
||||
}
|
||||
|
||||
private Post GetCurrentPost()
|
||||
{
|
||||
return allowedProfiles.Keys.First();
|
||||
}
|
||||
|
||||
private Dictionary<string, UserInfo> friends = GetFriends();
|
||||
|
||||
private Dictionary<Post, List<UserInfo>> allowedProfiles = MakePostDictionary();
|
||||
|
||||
private List<string> allowedNames = new List<string>();
|
||||
|
||||
// private List<Post> listPosts = getPosts();
|
||||
private void LoadUsernames()
|
||||
{
|
||||
listBox.Items.Clear();
|
||||
|
||||
foreach (UserInfo user in friends.Values)
|
||||
{
|
||||
listBox.Items.Add(user.Username);
|
||||
}
|
||||
}
|
||||
|
||||
public CustomWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
// listBox.ItemsSource = getUsernames();
|
||||
LoadUsernames();
|
||||
}
|
||||
|
||||
private void SearchButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string searchText = textBox.Text.ToLower();
|
||||
if (searchText != string.Empty)
|
||||
{
|
||||
List<string> filteredUsernames = friends.Values
|
||||
.Where(user => user.Username.ToLower().Contains(searchText))
|
||||
.Select(user => user.Username)
|
||||
.ToList();
|
||||
listBox.Items.Clear();
|
||||
|
||||
foreach (string user in filteredUsernames)
|
||||
{
|
||||
listBox.Items.Add(user);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadUsernames();
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
textBox.Text = string.Empty;
|
||||
}
|
||||
|
||||
private bool AddAllowedUserToSeePost(UserInfo user, Post key)
|
||||
{
|
||||
allowedProfiles[key].Add(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SaveButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (UserInfo user in friends.Values)
|
||||
{
|
||||
if (allowedNames.Contains(user.Username))
|
||||
{
|
||||
AddAllowedUserToSeePost(user, GetCurrentPost());
|
||||
}
|
||||
}
|
||||
|
||||
MessageBox.Show("Restricted Usernames: " + string.Join(", ", allowedNames));
|
||||
}
|
||||
|
||||
private void CheckedFunction(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox clickedButton = (CheckBox)sender;
|
||||
Grid grid = (Grid)VisualTreeHelper.GetParent(clickedButton);
|
||||
TextBlock textBlock = (TextBlock)grid.Children[1];
|
||||
string username = textBlock.Text;
|
||||
allowedNames.Add(username);
|
||||
MessageBox.Show("Restricted: " + username);
|
||||
}
|
||||
|
||||
private void UnCheckedFunction(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox clickedButton = (CheckBox)sender;
|
||||
Grid grid = (Grid)VisualTreeHelper.GetParent(clickedButton);
|
||||
TextBlock textBlock = (TextBlock)grid.Children[1];
|
||||
string username = textBlock.Text;
|
||||
allowedNames.Remove(username);
|
||||
MessageBox.Show("Removed from restricted: " + username);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.FriendsWindow
|
||||
{
|
||||
public class Post
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public Post(int id)
|
||||
{
|
||||
this.Id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.FriendsWindow
|
||||
{
|
||||
public class User
|
||||
{
|
||||
private Guid Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public DateTime? Birthday { get; set; }
|
||||
|
||||
public User(string newUsername, string newPhoneNumber)
|
||||
{
|
||||
Username = newUsername;
|
||||
PhoneNumber = newPhoneNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.FriendsWindow
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
private Guid Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public DateTime? Birthday { get; set; }
|
||||
|
||||
public UserInfo(string newUsername, string newPhoneNumber)
|
||||
{
|
||||
Username = newUsername;
|
||||
PhoneNumber = newPhoneNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 970 B |
+63
@@ -0,0 +1,63 @@
|
||||
<Window x:Class="District_3_App.HighlightsFE.CreateNewHighlight"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:District_3_App.HighlightsFE"
|
||||
mc:Ignorable="d"
|
||||
Title="CreateNewHighlight" Height="300" Width="300">
|
||||
<Grid>
|
||||
<Popup x:Name="ChooseCoverPopUp" Width="250" Height="150" StaysOpen="False" PlacementTarget="{Binding ElementName=CoverButton}" >
|
||||
<Border Background="White" BorderBrush="#FF47525E" Width="250" Height="150" BorderThickness="1" CornerRadius="5">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Which post do you want to be the cover?" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="12" Foreground="#FF47525E" Margin="0,0,0,5"/>
|
||||
<TextBlock Text="Enter a number between 1 and" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="10" Foreground="#FF47525E"/>
|
||||
<TextBlock Text="{Binding nrPosts }" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="10" Foreground="#FF47525E" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="coverInput" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Bottom" Width="70" Height="26" FontSize="8" SelectionTextBrush="#FF8492A6" SelectionBrush="#FF8492A6" BorderBrush="#8492A6" TextChanged="CoverInput_TextChanged" Grid.IsSharedSizeScope="True" Background="#FF8492A6">
|
||||
<TextBox.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</TextBox.Resources>
|
||||
</TextBox>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
|
||||
<Label Content="Add new Highlight" HorizontalAlignment="Left" Margin="20,21,0,0" VerticalAlignment="Top" FontSize="12" Foreground="#FF47525E" FontWeight="Bold"/>
|
||||
|
||||
<Button x:Name="CoverButton" HorizontalAlignment="Center" Margin="0,57,0,0" VerticalAlignment="Top" Height="40" Width="40" Click="Button_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="20"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border CornerRadius="20" BorderThickness="1" Width="40" Height="40" Background="{TemplateBinding Background}">
|
||||
<Image Source="C:\Facultation\sem4\iss\fancierProfile\Images\cameraIcon.png" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
|
||||
<Border CornerRadius="3" Width="163" Height="27" Margin="68,120,68,87" BorderThickness="1" BorderBrush="#5A6978">
|
||||
<TextBox x:Name="textInputBox" HorizontalAlignment="Center" TextWrapping="Wrap" Text="Enter Highlight Name" VerticalAlignment="Bottom" Width="162" Height="26" FontSize="8" SelectionTextBrush="#FF8492A6" SelectionBrush="#FF8492A6" BorderBrush="#8492A6" TextChanged="TextBox_TextChanged" Grid.IsSharedSizeScope="True" Background="#FF8492A6" >
|
||||
<TextBox.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</TextBox.Resources>
|
||||
</TextBox>
|
||||
</Border>
|
||||
<Button x:Name="DoneButton" Content="Done" HorizontalAlignment="Center" Margin="0,177,0,0" VerticalAlignment="Top" BorderBrush="#5A6978" Background="#FF47525E" Foreground="White" FontSize="10" Width="56" Height="20" Click="DoneButton_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
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.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Service;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace District_3_App.HighlightsFE
|
||||
{
|
||||
public partial class CreateNewHighlight : Window
|
||||
{
|
||||
private List<Guid> guids = new ();
|
||||
private string newHighlightName;
|
||||
private string newHighlightCover;
|
||||
private SnapshotsService snapshotsService;
|
||||
public CreateNewHighlight(List<Guid> selectedPostsGuids)
|
||||
{
|
||||
CasualProfileService casualProfileService = new CasualProfileService();
|
||||
snapshotsService = casualProfileService.GetSnapshotsService();
|
||||
|
||||
InitializeComponent();
|
||||
guids = selectedPostsGuids;
|
||||
int nrPosts = guids.Count;
|
||||
DataContext = nrPosts;
|
||||
}
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (textInputBox.Text != "Enter Highlight Name")
|
||||
{
|
||||
newHighlightName = textInputBox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (guids.Count <= 0)
|
||||
{
|
||||
MessageBox.Show("You didn't add any posts. The cover will be the default black");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChooseCoverPopUp.IsOpen = !ChooseCoverPopUp.IsOpen;
|
||||
}
|
||||
}
|
||||
|
||||
private void DoneButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
snapshotsService.AddHighlight(newHighlightName, newHighlightCover, guids);
|
||||
this.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
ChooseCoverPopUp.IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CoverInput_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string highlightCover = coverInput.Text;
|
||||
try
|
||||
{
|
||||
int numberOfPost = int.Parse(highlightCover);
|
||||
if (numberOfPost < 0 || numberOfPost > guids.Count)
|
||||
{
|
||||
MessageBox.Show("Please enter a number between 1 and " + guids.Count.ToString());
|
||||
}
|
||||
newHighlightCover = guids[numberOfPost].ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Something went wrong :(" + guids.Count.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<UserControl x:Class="District_3_App.HighlightsFE.HighlightsOnMain"
|
||||
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.HighlightsFE"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="100" d:DesignWidth="500"
|
||||
Background="White">
|
||||
<Grid>
|
||||
<Frame x:Name="navigationFrame" NavigationUIVisibility="Hidden"/>
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ItemsControl ItemsSource="{Binding}" >
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button x:Name="SelectHighlight" Click="SelectHighlight_Click" Margin="20" Background="White" >
|
||||
<Border Width="70" Height="70" CornerRadius="7" BorderBrush="Black" BorderThickness="1">
|
||||
<StackPanel>
|
||||
<Image Source="{Binding Cover}" Width="50" Height="50" />
|
||||
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
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.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Service;
|
||||
|
||||
namespace District_3_App.HighlightsFE
|
||||
{
|
||||
public partial class HighlightsOnMain : UserControl
|
||||
{
|
||||
public List<HighlightInfo> Highlights { get; set; }
|
||||
private Guid? currentlyOpenHighlightId = null;
|
||||
private SnapshotsService snapshotsService;
|
||||
private CasualProfileService casualProfileService;
|
||||
|
||||
public HighlightsOnMain()
|
||||
{
|
||||
casualProfileService = new CasualProfileService();
|
||||
snapshotsService = casualProfileService.GetSnapshotsService();
|
||||
InitializeComponent();
|
||||
LoadHighlights();
|
||||
}
|
||||
|
||||
private void LoadHighlights()
|
||||
{
|
||||
List<Highlight> highlights = snapshotsService.GetHighlightsOfUser();
|
||||
|
||||
if (highlights == null || highlights.Count == 0)
|
||||
{
|
||||
Console.WriteLine("No highlights found.");
|
||||
}
|
||||
|
||||
Highlights = new List<HighlightInfo>();
|
||||
foreach (Highlight highlight in highlights)
|
||||
{
|
||||
// HighlightsRepo highlightsRepo = new HighlightsRepo();
|
||||
List<MockPhotoPost> userPosts = casualProfileService.GetConnectedUserPosts();
|
||||
MockPhotoPost coverPost = userPosts.FirstOrDefault(post => post.GetPostId().ToString() == highlight.GetCover());
|
||||
|
||||
if (coverPost != null)
|
||||
{
|
||||
Highlights.Add(new HighlightInfo(highlight.GetName(), coverPost.GetPhoto(), highlight.GetHighlightId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Highlights.Add(new HighlightInfo(highlight.GetName(), "/images/black.png", highlight.GetHighlightId()));
|
||||
}
|
||||
}
|
||||
|
||||
DataContext = Highlights;
|
||||
}
|
||||
|
||||
private void SelectHighlight_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button clickedButton = e.OriginalSource as Button;
|
||||
HighlightInfo highlightInfo = clickedButton.DataContext as HighlightInfo;
|
||||
Guid highlightId = highlightInfo.HighlightId;
|
||||
|
||||
if (highlightId == currentlyOpenHighlightId)
|
||||
{
|
||||
navigationFrame.Content = null;
|
||||
currentlyOpenHighlightId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
navigationFrame.Navigate(new SeeHighlightPosts(highlightId));
|
||||
currentlyOpenHighlightId = highlightId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<UserControl x:Class="District_3_App.HighlightsFE.SeeHighlightPosts"
|
||||
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.HighlightsFE"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="500"
|
||||
Background="White">
|
||||
<Grid>
|
||||
<Frame x:Name="navigationFrame"/>
|
||||
|
||||
<ScrollViewer Margin="0,100,0,0">
|
||||
<ItemsControl ItemsSource="{Binding}" Width="500" VerticalAlignment="Top" Height="200">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="4"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Border CornerRadius="5" BorderThickness="1" BorderBrush="#FF47525E" Width="100" Height="100">
|
||||
<Image Source="{Binding FilePath}" Width="100" Height="100" />
|
||||
</Border>
|
||||
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="5"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
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.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Service;
|
||||
|
||||
namespace District_3_App.HighlightsFE
|
||||
{
|
||||
public partial class SeeHighlightPosts : UserControl
|
||||
{
|
||||
private List<PhotoInfo> photosInfo = new List<PhotoInfo>();
|
||||
private SnapshotsService snapshotsService;
|
||||
private CasualProfileService casualProfileService;
|
||||
|
||||
public SeeHighlightPosts(Guid highlightId)
|
||||
{
|
||||
casualProfileService = new CasualProfileService();
|
||||
snapshotsService = casualProfileService.GetSnapshotsService();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Highlight h = snapshotsService.GetHighlight(highlightId);
|
||||
List<MockPhotoPost> postsToShow = snapshotsService.GetPostsOfHighlight(highlightId);
|
||||
|
||||
foreach (MockPhotoPost post in postsToShow)
|
||||
{
|
||||
var photoInfo = new PhotoInfo(post.GetPhoto(), post.GetPostId());
|
||||
photoInfo.Description = post.GetDescription();
|
||||
|
||||
photosInfo.Add(photoInfo);
|
||||
}
|
||||
|
||||
DataContext = photosInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<Window x:Class="District_3_App.HighlightsFE.SelectHighlight"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:District_3_App.HighlightsFE"
|
||||
mc:Ignorable="d"
|
||||
Title="SelectHighlight" Height="250" Width="300">
|
||||
<Grid Margin="0,0,3,0">
|
||||
<Frame x:Name="navigationFrame"/>
|
||||
<Grid Background="#FFC8D0D9">
|
||||
|
||||
<Label Content="Choose a highlight" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="#FF47525E" FontSize="18" Margin="0,10,0,0" Height="34" Width="159"/>
|
||||
|
||||
<ScrollViewer Margin="3,44,57,71" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
|
||||
<ItemsControl ItemsSource="{Binding}" Margin="0,45,0,43" HorizontalAlignment="Left" Width="236">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="4"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Border CornerRadius="10" BorderThickness="1" BorderBrush="#FF47525E" Width="50" Height="50" ClipToBounds="True">
|
||||
<Image Source="{Binding Cover}" Width="50" Height="50" />
|
||||
</Border>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
IsChecked="False"
|
||||
Checked="CheckBox_Checked"
|
||||
Loaded="CheckBox_Loaded"
|
||||
Unchecked="CheckBox_Unchecked" />
|
||||
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<StackPanel Margin="241,48,0,128" HorizontalAlignment="Left" Width="35">
|
||||
<Button x:Name="createNewHighlightButton" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6" Click="CreateNewHighlightButton_Click" HorizontalAlignment="Right" Height="28" Width="31">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="20"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
<Image Source="../Images/plus.png" Stretch="Uniform" HorizontalAlignment="Center"></Image>
|
||||
</Button>
|
||||
<Label Content="new" Foreground="#FF47525E" FontSize="14" />
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
<Button Content="Done" x:Name="DoneButton" Background="#FF47525E" Foreground="White" BorderBrush="#5A6978" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,20" Click="DoneButton_Click" Width="76" Height="30">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
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.Shapes;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Service;
|
||||
|
||||
namespace District_3_App.HighlightsFE
|
||||
{
|
||||
public class HighlightInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Cover { get; set; }
|
||||
public Guid HighlightId { get; set; }
|
||||
|
||||
public HighlightInfo(string name, string cover, Guid highlightId)
|
||||
{
|
||||
Name = name;
|
||||
Cover = cover;
|
||||
HighlightId = highlightId;
|
||||
}
|
||||
}
|
||||
public partial class SelectHighlight : Window
|
||||
{
|
||||
public List<HighlightInfo> Highlights { get; set; }
|
||||
private List<Guid> selectedPostsGuid = new List<Guid>();
|
||||
private List<Guid> selectedHighlightsGUID = new List<Guid>();
|
||||
|
||||
private SnapshotsService snapshotsService;
|
||||
private CasualProfileService casualProfileService = new CasualProfileService();
|
||||
|
||||
public SelectHighlight(List<Guid> selectedPostsGuids)
|
||||
{
|
||||
this.selectedPostsGuid = selectedPostsGuids;
|
||||
this.snapshotsService = casualProfileService.GetSnapshotsService();
|
||||
|
||||
InitializeComponent();
|
||||
LoadHighlights();
|
||||
}
|
||||
private void LoadHighlights()
|
||||
{
|
||||
List<Highlight> highlights = snapshotsService.GetHighlightsOfUser();
|
||||
|
||||
if (highlights == null || highlights.Count == 0)
|
||||
{
|
||||
MessageBox.Show("No highlights found.");
|
||||
CreateNewHighlight createNewHighlight = new CreateNewHighlight(selectedPostsGuid);
|
||||
// navigationFrame.Navigate(createNewHighlight);
|
||||
createNewHighlight.Show();
|
||||
this.Close();
|
||||
}
|
||||
|
||||
Highlights = new List<HighlightInfo>();
|
||||
foreach (Highlight highlight in highlights)
|
||||
{
|
||||
// HighlightsRepo highlightsRepo = new HighlightsRepo();
|
||||
List<MockPhotoPost> userPosts = casualProfileService.GetConnectedUserPosts();
|
||||
MockPhotoPost coverPost = userPosts.FirstOrDefault(post => post.GetPostId().ToString() == highlight.GetCover());
|
||||
|
||||
if (coverPost != null)
|
||||
{
|
||||
Highlights.Add(new HighlightInfo(highlight.GetName(), coverPost.GetPhoto(), highlight.GetHighlightId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Highlights.Add(new HighlightInfo(highlight.GetName(), "/images/black.png", highlight.GetHighlightId()));
|
||||
}
|
||||
}
|
||||
|
||||
DataContext = Highlights;
|
||||
}
|
||||
private void CheckBox_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
HighlightInfo highlightInfo = (HighlightInfo)checkBox.DataContext;
|
||||
checkBox.Name = "CheckBox_" + highlightInfo.HighlightId.ToString().Replace("-", "_");
|
||||
}
|
||||
|
||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
string checkBoxName = checkBox.Name;
|
||||
if (checkBoxName.StartsWith("CheckBox_"))
|
||||
{
|
||||
string photoGuid = checkBoxName.Replace("CheckBox_", string.Empty);
|
||||
photoGuid = photoGuid.Replace("_", "-");
|
||||
if (!selectedHighlightsGUID.Contains(Guid.Parse(photoGuid)))
|
||||
{
|
||||
selectedHighlightsGUID.Add(Guid.Parse(photoGuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
string checkBoxName = checkBox.Name;
|
||||
if (checkBoxName.StartsWith("CheckBox_"))
|
||||
{
|
||||
string photoGuid = checkBoxName.Replace("CheckBox_", string.Empty);
|
||||
photoGuid = photoGuid.Replace("_", "-");
|
||||
if (selectedHighlightsGUID.Contains(Guid.Parse(photoGuid)))
|
||||
{
|
||||
selectedHighlightsGUID.Remove(Guid.Parse(photoGuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoneButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (selectedHighlightsGUID.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Guid highlightGuid in selectedHighlightsGUID)
|
||||
{
|
||||
if (highlightGuid == Guid.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (Guid postId in selectedPostsGuid)
|
||||
{
|
||||
snapshotsService.AddPostToHighlight(highlightGuid, postId);
|
||||
}
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void CreateNewHighlightButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CreateNewHighlight createNewHighlight = new CreateNewHighlight(selectedPostsGuid);
|
||||
// navigationFrame.Navigate(createNewHighlight);
|
||||
createNewHighlight.Show();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<UserControl x:Class="District_3_App.HighlightsFE.SelectPostsPage"
|
||||
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.HighlightsFE"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Background="White">
|
||||
<Grid>
|
||||
<Label x:Name="PostsLabel" Content="Posts" HorizontalAlignment="Left" Margin="50,24,0,0" VerticalAlignment="Top" Foreground="#FF47525E" Height="46" Width="117" FontSize="28"/>
|
||||
<Button x:Name="SubmitPostsButton" Content="Submit" HorizontalAlignment="Right" Margin="0,46,101,0" VerticalAlignment="Top" Width="94" Click="SubmitPostsButton_Click" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Button x:Name="DoneButton" Content="Done" HorizontalAlignment="Right" Margin="0,84,99,0" VerticalAlignment="Top" Width="94" Click="DoneButton_Click" Background="#FF47525E" Foreground="White" BorderBrush="#FF8492A6">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Label x:Name="labelExplanation" Content="Please check all the posts you want to add" HorizontalAlignment="Left" Margin="50,70,0,0" VerticalAlignment="Top" Foreground="#FF47525E" FontSize="18"/>
|
||||
|
||||
<ScrollViewer Margin="0,111,0,0">
|
||||
<ItemsControl ItemsSource="{Binding}" Width="694" Margin="0,100,0,0">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="4"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Border CornerRadius="5" BorderThickness="1" BorderBrush="#FF47525E" Width="100" Height="100">
|
||||
<Image Source="{Binding FilePath}" Width="100" Height="100" />
|
||||
</Border>
|
||||
<CheckBox HorizontalAlignment="Center"
|
||||
IsChecked="False"
|
||||
Loaded="CheckBox_Loaded"
|
||||
Checked="CheckBox_Checked"
|
||||
Unchecked="CheckBox_Unchecked"
|
||||
/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
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.Enitities.Mocks;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Service;
|
||||
|
||||
namespace District_3_App.HighlightsFE
|
||||
{
|
||||
public class PhotoInfo
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public Guid PostId { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public PhotoInfo(string filePath, Guid postId)
|
||||
{
|
||||
FilePath = filePath;
|
||||
PostId = postId;
|
||||
}
|
||||
}
|
||||
public partial class SelectPostsPage : UserControl
|
||||
{
|
||||
private List<PhotoInfo> photosInfo = new List<PhotoInfo>();
|
||||
private List<Guid> selectedPostsGuids = new List<Guid>();
|
||||
// HighlightsRepo highlightsRepo = new HighlightsRepo();
|
||||
private CasualProfileService casualProfileService = new CasualProfileService();
|
||||
private SnapshotsService snapshotsService;
|
||||
public SelectPostsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.snapshotsService = casualProfileService.GetSnapshotsService();
|
||||
List<MockPhotoPost> posts = casualProfileService.GetConnectedUserPosts();
|
||||
|
||||
foreach (MockPhotoPost post in posts)
|
||||
{
|
||||
var photoInfo = new PhotoInfo(post.GetPhoto(), post.GetPostId());
|
||||
photosInfo.Add(photoInfo);
|
||||
}
|
||||
|
||||
DataContext = photosInfo;
|
||||
}
|
||||
private void CheckBox_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
PhotoInfo photoInfo = (PhotoInfo)checkBox.DataContext;
|
||||
checkBox.Name = "CheckBox_" + photoInfo.PostId.ToString().Replace("-", "_");
|
||||
}
|
||||
|
||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
string checkBoxName = checkBox.Name;
|
||||
if (checkBoxName.StartsWith("CheckBox_"))
|
||||
{
|
||||
string photoGuid = checkBoxName.Replace("CheckBox_", string.Empty);
|
||||
photoGuid = photoGuid.Replace("_", "-");
|
||||
if (!selectedPostsGuids.Contains(Guid.Parse(photoGuid)))
|
||||
{
|
||||
selectedPostsGuids.Add(Guid.Parse(photoGuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
string checkBoxName = checkBox.Name;
|
||||
if (checkBoxName.StartsWith("CheckBox_"))
|
||||
{
|
||||
string photoGuid = checkBoxName.Replace("CheckBox_", string.Empty);
|
||||
photoGuid = photoGuid.Replace("_", "-");
|
||||
if (selectedPostsGuids.Contains(Guid.Parse(photoGuid)))
|
||||
{
|
||||
selectedPostsGuids.Remove(Guid.Parse(photoGuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SubmitPostsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (snapshotsService.GetHighlightsOfUser().Count() > 0)
|
||||
{
|
||||
SelectHighlight selectHighlight = new SelectHighlight(selectedPostsGuids);
|
||||
selectHighlight.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateNewHighlight createNewHighlight = new CreateNewHighlight(selectedPostsGuids);
|
||||
createNewHighlight.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void DoneButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Panel parentContainer = Parent as Panel;
|
||||
if (parentContainer != null)
|
||||
{
|
||||
parentContainer.Children.Remove(this);
|
||||
}
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<UserControl x:Class="District_3_App.LogIn.ForgotPassword"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:WpfTest="clr-namespace:Log_In"
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="RoundedTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5">
|
||||
<TextBox Text="{TemplateBinding Text}"
|
||||
BorderThickness="0"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="passwordbox" TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Type PasswordBox}}">
|
||||
<Setter Property="Padding" Value="10, 10" />
|
||||
<Setter Property="WpfTest:PasswordBoxMonitor.IsMonitoring"
|
||||
Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
x:Name="Bd" BorderBrush="#8492A6"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
|
||||
<TextBlock x:Name="txtPrompt" Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Visibility="Collapsed"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="WpfTest:PasswordBoxMonitor.PasswordLength" Value="0">
|
||||
<Setter Property="Visibility" TargetName="txtPrompt" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Padding" Value="10, 10"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
<TextBlock Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" IsHitTestVisible="False">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource AncestorType=TextBox}}"
|
||||
Value="">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="ResetPasswordGrid" Background="White" Width="1300" Height="901" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="40,-10,0,0">
|
||||
<Border BorderBrush="#5A6978" BorderThickness="1" Margin="389,22,389,407">
|
||||
<Grid Margin="65,50,36,50">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Reset Password" FontSize="33" FontWeight="DemiBold" HorizontalAlignment="Center" Margin="0,-4,0,24" Foreground="#47525E"/>
|
||||
<TextBlock Text="Enter the email address associated with your account and" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="16" Margin="0,51,0,26" Grid.RowSpan="3" Width="462" Foreground="#8190A5"/>
|
||||
<TextBlock Grid.Row="2" Text="enter your new password below" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="16" Margin="79,13,0,10" Foreground="#8190A5"/>
|
||||
<TextBox Grid.Row="3" x:Name="txtEmail" Tag="Email" Width="290" Margin="11,20,11,11" Style="{StaticResource placeHolder}" Height="46" FontSize="16" Foreground="#8190A5"/>
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Top" Margin="46,80,0,0" Grid.RowSpan="2">
|
||||
<PasswordBox Tag="New password" x:Name="txtNewPassword" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource passwordbox}" RenderTransformOrigin="0.471,0.635"/>
|
||||
<TextBox x:Name="txtVisiblePassword" Text="{Binding ElementName=txtNewPassword, Path=Password, Mode=TwoWay}" Visibility="Collapsed" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource RoundedTextBoxStyle}"/>
|
||||
<ToggleButton x:Name="TogglePasswordVisibility" Width="40" Height="40" Margin="0,22,10,0" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Click="TogglePasswordVisibility_Click">
|
||||
<Image x:Name="PasswordVisibilityIcon" Width="30" Height="30" Source="\images\hidePasswordIcon.png" RenderTransformOrigin="1.786,0.428" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="5" x:Name="ResetPasswordButton" Content="Reset Password" Background="#FF47525E" Foreground="White" Margin="0,24,0,37" Width="290" Height="46" HorizontalAlignment="Center" FontSize="16" BorderBrush="#FF47525E" Grid.RowSpan="2" Click="ResetPasswordButton_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
|
||||
<TextBlock Grid.Row="6" HorizontalAlignment="Left" Margin="161,128,0,-49" RenderTransformOrigin="0.621,1.479">
|
||||
<Hyperlink Click="BackToSignIn_Click">
|
||||
<TextBlock Text="<" VerticalAlignment="Center" FontSize="18" Foreground="#8190A5"/>
|
||||
</Hyperlink>
|
||||
<Run Text=" Back" FontSize="16" Foreground="#8190A5"/>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
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.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
using Log_In;
|
||||
|
||||
namespace District_3_App.LogIn
|
||||
{
|
||||
public partial class ForgotPassword : UserControl
|
||||
{
|
||||
private string filePath = "./Users.xml";
|
||||
private UsersRepository usersRepository;
|
||||
|
||||
public ForgotPassword()
|
||||
{
|
||||
InitializeComponent();
|
||||
usersRepository = new UsersRepository(filePath);
|
||||
}
|
||||
|
||||
private void BackToSignIn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ResetPasswordGrid.Children.Clear();
|
||||
var newContent = new SignInPage();
|
||||
Grid.SetColumn(newContent, 2);
|
||||
Grid.SetRow(newContent, 0);
|
||||
Grid.SetRowSpan(newContent, 6);
|
||||
ResetPasswordGrid.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void TogglePasswordVisibility_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (PasswordVisibilityIcon.Source.ToString().Contains("hidePasswordIcon") && txtVisiblePassword.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
txtNewPassword.Visibility = Visibility.Collapsed;
|
||||
txtVisiblePassword.Visibility = Visibility.Visible;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/showPasswordIcon.png"));
|
||||
txtVisiblePassword.Text = txtNewPassword.Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtNewPassword.Visibility = Visibility.Visible;
|
||||
txtVisiblePassword.Visibility = Visibility.Collapsed;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/hidePasswordIcon.png"));
|
||||
txtNewPassword.Password = txtVisiblePassword.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetPasswordButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string newEmail = txtEmail.Text;
|
||||
string newPassword = txtNewPassword.Password;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(newEmail) && !string.IsNullOrWhiteSpace(newPassword))
|
||||
{
|
||||
if (ValidateNewPassword(newPassword) == true)
|
||||
{
|
||||
if (usersRepository.UpdatePassword(newEmail, newPassword))
|
||||
{
|
||||
MessageBox.Show("Password updated successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
var newContent = new SignInPage();
|
||||
ResetPasswordGrid.Children.Clear();
|
||||
ResetPasswordGrid.Children.Add(newContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Email address not found.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid password. The password's length must be between 5 and 10 characters and must contain at least one uppercase letter, one lowercase letter, one number, and one special character (/_-.).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please enter both email and new password.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateNewPassword(string newPassword)
|
||||
{
|
||||
var hasNumericChar = new Regex(@"[0-9]+");
|
||||
var hasUpperChar = new Regex(@"[A-Z]+");
|
||||
var hasLowerChar = new Regex(@"[a-z]+");
|
||||
var hasSpecialChar = new Regex(@"[/\-_.]+");
|
||||
var hasMiniMaxChars = new Regex(@".{5,10}");
|
||||
|
||||
bool isNewPasswordValid = hasNumericChar.IsMatch(newPassword) && hasUpperChar.IsMatch(newPassword) && hasLowerChar.IsMatch(newPassword) && hasSpecialChar.IsMatch(newPassword) && hasMiniMaxChars.IsMatch(newPassword);
|
||||
return isNewPasswordValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<UserControl x:Class="District_3_App.LogIn.SignInPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:WpfTest="clr-namespace:Log_In">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="RoundedTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5">
|
||||
<TextBox Text="{TemplateBinding Text}"
|
||||
BorderThickness="0"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="passwordbox" TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Type PasswordBox}}">
|
||||
<Setter Property="Padding" Value="10, 10" />
|
||||
<Setter Property="WpfTest:PasswordBoxMonitor.IsMonitoring"
|
||||
Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
x:Name="Bd" BorderBrush="#8492A6"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
|
||||
<TextBlock x:Name="txtPrompt" Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Visibility="Collapsed"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="WpfTest:PasswordBoxMonitor.PasswordLength" Value="0">
|
||||
<Setter Property="Visibility" TargetName="txtPrompt" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Padding" Value="10, 10"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
|
||||
<TextBlock Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" IsHitTestVisible="False">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource AncestorType=TextBox}}"
|
||||
Value="">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="SignInGrid" Background="White" Width="1000" Height="1001" Margin="120,45,0,0" VerticalAlignment="Top">
|
||||
<Border BorderBrush="#5A6978" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="184,33,0,0" Height="576">
|
||||
<Grid Margin="60,90">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Source="\images\app_logo.png" Width="90" Height="54" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="179,-10,0,0"/>
|
||||
<TextBlock Grid.Row="1" Text="Sign in" FontSize="25" HorizontalAlignment="Center" FontWeight="Bold" Margin="0,19,0,52" Foreground="#47525E" RenderTransformOrigin="0.528,1.16"/>
|
||||
<TextBox Grid.Row="2" Tag="Username/Email" x:Name="txtUsernameAndEmail" Width="290" Margin="12,1,10,0" Height="46" VerticalAlignment="Top" FontSize="16" Style="{StaticResource placeHolder}" Foreground="#8190A5"/>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Top" Margin="42,46,0,0" Grid.RowSpan="2">
|
||||
<PasswordBox Tag="Password" x:Name="txtPassword" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" PasswordChar="•" Style="{StaticResource passwordbox}"/>
|
||||
<TextBox x:Name="txtVisiblePassword" IsEnabled="False" Visibility="Collapsed" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource RoundedTextBoxStyle}"/>
|
||||
<ToggleButton x:Name="TogglePasswordVisibility" Width="40" Height="40" Margin="0,22,10,0" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Click="TogglePasswordVisibility_Click">
|
||||
<Image x:Name="PasswordVisibilityIcon" Width="30" Height="30" Source="\images\hidePasswordIcon.png" RenderTransformOrigin="1.786,0.428" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="4" x:Name="SignInButton" Content="Sign In" Background="#FF46525E" Foreground="White" Margin="0,35,0,45" Width="220" Height="38" HorizontalAlignment="Center" FontSize="16" BorderBrush="#FF47525E" Grid.RowSpan="2" Click="SignInButton_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<TextBlock Grid.Row="5" FontSize="14" HorizontalAlignment="Center" Margin="0,56,0,-26" Foreground="#8190A5">
|
||||
<Hyperlink Click="ForgotPasswordLink_Click">
|
||||
<TextBlock Text="Forgot your password?" Foreground="#8190A5"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Grid Margin="0,-10,0,10">
|
||||
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10" FontSize="14" Foreground="#8190A5">
|
||||
<Hyperlink Click="BackToSignUp_Click">
|
||||
<TextBlock Text="<" VerticalAlignment="Center" FontSize="17" Foreground="Black"/>
|
||||
</Hyperlink>
|
||||
<Run Text="Back" FontSize="16" Foreground="#8190A5"/>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
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.ExtraInfo;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
using Log_In;
|
||||
|
||||
namespace District_3_App.LogIn
|
||||
{
|
||||
public partial class SignInPage : UserControl
|
||||
{
|
||||
private UsersRepository usersRepository;
|
||||
private UserManager userManager;
|
||||
private User User { get; set; }
|
||||
public SignInPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
string filePath = "./Users.xml";
|
||||
usersRepository = new UsersRepository(filePath);
|
||||
userManager = new UserManager(filePath);
|
||||
}
|
||||
|
||||
private void ForgotPasswordLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SignInGrid.Children.Clear();
|
||||
var newContent = new ForgotPassword();
|
||||
Grid.SetColumn(newContent, 1);
|
||||
Grid.SetRow(newContent, 1);
|
||||
Grid.SetRowSpan(newContent, 6);
|
||||
SignInGrid.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void BackToSignUp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SignInGrid.Children.Clear();
|
||||
var newContent = new SignUp();
|
||||
SignInGrid.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void TogglePasswordVisibility_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (PasswordVisibilityIcon.Source.ToString().Contains("hidePasswordIcon") && txtVisiblePassword.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
txtPassword.Visibility = Visibility.Collapsed;
|
||||
txtVisiblePassword.Visibility = Visibility.Visible;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/showPasswordIcon.png"));
|
||||
txtVisiblePassword.Text = txtPassword.Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtPassword.Visibility = Visibility.Visible;
|
||||
txtVisiblePassword.Visibility = Visibility.Collapsed;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/hidePasswordIcon.png"));
|
||||
txtPassword.Password = txtVisiblePassword.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void SignInButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string usernameOrEmail = txtUsernameAndEmail.Text;
|
||||
string password = txtPassword.Password;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(usernameOrEmail) && !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
User user = usersRepository.GetUserByUsernameOrEmail(usernameOrEmail);
|
||||
|
||||
if (user != null && user.Password == password)
|
||||
{
|
||||
userManager.StartOrRenewSession(user);
|
||||
var newContent = new MainWindow();
|
||||
newContent.Username = user.Username;
|
||||
newContent.Show();
|
||||
Window.GetWindow(this).Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid username/email or password. Please try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please enter both username/email and password.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
<UserControl x:Class="District_3_App.LogIn.SignUp"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:WpfTest="clr-namespace:Log_In"
|
||||
TextElement.FontFamily="Lato">
|
||||
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="RoundedTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5">
|
||||
<TextBox Text="{TemplateBinding Text}"
|
||||
BorderThickness="0"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleSwitchStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Viewbox>
|
||||
<Border x:Name="Border" CornerRadius="10"
|
||||
Background="#FFFFFFFF"
|
||||
Width="40" Height="20">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect ShadowDepth="0.5" Direction="0" Opacity="0.3" />
|
||||
</Border.Effect>
|
||||
<Ellipse x:Name="Ellipse" Fill="#FFFFFFFF" Stretch="Uniform"
|
||||
Margin="2 1 2 1"
|
||||
Stroke="Gray" StrokeThickness="0.2"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Ellipse.Effect>
|
||||
<DropShadowEffect BlurRadius="10" ShadowDepth="1" Opacity="0.3" Direction="260" />
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
</Border>
|
||||
</Viewbox>
|
||||
<ControlTemplate.Triggers>
|
||||
<EventTrigger RoutedEvent="Checked">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetName="Border"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||||
To="#FF4CD661"
|
||||
Duration="0:0:0.1" />
|
||||
<ThicknessAnimation Storyboard.TargetName="Ellipse"
|
||||
Storyboard.TargetProperty="Margin"
|
||||
To="20 1 2 1"
|
||||
Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Unchecked">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetName="Border"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||||
To="White"
|
||||
Duration="0:0:0.1" />
|
||||
<ThicknessAnimation Storyboard.TargetName="Ellipse"
|
||||
Storyboard.TargetProperty="Margin"
|
||||
To="2 1 2 1"
|
||||
Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="passwordbox" TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Type PasswordBox}}">
|
||||
<Setter Property="Padding" Value="10, 10" />
|
||||
<Setter Property="WpfTest:PasswordBoxMonitor.IsMonitoring"
|
||||
Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
x:Name="Bd" BorderBrush="#8492A6"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
|
||||
<TextBlock x:Name="txtPrompt" Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Visibility="Collapsed"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="WpfTest:PasswordBoxMonitor.PasswordLength" Value="0">
|
||||
<Setter Property="Visibility" TargetName="txtPrompt" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Padding" Value="10, 10"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
|
||||
<TextBlock Text="{TemplateBinding Tag}"
|
||||
Background="Transparent"
|
||||
Padding="10,10"
|
||||
Foreground="#8190A5" IsHitTestVisible="False">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource AncestorType=TextBox}}"
|
||||
Value="">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
<Grid x:Name="SignUpGrid" Background="White" Width="1300" Height="1000" Margin="-450,-40,0,0">
|
||||
<Border BorderBrush="#5A6978" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="433,50,0,0">
|
||||
<Grid Margin="65">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Image Grid.Row="0" Source="\images\app_logo.png" Width="90" Height="55" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,-34,0,0"/>
|
||||
<TextBlock Grid.Row="1" Text="Sign up" FontSize="30" HorizontalAlignment="Center" Margin="0,23,0,48" Foreground="#47525E" FontWeight="Bold"/>
|
||||
|
||||
<TextBox Tag="Username" Grid.Row="2" x:Name="txtUsername" Width="290" Margin="60,0,60,0" Style="{StaticResource placeHolder}" Height="46" VerticalAlignment="Center" FontSize="16" Foreground="#8190A5" />
|
||||
<TextBox Grid.Row="3" x:Name="txtEmail" Tag="Email" Width="290" Margin="11,16,11,11" Style="{StaticResource placeHolder}" Height="46" FontSize="16" Foreground="#8190A5"/>
|
||||
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Top" Margin="42,46,0,0" Grid.RowSpan="2">
|
||||
<PasswordBox Tag="Password" x:Name="txtPassword" Width="290" Margin="18,32,10,0" Height="46" FontSize="16" Foreground="#8190A5" PasswordChar="•" Style="{StaticResource passwordbox}"/>
|
||||
<TextBox x:Name="txtVisiblePassword" IsEnabled="False" Visibility="Collapsed" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource RoundedTextBoxStyle}"/>
|
||||
<ToggleButton x:Name="TogglePasswordVisibility" Width="40" Height="40" Margin="0,22,10,0" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Click="TogglePasswordVisibility_Click">
|
||||
<Image x:Name="PasswordVisibilityIcon" Width="30" Height="30" Source="\images\hidePasswordIcon.png" RenderTransformOrigin="1.786,0.428" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Top" Margin="42,46,0,0" Grid.RowSpan="2">
|
||||
<PasswordBox Tag="Confirm password" x:Name="txtConfirmPassword" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" PasswordChar="•" Style="{StaticResource passwordbox}" Password=""/>
|
||||
<TextBox x:Name="txtVisibleConfirmPassword" IsEnabled="False" Visibility="Collapsed" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource RoundedTextBoxStyle}"/>
|
||||
<ToggleButton x:Name="ToggleConfirmPasswordVisibility" Width="40" Height="40" Margin="0,22,10,0" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Click="ToggleConfirmPasswordVisibility_Click">
|
||||
<Image x:Name="ConfirmPasswordVisibilityIcon" Width="30" Height="30" Source="\images\hidePasswordIcon.png" RenderTransformOrigin="1.786,0.428" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10">
|
||||
<TextBlock Text="Business Account" FontSize="14" Foreground="#8190A5"/>
|
||||
<ToggleButton x:Name="Toggle" Style="{StaticResource ToggleSwitchStyle}" Margin="20,0"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="7" x:Name="SignUpButton" Content="Sign Up" Background="#FF47525E" Foreground="White" Margin="0,10,0,-3" Width="220" Height="38" HorizontalAlignment="Center" FontSize="16" BorderBrush="#FF47525E" Click="SignUpButton_Click">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<TextBlock Grid.Row="8" FontSize="14" HorizontalAlignment="Center" Margin="0,20,0,10" Foreground="#8190A5">
|
||||
<Run Text="If you already have an account"/>
|
||||
<Hyperlink Click="SignInLink_Click">
|
||||
<TextBlock Text="sign in" Foreground="#8190A5"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
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.ExtraInfo;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
using Log_In;
|
||||
|
||||
namespace District_3_App.LogIn
|
||||
{
|
||||
public partial class SignUp : UserControl
|
||||
{
|
||||
public User User { get; set; }
|
||||
private string currentUsername;
|
||||
|
||||
private UsersRepository usersRepository;
|
||||
private UserManager userManager;
|
||||
public SignUp()
|
||||
{
|
||||
InitializeComponent();
|
||||
string filePath = "./Users.xml";
|
||||
usersRepository = new UsersRepository(filePath);
|
||||
userManager = new UserManager(filePath);
|
||||
}
|
||||
|
||||
private Guid GenerateRandomUserId()
|
||||
{
|
||||
return Guid.NewGuid();
|
||||
}
|
||||
|
||||
private void SignInLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newContent = new SignInPage();
|
||||
Grid.SetColumn(newContent, 2);
|
||||
Grid.SetRow(newContent, 0);
|
||||
Grid.SetRowSpan(newContent, 6);
|
||||
SignUpGrid.Children.Clear();
|
||||
SignUpGrid.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void TogglePasswordVisibility_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (PasswordVisibilityIcon.Source.ToString().Contains("hidePasswordIcon") && txtVisiblePassword.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
txtPassword.Visibility = Visibility.Collapsed;
|
||||
txtVisiblePassword.Visibility = Visibility.Visible;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/showPasswordIcon.png"));
|
||||
txtVisiblePassword.Text = txtPassword.Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtPassword.Visibility = Visibility.Visible;
|
||||
txtVisiblePassword.Visibility = Visibility.Collapsed;
|
||||
PasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/hidePasswordIcon.png"));
|
||||
txtPassword.Password = txtVisiblePassword.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleConfirmPasswordVisibility_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ConfirmPasswordVisibilityIcon.Source.ToString().Contains("hidePasswordIcon") && txtVisibleConfirmPassword.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
txtConfirmPassword.Visibility = Visibility.Collapsed;
|
||||
txtVisibleConfirmPassword.Visibility = Visibility.Visible;
|
||||
ConfirmPasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/showPasswordIcon.png"));
|
||||
txtVisibleConfirmPassword.Text = txtConfirmPassword.Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtConfirmPassword.Visibility = Visibility.Visible;
|
||||
txtVisibleConfirmPassword.Visibility = Visibility.Collapsed;
|
||||
ConfirmPasswordVisibilityIcon.Source = new BitmapImage(new Uri("pack://application:,,,/images/hidePasswordIcon.png"));
|
||||
txtConfirmPassword.Password = txtVisibleConfirmPassword.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void SignUpButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool isValid = true;
|
||||
bool userDoesntExist = true;
|
||||
|
||||
if (!ValidateUsername(txtUsername.Text))
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!ValidateEmail(txtEmail.Text))
|
||||
{
|
||||
MessageBox.Show("Invalid email.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// if (ValidatePassword(txtPassword.Password) == false)
|
||||
// {
|
||||
// MessageBox.Show("Invalid password. The password's length must be between 5 and 10 characters and must contain at least one uppercase letter, one lowercase letter, one number, and one special character(/_-.)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
// isValid = false;
|
||||
// }
|
||||
|
||||
// if (ValidateConfirmPassword(txtConfirmPassword.Password) == false)
|
||||
// {
|
||||
// MessageBox.Show("Invalid confirmation password. The password's length must be between 5 and 10 characters and must contain at least one uppercase letter, one lowercase letter, one number, and one special character(/_-.)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
// isValid = false;
|
||||
// }
|
||||
if (txtPassword.Password.Equals(txtConfirmPassword.Password) == false)
|
||||
{
|
||||
MessageBox.Show("Please choose the same password!.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
if (usersRepository.UsernameExists(txtUsername.Text) || usersRepository.EmailExists(txtEmail.Text) || (usersRepository.UsernameExists(txtUsername.Text) && usersRepository.EmailExists(txtEmail.Text)))
|
||||
{
|
||||
MessageBox.Show("Account already exists.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
userDoesntExist = false;
|
||||
}
|
||||
if (userDoesntExist)
|
||||
{
|
||||
User newUser = new User
|
||||
{
|
||||
Id = GenerateRandomUserId(),
|
||||
Username = txtUsername.Text,
|
||||
Email = txtEmail.Text,
|
||||
Password = txtPassword.Password,
|
||||
ConfirmationPassword = txtConfirmPassword.Password
|
||||
};
|
||||
try
|
||||
{
|
||||
usersRepository.AddUser(newUser);
|
||||
userManager.StartOrRenewSession(newUser);
|
||||
// UserManager.currentUsername = newUser.username;
|
||||
ClearSignUpForm();
|
||||
var newContent = new MainWindow();
|
||||
newContent.Show();
|
||||
Window.GetWindow(this).Close();
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
// Handle the case where the username already exists
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearSignUpForm()
|
||||
{
|
||||
txtUsername.Clear();
|
||||
txtEmail.Clear();
|
||||
txtPassword.Clear();
|
||||
txtConfirmPassword.Clear();
|
||||
}
|
||||
|
||||
private bool ValidateUsername(string username)
|
||||
{
|
||||
var hasMiniMaxChars = new Regex(@".{5,11}");
|
||||
var hasNumericChar = new Regex(@"[0-9]+");
|
||||
var hasAlphabeticChar = new Regex(@"[A-Za-z]");
|
||||
var hasSpecialChar = new Regex(@"[_.-]");
|
||||
|
||||
if (hasMiniMaxChars.IsMatch(username) && hasNumericChar.IsMatch(username) && hasAlphabeticChar.IsMatch(username) && hasSpecialChar.IsMatch(username))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!hasMiniMaxChars.IsMatch(username))
|
||||
{
|
||||
MessageBox.Show("Invalid username. The username's length must be between 5 and 11 characters.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
else if (!hasNumericChar.IsMatch(username))
|
||||
{
|
||||
MessageBox.Show("Invalid username. The username must contain at least one number.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
else if (!hasAlphabeticChar.IsMatch(username))
|
||||
{
|
||||
MessageBox.Show("Invalid username. The username must contain at least one alphabetic character..", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
else if (!hasSpecialChar.IsMatch(username))
|
||||
{
|
||||
MessageBox.Show("Invalid username. The username must contain at least one special character(_ . -).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateEmail(string email)
|
||||
{
|
||||
if (Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ValidatePassword(string password)
|
||||
{
|
||||
var hasNumericChar = new Regex(@"[0-9]+");
|
||||
var hasUpperChar = new Regex(@"[A-Z]+");
|
||||
var hasLowerChar = new Regex(@"[a-z]+");
|
||||
var hasSpecialChar = new Regex(@"[/-_.]+");
|
||||
var hasMiniMaxChars = new Regex(@".{5,10}");
|
||||
|
||||
bool isPasswordValid = hasNumericChar.IsMatch(password) && hasUpperChar.IsMatch(password) && hasLowerChar.IsMatch(password) && hasSpecialChar.IsMatch(password) && hasMiniMaxChars.IsMatch(password);
|
||||
return isPasswordValid;
|
||||
}
|
||||
|
||||
private bool ValidateConfirmPassword(string confirmPassword)
|
||||
{
|
||||
var hasNumericChar = new Regex(@"[0-9]+");
|
||||
var hasUpperChar = new Regex(@"[A-Z]+");
|
||||
var hasLowerChar = new Regex(@"[a-z]+");
|
||||
var hasSpecialChar = new Regex(@"[/\-_.]+");
|
||||
var hasMiniMaxChars = new Regex(@".{5,10}");
|
||||
|
||||
bool isConfirmationPasswordValid = hasNumericChar.IsMatch(confirmPassword) && hasUpperChar.IsMatch(confirmPassword) && hasLowerChar.IsMatch(confirmPassword) && hasSpecialChar.IsMatch(confirmPassword) && hasMiniMaxChars.IsMatch(confirmPassword);
|
||||
return isConfirmationPasswordValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
|
||||
namespace District_3_App.LogIn
|
||||
{
|
||||
public class UserManager
|
||||
{
|
||||
private List<User> users = new List<User>();
|
||||
private static User? currentUser;
|
||||
|
||||
public string GetCurrentUser()
|
||||
{
|
||||
if (currentUser == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return currentUser.Username;
|
||||
}
|
||||
public UserManager(string filePath)
|
||||
{
|
||||
LoadUsersFromXml(filePath);
|
||||
}
|
||||
|
||||
public bool AuthenticateUser(string username, string password)
|
||||
{
|
||||
User? user = users.Find(u => u.Username == username);
|
||||
if (user != null && user.Password == password)
|
||||
{
|
||||
StartOrRenewSession(user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void StartOrRenewSession(User user)
|
||||
{
|
||||
UserManager.currentUser = user;
|
||||
}
|
||||
|
||||
public bool IsUserLoggedIn()
|
||||
{
|
||||
return UserManager.currentUser != null;
|
||||
}
|
||||
|
||||
public void LogOutUser()
|
||||
{
|
||||
UserManager.currentUser = null;
|
||||
}
|
||||
|
||||
private void LoadUsersFromXml(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = XDocument.Load(filePath);
|
||||
foreach (var userElement in doc.Root.Elements("User"))
|
||||
{
|
||||
User user = 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,
|
||||
Usersession = TimeSpan.FromMinutes(0)
|
||||
};
|
||||
users.Add(user);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("File not found");
|
||||
}
|
||||
}
|
||||
public IReadOnlyList<User> GetUsers()
|
||||
{
|
||||
return users.AsReadOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="Log_In.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Log_In"
|
||||
mc:Ignorable="d"
|
||||
Title="Window1" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,80 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace Log_In
|
||||
{
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
public class PasswordBoxMonitor : DependencyObject
|
||||
{
|
||||
public static bool GetIsMonitoring(DependencyObject obj)
|
||||
{
|
||||
return (bool)obj.GetValue(IsMonitoringProperty);
|
||||
}
|
||||
|
||||
public static void SetIsMonitoring(DependencyObject obj, bool value)
|
||||
{
|
||||
obj.SetValue(IsMonitoringProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsMonitoringProperty =
|
||||
DependencyProperty.RegisterAttached("IsMonitoring", typeof(bool), typeof(PasswordBoxMonitor), new UIPropertyMetadata(false, OnIsMonitoringChanged));
|
||||
|
||||
public static int GetPasswordLength(DependencyObject obj)
|
||||
{
|
||||
return (int)obj.GetValue(PasswordLengthProperty);
|
||||
}
|
||||
|
||||
public static void SetPasswordLength(DependencyObject obj, int value)
|
||||
{
|
||||
obj.SetValue(PasswordLengthProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PasswordLengthProperty =
|
||||
DependencyProperty.RegisterAttached("PasswordLength", typeof(int), typeof(PasswordBoxMonitor), new UIPropertyMetadata(0));
|
||||
|
||||
private static void OnIsMonitoringChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var pb = d as PasswordBox;
|
||||
if (pb == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((bool)e.NewValue)
|
||||
{
|
||||
pb.PasswordChanged += PasswordChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
pb.PasswordChanged -= PasswordChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var pb = sender as PasswordBox;
|
||||
if (pb == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetPasswordLength(pb, pb.Password.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
<Window x:Class="District_3_App.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:highlights="clr-namespace:District_3_App.HighlightsFE"
|
||||
xmlns:local="clr-namespace:District_3_App"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid x:Name="mainGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.20*"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition Width="0.75*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="District 3" FontWeight="Bold" FontSize="30" Foreground="#47525E" HorizontalAlignment="Center" Margin="0,20,0,0"/>
|
||||
<StackPanel Orientation="Vertical" Margin="0,10,0,10">
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="Button_Click_Home">
|
||||
<TextBlock Text="Home" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="Button_Click_Search">
|
||||
<TextBlock Text="Search" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="Button_Click_Explore">
|
||||
<TextBlock Text="Explore" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="Button_Click_Reels">
|
||||
<TextBlock Text="Reels" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="Button_Click_Messages">
|
||||
<TextBlock Text="Messages" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="20,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" Click="Button_Click_Notifications">
|
||||
<TextBlock Text="Notifications" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,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" Click="ProfileButton_Click">
|
||||
<TextBlock Text="Profile" Margin="5,0,0,0" FontSize="22px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<ContentControl x:Name="ExtraInfoControl"></ContentControl>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<GridSplitter Grid.Column="1" Width="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#8492A6" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" />
|
||||
<StackPanel Grid.Column="2">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button x:Name="Menu" Background="Transparent" BorderBrush="Transparent" Click="MoreButton_Click">
|
||||
<Image Source="\images\menu.png" Width="30" Height="30" Margin="30,20,10,0"/>
|
||||
</Button>
|
||||
<Button x:Name="Plus" Background="Transparent" BorderBrush="Transparent" Click="PlusButton_Click">
|
||||
<Image Source="\images\plus.png" Width="30" Height="30" Margin="0,20,10,0"/>
|
||||
</Button>
|
||||
<Popup x:Name="Popup" Placement="Center" StaysOpen="False" PlacementTarget="{Binding ElementName=Plus}" VerticalOffset="105">
|
||||
<Grid>
|
||||
<Rectangle RenderTransformOrigin="0.5,0.5" Fill="#FFC4C4C4"/>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Content="Add Story" Margin="10" Width="192" Height="50" Background="#47525E" BorderBrush="#8492A6" Foreground="white"/>
|
||||
<Button Grid.Column="1" Content="Add Reel" Margin="10" Width="192" Height="50" Background="#47525E" BorderBrush="#8492A6" Foreground="white"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Content="Add Highlight" Margin="10" Width="192" Height="50" Background="#47525E" BorderBrush="#8492A6" Foreground="white" Click="OnAddHighlight_Click"/>
|
||||
<Button Grid.Column="1" Content="Add Post" Margin="10" Width="192" Height="50" Background="#47525E" BorderBrush="#8492A6" Foreground="white"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Popup>
|
||||
<Popup x:Name="Popup2" Placement="Bottom" StaysOpen="False" PlacementTarget="{Binding ElementName=Menu}" VerticalOffset="5">
|
||||
<Border Background="#FFC4C4C4" BorderBrush="Gray" BorderThickness="2" Width="150" CornerRadius="8">
|
||||
<StackPanel Orientation="Vertical" Margin="5">
|
||||
<Button Content="Extra Info" Margin="0,5" Width="Auto" Height="30" Background="Transparent" BorderBrush="Transparent" Click="ExtraInfo_Click" Foreground="white"/>
|
||||
<Button Content="Logout" Margin="0,5" Width="Auto" Height="30" Background="Transparent" BorderBrush="Transparent" Click="Logout_Click" Foreground="white"/>
|
||||
<Button Content="Cancel" Margin="0,5" Width="Auto" Height="30" Background="Transparent" BorderBrush="Transparent" Click="Cancel_Click" Foreground="white"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Margin="30,7,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Description" FontSize="20px" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Background="Transparent" BorderBrush="Transparent" Margin="5,0,0,0" VerticalAlignment="Center" Click="MoreDescriptionButton_Click">
|
||||
<Image Source="/images/threedots.png" Width="20" Height="20"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<StackPanel x:Name="AdditionalDescription" Grid.Row="1" Margin="20,0, 0,200" Visibility="Collapsed" VerticalAlignment="Top">
|
||||
<TextBlock Text="DESCRIPTION" FontSize="20px" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="hashtagText" FontSize="18px" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
<TextBlock x:Name="mottoText" FontSize="18px" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
<TextBlock x:Name="link1Text" FontSize="18px" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
<TextBlock x:Name="link2Text" FontSize="18px" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<StackPanel Width="180" Height="180" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,20,0,0">
|
||||
<Grid>
|
||||
<Rectangle x:Name="firstFrame" Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFFF00BD"/>
|
||||
<GradientStop Color="#FF0A2CB9" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Rectangle x:Name="secondFrame" Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="Black"/>
|
||||
<GradientStop Color="#FF80006E" Offset="1"/>
|
||||
<GradientStop Color="#FFEE47F2" Offset="0.798"/>
|
||||
<GradientStop Color="White" Offset="0.616"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Rectangle x:Name="thirdFrame" Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFD52D00"/>
|
||||
<GradientStop Color="#FFA30262" Offset="1"/>
|
||||
<GradientStop Color="#FFB55690" Offset="0.858"/>
|
||||
<GradientStop Color="#FFD162A4" Offset="0.629"/>
|
||||
<GradientStop Color="White" Offset="0.497"/>
|
||||
<GradientStop Color="#FFFF9A56" Offset="0.36"/>
|
||||
<GradientStop Color="#FFEF7627" Offset="0.199"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Rectangle x:Name="fourthFrame" Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed" >
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFE40303"/>
|
||||
<GradientStop Color="DarkOrange" Offset="0.21"/>
|
||||
<GradientStop Color="#FFFFED00" Offset="0.401"/>
|
||||
<GradientStop Color="#FF008026" Offset="0.57"/>
|
||||
<GradientStop Color="#FF24408E" Offset="0.766"/>
|
||||
<GradientStop Color="#FF732982" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Rectangle Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed" x:Name="fifthFrame" >
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FF5BCEFA"/>
|
||||
<GradientStop Color="#FFF5A9B8" Offset="0.272"/>
|
||||
<GradientStop Color="White" Offset="0.519"/>
|
||||
<GradientStop Color="#FFF5A9B8" Offset="0.734"/>
|
||||
<GradientStop Color="#FF5BCEFA" Offset="0.981"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Rectangle Height="160" Width="160" StrokeThickness="10" Visibility="Collapsed" x:Name="romanianFrame">
|
||||
<Rectangle.Stroke>
|
||||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0" MappingMode="RelativeToBoundingBox" SpreadMethod="Pad">
|
||||
<GradientStop Color="#0033A0" Offset="0"/>
|
||||
<GradientStop Color="#0033A0" Offset="0.333"/>
|
||||
<GradientStop Color="#FFCE1126" Offset="0.333"/>
|
||||
<GradientStop Color="#FFCE1126" Offset="0.666"/>
|
||||
<GradientStop Color="#FCD116" Offset="0.666"/>
|
||||
<GradientStop Color="#FCD116" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Stroke>
|
||||
</Rectangle>
|
||||
<Image Source="\images\avatar.png" Width="150" Height="150" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Margin="0,5,0,0" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Name="FollowerCountTextBlock" Margin="20,0,10,0" FontWeight="Bold" FontSize="20px"/>
|
||||
<TextBlock Text="Followers" Margin="0,0,40,0" FontSize="20px"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Name="FollowingTextBlock" Margin="20,0,5,0" FontWeight="Bold" FontSize="20px"/>
|
||||
<TextBlock Text="Following" FontSize="20px"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="UsernameTextBlock" Text="Username" Grid.Column="1" Margin="10,2,60,0" FontSize="20px" FontWeight="Bold"/>
|
||||
<Image Source="\images\verified.png" Width="20" Height="20" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Margin="0,4,30,0"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="30,0,5,0">
|
||||
<Image Source="\images\right-arrow.png" Width="20" Height="20" Margin="0,0,5,0"/>
|
||||
<Button x:Name="MoreAbout" Background="Transparent" BorderBrush="Transparent" Click="MoreAbout_Click" >
|
||||
<TextBlock Text="More About Me" Margin="0,0,0,0" Foreground="#47525E" FontWeight="Bold" FontSize="20px"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<!-- Popup Definition -->
|
||||
<Popup x:Name="MoreAboutPopup" Placement="Bottom" StaysOpen="False" PlacementTarget="{Binding ElementName=MoreAbout}" VerticalOffset="5" >
|
||||
<Border Background="White" BorderBrush="Gray" BorderThickness="2" Width="300" CornerRadius="8">
|
||||
<StackPanel Orientation="Vertical" Margin="5">
|
||||
<!-- Title -->
|
||||
<TextBlock Text="About Me" FontSize="20" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,0,0,10"/>
|
||||
|
||||
<!-- Date of Birth -->
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Date of Birth: "/>
|
||||
<TextBlock x:Name="TextBlockDateOfBirth" Text=""/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Contact Info -->
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Name: "/>
|
||||
<TextBlock x:Name="TextBlockName" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Phone Number: "/>
|
||||
<TextBlock x:Name="TextBlockPhoneNumber" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Contact info: "/>
|
||||
<TextBlock x:Name="TextBlockEmail" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Places: "/>
|
||||
<TextBlock x:Name="TextBlockPlaces" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Hobbies: "/>
|
||||
<TextBlock x:Name="TextBlockHobbies" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Music: "/>
|
||||
<TextBlock x:Name="TextBlockMusic" Text=""/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Education -->
|
||||
<StackPanel Margin="0,10,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Education: "/>
|
||||
<TextBlock x:Name="TextBlockEducation" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Start Date: "/>
|
||||
<TextBlock x:Name="TextBlockEducationStartDate" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="End Date: "/>
|
||||
<TextBlock x:Name="TextBlockEducationEndDate" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Location: "/>
|
||||
<TextBlock x:Name="TextBlockEducationLocation" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,10" Orientation="Horizontal">
|
||||
<TextBlock Text="Level: "/>
|
||||
<TextBlock x:Name="TextBlockEducationLevel" Text=""/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Work -->
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Work: "/>
|
||||
<TextBlock x:Name="TextBlockWork" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Start Date: "/>
|
||||
<TextBlock x:Name="TextBlockWorkStartDate" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="End Date: "/>
|
||||
<TextBlock x:Name="TextBlockWorkEndDate" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Work Description: "/>
|
||||
<TextBlock x:Name="TextBlockWorkDescription" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<TextBlock Text="Location: "/>
|
||||
<TextBlock x:Name="TextBlockWorkLocation" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,10" Orientation="Horizontal">
|
||||
<TextBlock Text="Position: "/>
|
||||
<TextBlock x:Name="TextBlockWorkPosition" Text=""/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,0,10" Orientation="Horizontal">
|
||||
<TextBlock Text="Description: "/>
|
||||
<TextBlock x:Name="TextBlockDescription" Text=""/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="2" Margin="20,10,0,0" Orientation="Horizontal" HorizontalAlignment="Center" >
|
||||
<!--<StackPanel Orientation="Vertical" Margin="0,5,0,5">
|
||||
<Image Source="\images\square.png" Width="60" Height="60" Margin="0,0,10,0" />
|
||||
<TextBlock Text="H1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" Margin="0,5,0,5">
|
||||
<Image Source="\images\square.png" Width="60" Height="60" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="H2" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" Margin="0,5,0,5">
|
||||
<Image Source="\images\square.png" Width="60" Height="60" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="H3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" Margin="0,5,0,5">
|
||||
<Image Source="\images\square.png" Width="60" Height="60" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="H4" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>-->
|
||||
<highlights:HighlightsOnMain/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="4" Margin="0,20,0,0">
|
||||
<UniformGrid Columns="3">
|
||||
<Button x:Name="PostsButton" Background="Transparent" BorderBrush="Transparent" Click="PostsButton_Click">
|
||||
<TextBlock Text="Posts" Margin="5,0,0,0" FontSize="22px" Foreground="#47525E"/>
|
||||
</Button>
|
||||
<Button x:Name="ReelsButton" Background="Transparent" BorderBrush="Transparent" Click="ReelsButton_Click">
|
||||
<TextBlock Text="Reels" Margin="5,0,0,0" FontSize="22px" Foreground="#47525E"/>
|
||||
</Button>
|
||||
<Button x:Name="TagsButton" Background="Transparent" BorderBrush="Transparent" Click="TagsButton_Click">
|
||||
<TextBlock Text="Tags" Margin="5,0,0,0" FontSize="22px" Foreground="#47525E"/>
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
<Border BorderBrush="#47525E" BorderThickness="0,1,0,0" Margin="40,10,40,40"/>
|
||||
<StackPanel x:Name="PostsPanel" Background="Transparent" Margin="20,0,0,0">
|
||||
<UniformGrid Columns="3" Margin="20,0,0,0">
|
||||
<Border Background="LightGray" Width="300" Height="300" Margin="0,0,0,5">
|
||||
<Grid>
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
<Image Source="\images\more2.png" Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" MouseDown="MoreImage_MouseDown"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Background="LightGray" Width="300" Height="300" Margin="10,0">
|
||||
<Grid>
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
<Image Source="\images\more2.png" Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" MouseDown="MoreImage_MouseDown"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Background="LightGray" Width="300" Height="300" Margin="10,0,0,5">
|
||||
<Grid>
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
<Image Source="\images\more2.png" Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" MouseDown="MoreImage_MouseDown"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
<StackPanel x:Name="ReelsPanel" Visibility="Collapsed" Margin="20,0,0,0">
|
||||
<UniformGrid Columns="3" Margin="20,0,0,0">
|
||||
<Border Background="LightBlue" Width="300" Height="300" Margin="0,0,0,5">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
<Border Background="LightBlue" Width="300" Height="300" Margin="10,0">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
<Border Background="LightBlue" Width="300" Height="300" Margin="10,0,0,5">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
<StackPanel x:Name="TagsPanel" Visibility="Collapsed" Margin="20,0,0,0">
|
||||
<UniformGrid Columns="3" Margin="20,0,0,0">
|
||||
<Border Background="LightGreen" Width="300" Height="300" Margin="0,0,0,5">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
<Border Background="LightGreen" Width="300" Height="300" Margin="10,0">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
<Border Background="LightGreen" Width="300" Height="300" Margin="10,0,0,5">
|
||||
<Image Source="\images\square1.png" Width="300" Height="300"/>
|
||||
</Border>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<ContentControl x:Name="CC" Grid.Column="2"></ContentControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,403 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
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;
|
||||
using District_3_App.ExtraInfo;
|
||||
using District_3_App.HighlightsFE;
|
||||
using District_3_App.LogIn;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
using District_3_App.Service;
|
||||
using Log_In;
|
||||
|
||||
namespace District_3_App
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private ProfileInfoSettings profileInfoSettings;
|
||||
private CasualProfileService casualProfileService = new CasualProfileService();
|
||||
private UsersRepository userRepository;
|
||||
private UserManager userManager;
|
||||
public string Username { get; set; }
|
||||
private Stopwatch timer = new Stopwatch();
|
||||
protected int time;
|
||||
private DateTime currentDate;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
timer.Start();
|
||||
InitializeComponent();
|
||||
GenerateFrame();
|
||||
this.profileInfoSettings = casualProfileService.GetProfileInfoSettings();
|
||||
userRepository = new UsersRepository("./Users.xml");
|
||||
userManager = new UserManager("./Users.xml");
|
||||
LoadUserProfile();
|
||||
}
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
base.OnClosing(e);
|
||||
|
||||
timer.Stop();
|
||||
|
||||
TimeSpan elapsedTime = timer.Elapsed;
|
||||
string formattedTime = $"{elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}.{elapsedTime.Milliseconds / 10:00}";
|
||||
|
||||
time = (int)elapsedTime.TotalSeconds;
|
||||
|
||||
currentDate = DateTime.Now;
|
||||
|
||||
SaveTimeToXml(time);
|
||||
}
|
||||
private void SaveTimeToXml(int time)
|
||||
{
|
||||
string filePath = "TimeData.xml";
|
||||
|
||||
try
|
||||
{
|
||||
// Check if the XML file exists
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
// Load the existing XML document
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(filePath);
|
||||
|
||||
// Get the root element
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
|
||||
// Create the entry element
|
||||
XmlElement entryElement = xmlDoc.CreateElement("Entry");
|
||||
|
||||
// Create the time element
|
||||
XmlElement timeElement = xmlDoc.CreateElement("Time");
|
||||
timeElement.InnerText = time.ToString();
|
||||
|
||||
// Create the date element
|
||||
XmlElement dateElement = xmlDoc.CreateElement("Date");
|
||||
dateElement.InnerText = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
|
||||
// Append time and date elements to the entry element
|
||||
entryElement.AppendChild(timeElement);
|
||||
entryElement.AppendChild(dateElement);
|
||||
|
||||
// Append the entry element to the root element
|
||||
root.AppendChild(entryElement);
|
||||
|
||||
// Save the XML document back to the file
|
||||
xmlDoc.Save(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the file doesn't exist, create a new XML document and save the time value
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
|
||||
// Create the root element
|
||||
XmlElement root = xmlDoc.CreateElement("TimeData");
|
||||
xmlDoc.AppendChild(root);
|
||||
|
||||
// Create the entry element
|
||||
XmlElement entryElement = xmlDoc.CreateElement("Entry");
|
||||
|
||||
// Create the time element
|
||||
XmlElement timeElement = xmlDoc.CreateElement("Time");
|
||||
timeElement.InnerText = time.ToString();
|
||||
|
||||
// Create the date element
|
||||
XmlElement dateElement = xmlDoc.CreateElement("Date");
|
||||
dateElement.InnerText = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
|
||||
// Append time and date elements to the entry element
|
||||
entryElement.AppendChild(timeElement);
|
||||
entryElement.AppendChild(dateElement);
|
||||
|
||||
// Append the entry element to the root element
|
||||
root.AppendChild(entryElement);
|
||||
|
||||
// Save the XML document to a file
|
||||
xmlDoc.Save(filePath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle any exceptions
|
||||
MessageBox.Show($"Error saving time data to XML file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
private void LoadUserProfile()
|
||||
{
|
||||
User user;
|
||||
if (userManager != null)
|
||||
{
|
||||
user = userRepository.GetUserByName(userManager.GetCurrentUser());
|
||||
}
|
||||
else
|
||||
{
|
||||
user = null;
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
// Display the username
|
||||
UsernameTextBlock.Text = $"{user.Username}";
|
||||
|
||||
// Display the followers count
|
||||
FollowerCountTextBlock.Text = $"{userRepository.GetFollowersCount(user.Username)}";
|
||||
|
||||
// Display the following count
|
||||
FollowingTextBlock.Text = $"{userRepository.GetFollowingCount(user.Username)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// User not found
|
||||
MessageBox.Show("User not found.");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAboutYou(
|
||||
string email, string phoneNumber, string dateOfBirth, string name,
|
||||
string education, string educationLevel,
|
||||
string educationStartDate, string educationEndDate,
|
||||
string educationLocation, string hobbies, string music, string places,
|
||||
string work, string position, string workStartDate,
|
||||
string workEndDate, string workLocation, string description)
|
||||
{
|
||||
TextBlockEmail.Text = email;
|
||||
TextBlockPhoneNumber.Text = phoneNumber;
|
||||
TextBlockDateOfBirth.Text = dateOfBirth;
|
||||
TextBlockName.Text = name;
|
||||
TextBlockEducation.Text = education;
|
||||
TextBlockEducationLevel.Text = educationLevel;
|
||||
TextBlockEducationStartDate.Text = educationStartDate;
|
||||
TextBlockEducationEndDate.Text = educationEndDate;
|
||||
TextBlockEducationLocation.Text = educationLocation;
|
||||
TextBlockHobbies.Text = hobbies;
|
||||
TextBlockMusic.Text = music;
|
||||
TextBlockPlaces.Text = places;
|
||||
TextBlockWork.Text = work;
|
||||
TextBlockWorkPosition.Text = position;
|
||||
TextBlockWorkStartDate.Text = workStartDate;
|
||||
TextBlockWorkEndDate.Text = workEndDate;
|
||||
TextBlockWorkLocation.Text = workLocation;
|
||||
TextBlockDescription.Text = description;
|
||||
}
|
||||
private void Button_Click_Home(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl6();
|
||||
}
|
||||
private void Button_Click_Search(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl5();
|
||||
}
|
||||
private void Button_Click_Explore(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl4();
|
||||
}
|
||||
private void Button_Click_Reels(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl3();
|
||||
}
|
||||
private void Button_Click_Messages(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl2();
|
||||
}
|
||||
private void Button_Click_Notifications(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = new UserControl1();
|
||||
}
|
||||
private void ProfileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CC.Content = null;
|
||||
}
|
||||
|
||||
private void PlusButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Popup.IsOpen = true;
|
||||
}
|
||||
private void MoreButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Popup2.IsOpen = true;
|
||||
}
|
||||
private void ExtraInfo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newContent = new ExtraInfo.ExtraInfo();
|
||||
Grid.SetColumn(newContent, 2);
|
||||
Grid.SetRow(newContent, 0);
|
||||
Grid.SetRowSpan(newContent, 6);
|
||||
mainGrid.Children.Add(newContent);
|
||||
}
|
||||
private void Logout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
userManager.LogOutUser();
|
||||
mainGrid.Children.Clear();
|
||||
var newContent = new SignUp();
|
||||
Grid.SetColumn(newContent, 2);
|
||||
Grid.SetRow(newContent, 0);
|
||||
Grid.SetRowSpan(newContent, 6);
|
||||
mainGrid.Children.Add(newContent);
|
||||
}
|
||||
private void Cancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Popup2.IsOpen = false;
|
||||
}
|
||||
private void MoreAbout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MoreAboutPopup.IsOpen = true;
|
||||
}
|
||||
|
||||
private void OnAddHighlight_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
mainGrid.Children.Clear();
|
||||
var newContent = new SelectPostsPage();
|
||||
Grid.SetColumn(newContent, 2); // Place in the third column
|
||||
Grid.SetRow(newContent, 0); // Place in the first row
|
||||
Grid.SetRowSpan(newContent, 4); // Span multiple rows if necessary
|
||||
mainGrid.Children.Add(newContent);
|
||||
}
|
||||
private void PostsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Show PostsPanel and hide ReelsPanel and TagsPanel
|
||||
PostsPanel.Visibility = Visibility.Visible;
|
||||
ReelsPanel.Visibility = Visibility.Collapsed;
|
||||
TagsPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ReelsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Show ReelsPanel and hide PostsPanel and TagsPanel
|
||||
PostsPanel.Visibility = Visibility.Collapsed;
|
||||
ReelsPanel.Visibility = Visibility.Visible;
|
||||
TagsPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void TagsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Show TagsPanel and hide PostsPanel and ReelsPanel
|
||||
PostsPanel.Visibility = Visibility.Collapsed;
|
||||
ReelsPanel.Visibility = Visibility.Collapsed;
|
||||
TagsPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
private bool isDescriptionVisible = false;
|
||||
private void MoreDescriptionButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isDescriptionVisible)
|
||||
{
|
||||
// Hide the additional description
|
||||
AdditionalDescription.Visibility = Visibility.Collapsed;
|
||||
isDescriptionVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show the additional description
|
||||
AdditionalDescription.Visibility = Visibility.Visible;
|
||||
isDescriptionVisible = true;
|
||||
}
|
||||
|
||||
var links = profileInfoSettings.GetLinks();
|
||||
if (links != null && links.Count >= 1)
|
||||
{
|
||||
link1Text.Text = links[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
link1Text.Text = string.Empty;
|
||||
}
|
||||
|
||||
if (links != null && links.Count >= 2)
|
||||
{
|
||||
link2Text.Text = links[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
link2Text.Text = string.Empty;
|
||||
}
|
||||
|
||||
var dailyMotto = profileInfoSettings.GetDailyMotto();
|
||||
mottoText.Text = dailyMotto != null ? dailyMotto : string.Empty;
|
||||
|
||||
var hashtag = profileInfoSettings.GetHashtag();
|
||||
hashtagText.Text = hashtag != null ? hashtag : string.Empty;
|
||||
}
|
||||
private void GenerateFrame()
|
||||
{
|
||||
int frameNumber = casualProfileService.GetProfileInfoSettings().GetFrameNumber();
|
||||
if (frameNumber == 1)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Visible;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (frameNumber == 2)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Visible;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (frameNumber == 3)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Visible;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (frameNumber == 4)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Visible;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (frameNumber == 5)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Visible;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (frameNumber == 6)
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstFrame.Visibility = Visibility.Collapsed;
|
||||
secondFrame.Visibility = Visibility.Collapsed;
|
||||
thirdFrame.Visibility = Visibility.Collapsed;
|
||||
fourthFrame.Visibility = Visibility.Collapsed;
|
||||
fifthFrame.Visibility = Visibility.Collapsed;
|
||||
romanianFrame.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void MoreImage_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// Perform your action here
|
||||
MessageBox.Show("More2 image clicked!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
<UserControl x:Class="District_3_App.ProfileInfo_GUI.EditProfileInfo"
|
||||
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.ProfileInfo_GUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Background="White">
|
||||
|
||||
<StackPanel x:Name="EditProfileInfoStackPanel" Orientation="Horizontal" Width="1000">
|
||||
|
||||
<Border BorderThickness="0,0,0,0" BorderBrush="Black">
|
||||
<StackPanel Orientation="Vertical" Margin="0,15,-290,0" VerticalAlignment="Top">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Text="Email"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="EmailTextBox"
|
||||
Text="name@gmail.com"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="9"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Phone number"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="PhoneNumberTextBox"
|
||||
Text="073177151"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="9"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Date of Birth"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<DatePicker x:Name="DatePickerBirthDate" Width="159" Height="27">
|
||||
<DatePicker.Resources>
|
||||
<Style TargetType="{x:Type DatePickerTextBox}">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
</Style>
|
||||
</DatePicker.Resources>
|
||||
</DatePicker>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Username"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="UsernameTextBox"
|
||||
Text="name.lastName"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="9"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Name"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="NameTextBox"
|
||||
Text="Stoica Patricia"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="9"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Work"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="WorkTextBox"
|
||||
Text="Tesla"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="9"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Position"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="PositionTextBox"
|
||||
Text="Tesla"
|
||||
Width="157"
|
||||
Height="25"
|
||||
Margin="8,0,0,0"
|
||||
FontSize="13"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Start date"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<DatePicker x:Name="DatePickerWorkStartDate" Width="200" Height="25" Margin="5,0,0,0">
|
||||
<DatePicker.Resources>
|
||||
<Style TargetType="DatePickerTextBox">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
</Style>
|
||||
</DatePicker.Resources>
|
||||
</DatePicker>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="End date"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<DatePicker x:Name="DatePickerWorkEndDate" Width="200" Height="25" Margin="5,0,0,0">
|
||||
<DatePicker.Resources>
|
||||
<Style TargetType="DatePickerTextBox">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
</Style>
|
||||
</DatePicker.Resources>
|
||||
</DatePicker>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Location"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<ComboBox x:Name="WorkLocationComboBox" Width="200" Height="27" Margin="7,0,0,0" SelectedIndex="0">
|
||||
<ComboBoxItem IsSelected="True">Choose Location</ComboBoxItem>
|
||||
<ComboBoxItem Content="Option 1"/>
|
||||
<ComboBoxItem Content="Option 2"/>
|
||||
<ComboBoxItem Content="Option 3"/>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Description"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="DescriptionTextBox"
|
||||
Text=""
|
||||
Width="183"
|
||||
Height="28"
|
||||
Margin="8,0,0,0"
|
||||
FontSize="10"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="300,15,0,0" VerticalAlignment="Top" Width="407">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Text="Education"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<ComboBox x:Name="EducationComboBox" Width="185" Height="27" Margin="7,0,0,0" SelectedIndex="0">
|
||||
<ComboBoxItem IsSelected="True">Choose Education</ComboBoxItem>
|
||||
<ComboBoxItem Content="Option 1"/>
|
||||
<ComboBoxItem Content="Option 2"/>
|
||||
<ComboBoxItem Content="Option 3"/>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<TextBlock
|
||||
Text="Education level"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Margin="0"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="EducationLevelTextBox"
|
||||
Text=""
|
||||
Width="154"
|
||||
Height="30"
|
||||
Margin="5,0,0,0"
|
||||
FontSize="8"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Start date"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<DatePicker x:Name="DatePickerEducationStartDate" Width="181" Height="27" Margin="5,0,0,0">
|
||||
<DatePicker.Resources>
|
||||
<Style TargetType="DatePickerTextBox">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
</Style>
|
||||
</DatePicker.Resources>
|
||||
</DatePicker>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="End date"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<DatePicker x:Name="DatePickerEducationEndDate" Width="184" Height="25" Margin="5,0,0,0">
|
||||
<DatePicker.Resources>
|
||||
<Style TargetType="DatePickerTextBox">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
</Style>
|
||||
</DatePicker.Resources>
|
||||
</DatePicker>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="15,13,0,0">
|
||||
<TextBlock
|
||||
Text="Location"
|
||||
FontSize="10"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<ComboBox x:Name="EducationLocationComboBox" Width="200" Height="27" Margin="7,0,0,0" SelectedIndex="0">
|
||||
<ComboBoxItem IsSelected="True">Choose Location</ComboBoxItem>
|
||||
<ComboBoxItem Content="Option 1"/>
|
||||
<ComboBoxItem Content="Option 2"/>
|
||||
<ComboBoxItem Content="Option 3"/>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Orientation="Vertical" Margin="15,13,0,0" HorizontalAlignment="Left">
|
||||
<TextBlock
|
||||
Text="Hobbies"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="HobbiesTextBox"
|
||||
Text=""
|
||||
Margin="0,10,0,0"
|
||||
Width="108"
|
||||
Height="114"
|
||||
FontSize="10" RenderTransformOrigin="0.315,0.891"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="15,13,0,0" HorizontalAlignment="Left">
|
||||
<TextBlock
|
||||
Text="Music"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="MusicTextBox"
|
||||
Text=""
|
||||
Margin="0,10,0,0"
|
||||
Width="114"
|
||||
Height="114"
|
||||
FontSize="9" RenderTransformOrigin="0.315,0.891"
|
||||
/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,20,0,0">
|
||||
<TextBlock
|
||||
Text="Places"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<ComboBox x:Name="PlacesComboBox" Width="206" Height="27" Margin="7,0,0,0" SelectedIndex="0">
|
||||
<ComboBoxItem IsSelected="True">Choose Location</ComboBoxItem>
|
||||
<ComboBoxItem Content="Option 1"/>
|
||||
<ComboBoxItem Content="Option 2"/>
|
||||
<ComboBoxItem Content="Option 3"/>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Width="376" Margin="27,25,0,0">
|
||||
<Button Content="Save changes" Width="100" Height="25" Background="Gray" Click="SaveChanges_Button"/>
|
||||
<Button Content="Cancel" Width="100" Height="25" Margin="5" Background="Gray" Click="Cancel_Button"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
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;
|
||||
|
||||
namespace District_3_App.ProfileInfo_GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EditProfileInfo.xaml
|
||||
/// </summary>
|
||||
public partial class EditProfileInfo : UserControl
|
||||
{
|
||||
private ProfileInfoDisplay profileInfoDisplay;
|
||||
|
||||
/*public EditProfileInfo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}*/
|
||||
|
||||
public EditProfileInfo(ProfileInfoDisplay profileInfoDisplay)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.profileInfoDisplay = profileInfoDisplay;
|
||||
|
||||
EmailTextBox.Text = profileInfoDisplay.TextBlockEmail.Text;
|
||||
PhoneNumberTextBox.Text = profileInfoDisplay.TextBlockPhoneNumber.Text;
|
||||
DatePickerBirthDate.SelectedDate = DateTime.ParseExact(profileInfoDisplay.TextBlockDateOfBirth.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
UsernameTextBox.Text = profileInfoDisplay.TextBlockUsername.Text;
|
||||
NameTextBox.Text = profileInfoDisplay.TextBlockName.Text;
|
||||
WorkTextBox.Text = profileInfoDisplay.TextBlockWork.Text;
|
||||
PositionTextBox.Text = profileInfoDisplay.TextBlockWorkPosition.Text;
|
||||
DatePickerWorkStartDate.SelectedDate = DateTime.ParseExact(profileInfoDisplay.TextBlockWorkStartDate.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
DatePickerWorkEndDate.SelectedDate = DateTime.ParseExact(profileInfoDisplay.TextBlockWorkEndDate.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
WorkLocationComboBox.SelectedItem = WorkLocationComboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => item.Content.ToString() == profileInfoDisplay.TextBlockWorkLocation.Text);
|
||||
DescriptionTextBox.Text = profileInfoDisplay.TextBlockDescription.Text;
|
||||
EducationComboBox.SelectedItem = EducationComboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => item.Content.ToString() == profileInfoDisplay.TextBlockEducation.Text);
|
||||
EducationLevelTextBox.Text = profileInfoDisplay.TextBlockEducationLevel.Text;
|
||||
DatePickerEducationStartDate.SelectedDate = DateTime.ParseExact(profileInfoDisplay.TextBlockEducationStartDate.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
DatePickerEducationEndDate.SelectedDate = DateTime.ParseExact(profileInfoDisplay.TextBlockEducationEndDate.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
EducationLocationComboBox.SelectedItem = EducationLocationComboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => item.Content.ToString() == profileInfoDisplay.TextBlockEducationLocation.Text);
|
||||
HobbiesTextBox.Text = profileInfoDisplay.TextBlockHobbies.Text;
|
||||
MusicTextBox.Text = profileInfoDisplay.TextBlockMusic.Text;
|
||||
PlacesComboBox.SelectedItem = PlacesComboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => item.Content.ToString() == profileInfoDisplay.TextBlockPlaces.Text);
|
||||
}
|
||||
|
||||
private void SaveChanges_Button(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string email = EmailTextBox.Text;
|
||||
string phoneNumber = PhoneNumberTextBox.Text;
|
||||
string dateOfBirth = DatePickerBirthDate.SelectedDate?.ToString("dd.MM.yyyy");
|
||||
string username = UsernameTextBox.Text;
|
||||
string name = NameTextBox.Text;
|
||||
string work = WorkTextBox.Text;
|
||||
string position = PositionTextBox.Text;
|
||||
string workStartDate = DatePickerWorkStartDate.SelectedDate?.ToString("dd.MM.yyyy");
|
||||
string workEndDate = DatePickerWorkEndDate.SelectedDate?.ToString("dd.MM.yyyy");
|
||||
string workLocation = (WorkLocationComboBox.SelectedItem as ComboBoxItem)?.Content.ToString();
|
||||
string description = DescriptionTextBox.Text;
|
||||
string education = (EducationComboBox.SelectedItem as ComboBoxItem)?.Content.ToString();
|
||||
string educationLevel = EducationLevelTextBox.Text;
|
||||
string educationStartDate = DatePickerEducationStartDate.SelectedDate?.ToString("dd.MM.yyyy");
|
||||
string educationEndDate = DatePickerEducationEndDate.SelectedDate?.ToString("dd.MM.yyyy");
|
||||
string educationLocation = (EducationLocationComboBox.SelectedItem as ComboBoxItem)?.Content.ToString();
|
||||
string hobbies = HobbiesTextBox.Text;
|
||||
string music = MusicTextBox.Text;
|
||||
string places = (PlacesComboBox.SelectedItem as ComboBoxItem)?.Content.ToString();
|
||||
|
||||
// Redirect to ProfileInfoDisplay page
|
||||
|
||||
// Clear the EditProfileInfoStackPanel
|
||||
EditProfileInfoStackPanel.Children.Clear();
|
||||
|
||||
// Add a new ProfileInfoDisplay instance to display the updated profile information
|
||||
var newProfileInfoDisplay = new ProfileInfoDisplay();
|
||||
newProfileInfoDisplay.UpdateProfileInfo(
|
||||
email, phoneNumber, dateOfBirth, name,
|
||||
username, education, educationLevel,
|
||||
educationStartDate, educationEndDate,
|
||||
educationLocation, hobbies, music, places,
|
||||
work, position, workStartDate,
|
||||
workEndDate, workLocation, description);
|
||||
|
||||
var newMainWindow = new MainWindow();
|
||||
newMainWindow.UpdateAboutYou(
|
||||
email, phoneNumber, dateOfBirth, name,
|
||||
education, educationLevel,
|
||||
educationStartDate, educationEndDate,
|
||||
educationLocation, hobbies, music, places,
|
||||
work, position, workStartDate,
|
||||
workEndDate, workLocation, description);
|
||||
|
||||
EditProfileInfoStackPanel.Children.Add(newProfileInfoDisplay);
|
||||
}
|
||||
|
||||
private void Cancel_Button(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newContent = new ProfileInfoDisplay();
|
||||
|
||||
EditProfileInfoStackPanel.Children.Clear();
|
||||
EditProfileInfoStackPanel.Children.Add(newContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<UserControl x:Class="District_3_App.ProfileInfo_GUI.ProfileInfoDisplay"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="709" Height="453">
|
||||
|
||||
<Grid x:Name="ProfileInfoGrid" Background="White" HorizontalAlignment="Center" Width="709" Height="454">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="220.573"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel x:Name="ProfileInfoStackPanel" Grid.Column="1" Orientation="Horizontal" Margin="0,0,-152,0">
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" Width="293">
|
||||
<StackPanel Margin="0,10,141,0" Width="251">
|
||||
<TextBlock Text="Profile Info"
|
||||
FontWeight="Bold"
|
||||
FontSize="18"
|
||||
Foreground="Black"
|
||||
Margin="4,0,0,0"/>
|
||||
<StackPanel Orientation="Horizontal" Margin="20,15,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/mail.png" Width="14" Height="14"/>
|
||||
<TextBlock
|
||||
Text="Email"
|
||||
FontSize="8"
|
||||
Margin="5"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock
|
||||
x:Name="TextBlockEmail"
|
||||
Text="patristoica@gmail.com"
|
||||
FontSize="8"
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/phone.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Phone number" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockPhoneNumber" Text="743177151" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="18">
|
||||
<Image Source="/images/calendar.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Date of birth" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockDateOfBirth" Text="06.06.2003" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="18">
|
||||
<Image Source="/images/profile-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Name" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockName" Text="Patricia" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="18">
|
||||
<Image Source="/images/Username.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Username" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockUsername" Text="patri.stoica" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/studies-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Education" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockEducation" Text="UBB Facultatea de matematica si informatica" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Level" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockEducationLevel" Text="Student" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Start Date" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockEducationStartDate" Text="06.06.2003" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="End Date" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockEducationEndDate" Text="06.06.2003" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Location" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockEducationLocation" Text="Cluj-Napoca" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/hobbies-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Hobbies" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockHobbies" Text="ski" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/music-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Music" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockMusic" Text="clssical" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/places-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Places" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockPlaces" Text="Cluj-Napoca" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" Width="740" Height="17">
|
||||
<Image Source="/images/work-icon.png" Width="14" Height="14"/>
|
||||
<TextBlock Text="Work" FontSize="8" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockWork" Text="Tesla" FontSize="8" Margin="5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Position" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockWorkPosition" Text="software developer" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Start date" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockWorkStartDate" Text="06.06.2003" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="End date" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockWorkEndDate" Text="06.06.2003" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Description" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockDescription" Text="working on embedded systems" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="38,0,0,0" Width="740" Height="16">
|
||||
<TextBlock Text="Location" FontSize="7" FontWeight="Bold" Margin="5" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TextBlockWorkLocation" Text="Cluj-Napoca" FontSize="7" Margin="0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<Button Margin="20,2,0,0" Background="Transparent" BorderThickness="0" Cursor="Hand" HorizontalAlignment="Left" Click="EditInfoButton_Click">
|
||||
<TextBlock Text="Edit info" FontSize="9" FontWeight="Bold"/>
|
||||
</Button>
|
||||
|
||||
<TextBlock Margin="21,1,0,0" Text="Description" FontSize="9" FontWeight="Bold"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="22,4,0,0" Width="740" Height="47">
|
||||
<TextBlock Text="vdbvievbiws" TextWrapping="Wrap" VerticalAlignment="Top" Width="116" FontSize="10"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
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.ProfileInfo_GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ProfileInfoDisplay.xaml
|
||||
/// </summary>
|
||||
public partial class ProfileInfoDisplay : UserControl
|
||||
{
|
||||
public ProfileInfoDisplay()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UpdateProfileInfo(
|
||||
string email, string phoneNumber, string dateOfBirth, string name,
|
||||
string username, string education, string educationLevel,
|
||||
string educationStartDate, string educationEndDate,
|
||||
string educationLocation, string hobbies, string music, string places,
|
||||
string work, string position, string workStartDate,
|
||||
string workEndDate, string workLocation, string description)
|
||||
{
|
||||
// Update TextBlocks with edited profile info
|
||||
TextBlockEmail.Text = email;
|
||||
TextBlockPhoneNumber.Text = phoneNumber;
|
||||
TextBlockDateOfBirth.Text = dateOfBirth;
|
||||
TextBlockName.Text = name;
|
||||
TextBlockUsername.Text = username;
|
||||
TextBlockEducation.Text = education;
|
||||
TextBlockEducationLevel.Text = educationLevel;
|
||||
TextBlockEducationStartDate.Text = educationStartDate;
|
||||
TextBlockEducationEndDate.Text = educationEndDate;
|
||||
TextBlockEducationLocation.Text = educationLocation;
|
||||
TextBlockHobbies.Text = hobbies;
|
||||
TextBlockMusic.Text = music;
|
||||
TextBlockPlaces.Text = places;
|
||||
TextBlockWork.Text = work;
|
||||
TextBlockWorkPosition.Text = position;
|
||||
TextBlockWorkStartDate.Text = workStartDate;
|
||||
TextBlockWorkEndDate.Text = workEndDate;
|
||||
TextBlockWorkLocation.Text = workLocation;
|
||||
TextBlockDescription.Text = description;
|
||||
}
|
||||
|
||||
private void EditInfoButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newContent = new EditProfileInfo(this);
|
||||
ProfileInfoStackPanel.Children.Clear();
|
||||
ProfileInfoStackPanel.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void MainProfileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newContent = new MainWindow();
|
||||
ProfileInfoStackPanel.Children.Clear();
|
||||
ProfileInfoStackPanel.Children.Add(newContent);
|
||||
}
|
||||
|
||||
private void Save_Button(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfilePage.Entities
|
||||
{
|
||||
public class User
|
||||
{
|
||||
private Guid id;
|
||||
private DateTime birthday;
|
||||
private string phoneNumber;
|
||||
private string email;
|
||||
private string username;
|
||||
|
||||
public User(Guid id, DateTime birthday, string phoneNumber, string email, string username)
|
||||
{
|
||||
this.id = id;
|
||||
this.birthday = birthday;
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.email = email;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Guid Id
|
||||
{
|
||||
get { return id; }
|
||||
set { id = value; }
|
||||
}
|
||||
|
||||
public DateTime Birthday
|
||||
{
|
||||
get { return birthday; }
|
||||
set { birthday = value; }
|
||||
}
|
||||
|
||||
public string PhoneNumber
|
||||
{
|
||||
get { return phoneNumber; }
|
||||
set { phoneNumber = value; }
|
||||
}
|
||||
|
||||
public string Email
|
||||
{
|
||||
get { return email; }
|
||||
set { email = value; }
|
||||
}
|
||||
|
||||
public string Username
|
||||
{
|
||||
get { return username; }
|
||||
set { username = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<groups>
|
||||
<group groupId="c221950c-7e1d-4a17-83a7-9af616bba78d" groupName="group 1">
|
||||
<members>
|
||||
<user userId="d161f928-2601-4e63-be9f-c05a1399b6b3" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
|
||||
<user userId="cf9428ef-97c3-4003-9815-03942dc79da8" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
|
||||
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
<user userId="db61df0b-f9ae-489e-8406-bc116ee26ebc" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="efa488bd-050b-442c-8ebb-5ae3a4d9b7e4" groupName="group 3">
|
||||
<members>
|
||||
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
|
||||
<user userId="d161f928-2601-4e63-be9f-c05a1399b6b3" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="487a96c4-eb2b-4eea-9ac2-ecf3458206ec" groupName="group 2">
|
||||
<members>
|
||||
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
|
||||
<user userId="ad36cdfe-3a9f-4f6b-a2ce-d9a73fd4c405" username="username4" password="password4" email="username4@stud.ubbcluj.ro" confirmationPassword="password4" />
|
||||
<user userId="5d0cd3c3-9f92-481c-9c6e-75830d3743a4" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="df05a760-20bd-4b3f-920f-a5407ad0c25a" groupName="another group">
|
||||
<members>
|
||||
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
|
||||
<user userId="cf9428ef-97c3-4003-9815-03942dc79da8" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
|
||||
<user userId="ce7ad3bd-0b87-4122-8766-54be4cef5fe9" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
<user userId="ba8f4eca-daa5-4c34-af00-0ff70a022526" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="4163dad5-ab81-4d26-9d02-559d04d88733" groupName="testXMLGroup">
|
||||
<members>
|
||||
<user userId="998e1318-0a8c-4896-9aa0-6cd64419fc78" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="14620abb-17a0-4dd3-9c7e-8aa1de3b8225" groupName="newGrouptestXML">
|
||||
<members>
|
||||
<user userId="51a31753-6359-47c9-82fa-b8468136e14f" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="61ffb63b-5f2d-4ef6-8a1a-d01ef83b784b" groupName="testAllXML">
|
||||
<members>
|
||||
<user userId="88d05d97-0cad-4ce3-a06f-be6e69d698b5" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
</members>
|
||||
</group>
|
||||
<group groupId="1ffeb77a-a4dd-437b-a561-d5a90ace73d7" groupName="THELAST___TEST">
|
||||
<members>
|
||||
<user userId="52e1cf6f-c1a9-4100-af4b-9eedc2172cb2" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
|
||||
<user userId="2d793e4d-0dd3-43f4-b6d3-c3a415212b45" username="username4" password="password4" email="username4@stud.ubbcluj.ro" confirmationPassword="password4" />
|
||||
</members>
|
||||
</group>
|
||||
</groups>
|
||||
+6802
File diff suppressed because it is too large
Load Diff
+35
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.ExtraInfo;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Entities
|
||||
{
|
||||
public class BlockedProfile : IComparable<BlockedProfile>
|
||||
{
|
||||
public User User { get; set; }
|
||||
public DateTime BlockDate { get; set; }
|
||||
|
||||
public BlockedProfile()
|
||||
{
|
||||
}
|
||||
|
||||
public BlockedProfile(User user, DateTime date)
|
||||
{
|
||||
this.User = user;
|
||||
this.BlockDate = date;
|
||||
}
|
||||
|
||||
public string DateToString()
|
||||
{
|
||||
return BlockDate.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
public int CompareTo(BlockedProfile other)
|
||||
{
|
||||
return this.BlockDate.CompareTo(other.BlockDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Entities
|
||||
{
|
||||
public class CloseFriendProfile : IComparable<CloseFriendProfile>
|
||||
{
|
||||
public User User { get; set; }
|
||||
|
||||
public DateTime CloseFriendedDate { get; set; }
|
||||
|
||||
public CloseFriendProfile()
|
||||
{
|
||||
}
|
||||
|
||||
public CloseFriendProfile(User user, DateTime closeFriendedDate)
|
||||
{
|
||||
this.User = user;
|
||||
this.CloseFriendedDate = closeFriendedDate;
|
||||
}
|
||||
|
||||
public int CompareTo(CloseFriendProfile other)
|
||||
{
|
||||
return this.User.CompareTo(other.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.ExtraInfo;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Entities
|
||||
{
|
||||
public class Group : IComparable<Group>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public List<User> GroupMembers { get; set; }
|
||||
|
||||
public Group()
|
||||
{
|
||||
}
|
||||
|
||||
public Group(Guid id, string groupName, List<User> groupMembers)
|
||||
{
|
||||
this.Id = id;
|
||||
this.GroupName = groupName;
|
||||
this.GroupMembers = groupMembers;
|
||||
}
|
||||
|
||||
public int CompareTo(Group other)
|
||||
{
|
||||
return this.GroupName.CompareTo(other.GroupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Entities
|
||||
{
|
||||
public class User : IComparable<User> // MODIFY UML DIAGRAM USER CLASS
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string ConfirmationPassword { get; set; }
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
public int FollowingCount { get; set; }
|
||||
public int FollowersCount { get; set; }
|
||||
public TimeSpan Usersession { get; set; }
|
||||
|
||||
public User()
|
||||
{
|
||||
}
|
||||
public User(Guid id, string username, string password, string email, string confirmationPassword)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Username = username;
|
||||
this.Password = password;
|
||||
this.Email = email;
|
||||
this.ConfirmationPassword = confirmationPassword;
|
||||
}
|
||||
|
||||
public User(Guid id, string username, string password, string email, string confirmationPassword, int followingCount, int followersCount)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Username = username;
|
||||
this.Password = password;
|
||||
this.Email = email;
|
||||
this.ConfirmationPassword = confirmationPassword;
|
||||
this.FollowersCount = followersCount;
|
||||
this.FollowingCount = followingCount;
|
||||
}
|
||||
|
||||
public User(Guid id, string username, string password, string email, string confirmationPassword, TimeSpan usersession)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Username = username;
|
||||
this.Password = password;
|
||||
this.Email = email;
|
||||
this.ConfirmationPassword = confirmationPassword;
|
||||
this.Usersession = usersession;
|
||||
}
|
||||
|
||||
public string RegistrationDateToString()
|
||||
{
|
||||
return this.RegistrationDate.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
public int CompareTo(User other)
|
||||
{
|
||||
return this.Username.CompareTo(other.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Entities
|
||||
{
|
||||
public class UserProfileSocialNetworkInfo
|
||||
{
|
||||
public User User { get; set; }
|
||||
public List<BlockedProfile> BlockedProfiles { get; set; }
|
||||
public List<CloseFriendProfile> CloseFriendsProfiles { get; set; }
|
||||
public List<Group> Groups { get; set; }
|
||||
|
||||
public List<User> RestrictedStoriesAudience { get; set; }
|
||||
|
||||
public List<User> RestrictedPostsAudience { get; set; }
|
||||
|
||||
public bool IsProfilePrivate { get; set; }
|
||||
|
||||
public UserProfileSocialNetworkInfo()
|
||||
{
|
||||
// Create mock data with default values
|
||||
User = new User();
|
||||
BlockedProfiles = new List<BlockedProfile>();
|
||||
CloseFriendsProfiles = new List<CloseFriendProfile>();
|
||||
Groups = new List<Group>();
|
||||
RestrictedStoriesAudience = new List<User>();
|
||||
RestrictedPostsAudience = new List<User>();
|
||||
IsProfilePrivate = false; // Assuming the default profile privacy is set to public
|
||||
}
|
||||
|
||||
public UserProfileSocialNetworkInfo(User user, List<BlockedProfile> blockedProfiles, List<CloseFriendProfile> closeFriendsProfiles, List<Group> groups, List<User> restrictedStoriesAudience, List<User> restrictedPostsAudience)
|
||||
{
|
||||
this.User = user;
|
||||
this.BlockedProfiles = blockedProfiles;
|
||||
this.CloseFriendsProfiles = closeFriendsProfiles;
|
||||
this.Groups = groups;
|
||||
this.RestrictedStoriesAudience = restrictedStoriesAudience;
|
||||
this.RestrictedPostsAudience = restrictedPostsAudience;
|
||||
this.IsProfilePrivate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository
|
||||
{
|
||||
public class GroupsRepository
|
||||
{
|
||||
public List<Group> GroupsRepository1 { get; set; }
|
||||
private string filePath;
|
||||
|
||||
public GroupsRepository()
|
||||
{
|
||||
this.filePath = "./ProfileSocialNetworkInfoStuff/Groups.xml";
|
||||
this.GroupsRepository1 = LoadGroupsFromXML();
|
||||
}
|
||||
public GroupsRepository(List<Group> groupsRepository)
|
||||
{
|
||||
this.GroupsRepository1 = groupsRepository;
|
||||
this.filePath = "./ProfileSocialNetworkInfoStuff/Groups.xml";
|
||||
|
||||
SaveGroupsInXML();
|
||||
}
|
||||
|
||||
private List<Group> LoadGroupsFromXML()
|
||||
{
|
||||
List<Group> loadedGroups = new List<Group>();
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "ProfileSocialNetworkInfoStuff");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Groups.xml");
|
||||
|
||||
xmlDoc.Load(filePath);
|
||||
|
||||
foreach (XmlNode groupNode in xmlDoc.SelectNodes("//group"))
|
||||
{
|
||||
Group group = new Group();
|
||||
group.Id = Guid.Parse(groupNode.Attributes["groupId"].Value);
|
||||
group.GroupName = groupNode.Attributes["groupName"].Value;
|
||||
group.GroupMembers = new List<User>();
|
||||
|
||||
foreach (XmlNode userNode in groupNode.SelectNodes("members/user"))
|
||||
{
|
||||
User user = new User();
|
||||
user.Id = Guid.Parse(userNode.Attributes["userId"].Value);
|
||||
user.Username = userNode.Attributes["username"].Value;
|
||||
user.Password = userNode.Attributes["password"].Value;
|
||||
user.Email = userNode.Attributes["email"].Value;
|
||||
user.ConfirmationPassword = userNode.Attributes["confirmationPassword"].Value;
|
||||
|
||||
group.GroupMembers.Add(user);
|
||||
}
|
||||
|
||||
loadedGroups.Add(group);
|
||||
}
|
||||
|
||||
return loadedGroups;
|
||||
}
|
||||
|
||||
private void SaveGroupsInXML()
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
|
||||
XmlNode groupsNode = xmlDocument.CreateElement("groups");
|
||||
xmlDocument.AppendChild(groupsNode);
|
||||
|
||||
foreach (Group group in GroupsRepository1)
|
||||
{
|
||||
XmlNode groupNode = xmlDocument.CreateElement("group");
|
||||
groupsNode.AppendChild(groupNode);
|
||||
|
||||
XmlAttribute groupIdAttribute = xmlDocument.CreateAttribute("groupId");
|
||||
groupIdAttribute.Value = group.Id.ToString();
|
||||
groupNode.Attributes.Append(groupIdAttribute);
|
||||
|
||||
XmlAttribute groupNameAttribute = xmlDocument.CreateAttribute("groupName");
|
||||
groupNameAttribute.Value = group.GroupName;
|
||||
groupNode.Attributes.Append(groupNameAttribute);
|
||||
|
||||
XmlNode members = xmlDocument.CreateElement("members");
|
||||
groupNode.AppendChild(members);
|
||||
|
||||
foreach (var member in group.GroupMembers)
|
||||
{
|
||||
XmlNode userNode = xmlDocument.CreateElement("user");
|
||||
members.AppendChild(userNode);
|
||||
|
||||
XmlAttribute userIdAttribute = xmlDocument.CreateAttribute("userId");
|
||||
userIdAttribute.Value = member.Id.ToString();
|
||||
userNode.Attributes.Append(userIdAttribute);
|
||||
|
||||
XmlAttribute usernameAttribute = xmlDocument.CreateAttribute("username");
|
||||
usernameAttribute.Value = member.Username;
|
||||
userNode.Attributes.Append(usernameAttribute);
|
||||
|
||||
XmlAttribute passwordAttribute = xmlDocument.CreateAttribute("password");
|
||||
passwordAttribute.Value = member.Password;
|
||||
userNode.Attributes.Append(passwordAttribute);
|
||||
|
||||
XmlAttribute emailAttribute = xmlDocument.CreateAttribute("email");
|
||||
emailAttribute.Value = member.Email;
|
||||
userNode.Attributes.Append(emailAttribute);
|
||||
|
||||
XmlAttribute confirmationPasswordAttribute = xmlDocument.CreateAttribute("confirmationPassword");
|
||||
confirmationPasswordAttribute.Value = member.ConfirmationPassword;
|
||||
userNode.Attributes.Append(confirmationPasswordAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
xmlDocument.Save(this.filePath);
|
||||
}
|
||||
|
||||
public List<Group> GetAllGroups()
|
||||
{
|
||||
return this.GroupsRepository1;
|
||||
}
|
||||
|
||||
public bool AddGroup(Group groupToAdd)
|
||||
{
|
||||
foreach (var group in GroupsRepository1)
|
||||
{
|
||||
if (group.Id == groupToAdd.Id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.GroupsRepository1.Add(groupToAdd);
|
||||
SaveGroupsInXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveGroup(Group groupToRemove)
|
||||
{
|
||||
foreach (var group in GroupsRepository1)
|
||||
{
|
||||
if (group.Id == groupToRemove.Id)
|
||||
{
|
||||
GroupsRepository1.Remove(group);
|
||||
SaveGroupsInXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Group GetGroupByGroupName(string groupName)
|
||||
{
|
||||
foreach (var group in GroupsRepository1)
|
||||
{
|
||||
if (groupName == group.GroupName)
|
||||
{
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool AddMemberToGroup(string groupName, User memberToAdd)
|
||||
{
|
||||
foreach (var group in GroupsRepository1)
|
||||
{
|
||||
if (group.GroupName == groupName)
|
||||
{
|
||||
foreach (var currentMember in group.GroupMembers)
|
||||
{
|
||||
if (currentMember.Username == memberToAdd.Username)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
group.GroupMembers.Add(memberToAdd);
|
||||
SaveGroupsInXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RemoveMemberFromGroup(string groupName, User memberToRemove)
|
||||
{
|
||||
foreach (var group in GroupsRepository1)
|
||||
{
|
||||
if (group.GroupName == groupName)
|
||||
{
|
||||
foreach (var currentMember in group.GroupMembers)
|
||||
{
|
||||
if (currentMember.Username == memberToRemove.Username)
|
||||
{
|
||||
group.GroupMembers.Remove(memberToRemove);
|
||||
SaveGroupsInXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository
|
||||
{
|
||||
public class ProfileNetworkInfoRepository<T>
|
||||
{
|
||||
private List<UserProfileSocialNetworkInfo> repositoryList;
|
||||
private string filePath;
|
||||
|
||||
public ProfileNetworkInfoRepository(List<UserProfileSocialNetworkInfo> repositoryList)
|
||||
{
|
||||
this.repositoryList = repositoryList;
|
||||
SaveProfilesInXML();
|
||||
}
|
||||
|
||||
public ProfileNetworkInfoRepository()
|
||||
{
|
||||
this.filePath = "./ProfileSocialNetworkInfoStuff/Profiles.xml";
|
||||
LoadProfilesInXML();
|
||||
|
||||
SaveProfilesInXML();
|
||||
}
|
||||
|
||||
public void LoadProfilesInXML()
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<UserProfileSocialNetworkInfo>));
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "ProfileSocialNetworkInfoStuff");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Profiles.xml");
|
||||
// MessageBox.Show(filePath);
|
||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
repositoryList = (List<UserProfileSocialNetworkInfo>)serializer.Deserialize(fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveProfilesInXML()
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<UserProfileSocialNetworkInfo>));
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string relativePath = baseDirectory.Substring(0, baseDirectory.IndexOf("bin\\Debug"));
|
||||
|
||||
string currfilePath = System.IO.Path.Combine(relativePath, "ProfileSocialNetworkInfoStuff");
|
||||
filePath = System.IO.Path.Combine(currfilePath, "Profiles.xml");
|
||||
|
||||
using (TextWriter writer = new StreamWriter(filePath))
|
||||
{
|
||||
serializer.Serialize(writer, repositoryList);
|
||||
}
|
||||
// XmlDocument xmlDocument = new XmlDocument();
|
||||
|
||||
// XmlNode profilesNode = xmlDocument.CreateElement("profiles");
|
||||
// xmlDocument.AppendChild(profilesNode);
|
||||
|
||||
// foreach (UserProfileSocialNetworkInfo profile in repositoryList)
|
||||
// {
|
||||
// XmlNode profileNode = xmlDocument.CreateElement("profile");
|
||||
// profilesNode.AppendChild(profileNode);
|
||||
|
||||
// XmlNode userNode = xmlDocument.CreateElement("user");
|
||||
// profileNode.AppendChild(userNode);
|
||||
|
||||
// XmlAttribute userIdAttribute = xmlDocument.CreateAttribute("id");
|
||||
// userIdAttribute.Value = profile.user.id.ToString();
|
||||
// userNode.Attributes.Append(userIdAttribute);
|
||||
|
||||
// XmlAttribute usernameAttribute = xmlDocument.CreateAttribute("username");
|
||||
// usernameAttribute.Value = profile.user.username;
|
||||
// userNode.Attributes.Append(usernameAttribute);
|
||||
|
||||
// XmlAttribute passwordAttribute = xmlDocument.CreateAttribute("password");
|
||||
// passwordAttribute.Value = profile.user.password;
|
||||
// userNode.Attributes.Append(passwordAttribute);
|
||||
|
||||
// XmlAttribute emailAttribute = xmlDocument.CreateAttribute("email");
|
||||
// emailAttribute.Value = profile.user.email;
|
||||
// userNode.Attributes.Append(emailAttribute);
|
||||
|
||||
// XmlAttribute confirmationPasswordAttribute = xmlDocument.CreateAttribute("confirmationPassword");
|
||||
// confirmationPasswordAttribute.Value = profile.user.confirmationPassword;
|
||||
// userNode.Attributes.Append(confirmationPasswordAttribute);
|
||||
|
||||
// XmlNode blockedAccountsNode = xmlDocument.CreateElement("blockedAccounts");
|
||||
// profileNode.AppendChild(blockedAccountsNode);
|
||||
|
||||
// foreach(var blockedAccount in profile.blockedProfiles)
|
||||
// {
|
||||
// XmlNode blockedAccNode = xmlDocument.CreateElement("blockedAccount");
|
||||
// blockedAccountsNode.AppendChild(blockedAccNode);
|
||||
|
||||
// XmlNode userBlockedAccountNode = xmlDocument.CreateElement("user");
|
||||
// blockedAccNode.AppendChild(userBlockedAccountNode);
|
||||
|
||||
// XmlAttribute userIdBlockedAttribute = xmlDocument.CreateAttribute("id");
|
||||
// userIdAttribute.Value = blockedAccount.user.id.ToString();
|
||||
// userBlockedAccountNode.Attributes.Append(userIdBlockedAttribute);
|
||||
|
||||
// XmlAttribute usernameBlockedAttribute = xmlDocument.CreateAttribute("username");
|
||||
// usernameAttribute.Value = blockedAccount.user.username;
|
||||
// userBlockedAccountNode.Attributes.Append(usernameBlockedAttribute);
|
||||
|
||||
// XmlAttribute passwordBlockedAttribute = xmlDocument.CreateAttribute("password");
|
||||
// passwordAttribute.Value = blockedAccount.user.password;
|
||||
// userBlockedAccountNode.Attributes.Append(passwordBlockedAttribute);
|
||||
|
||||
// XmlAttribute emailBlockedAttribute = xmlDocument.CreateAttribute("email");
|
||||
// emailAttribute.Value = blockedAccount.user.email;
|
||||
// userBlockedAccountNode.Attributes.Append(emailBlockedAttribute);
|
||||
|
||||
// XmlAttribute confirmationPasswordBlockedAttribute = xmlDocument.CreateAttribute("confirmationPassword");
|
||||
// confirmationPasswordAttribute.Value = blockedAccount.user.confirmationPassword;
|
||||
// userBlockedAccountNode.Attributes.Append(confirmationPasswordBlockedAttribute);
|
||||
|
||||
// XmlAttribute blockDateAttribute = xmlDocument.CreateAttribute("blockDate");
|
||||
// blockDateAttribute.Value = blockedAccount.blockDate.ToString();
|
||||
// userBlockedAccountNode.Attributes.Append(confirmationPasswordBlockedAttribute);
|
||||
|
||||
// }
|
||||
|
||||
// foreach(var closeFriend in profile.closeFriendsProfiles)
|
||||
// {
|
||||
// XmlNode blockedAccNode = xmlDocument.CreateElement("blockedAccount");
|
||||
// blockedAccountsNode.AppendChild(blockedAccNode);
|
||||
|
||||
// XmlNode userBlockedAccountNode = xmlDocument.CreateElement("user");
|
||||
// blockedAccNode.AppendChild(userBlockedAccountNode);
|
||||
|
||||
// XmlAttribute userIdBlockedAttribute = xmlDocument.CreateAttribute("id");
|
||||
// userIdAttribute.Value = profile.user.id.ToString();
|
||||
// userBlockedAccountNode.Attributes.Append(userIdBlockedAttribute);
|
||||
|
||||
// XmlAttribute usernameBlockedAttribute = xmlDocument.CreateAttribute("username");
|
||||
// usernameAttribute.Value = profile.user.username;
|
||||
// userBlockedAccountNode.Attributes.Append(usernameBlockedAttribute);
|
||||
|
||||
// XmlAttribute passwordBlockedAttribute = xmlDocument.CreateAttribute("password");
|
||||
// passwordAttribute.Value = profile.user.password;
|
||||
// userBlockedAccountNode.Attributes.Append(passwordBlockedAttribute);
|
||||
|
||||
// XmlAttribute emailBlockedAttribute = xmlDocument.CreateAttribute("email");
|
||||
// emailAttribute.Value = profile.user.email;
|
||||
// userBlockedAccountNode.Attributes.Append(emailBlockedAttribute);
|
||||
|
||||
// XmlAttribute confirmationPasswordBlockedAttribute = xmlDocument.CreateAttribute("confirmationPassword");
|
||||
// confirmationPasswordAttribute.Value = profile.user.confirmationPassword;
|
||||
// userBlockedAccountNode.Attributes.Append(confirmationPasswordBlockedAttribute);
|
||||
// }
|
||||
|
||||
// foreach (var member in group.groupMembers)
|
||||
// {
|
||||
// XmlNode userNode = xmlDocument.CreateElement("user");
|
||||
// members.AppendChild(userNode);
|
||||
|
||||
// XmlAttribute userIdAttribute = xmlDocument.CreateAttribute("userId");
|
||||
// userIdAttribute.Value = member.id.ToString();
|
||||
// userNode.Attributes.Append(userIdAttribute);
|
||||
|
||||
// XmlAttribute usernameAttribute = xmlDocument.CreateAttribute("username");
|
||||
// usernameAttribute.Value = member.username;
|
||||
// userNode.Attributes.Append(usernameAttribute);
|
||||
|
||||
// XmlAttribute passwordAttribute = xmlDocument.CreateAttribute("password");
|
||||
// passwordAttribute.Value = member.password;
|
||||
// userNode.Attributes.Append(passwordAttribute);
|
||||
|
||||
// XmlAttribute emailAttribute = xmlDocument.CreateAttribute("email");
|
||||
// emailAttribute.Value = member.email;
|
||||
// userNode.Attributes.Append(emailAttribute);
|
||||
|
||||
// XmlAttribute confirmationPasswordAttribute = xmlDocument.CreateAttribute("confirmationPassword");
|
||||
// confirmationPasswordAttribute.Value = member.confirmationPassword;
|
||||
// userNode.Attributes.Append(confirmationPasswordAttribute);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// xmlDocument.Save(this.filePath);
|
||||
}
|
||||
|
||||
public List<UserProfileSocialNetworkInfo> GetProfileRepositoryList()
|
||||
{
|
||||
return this.repositoryList;
|
||||
}
|
||||
public void SetProfileRepositoryList(List<UserProfileSocialNetworkInfo> newList)
|
||||
{
|
||||
this.repositoryList = newList;
|
||||
}
|
||||
|
||||
public bool AddProfileSocialNetworkInfo(UserProfileSocialNetworkInfo profileToAdd)
|
||||
{
|
||||
foreach (var profile in this.GetProfileRepositoryList())
|
||||
{
|
||||
if ((profile?.User?.Id ?? new Guid()) == profileToAdd.User.Id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.repositoryList.Add(profileToAdd);
|
||||
SaveProfilesInXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveProfileSocialNetworkInfo(UserProfileSocialNetworkInfo profileToRemove)
|
||||
{
|
||||
foreach (var profile in this.GetProfileRepositoryList())
|
||||
{
|
||||
if (profile.User.Id == profileToRemove.User.Id)
|
||||
{
|
||||
this.repositoryList.Remove(profile);
|
||||
SaveProfilesInXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository
|
||||
{
|
||||
public class UsersRepository
|
||||
{
|
||||
public List<User> UsersRepositoryList { get; set; }
|
||||
|
||||
private string filePath;
|
||||
|
||||
public UsersRepository()
|
||||
{
|
||||
}
|
||||
public UsersRepository(List<User> usersRepositoryList)
|
||||
{
|
||||
this.UsersRepositoryList = usersRepositoryList;
|
||||
}
|
||||
public UsersRepository(string filePath)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
LoadUsersFromXml();
|
||||
}
|
||||
|
||||
private void LoadUsersFromXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
UsersRepositoryList = new List<User>();
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
var users = xDocument.Descendants("User");
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
User newUser = new User
|
||||
{
|
||||
Id = (Guid)user.Attribute("id"),
|
||||
Username = (string)user.Attribute("Username"),
|
||||
Email = (string)user.Attribute("Email"),
|
||||
Password = (string)user.Attribute("Password"),
|
||||
ConfirmationPassword = (string)user.Attribute("ConfirmationPassword"),
|
||||
FollowingCount = (int)user.Element("Following"),
|
||||
FollowersCount = (int)user.Element("Followers")
|
||||
};
|
||||
|
||||
UsersRepositoryList.Add(newUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("An error occurred while loading users from XML: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveUsersToXml()
|
||||
{
|
||||
XDocument xDocument = new XDocument(
|
||||
new XElement("UserAccounts",
|
||||
UsersRepositoryList.Select(user =>
|
||||
new XElement("User",
|
||||
new XAttribute("id", user.Id),
|
||||
new XAttribute("Username", user.Username),
|
||||
new XAttribute("Email", user.Email),
|
||||
new XAttribute("Password", user.Password),
|
||||
new XAttribute("ConfirmationPassword", user.ConfirmationPassword),
|
||||
new XElement("Following", user.FollowingCount),
|
||||
new XElement("Followers", user.FollowersCount)))));
|
||||
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
|
||||
public User GetUserByName(string username)
|
||||
{
|
||||
foreach (var user in UsersRepositoryList)
|
||||
{
|
||||
if (user.Username == username)
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
return UsersRepositoryList;
|
||||
}
|
||||
|
||||
public void AddUser(User user)
|
||||
{
|
||||
UsersRepositoryList.Add(user);
|
||||
SaveUsersToXml();
|
||||
}
|
||||
public int GetFollowersCount(string username)
|
||||
{
|
||||
User user = GetUserByName(username);
|
||||
if (user != null)
|
||||
{
|
||||
return user.FollowersCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle user not found scenario
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public int GetFollowingCount(string username)
|
||||
{
|
||||
User user = GetUserByName(username);
|
||||
if (user != null)
|
||||
{
|
||||
return user.FollowingCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdatePassword(string email, string newPassword)
|
||||
{
|
||||
try
|
||||
{
|
||||
XElement root = XElement.Load(filePath);
|
||||
IEnumerable<XElement> users = from user in root.Elements("User")
|
||||
where (string)user.Attribute("Email") == email
|
||||
select user;
|
||||
|
||||
if (users.Any())
|
||||
{
|
||||
foreach (XElement user in users)
|
||||
{
|
||||
user.SetAttributeValue("Password", newPassword);
|
||||
}
|
||||
|
||||
root.Save(filePath);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error updating password: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public User GetUserByUsernameOrEmail(string usernameOrEmail)
|
||||
{
|
||||
return UsersRepositoryList.FirstOrDefault(user => user.Username == usernameOrEmail || user.Email == usernameOrEmail);
|
||||
}
|
||||
|
||||
public bool UsernameExists(string username)
|
||||
{
|
||||
return UsersRepositoryList.Any(user => user.Username == username);
|
||||
}
|
||||
|
||||
public bool EmailExists(string email)
|
||||
{
|
||||
return UsersRepositoryList.Any(user => user.Email == email);
|
||||
}
|
||||
}
|
||||
}
|
||||
+477
@@ -0,0 +1,477 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Sorting_module;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service
|
||||
{
|
||||
public class ProfileNetworkInfoService
|
||||
{
|
||||
public ProfileNetworkInfoRepository<UserProfileSocialNetworkInfo> Repository { get; set; }
|
||||
public GroupsRepository GroupsRepository { get; set; }
|
||||
public UsersRepository UsersRepository { get; set; }
|
||||
|
||||
public User CurrentConnectedUser { get; set; }
|
||||
|
||||
public ProfileNetworkInfoService()
|
||||
{
|
||||
//// HARDCODED STUFF
|
||||
}
|
||||
public ProfileNetworkInfoService(GroupsRepository groupsRepository, ProfileNetworkInfoRepository<UserProfileSocialNetworkInfo> repository, UsersRepository usersRepository)
|
||||
{
|
||||
this.GroupsRepository = groupsRepository;
|
||||
this.Repository = repository;
|
||||
this.UsersRepository = usersRepository;
|
||||
}
|
||||
|
||||
// delegate types: takes 2 BlockedProfile params and returns int using CompareTo function
|
||||
public Func<BlockedProfile, BlockedProfile, int> CompareBlockedProfilesByDateValue = (profile1, profile2) => profile1.BlockDate.CompareTo(profile2.BlockDate);
|
||||
public Func<CloseFriendProfile, CloseFriendProfile, int> CompareCloseFriendsByUsernameValue = (profile1, profile2) => profile1.User.CompareTo(profile2.User);
|
||||
public Func<Group, Group, int> CompareGroupsByNameValue = (group1, group2) => group1.GroupName.CompareTo(group2.GroupName);
|
||||
|
||||
public Func<User, User, int> CompareUsersByUsername = (user1, user2) => user1.Username.CompareTo(user2.Username);
|
||||
// public Func<LikedPost, LikedPost, int> compareLikedPostbyDate = (Post1, Post2) => Post1.date.CompareTo(Post2.date);
|
||||
public Func<BlockedProfile, BlockedProfile, int> CompareBlockedProfilesByDate
|
||||
{
|
||||
get { return this.CompareBlockedProfilesByDateValue; }
|
||||
}
|
||||
public Func<CloseFriendProfile, CloseFriendProfile, int> CompareCloseFriendsByUsername
|
||||
{
|
||||
get { return this.CompareCloseFriendsByUsernameValue; }
|
||||
}
|
||||
public Func<Group, Group, int> CompareGroupsByName
|
||||
{
|
||||
get { return this.CompareGroupsByNameValue; }
|
||||
}
|
||||
public Func<User, User, int> CompareRestrictedUsersByUsername
|
||||
{
|
||||
get { return this.CompareUsersByUsername; }
|
||||
}
|
||||
|
||||
// public Func<LikedPost, LikedPost, int> CompareLikedPostsByDate
|
||||
// {
|
||||
// get { return this.compareLikedPostbyDate; }
|
||||
// }
|
||||
public void QuickSortBlockedProfiles(Func<BlockedProfile, BlockedProfile, int> compareFunction)
|
||||
{
|
||||
if (this.Repository.GetProfileRepositoryList().Count > 0 && this.Repository.GetProfileRepositoryList() != null)
|
||||
{
|
||||
ISortingAlgorithms<BlockedProfile> sortingAlgorithms = new SortingAlgorithms<BlockedProfile>();
|
||||
|
||||
foreach (UserProfileSocialNetworkInfo profile in this.Repository.GetProfileRepositoryList())
|
||||
{
|
||||
sortingAlgorithms.QuickSortDescending(profile.BlockedProfiles, compareFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSortRestrictedPostsAudience(Func<User, User, int> compareFunction)
|
||||
{
|
||||
if (this.Repository.GetProfileRepositoryList().Count > 0 && this.Repository.GetProfileRepositoryList() != null)
|
||||
{
|
||||
ISortingAlgorithms<User> sortingAlgorithms = new SortingAlgorithms<User>();
|
||||
|
||||
foreach (UserProfileSocialNetworkInfo profile in this.Repository.GetProfileRepositoryList())
|
||||
{
|
||||
sortingAlgorithms.QuickSortAscending(profile.RestrictedPostsAudience, compareFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSortRestrictedStoriesAudience(Func<User, User, int> compareFunction)
|
||||
{
|
||||
if (this.Repository.GetProfileRepositoryList().Count > 0 && this.Repository.GetProfileRepositoryList() != null)
|
||||
{
|
||||
ISortingAlgorithms<User> sortingAlgorithms = new SortingAlgorithms<User>();
|
||||
|
||||
foreach (UserProfileSocialNetworkInfo profile in this.Repository.GetProfileRepositoryList())
|
||||
{
|
||||
sortingAlgorithms.QuickSortAscending(profile.RestrictedStoriesAudience, compareFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSortCloseFriends(Func<CloseFriendProfile, CloseFriendProfile, int> compareFunction)
|
||||
{
|
||||
if (this.Repository.GetProfileRepositoryList().Count > 0 && this.Repository.GetProfileRepositoryList() != null)
|
||||
{
|
||||
ISortingAlgorithms<CloseFriendProfile> sortingAlgorithms = new SortingAlgorithms<CloseFriendProfile>();
|
||||
|
||||
foreach (UserProfileSocialNetworkInfo profile in this.Repository.GetProfileRepositoryList())
|
||||
{
|
||||
sortingAlgorithms.QuickSortAscending(profile.CloseFriendsProfiles, compareFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSortGroups(Func<Group, Group, int> compareFunction)
|
||||
{
|
||||
if (this.Repository.GetProfileRepositoryList().Count > 0 && this.Repository.GetProfileRepositoryList() != null)
|
||||
{
|
||||
ISortingAlgorithms<Group> sortingAlgorithms = new SortingAlgorithms<Group>();
|
||||
|
||||
foreach (UserProfileSocialNetworkInfo profile in this.Repository.GetProfileRepositoryList())
|
||||
{
|
||||
sortingAlgorithms.QuickSortAscending(profile.Groups, compareFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckIfProfileExists(UserProfileSocialNetworkInfo profileToCheck)
|
||||
{
|
||||
foreach (var profile in this.GetAllUserProfileSocialNetworks())
|
||||
{
|
||||
if (profile.User.Id == profileToCheck.User.Id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UserProfileSocialNetworkInfo> GetAllUserProfileSocialNetworks()
|
||||
{
|
||||
return this.Repository.GetProfileRepositoryList();
|
||||
}
|
||||
|
||||
public UserProfileSocialNetworkInfo GetProfileSocialNetworkInfoCurrentUser(User currentUser)
|
||||
{
|
||||
foreach (var profile in this.GetAllUserProfileSocialNetworks())
|
||||
{
|
||||
if (profile.User.Username == currentUser.Username)
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool AddProfileSocialNetworkInfo(UserProfileSocialNetworkInfo profileToAdd)
|
||||
{
|
||||
return this.Repository.AddProfileSocialNetworkInfo(profileToAdd);
|
||||
}
|
||||
public bool RemoveProfileSocialNetworkInfo(UserProfileSocialNetworkInfo profileToRemove)
|
||||
{
|
||||
return this.Repository.RemoveProfileSocialNetworkInfo(profileToRemove);
|
||||
}
|
||||
|
||||
// add / remove group
|
||||
public bool AddGroupToCurrentUser(UserProfileSocialNetworkInfo currentUser, Group groupToAdd)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var group in currentUser.Groups)
|
||||
{
|
||||
if (group == groupToAdd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currentUser.Groups.Add(groupToAdd);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool RemoveGroupFromCurrentUser(UserProfileSocialNetworkInfo currentUser, Group groupToRemove)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var group in currentUser.Groups)
|
||||
{
|
||||
if (group.GroupName == groupToRemove.GroupName)
|
||||
{
|
||||
currentUser.Groups.Remove(group);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// add / remove close friend
|
||||
public bool AddCloseFriendToCurrentUser(UserProfileSocialNetworkInfo currentUser, CloseFriendProfile closeFriendToAdd)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var closeFriend in currentUser.CloseFriendsProfiles)
|
||||
{
|
||||
if (closeFriend == closeFriendToAdd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currentUser.CloseFriendsProfiles.Add(closeFriendToAdd);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool RemoveCloseFriendFromCurrentUser(UserProfileSocialNetworkInfo currentUser, CloseFriendProfile closeFriendToRemove)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var closeFriend in currentUser.CloseFriendsProfiles)
|
||||
{
|
||||
if (closeFriend.User.Id == closeFriendToRemove.User.Id)
|
||||
{
|
||||
currentUser.CloseFriendsProfiles.Remove(closeFriend);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// add / remove blocked profile
|
||||
public bool AddBlockedProfileToCurrentUser(UserProfileSocialNetworkInfo currentUser, BlockedProfile blockedProfileToAdd)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var blockedProfile in currentUser.BlockedProfiles)
|
||||
{
|
||||
if (blockedProfile.User.Id == blockedProfileToAdd.User.Id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currentUser.BlockedProfiles.Add(blockedProfileToAdd);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool RemoveBlockedProfileFromCurrentUser(UserProfileSocialNetworkInfo currentUser, BlockedProfile blockedProfileToRemove)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var blockedProfile in currentUser.BlockedProfiles)
|
||||
{
|
||||
if (blockedProfile.User.Id == blockedProfileToRemove.User.Id)
|
||||
{
|
||||
currentUser.BlockedProfiles.Remove(blockedProfile);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// add / remove Restricted posts
|
||||
public bool AddRestrictedPostsAudienceUserToCurrentUser(UserProfileSocialNetworkInfo currentUser, User userToAdd)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var restrictedUser in currentUser.RestrictedPostsAudience)
|
||||
{
|
||||
if (restrictedUser == userToAdd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currentUser.RestrictedPostsAudience.Add(userToAdd);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool RemoveRestrictedPostsAudienceUserFromCurrentUser(UserProfileSocialNetworkInfo currentUser, User userToRemove)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var restrictedUser in currentUser.RestrictedPostsAudience)
|
||||
{
|
||||
if (restrictedUser.Username == userToRemove.Username)
|
||||
{
|
||||
currentUser.RestrictedPostsAudience.Remove(restrictedUser);
|
||||
SaveDataIntoXML();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// add / remove Restricted stories
|
||||
public bool AddRestrictedStoriesAudienceUserToCurrentUser(UserProfileSocialNetworkInfo currentUser, User userToAdd)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var restrictedUser in currentUser.RestrictedStoriesAudience)
|
||||
{
|
||||
if (restrictedUser == userToAdd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currentUser.RestrictedStoriesAudience.Add(userToAdd);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool RemoveRestrictedStoriesAudienceUserFromCurrentUser(UserProfileSocialNetworkInfo currentUser, User userToRemove)
|
||||
{
|
||||
if (this.CheckIfProfileExists(currentUser))
|
||||
{
|
||||
foreach (var restrictedUser in currentUser.RestrictedStoriesAudience)
|
||||
{
|
||||
if (restrictedUser.Username == userToRemove.Username)
|
||||
{
|
||||
currentUser.RestrictedStoriesAudience.Remove(restrictedUser);
|
||||
SaveDataIntoXML();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Group> GetAllGroupsService()
|
||||
{
|
||||
return this.GroupsRepository.GetAllGroups();
|
||||
}
|
||||
|
||||
public Group GetGroupByName(string name)
|
||||
{
|
||||
return this.GroupsRepository.GetGroupByGroupName(name);
|
||||
}
|
||||
|
||||
public bool CreateGroupToRepository(string groupName, List<User> groupMembers)
|
||||
{
|
||||
Group groupToAdd = new Group(Guid.NewGuid(), groupName, groupMembers);
|
||||
|
||||
return GroupsRepository.AddGroup(groupToAdd);
|
||||
}
|
||||
public bool DeleteGroupFromRepository(string groupName)
|
||||
{
|
||||
if (GroupsRepository.GetGroupByGroupName(groupName) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GroupsRepository.RemoveGroup(GroupsRepository.GetGroupByGroupName(groupName));
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddMemberToGroup(string groupName, User user)
|
||||
{
|
||||
return GroupsRepository.AddMemberToGroup(groupName, user);
|
||||
}
|
||||
|
||||
public bool RemoveMemberFromGroup(string groupName, User user)
|
||||
{
|
||||
return GroupsRepository.RemoveMemberFromGroup(groupName, user);
|
||||
}
|
||||
|
||||
public void AddMemberToGroupProfile(UserProfileSocialNetworkInfo profile, string groupName, string username)
|
||||
{
|
||||
foreach (var gr in profile.Groups)
|
||||
{
|
||||
if (gr.GroupName == groupName)
|
||||
{
|
||||
foreach (var user in GetAllUsers())
|
||||
{
|
||||
if (user.Username == username)
|
||||
{
|
||||
gr.GroupMembers.Add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// USERS REPOSITORY
|
||||
|
||||
///
|
||||
public User GetUserByName(string username)
|
||||
{
|
||||
return UsersRepository.GetUserByName(username);
|
||||
}
|
||||
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
return UsersRepository.GetAllUsers();
|
||||
}
|
||||
|
||||
public UserProfileSocialNetworkInfo GetProfileSocialNetworkInfoByUser(string username)
|
||||
{
|
||||
foreach (User user in UsersRepository.GetAllUsers())
|
||||
{
|
||||
if (user.Username == username)
|
||||
{
|
||||
foreach (var profile in Repository.GetProfileRepositoryList())
|
||||
{
|
||||
if (profile.User.Username == username)
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlockedProfile GetBlockedProfileByName(UserProfileSocialNetworkInfo profile, string username)
|
||||
{
|
||||
foreach (var blockedProfile in profile.BlockedProfiles)
|
||||
{
|
||||
if (blockedProfile.User.Username == username)
|
||||
{
|
||||
return blockedProfile;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CloseFriendProfile GetCloseFriendByName(UserProfileSocialNetworkInfo profile, string username)
|
||||
{
|
||||
foreach (var closeFriend in profile.CloseFriendsProfiles)
|
||||
{
|
||||
if (closeFriend.User.Username == username)
|
||||
{
|
||||
return closeFriend;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SwitchAccountPrivacyPublicPrivate(User currentConnectedUser)
|
||||
{
|
||||
UserProfileSocialNetworkInfo profile = GetProfileSocialNetworkInfoByUser(currentConnectedUser.Username);
|
||||
|
||||
profile.IsProfilePrivate = !profile.IsProfilePrivate;
|
||||
|
||||
SaveDataIntoXML();
|
||||
}
|
||||
|
||||
public void SaveDataIntoXML()
|
||||
{
|
||||
this.Repository.SaveProfilesInXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Sorting_module
|
||||
{
|
||||
public interface ISortingAlgorithms<T>
|
||||
{
|
||||
void BubbleSortAscending(List<T> list, Func<T, T, int> compare);
|
||||
void BubbleSortDescending(List<T> list, Func<T, T, int> compare);
|
||||
|
||||
void MergeSortAscending(List<T> domainList, Func<T, T, int> compare);
|
||||
void MergeSortDescending(List<T> domainList, Func<T, T, int> compare);
|
||||
|
||||
void GnomeSortAscending(List<T> domainList, Func<T, T, int> compare);
|
||||
void GnomeSortDescending(List<T> domainList, Func<T, T, int> compare);
|
||||
|
||||
void QuickSortAscending(List<T> domainList, Func<T, T, int> compare);
|
||||
void QuickSortDescending(List<T> domainList, Func<T, T, int> compare);
|
||||
}
|
||||
}
|
||||
+238
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace District_3_App.ProfileSocialNetworkInfoStuff.Sorting_module
|
||||
{
|
||||
public class SortingAlgorithms<T> : ISortingAlgorithms<T>
|
||||
where T : IComparable<T>
|
||||
{
|
||||
public SortingAlgorithms()
|
||||
{
|
||||
}
|
||||
|
||||
public void BubbleSortAscending(List<T> list, Func<T, T, int> compare)
|
||||
{
|
||||
bool swapped = false;
|
||||
int numberOfElements = list.Count;
|
||||
while (swapped != true)
|
||||
{
|
||||
swapped = true;
|
||||
for (int index = 0; index < numberOfElements - 1; index++)
|
||||
{
|
||||
if (list[index].CompareTo(list[index + 1]) > 0)
|
||||
{
|
||||
T temporary = list[index];
|
||||
list[index] = list[index + 1];
|
||||
list[index + 1] = temporary;
|
||||
swapped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void BubbleSortDescending(List<T> list, Func<T, T, int> compare)
|
||||
{
|
||||
bool swapped = false;
|
||||
int numberOfElements = list.Count;
|
||||
while (swapped != true)
|
||||
{
|
||||
swapped = true;
|
||||
for (int index = 0; index < numberOfElements - 1; index++)
|
||||
{
|
||||
if (list[index].CompareTo(list[index + 1]) < 0)
|
||||
{
|
||||
T temporary = list[index];
|
||||
list[index] = list[index + 1];
|
||||
list[index + 1] = temporary;
|
||||
swapped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeLists(List<T> domainList, int left, int middle, int right, Func<T, T, int> compare, bool sortingTypes)
|
||||
{
|
||||
var leftListLength = middle - left + 1;
|
||||
var rightListLength = right - middle;
|
||||
|
||||
var leftTemporaryList = new List<T>();
|
||||
var rightTemporaryList = new List<T>();
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < leftListLength; i++)
|
||||
{
|
||||
leftTemporaryList.Add(domainList[left + i]);
|
||||
}
|
||||
|
||||
for (j = 0; j < rightListLength; j++)
|
||||
{
|
||||
rightTemporaryList.Add(domainList[middle + 1 + j]);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
int k = left;
|
||||
|
||||
while (i < leftListLength && j < rightListLength)
|
||||
{
|
||||
if (sortingTypes)
|
||||
{
|
||||
if (compare(leftTemporaryList[i], rightTemporaryList[j]) <= 0)
|
||||
{
|
||||
domainList[k++] = leftTemporaryList[i++];
|
||||
}
|
||||
else
|
||||
{
|
||||
domainList[k++] = rightTemporaryList[j++];
|
||||
}
|
||||
}
|
||||
else
|
||||
if (compare(leftTemporaryList[i], rightTemporaryList[j]) >= 0)
|
||||
{
|
||||
domainList[k++] = leftTemporaryList[i++];
|
||||
}
|
||||
else
|
||||
{
|
||||
domainList[k++] = rightTemporaryList[j++];
|
||||
}
|
||||
}
|
||||
|
||||
while (i < leftListLength)
|
||||
{
|
||||
domainList[k++] = leftTemporaryList[i++];
|
||||
}
|
||||
while (j < rightListLength)
|
||||
{
|
||||
domainList[k++] = rightTemporaryList[j++];
|
||||
}
|
||||
}
|
||||
|
||||
private void RecursiveMergeSort(List<T> domainList, int left, int right, Func<T, T, int> compare, bool sortingType)
|
||||
{
|
||||
if (left < right)
|
||||
{
|
||||
int middle = (left + right) / 2;
|
||||
|
||||
RecursiveMergeSort(domainList, left, middle, compare, sortingType);
|
||||
RecursiveMergeSort(domainList, middle + 1, right, compare, sortingType);
|
||||
|
||||
MergeLists(domainList, left, middle, right, compare, sortingType);
|
||||
}
|
||||
}
|
||||
|
||||
public void MergeSortAscending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
// List<DomainObject> temporaryList = new List<DomainObject>(domainList.Count);
|
||||
RecursiveMergeSort(domainList, 0, domainList.Count - 1, compare, true);
|
||||
}
|
||||
public void MergeSortDescending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
RecursiveMergeSort(domainList, 0, domainList.Count - 1, compare, false);
|
||||
}
|
||||
|
||||
public void GnomeSortAscending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while (index < domainList.Count)
|
||||
{
|
||||
if (index == 0 || compare(domainList[index], domainList[index - 1]) >= 0)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
T temporaryObject = domainList[index];
|
||||
domainList[index] = domainList[index - 1];
|
||||
domainList[index - 1] = temporaryObject;
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GnomeSortDescending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while (index < domainList.Count)
|
||||
{
|
||||
if (index == 0 || compare(domainList[index], domainList[index - 1]) <= 0)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
T temporaryObject = domainList[index];
|
||||
domainList[index] = domainList[index - 1];
|
||||
domainList[index - 1] = temporaryObject;
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSortAscending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
domainList = QuickSort(domainList, 0, domainList.Count - 1, compare, true); // ascending
|
||||
}
|
||||
public void QuickSortDescending(List<T> domainList, Func<T, T, int> compare)
|
||||
{
|
||||
domainList = QuickSort(domainList, 0, domainList.Count - 1, compare, false); // ascending
|
||||
}
|
||||
|
||||
private List<T> QuickSort(List<T> domainList, int leftIndex, int rightIndex, Func<T, T, int> compare, bool sortingType)
|
||||
{
|
||||
int index_1 = leftIndex;
|
||||
int index_2 = rightIndex;
|
||||
T pivot = domainList[leftIndex];
|
||||
while (index_1 <= index_2)
|
||||
{
|
||||
if (sortingType)
|
||||
{
|
||||
while (compare(domainList[index_1], pivot) < 0)
|
||||
{
|
||||
index_1++;
|
||||
}
|
||||
|
||||
while (compare(domainList[index_2], pivot) > 0)
|
||||
{
|
||||
index_2--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (compare(domainList[index_1], pivot) > 0)
|
||||
{
|
||||
index_1++;
|
||||
}
|
||||
|
||||
while (compare(domainList[index_2], pivot) < 0)
|
||||
{
|
||||
index_2--;
|
||||
}
|
||||
}
|
||||
|
||||
if (index_1 <= index_2)
|
||||
{
|
||||
T temp = domainList[index_1];
|
||||
domainList[index_1] = domainList[index_2];
|
||||
domainList[index_2] = temp;
|
||||
index_1++;
|
||||
index_2--;
|
||||
}
|
||||
}
|
||||
|
||||
if (leftIndex < index_2)
|
||||
{
|
||||
QuickSort(domainList, leftIndex, index_2, compare, sortingType);
|
||||
}
|
||||
|
||||
if (index_1 < rightIndex)
|
||||
{
|
||||
QuickSort(domainList, index_1, rightIndex, compare, sortingType);
|
||||
}
|
||||
|
||||
return domainList;
|
||||
}
|
||||
}
|
||||
}
|
||||
+394
@@ -0,0 +1,394 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using District_3_App.Enitities;
|
||||
|
||||
namespace District_3_App.Repository
|
||||
{
|
||||
public class FancierProfile
|
||||
{
|
||||
public Guid ProfileId { get; set; }
|
||||
public List<string> Links { get; set; }
|
||||
public string DailyMotto { get; set; }
|
||||
public DateTime? RemoveMottoDate { get; set; }
|
||||
public int FrameNumber { get; set; }
|
||||
public string Hashtag { get; set; }
|
||||
}
|
||||
|
||||
public class FancierProfileRepo
|
||||
{
|
||||
private Dictionary<Guid, FancierProfile> profileRepo = new Dictionary<Guid, FancierProfile>();
|
||||
private string filePath;
|
||||
|
||||
public FancierProfileRepo()
|
||||
{
|
||||
filePath = GenerateDefaultFilePath();
|
||||
Console.WriteLine(filePath);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
CreateXml(filePath);
|
||||
}
|
||||
Load(filePath);
|
||||
}
|
||||
|
||||
private string GenerateDefaultFilePath()
|
||||
{
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FancierProfile.xml");
|
||||
}
|
||||
|
||||
private void CreateXml(string filePath)
|
||||
{
|
||||
XDocument xDocument = new XDocument(new XElement("FancierProfiles"));
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
|
||||
private void Load(string filePath)
|
||||
{
|
||||
Console.WriteLine("Reading profile info fancy settings from file: " + filePath);
|
||||
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
XElement root = xDocument.Element("FancierProfiles");
|
||||
if (root != null && root.HasElements)
|
||||
{
|
||||
foreach (var userElem in root.Elements("FancierProfile"))
|
||||
{
|
||||
Guid userId;
|
||||
if (!Guid.TryParse((string)userElem.Attribute("ProfileId"), out userId))
|
||||
{
|
||||
userId = Guid.NewGuid();
|
||||
}
|
||||
FancierProfile profile = new FancierProfile();
|
||||
try
|
||||
{
|
||||
profile.ProfileId = userId;
|
||||
profile.DailyMotto = (string)userElem.Attribute("DailyMotto");
|
||||
profile.RemoveMottoDate = (DateTime)userElem.Attribute("RemoveMottoDate");
|
||||
if (profile.RemoveMottoDate < DateTime.Now)
|
||||
{
|
||||
profile.DailyMotto = null;
|
||||
profile.RemoveMottoDate = null;
|
||||
}
|
||||
|
||||
var linksElem = userElem.Element("Links");
|
||||
if (linksElem != null)
|
||||
{
|
||||
profile.Links = linksElem.Elements("Link")
|
||||
.Select(e => e.Value)
|
||||
.Where(e => !string.IsNullOrEmpty(e))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
profile.FrameNumber = (int)userElem.Attribute("FrameNumber");
|
||||
profile.Hashtag = (string)userElem.Attribute("Hashtag");
|
||||
|
||||
profileRepo.Add(userId, profile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error parsing profile: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveToXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument xDocument;
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
xDocument = XDocument.Load(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
xDocument = new XDocument(new XElement("FancierProfiles"));
|
||||
}
|
||||
|
||||
XElement root = xDocument.Element("FancierProfiles");
|
||||
root?.RemoveAll();
|
||||
|
||||
foreach (var profileId in profileRepo.Keys)
|
||||
{
|
||||
FancierProfile profile = profileRepo[profileId];
|
||||
|
||||
XElement profileElement = new XElement("FancierProfile",
|
||||
new XAttribute("ProfileId", profile.ProfileId),
|
||||
new XAttribute("DailyMotto", profile.DailyMotto),
|
||||
new XAttribute("RemoveMottoDate", profile.RemoveMottoDate),
|
||||
new XAttribute("FrameNumber", profile.FrameNumber),
|
||||
new XAttribute("Hashtag", profile.Hashtag));
|
||||
|
||||
if (profile.Links != null && profile.Links.Any())
|
||||
{
|
||||
XElement linksElement = new XElement("Links");
|
||||
foreach (var link in profile.Links)
|
||||
{
|
||||
linksElement.Add(new XElement("Link", link));
|
||||
}
|
||||
profileElement.Add(linksElement);
|
||||
}
|
||||
|
||||
root.Add(profileElement);
|
||||
}
|
||||
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error saving profiles to XML: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddLink(Guid userId, string newLink)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
if (profileRepo[userId].Links == null)
|
||||
{
|
||||
profileRepo[userId].Links = new List<string>();
|
||||
}
|
||||
profileRepo[userId].Links.Add(newLink);
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FancierProfile profile = new FancierProfile
|
||||
{
|
||||
ProfileId = userId,
|
||||
Links = new List<string> { newLink }
|
||||
};
|
||||
profileRepo.Add(userId, profile);
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error adding link: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteLink(Guid userId, string linkToDelete)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
if (profileRepo[userId].Links != null)
|
||||
{
|
||||
profileRepo[userId].Links.Remove(linkToDelete);
|
||||
SaveToXml();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("User ID not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error deleting link: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetFrameNumber(Guid userId, int newFrameNumber)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].FrameNumber = newFrameNumber;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FancierProfile profile = new FancierProfile
|
||||
{
|
||||
ProfileId = userId,
|
||||
FrameNumber = newFrameNumber,
|
||||
};
|
||||
profileRepo.Add(userId, profile);
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error setting frame number: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteFrameNumber(Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].FrameNumber = 0;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("User ID not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error deleting frame number: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetHashtag(Guid userId, string newHashtag)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].Hashtag = newHashtag;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FancierProfile profile = new FancierProfile
|
||||
{
|
||||
ProfileId = userId,
|
||||
Hashtag = newHashtag,
|
||||
};
|
||||
profileRepo.Add(userId, profile);
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error setting hashtag: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteHashtag(Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].Hashtag = string.Empty;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("User ID not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error deleting hashtag: " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddDailyMotto(Guid userId, string newMotto, DateTime dateToRemove)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].DailyMotto = newMotto;
|
||||
profileRepo[userId].RemoveMottoDate = dateToRemove;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FancierProfile profile = new FancierProfile();
|
||||
profile.DailyMotto = newMotto;
|
||||
profile.RemoveMottoDate = dateToRemove;
|
||||
profileRepo.Add(userId, profile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteDailyMotto(Guid userId)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
profileRepo[userId].DailyMotto = null;
|
||||
SaveToXml();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDailyMotto(Guid userId)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
return profileRepo[userId].DailyMotto;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetLinks(Guid userId)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
return profileRepo[userId].Links;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFrameNumber(Guid userId)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
return profileRepo[userId].FrameNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHashtag(Guid userId)
|
||||
{
|
||||
if (profileRepo.ContainsKey(userId))
|
||||
{
|
||||
return profileRepo[userId].Hashtag;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
|
||||
namespace District_3_App.Repository
|
||||
{
|
||||
public class HighlightsRepo
|
||||
{
|
||||
private Dictionary<Guid, Dictionary<Guid, Highlight>> userHighlights = new Dictionary<Guid, Dictionary<Guid, Highlight>>();
|
||||
private string filePath;
|
||||
|
||||
public HighlightsRepo()
|
||||
{
|
||||
filePath = GenerateDefaultFilePath();
|
||||
Console.WriteLine(filePath);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
CreateXml(filePath);
|
||||
}
|
||||
LoadHighlights(filePath);
|
||||
}
|
||||
|
||||
private string GenerateDefaultFilePath()
|
||||
{
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Highlights.xml");
|
||||
}
|
||||
|
||||
private void CreateXml(string filePath)
|
||||
{
|
||||
XDocument xDocument = new XDocument(new XElement("Highlights"));
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
|
||||
private void LoadHighlights(string filePath)
|
||||
{
|
||||
Console.WriteLine("Reading highlights from file: " + filePath);
|
||||
|
||||
XDocument xDocument = XDocument.Load(filePath);
|
||||
XElement root = xDocument.Element("Highlights");
|
||||
if (root != null && root.HasElements)
|
||||
{
|
||||
foreach (var userElem in root.Elements("User"))
|
||||
{
|
||||
Guid userId;
|
||||
if (!Guid.TryParse((string)userElem.Attribute("userId"), out userId))
|
||||
{
|
||||
// Skip this user element if userId attribute is not valid
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var highlightElem in userElem.Elements("Highlight"))
|
||||
{
|
||||
Highlight highlight = new Highlight();
|
||||
highlight.SetUserId(userId);
|
||||
|
||||
// Wrap the parsing in a try-catch block
|
||||
try
|
||||
{
|
||||
Guid guid;
|
||||
if (Guid.TryParse((string)highlightElem.Attribute("guid"), out guid))
|
||||
{
|
||||
highlight.SetGuid(guid);
|
||||
}
|
||||
|
||||
highlight.SetName((string)highlightElem.Attribute("name"));
|
||||
|
||||
var postsElem = highlightElem.Element("posts");
|
||||
if (postsElem != null)
|
||||
{
|
||||
// Parse post elements
|
||||
var posts = postsElem.Elements("post").Select(e =>
|
||||
{
|
||||
Guid postGuid;
|
||||
if (Guid.TryParse(e.Value, out postGuid))
|
||||
{
|
||||
return postGuid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Guid.Empty; // or any other default value
|
||||
}
|
||||
}).Where(e => e != Guid.Empty).ToList();
|
||||
|
||||
highlight.SetListPosts(posts);
|
||||
}
|
||||
|
||||
highlight.SetCover((string)highlightElem.Attribute("cover"));
|
||||
|
||||
if (!userHighlights.ContainsKey(userId))
|
||||
{
|
||||
userHighlights[userId] = new Dictionary<Guid, Highlight>();
|
||||
}
|
||||
|
||||
userHighlights[userId].Add(highlight.GetHighlightId(), highlight);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the error or handle it as needed
|
||||
Console.WriteLine($"Error parsing highlight: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveHighlightsToXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument xDocument;
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
xDocument = XDocument.Load(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
xDocument = new XDocument(new XElement("Highlights"));
|
||||
}
|
||||
|
||||
XElement root = xDocument.Element("Highlights");
|
||||
root?.RemoveAll();
|
||||
|
||||
foreach (var userHighlight in userHighlights)
|
||||
{
|
||||
XElement userElement = new XElement("User", new XAttribute("userId", userHighlight.Key));
|
||||
|
||||
foreach (var highlight in userHighlight.Value)
|
||||
{
|
||||
Highlight highlight1 = highlight.Value;
|
||||
XElement highlightElement = new XElement("Highlight",
|
||||
new XAttribute("userId", userHighlight.Key),
|
||||
new XAttribute("guid", highlight1.GetHighlightId()), // Use the highlight's guid
|
||||
new XAttribute("name", highlight1.GetName()), // Use the highlight's name
|
||||
new XElement("posts", highlight1.GetPosts().Select(p => new XElement("post", p))),
|
||||
new XAttribute("cover", highlight1.GetCover()));
|
||||
|
||||
userElement.Add(highlightElement);
|
||||
}
|
||||
|
||||
root.Add(userElement);
|
||||
}
|
||||
|
||||
xDocument.Save(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error saving highlights to XML: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public List<MockPhotoPost> GetConnectedUserPosts(Guid userId)
|
||||
{
|
||||
List<MockPhotoPost> posts = new List<MockPhotoPost>();
|
||||
string path1 = "/Images/snow.jpg";
|
||||
string path2 = "/Images/peeta.jpeg";
|
||||
string path3 = "/Images/katniss.jpg";
|
||||
string path4 = "/Images/poster.jpeg";
|
||||
|
||||
MockPhotoPost post1 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 1", "Description 1", path1);
|
||||
post1.SetPostId(new Guid("11111111-1111-1111-1111-111111111111"));
|
||||
MockPhotoPost post2 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 2", "Description 2", path2);
|
||||
post2.SetPostId(new Guid("22222222-2222-2222-2222-222222222222"));
|
||||
MockPhotoPost post3 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 3", "Description 3", path3);
|
||||
post3.SetPostId(new Guid("33333333-3333-3333-3333-333333333333"));
|
||||
MockPhotoPost post4 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 4", "Description 4", path4);
|
||||
post4.SetPostId(new Guid("44444444-4444-4444-4444-444444444444"));
|
||||
|
||||
posts.Add(post1);
|
||||
posts.Add(post2);
|
||||
posts.Add(post3);
|
||||
posts.Add(post4);
|
||||
|
||||
return posts;
|
||||
}
|
||||
public bool AddHighlight(Guid userId, Highlight highlight)
|
||||
{
|
||||
if (!userHighlights.ContainsKey(userId))
|
||||
{
|
||||
userHighlights[userId] = new Dictionary<Guid, Highlight>();
|
||||
}
|
||||
userHighlights[userId].Add(highlight.GetHighlightId(), highlight);
|
||||
SaveHighlightsToXml();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveHighlight(Guid userId, Guid highlightId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId) && userHighlights[userId].ContainsKey(highlightId))
|
||||
{
|
||||
userHighlights[userId].Remove(highlightId);
|
||||
SaveHighlightsToXml();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddPostToHighlight(Guid userId, Guid postId, Guid highlightId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId) && userHighlights[userId].ContainsKey(highlightId))
|
||||
{
|
||||
List<Guid> listPosts = userHighlights[userId][highlightId].GetPosts();
|
||||
if (!listPosts.Contains(postId))
|
||||
{
|
||||
listPosts.Add(postId);
|
||||
userHighlights[userId][highlightId].SetListPosts(listPosts);
|
||||
SaveHighlightsToXml();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RemovePostFromHighlight(Guid userId, Guid postId, Guid highlightId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId) && userHighlights[userId].ContainsKey(highlightId))
|
||||
{
|
||||
List<Guid> listPosts = userHighlights[userId][highlightId].GetPosts();
|
||||
if (listPosts.Contains(postId))
|
||||
{
|
||||
listPosts.Remove(postId);
|
||||
userHighlights[userId][highlightId].SetListPosts(listPosts);
|
||||
SaveHighlightsToXml();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<Highlight> GetHighlights()
|
||||
{
|
||||
return userHighlights.Values.SelectMany(dict => dict.Values).ToList();
|
||||
}
|
||||
|
||||
public List<Highlight> GetHighlightsOfUser(Guid userId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId))
|
||||
{
|
||||
return userHighlights[userId].Values.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<Highlight>();
|
||||
}
|
||||
}
|
||||
|
||||
public Highlight GetHighlight(Guid userId, Guid highlightId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId) && userHighlights[userId].ContainsKey(highlightId))
|
||||
{
|
||||
return userHighlights[userId][highlightId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<MockPhotoPost> GetPostsOfHighlight(Guid userId, Guid highlightId)
|
||||
{
|
||||
if (userHighlights.ContainsKey(userId) && userHighlights[userId].ContainsKey(highlightId))
|
||||
{
|
||||
List<MockPhotoPost> postsOfHighlight = new List<MockPhotoPost>();
|
||||
Highlight highlight = userHighlights[userId][highlightId];
|
||||
foreach (var post in GetConnectedUserPosts(userId))
|
||||
{
|
||||
if (highlight.GetPosts().Contains(post.GetPostId()))
|
||||
{
|
||||
postsOfHighlight.Add(post);
|
||||
}
|
||||
}
|
||||
return postsOfHighlight;
|
||||
}
|
||||
return new List<MockPhotoPost>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
|
||||
namespace District_3_App.Repository
|
||||
{
|
||||
public class SnapshotsRepo
|
||||
{
|
||||
private HighlightsRepo highlightsRepo = new HighlightsRepo();
|
||||
private Guid userId;
|
||||
public SnapshotsRepo(Guid userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public bool AddHighlight(Highlight highlight)
|
||||
{
|
||||
return highlightsRepo.AddHighlight(userId, highlight);
|
||||
}
|
||||
public bool RemoveHighlight(Highlight highlight)
|
||||
{
|
||||
return highlightsRepo.RemoveHighlight(userId, highlight.GetHighlightId());
|
||||
}
|
||||
public bool AddPostToHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return highlightsRepo.AddPostToHighlight(userId, highlightId, postId);
|
||||
}
|
||||
public bool RemovePostFromHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return highlightsRepo.RemovePostFromHighlight(userId, highlightId, postId);
|
||||
}
|
||||
public HighlightsRepo GetHighlightsRepo()
|
||||
{
|
||||
return highlightsRepo;
|
||||
}
|
||||
public List<Highlight> GetHighlightsOfUser()
|
||||
{
|
||||
return highlightsRepo.GetHighlightsOfUser(userId);
|
||||
}
|
||||
public Highlight GetHighlight(Guid highlightId)
|
||||
{
|
||||
return highlightsRepo.GetHighlight(userId, highlightId);
|
||||
}
|
||||
|
||||
public List<MockPhotoPost> GetPostsOfHighlight(Guid highlightId)
|
||||
{
|
||||
return highlightsRepo.GetPostsOfHighlight(userId, highlightId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?xml version="1.0"?>
|
||||
<RuleSet Name="StyleCop.Analyzers rules with default action" Description="StyleCop.Analyzers with default action. Rules with IsEnabledByDefault = false are disabled." ToolsVersion="14.0">
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpecialRules">
|
||||
<Rule Id="SA0001" Action="Warning" /> <!-- XML comment analysis disabled -->
|
||||
<Rule Id="SA0002" Action="Warning" /> <!-- Invalid settings file -->
|
||||
</Rules>
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpacingRules">
|
||||
<Rule Id="SA1000" Action="Error" /> <!-- Keywords should be spaced correctly -->
|
||||
<Rule Id="SA1001" Action="Error" /> <!-- Commas should be spaced correctly -->
|
||||
<Rule Id="SA1002" Action="Error" /> <!-- Semicolons should be spaced correctly -->
|
||||
<Rule Id="SA1003" Action="Error" /> <!-- Symbols should be spaced correctly -->
|
||||
<Rule Id="SA1004" Action="Error" /> <!-- Documentation lines should begin with single space -->
|
||||
<Rule Id="SA1005" Action="Error" /> <!-- Single line comments should begin with single space -->
|
||||
<Rule Id="SA1006" Action="None" /> <!-- Preprocessor keywords should not be preceded by space -->
|
||||
<Rule Id="SA1007" Action="None" /> <!-- Operator keyword should be followed by space -->
|
||||
<Rule Id="SA1008" Action="Error" /> <!-- Opening parenthesis should be spaced correctly -->
|
||||
<Rule Id="SA1009" Action="Error" /> <!-- Closing parenthesis should be spaced correctly -->
|
||||
<Rule Id="SA1010" Action="Error" /> <!-- Opening square brackets should be spaced correctly -->
|
||||
<Rule Id="SA1011" Action="Error" /> <!-- Closing square brackets should be spaced correctly -->
|
||||
<Rule Id="SA1012" Action="Error" /> <!-- Opening braces should be spaced correctly -->
|
||||
<Rule Id="SA1013" Action="Error" /> <!-- Closing braces should be spaced correctly -->
|
||||
<Rule Id="SA1014" Action="Error" /> <!-- Opening generic brackets should be spaced correctly -->
|
||||
<Rule Id="SA1015" Action="Error" /> <!-- Closing generic brackets should be spaced correctly -->
|
||||
<Rule Id="SA1016" Action="Error" /> <!-- Opening attribute brackets should be spaced correctly -->
|
||||
<Rule Id="SA1017" Action="Error" /> <!-- Closing attribute brackets should be spaced correctly -->
|
||||
<Rule Id="SA1018" Action="Error" /> <!-- Nullable type symbols should be spaced correctly -->
|
||||
<Rule Id="SA1019" Action="Error" /> <!-- Member access symbols should be spaced correctly -->
|
||||
<Rule Id="SA1020" Action="Error" /> <!-- Increment decrement symbols should be spaced correctly -->
|
||||
<Rule Id="SA1021" Action="Error" /> <!-- Negative signs should be spaced correctly -->
|
||||
<Rule Id="SA1022" Action="Error" /> <!-- Positive signs should be spaced correctly -->
|
||||
<Rule Id="SA1023" Action="None" /> <!-- Dereference and access of symbols should be spaced correctly -->
|
||||
<Rule Id="SA1024" Action="Error" /> <!-- Colons should be spaced correctly -->
|
||||
<Rule Id="SA1025" Action="Error" /> <!-- Code should not contain multiple whitespace in a row -->
|
||||
<Rule Id="SA1026" Action="Error" /> <!-- Code should not contain space after new or stackalloc keyword in implicitly typed array allocation -->
|
||||
<Rule Id="SA1027" Action="None" /> <!-- Use tabs correctly -->
|
||||
<Rule Id="SA1028" Action="Error" /> <!-- Code should not contain trailing whitespace -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.ReadabilityRules">
|
||||
<Rule Id="SA1100" Action="Error" /> <!-- Do not prefix calls with base unless local implementation exists -->
|
||||
<Rule Id="SA1101" Action="None" /> <!-- Prefix local calls with this -->
|
||||
<Rule Id="SA1102" Action="Error" /> <!-- Query clause should follow previous clause -->
|
||||
<Rule Id="SA1103" Action="None" /> <!-- Query clauses should be on separate lines or all on one line -->
|
||||
<Rule Id="SA1104" Action="None" /> <!-- Query clause should begin on new line when previous clause spans multiple lines -->
|
||||
<Rule Id="SA1105" Action="None" /> <!-- Query clauses spanning multiple lines should begin on own line -->
|
||||
<Rule Id="SA1106" Action="Error" /> <!-- Code should not contain empty statements -->
|
||||
<Rule Id="SA1107" Action="Error" /> <!-- Code should not contain multiple statements on one line -->
|
||||
<Rule Id="SA1108" Action="Error" /> <!-- Block statements should not contain embedded comments -->
|
||||
<Rule Id="SA1109" Action="None" /> <!-- Block statements should not contain embedded regions -->
|
||||
<Rule Id="SA1110" Action="Error" /> <!-- Opening parenthesis or bracket should be on declaration line -->
|
||||
<Rule Id="SA1111" Action="Error" /> <!-- Closing parenthesis should be on line of last parameter -->
|
||||
<Rule Id="SA1112" Action="Error" /> <!-- Closing parenthesis should be on line of opening parenthesis -->
|
||||
<Rule Id="SA1113" Action="Error" /> <!-- Comma should be on the same line as previous parameter -->
|
||||
<Rule Id="SA1114" Action="Error" /> <!-- Parameter list should follow declaration -->
|
||||
<Rule Id="SA1115" Action="Error" /> <!-- Parameter should follow comma -->
|
||||
<Rule Id="SA1116" Action="None" /> <!-- Split parameters should start on line after declaration -->
|
||||
<Rule Id="SA1117" Action="None" /> <!-- Parameters should be on same line or separate lines -->
|
||||
<Rule Id="SA1118" Action="None" /> <!-- Parameter should not span multiple lines -->
|
||||
<Rule Id="SA1120" Action="Error" /> <!-- Comments should contain text -->
|
||||
<Rule Id="SA1121" Action="Error" /> <!-- Use built-in type alias -->
|
||||
<Rule Id="SA1122" Action="Error" /> <!-- Use string.Empty for empty strings -->
|
||||
<Rule Id="SA1123" Action="None" /> <!-- Do not place regions within elements -->
|
||||
<Rule Id="SA1124" Action="None" /> <!-- Do not use regions -->
|
||||
<Rule Id="SA1125" Action="Error" /> <!-- Use shorthand for nullable types -->
|
||||
<Rule Id="SA1126" Action="None" /> <!-- Prefix calls correctly -->
|
||||
<Rule Id="SA1127" Action="Error" /> <!-- Generic type constraints should be on their own line -->
|
||||
<Rule Id="SA1128" Action="None" /> <!-- Put constructor initializers on their own line -->
|
||||
<Rule Id="SA1129" Action="None" /> <!-- Do not use default value type constructor -->
|
||||
<Rule Id="SA1130" Action="None" /> <!-- Use lambda syntax -->
|
||||
<Rule Id="SA1131" Action="None" /> <!-- Use readable conditions -->
|
||||
<Rule Id="SA1132" Action="Error" /> <!-- Do not combine fields -->
|
||||
<Rule Id="SA1133" Action="None" /> <!-- Do not combine attributes -->
|
||||
<Rule Id="SA1134" Action="None" /> <!-- Attributes should not share line -->
|
||||
<Rule Id="SA1135" Action="None" /> <!-- Using directives should be qualified -->
|
||||
<Rule Id="SA1136" Action="Error" /> <!-- Enum values should be on separate lines -->
|
||||
<Rule Id="SA1137" Action="None" /> <!-- Elements should have the same indentation -->
|
||||
<Rule Id="SA1139" Action="None" /> <!-- Use literal suffix notation instead of casting -->
|
||||
<Rule Id="SX1101" Action="None" /> <!-- Do not prefix local calls with 'this.' -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.OrderingRules">
|
||||
<Rule Id="SA1200" Action="None" /> <!-- Using directives should be placed correctly -->
|
||||
<Rule Id="SA1201" Action="None" /> <!-- Elements should appear in the correct order -->
|
||||
<Rule Id="SA1202" Action="None" /> <!-- Elements should be ordered by access -->
|
||||
<Rule Id="SA1203" Action="None" /> <!-- Constants should appear before fields -->
|
||||
<Rule Id="SA1204" Action="None" /> <!-- Static elements should appear before instance elements -->
|
||||
<Rule Id="SA1205" Action="None" /> <!-- Partial elements should declare access -->
|
||||
<Rule Id="SA1206" Action="None" /> <!-- Declaration keywords should follow order -->
|
||||
<Rule Id="SA1207" Action="None" /> <!-- Protected should come before public -->
|
||||
<Rule Id="SA1208" Action="Error" /> <!-- System using directives should be placed before other using directives -->
|
||||
<Rule Id="SA1209" Action="None" /> <!-- Using alias directives should be placed after other using directives -->
|
||||
<Rule Id="SA1210" Action="None" /> <!-- Using directives should be ordered alphabetically by namespace -->
|
||||
<Rule Id="SA1211" Action="None" /> <!-- Using alias directives should be ordered alphabetically by alias name -->
|
||||
<Rule Id="SA1212" Action="Error" /> <!-- Property accessors should follow order -->
|
||||
<Rule Id="SA1213" Action="None" /> <!-- Event accessors should follow order -->
|
||||
<Rule Id="SA1214" Action="None" /> <!-- Readonly fields should appear before non-readonly fields -->
|
||||
<Rule Id="SA1216" Action="None" /> <!-- Using static directives should be placed at the correct location -->
|
||||
<Rule Id="SA1217" Action="None" /> <!-- Using static directives should be ordered alphabetically -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.NamingRules">
|
||||
<Rule Id="SA1300" Action="Error" /> <!-- Element should begin with upper-case letter -->
|
||||
<Rule Id="SA1301" Action="None" /> <!-- Element should begin with lower-case letter -->
|
||||
<Rule Id="SA1302" Action="Error" /> <!-- Interface names should begin with I -->
|
||||
<Rule Id="SA1303" Action="Error" /> <!-- Const field names should begin with upper-case letter -->
|
||||
<Rule Id="SA1304" Action="Error" /> <!-- Non-private readonly fields should begin with upper-case letter -->
|
||||
<Rule Id="SA1305" Action="None" /> <!-- Field names should not use Hungarian notation -->
|
||||
<Rule Id="SA1306" Action="Error" /> <!-- Field names should begin with lower-case letter -->
|
||||
<Rule Id="SA1307" Action="Error" /> <!-- Accessible fields should begin with upper-case letter -->
|
||||
<Rule Id="SA1308" Action="Error" /> <!-- Variable names should not be prefixed -->
|
||||
<Rule Id="SA1309" Action="Error" /> <!-- Field names should not begin with underscore -->
|
||||
<Rule Id="SA1310" Action="None" /> <!-- Field names should not contain underscore -->
|
||||
<Rule Id="SA1311" Action="Error" /> <!-- Static readonly fields should begin with upper-case letter -->
|
||||
<Rule Id="SA1312" Action="Error" /> <!-- Variable names should begin with lower-case letter -->
|
||||
<Rule Id="SA1313" Action="Error" /> <!-- Parameter names should begin with lower-case letter -->
|
||||
<Rule Id="SA1314" Action="None" /> <!-- Type parameter names should begin with T -->
|
||||
<Rule Id="SX1309" Action="None" /> <!-- Field names should begin with underscore -->
|
||||
<Rule Id="SX1309S" Action="None" /> <!-- Static field names should begin with underscore -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.MaintainabilityRules">
|
||||
<Rule Id="SA1119" Action="Warning" /> <!-- Statement should not use unnecessary parenthesis -->
|
||||
<Rule Id="SA1400" Action="Error" /> <!-- Access modifier should be declared -->
|
||||
<Rule Id="SA1401" Action="None" /> <!-- Fields should be private -->
|
||||
<Rule Id="SA1402" Action="None" /> <!-- File may only contain a single type -->
|
||||
<Rule Id="SA1403" Action="None" /> <!-- File may only contain a single namespace -->
|
||||
<Rule Id="SA1404" Action="None" /> <!-- Code analysis suppression should have justification -->
|
||||
<Rule Id="SA1405" Action="None" /> <!-- Debug.Assert should provide message text -->
|
||||
<Rule Id="SA1406" Action="None" /> <!-- Debug.Fail should provide message text -->
|
||||
<Rule Id="SA1407" Action="Error" /> <!-- Arithmetic expressions should declare precedence -->
|
||||
<Rule Id="SA1408" Action="Error" /> <!-- Conditional expressions should declare precedence -->
|
||||
<Rule Id="SA1409" Action="None" /> <!-- Remove unnecessary code -->
|
||||
<Rule Id="SA1410" Action="None" /> <!-- Remove delegate parenthesis when possible -->
|
||||
<Rule Id="SA1411" Action="None" /> <!-- Attribute constructor should not use unnecessary parenthesis -->
|
||||
<Rule Id="SA1412" Action="None" /> <!-- Store files as UTF-8 with byte order mark -->
|
||||
<Rule Id="SA1413" Action="None" /> <!-- Use trailing comma in multi-line initializers -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.LayoutRules">
|
||||
<Rule Id="SA1500" Action="Error" /> <!-- Braces for multi-line statements should not share line -->
|
||||
<Rule Id="SA1501" Action="Error" /> <!-- Statement should not be on a single line -->
|
||||
<Rule Id="SA1502" Action="Error" /> <!-- Element should not be on a single line -->
|
||||
<Rule Id="SA1503" Action="Error" /> <!-- Braces should not be omitted -->
|
||||
<Rule Id="SA1504" Action="Error" /> <!-- All accessors should be single-line or multi-line -->
|
||||
<Rule Id="SA1505" Action="Error" /> <!-- Opening braces should not be followed by blank line -->
|
||||
<Rule Id="SA1506" Action="Error" /> <!-- Element documentation headers should not be followed by blank line -->
|
||||
<Rule Id="SA1507" Action="Error" /> <!-- Code should not contain multiple blank lines in a row -->
|
||||
<Rule Id="SA1508" Action="Error" /> <!-- Closing braces should not be preceded by blank line -->
|
||||
<Rule Id="SA1509" Action="Error" /> <!-- Opening braces should not be preceded by blank line -->
|
||||
<Rule Id="SA1510" Action="Error" /> <!-- Chained statement blocks should not be preceded by blank line -->
|
||||
<Rule Id="SA1511" Action="Error" /> <!-- While-do footer should not be preceded by blank line -->
|
||||
<Rule Id="SA1512" Action="Error" /> <!-- Single-line comments should not be followed by blank line -->
|
||||
<Rule Id="SA1513" Action="None" /> <!-- Closing brace should be followed by blank line -->
|
||||
<Rule Id="SA1514" Action="Error" /> <!-- Element documentation header should be preceded by blank line -->
|
||||
<Rule Id="SA1515" Action="None" /> <!-- Single-line comment should be preceded by blank line -->
|
||||
<Rule Id="SA1516" Action="None" /> <!-- Elements should be separated by blank line -->
|
||||
<Rule Id="SA1517" Action="Error" /> <!-- Code should not contain blank lines at start of file -->
|
||||
<Rule Id="SA1518" Action="None" /> <!-- Use line endings correctly at end of file -->
|
||||
<Rule Id="SA1519" Action="None" /> <!-- Braces should not be omitted from multi-line child statement -->
|
||||
<Rule Id="SA1520" Action="Error" /> <!-- Use braces consistently -->
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.DocumentationRules">
|
||||
<Rule Id="SA1600" Action="None" /> <!-- Elements should be documented -->
|
||||
<Rule Id="SA1601" Action="None" /> <!-- Partial elements should be documented -->
|
||||
<Rule Id="SA1602" Action="None" /> <!-- Enumeration items should be documented -->
|
||||
<Rule Id="SA1603" Action="None" /> <!-- Documentation should contain valid XML -->
|
||||
<Rule Id="SA1604" Action="None" /> <!-- Element documentation should have summary -->
|
||||
<Rule Id="SA1605" Action="None" /> <!-- Partial element documentation should have summary -->
|
||||
<Rule Id="SA1606" Action="None" /> <!-- Element documentation should have summary text -->
|
||||
<Rule Id="SA1607" Action="None" /> <!-- Partial element documentation should have summary text -->
|
||||
<Rule Id="SA1608" Action="None" /> <!-- Element documentation should not have default summary -->
|
||||
<Rule Id="SA1609" Action="None" /> <!-- Property documentation should have value -->
|
||||
<Rule Id="SA1610" Action="None" /> <!-- Property documentation should have value text -->
|
||||
<Rule Id="SA1611" Action="None" /> <!-- Element parameters should be documented -->
|
||||
<Rule Id="SA1612" Action="None" /> <!-- Element parameter documentation should match element parameters -->
|
||||
<Rule Id="SA1613" Action="None" /> <!-- Element parameter documentation should declare parameter name -->
|
||||
<Rule Id="SA1614" Action="None" /> <!-- Element parameter documentation should have text -->
|
||||
<Rule Id="SA1615" Action="None" /> <!-- Element return value should be documented -->
|
||||
<Rule Id="SA1616" Action="None" /> <!-- Element return value documentation should have text -->
|
||||
<Rule Id="SA1617" Action="None" /> <!-- Void return value should not be documented -->
|
||||
<Rule Id="SA1618" Action="None" /> <!-- Generic type parameters should be documented -->
|
||||
<Rule Id="SA1619" Action="None" /> <!-- Generic type parameters should be documented partial class -->
|
||||
<Rule Id="SA1620" Action="None" /> <!-- Generic type parameter documentation should match type parameters -->
|
||||
<Rule Id="SA1621" Action="None" /> <!-- Generic type parameter documentation should declare parameter name -->
|
||||
<Rule Id="SA1622" Action="None" /> <!-- Generic type parameter documentation should have text -->
|
||||
<Rule Id="SA1623" Action="None" /> <!-- Property summary documentation should match accessors -->
|
||||
<Rule Id="SA1624" Action="None" /> <!-- Property summary documentation should omit accessor with restricted access -->
|
||||
<Rule Id="SA1625" Action="None" /> <!-- Element documentation should not be copied and pasted -->
|
||||
<Rule Id="SA1626" Action="None" /> <!-- Single-line comments should not use documentation style slashes -->
|
||||
<Rule Id="SA1627" Action="None" /> <!-- Documentation text should not be empty -->
|
||||
<Rule Id="SA1628" Action="None" /> <!-- Documentation text should begin with a capital letter -->
|
||||
<Rule Id="SA1629" Action="None" /> <!-- Documentation text should end with a period -->
|
||||
<Rule Id="SA1630" Action="None" /> <!-- Documentation text should contain whitespace -->
|
||||
<Rule Id="SA1631" Action="None" /> <!-- Documentation should meet character percentage -->
|
||||
<Rule Id="SA1632" Action="None" /> <!-- Documentation text should meet minimum character length -->
|
||||
<Rule Id="SA1633" Action="None" /> <!-- File should have header -->
|
||||
<Rule Id="SA1634" Action="None" /> <!-- File header should show copyright -->
|
||||
<Rule Id="SA1635" Action="None" /> <!-- File header should have copyright text -->
|
||||
<Rule Id="SA1636" Action="None" /> <!-- File header copyright text should match -->
|
||||
<Rule Id="SA1637" Action="None" /> <!-- File header should contain file name -->
|
||||
<Rule Id="SA1638" Action="None" /> <!-- File header file name documentation should match file name -->
|
||||
<Rule Id="SA1639" Action="None" /> <!-- File header should have summary -->
|
||||
<Rule Id="SA1640" Action="None" /> <!-- File header should have valid company text -->
|
||||
<Rule Id="SA1641" Action="None" /> <!-- File header company name text should match -->
|
||||
<Rule Id="SA1642" Action="None" /> <!-- Constructor summary documentation should begin with standard text -->
|
||||
<Rule Id="SA1643" Action="None" /> <!-- Destructor summary documentation should begin with standard text -->
|
||||
<Rule Id="SA1644" Action="None" /> <!-- Documentation headers should not contain blank lines -->
|
||||
<Rule Id="SA1645" Action="None" /> <!-- Included documentation file does not exist -->
|
||||
<Rule Id="SA1646" Action="None" /> <!-- Included documentation XPath does not exist -->
|
||||
<Rule Id="SA1647" Action="None" /> <!-- Include node does not contain valid file and path -->
|
||||
<Rule Id="SA1648" Action="None" /> <!-- Inheritdoc should be used with inheriting class -->
|
||||
<Rule Id="SA1649" Action="None" /> <!-- File name should match first type name -->
|
||||
<Rule Id="SA1650" Action="None" /> <!-- Element documentation should be spelled correctly -->
|
||||
<Rule Id="SA1651" Action="None" /> <!-- Do not use placeholder elements -->
|
||||
</Rules>
|
||||
</RuleSet>
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.ExtraInfo;
|
||||
using District_3_App.LogIn;
|
||||
using District_3_App.LogIn;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class CasualProfileService
|
||||
{
|
||||
private SnapshotsService SnapshotsService { get; set; }
|
||||
private ProfileInfoSettings ProfileInfoSettings { get; set; }
|
||||
// private ExtraInfoService extraInfoService { get; set; }
|
||||
public CasualProfileService()
|
||||
{
|
||||
this.SnapshotsService = new SnapshotsService(GetConnectedUserId());
|
||||
this.ProfileInfoSettings = new ProfileInfoSettings(GetConnectedUserId());
|
||||
}
|
||||
public List<MockPost> GetConnectedUserPosts1()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public Guid GetConnectedUserId()
|
||||
{
|
||||
UserManager userManager = new UserManager("./Users.xml");
|
||||
IReadOnlyList<User> users = userManager.GetUsers();
|
||||
foreach (User user in users)
|
||||
{
|
||||
if (userManager.IsUserLoggedIn())
|
||||
{
|
||||
return user.Id;
|
||||
}
|
||||
}
|
||||
return new Guid("11111111-1111-1111-1111-111111111111");
|
||||
}
|
||||
public List<MockPhotoPost> GetConnectedUserPosts()
|
||||
{
|
||||
Guid userId = GetConnectedUserId();
|
||||
List<MockPhotoPost> posts = new List<MockPhotoPost>();
|
||||
string path1 = "/Images/snow.jpg";
|
||||
string path2 = "/Images/peeta.jpeg";
|
||||
string path3 = "/Images/katniss.jpg";
|
||||
string path4 = "/Images/poster.jpeg";
|
||||
|
||||
MockPhotoPost post1 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 1", "Description 1", path1);
|
||||
post1.SetPostId(new Guid("11111111-1111-1111-1111-111111111111"));
|
||||
MockPhotoPost post2 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 2", "Description 2", path2);
|
||||
post2.SetPostId(new Guid("22222222-2222-2222-2222-222222222222"));
|
||||
MockPhotoPost post3 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 3", "Description 3", path3);
|
||||
post3.SetPostId(new Guid("33333333-3333-3333-3333-333333333333"));
|
||||
MockPhotoPost post4 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 4", "Description 4", path4);
|
||||
post4.SetPostId(new Guid("44444444-4444-4444-4444-444444444444"));
|
||||
|
||||
posts.Add(post1);
|
||||
posts.Add(post2);
|
||||
posts.Add(post3);
|
||||
posts.Add(post4);
|
||||
|
||||
return posts;
|
||||
}
|
||||
|
||||
public SnapshotsService GetSnapshotsService()
|
||||
{
|
||||
return SnapshotsService;
|
||||
}
|
||||
public ProfileInfoSettings GetProfileInfoSettings()
|
||||
{
|
||||
return ProfileInfoSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class ProfileInfoSettings
|
||||
{
|
||||
private FancierProfileRepo fancierRepo = new FancierProfileRepo();
|
||||
private Guid profileId;
|
||||
|
||||
public ProfileInfoSettings(Guid profileId)
|
||||
{
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
public bool AddDailyMotto(string newMotto)
|
||||
{
|
||||
DateTime tomorrow = DateTime.Now.AddDays(1);
|
||||
return fancierRepo.AddDailyMotto(profileId, newMotto, tomorrow);
|
||||
}
|
||||
|
||||
public bool DeleteDailyMotto()
|
||||
{
|
||||
return fancierRepo.DeleteDailyMotto(profileId);
|
||||
}
|
||||
|
||||
public string GetDailyMotto()
|
||||
{
|
||||
return fancierRepo.GetDailyMotto(profileId);
|
||||
}
|
||||
|
||||
public bool AddLink(string newLink)
|
||||
{
|
||||
if (newLink.StartsWith("http://") || newLink.StartsWith("www."))
|
||||
{
|
||||
return fancierRepo.AddLink(profileId, newLink);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteLink(string linkToDelete)
|
||||
{
|
||||
return fancierRepo.DeleteLink(profileId, linkToDelete);
|
||||
}
|
||||
|
||||
public List<string> GetLinks()
|
||||
{
|
||||
return fancierRepo.GetLinks(profileId);
|
||||
}
|
||||
|
||||
public bool SetFrameNumber(int newFrameNumber)
|
||||
{
|
||||
return fancierRepo.SetFrameNumber(profileId, newFrameNumber);
|
||||
}
|
||||
|
||||
public bool DeleteFrameNumber()
|
||||
{
|
||||
return fancierRepo.DeleteFrameNumber(profileId);
|
||||
}
|
||||
|
||||
public int GetFrameNumber()
|
||||
{
|
||||
return fancierRepo.GetFrameNumber(profileId);
|
||||
}
|
||||
|
||||
public bool SetHashtag(string newHashtag)
|
||||
{
|
||||
return fancierRepo.SetHashtag(profileId, newHashtag);
|
||||
}
|
||||
|
||||
public bool DeleteHashtag()
|
||||
{
|
||||
return fancierRepo.DeleteHashtag(profileId);
|
||||
}
|
||||
|
||||
public string GetHashtag()
|
||||
{
|
||||
return fancierRepo.GetHashtag(profileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class SnapshotsService
|
||||
{
|
||||
private SnapshotsRepo snapshotsRepo;
|
||||
private Guid userId;
|
||||
public SnapshotsService(Guid currentUserId)
|
||||
{
|
||||
this.snapshotsRepo = new SnapshotsRepo(currentUserId);
|
||||
this.userId = currentUserId;
|
||||
}
|
||||
|
||||
public bool AddHighlight(string newHighlightName, string newHighlightCover, List<Guid> guids)
|
||||
{
|
||||
HighlightsRepo repo = snapshotsRepo.GetHighlightsRepo();
|
||||
// aici ar trebui apelat din post repository
|
||||
Highlight h = new Highlight(newHighlightName, newHighlightCover);
|
||||
|
||||
if (newHighlightName == null)
|
||||
{
|
||||
newHighlightName = "Highlight_" + h.GetHighlightId().ToString().Replace("-", "_");
|
||||
h.SetName(newHighlightName);
|
||||
}
|
||||
|
||||
int rnd = new Random().Next(0, guids.Count());
|
||||
if (guids.Count == 0)
|
||||
{
|
||||
newHighlightCover = "../Images/black.png";
|
||||
}
|
||||
while (newHighlightCover == null)
|
||||
{
|
||||
foreach (MockPhotoPost photoPost in repo.GetConnectedUserPosts(new Guid()))
|
||||
{
|
||||
if (photoPost != null)
|
||||
{
|
||||
if (photoPost.GetPostId().Equals(guids[rnd]))
|
||||
{
|
||||
newHighlightCover = photoPost.GetPhoto();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
snapshotsRepo.AddHighlight(h);
|
||||
|
||||
foreach (Guid postId in guids)
|
||||
{
|
||||
repo.AddPostToHighlight(this.userId, postId, h.GetHighlightId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool RemoveHighlight(Highlight highlight)
|
||||
{
|
||||
return snapshotsRepo.RemoveHighlight(highlight);
|
||||
}
|
||||
public bool AddPostToHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return snapshotsRepo.AddPostToHighlight(postId, highlightId);
|
||||
}
|
||||
public bool RemovePostFromHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return snapshotsRepo.RemovePostFromHighlight(postId, highlightId);
|
||||
}
|
||||
public List<Highlight> GetHighlightsOfUser()
|
||||
{
|
||||
return snapshotsRepo.GetHighlightsOfUser();
|
||||
}
|
||||
public Highlight GetHighlight(Guid highlightId)
|
||||
{
|
||||
return snapshotsRepo.GetHighlight(highlightId);
|
||||
}
|
||||
|
||||
public List<MockPhotoPost> GetPostsOfHighlight(Guid highlightId)
|
||||
{
|
||||
return snapshotsRepo.GetPostsOfHighlight(highlightId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<UserControl x:Class="District_3_App.Settings_Privacy_GUI.MantainGroups"
|
||||
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.Settings_Privacy_GUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800" Background="White">
|
||||
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Label FontSize="25" Content="Mantain your groups" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"/>
|
||||
<ListView x:Name="allGroupsListView" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="10,84,508,94">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<ListView SelectionChanged="CurrentUserGroupsListView_SelectionChanged" x:Name="currentUserGroupsListView" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="384,84,258,217">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<ListView x:Name="currentUserGroupMembersListView" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="558,84,82,217">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<Label FontSize="18" Content="All available groups:" HorizontalAlignment="Left" Margin="10,48,0,0" VerticalAlignment="Top"/>
|
||||
<Label FontSize="18" Content="Groups you are in:" HorizontalAlignment="Left" Margin="384,53,0,0" VerticalAlignment="Top"/>
|
||||
<Label FontSize="18" Content="Members: " HorizontalAlignment="Left" Margin="558,53,0,0" VerticalAlignment="Top" Height="29"/>
|
||||
<Label FontWeight="Bold" VerticalAlignment="Bottom" Content="Search for a group:" Margin="10,0,508,68"></Label>
|
||||
<TextBox TextChanged="SearchGroupNameTextBox_TextChanged" x:Name="searchGroupNameTextBox" FontSize="18" HorizontalAlignment="Left" Margin="11,367,0,0" TextWrapping="Wrap" Text="search group by name..." VerticalAlignment="Top" Width="227"/>
|
||||
<Button Click="JoinGroupButton_Click" Background="White" x:Name="joinGroupButton" FontSize="16" Content="Join" HorizontalAlignment="Left" Margin="240,84,0,0" VerticalAlignment="Top"/>
|
||||
<Button Click="CreateGroupButton_Click" x:Name="createGroupButton" FontSize="16" Background="White" Content="Create new group" HorizontalAlignment="Left" Margin="390,311,0,0" VerticalAlignment="Top" Width="140"/>
|
||||
<Button Click="AddMemberToSpecificGroupButton_Click" x:Name="addMemberToSpecificGroupButton" Background="White" Content="Add member" HorizontalAlignment="Left" Margin="571,213,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="addMemberToSelectedGroupTextBox" HorizontalAlignment="Left" Margin="558,233,0,0" TextWrapping="Wrap" Text="give username..." VerticalAlignment="Top" Width="100"/>
|
||||
<TextBox Padding="3" x:Name="newGroupNameTextBox" HorizontalAlignment="Left" Margin="382,349,0,0" TextWrapping="Wrap" Text="give a name to the group..." VerticalAlignment="Top" Width="157" Height="31"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
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.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
|
||||
|
||||
namespace District_3_App.Settings_Privacy_GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MantainGroups.xaml
|
||||
/// </summary>
|
||||
public partial class MantainGroups : UserControl
|
||||
{
|
||||
private ProfileNetworkInfoService profileNetworkInfoService;
|
||||
private User currentConnectedUser;
|
||||
|
||||
public MantainGroups(User currentConnectedUser, ProfileNetworkInfoService profileNetworkInfoService)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.currentConnectedUser = currentConnectedUser;
|
||||
this.profileNetworkInfoService = profileNetworkInfoService;
|
||||
|
||||
// PopulateAllGroupsList();
|
||||
PopulateGroupsForCurrentUser();
|
||||
PopulateGroupMemberForSelectedGroup();
|
||||
}
|
||||
|
||||
public void PopulateAllGroupsList()
|
||||
{
|
||||
if (searchGroupNameTextBox.Text != string.Empty && profileNetworkInfoService != null)
|
||||
{
|
||||
allGroupsListView.Items.Clear();
|
||||
|
||||
foreach (var group in profileNetworkInfoService.GetAllGroupsService())
|
||||
{
|
||||
if (group.GroupName.Contains(searchGroupNameTextBox.Text) || searchGroupNameTextBox.Text == string.Empty)
|
||||
{
|
||||
allGroupsListView.Items.Add(group.GroupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (searchGroupNameTextBox.Text == string.Empty)
|
||||
{
|
||||
allGroupsListView.Items.Clear();
|
||||
foreach (var group in profileNetworkInfoService.GetAllGroupsService())
|
||||
{
|
||||
allGroupsListView.Items.Add(group.GroupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PopulateGroupsForCurrentUser()
|
||||
{
|
||||
currentUserGroupsListView.Items.Clear();
|
||||
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
foreach (var group in profile.Groups)
|
||||
{
|
||||
currentUserGroupsListView.Items.Add(group.GroupName);
|
||||
}
|
||||
}
|
||||
|
||||
public void PopulateGroupMemberForSelectedGroup()
|
||||
{
|
||||
if (currentUserGroupsListView.SelectedItems.Count > 0)
|
||||
{
|
||||
currentUserGroupMembersListView.Items.Clear();
|
||||
string selectedGroupName = currentUserGroupsListView.SelectedItem.ToString(); // get selected group members
|
||||
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
foreach (var group in profile.Groups)
|
||||
{
|
||||
if (group.GroupName == selectedGroupName)
|
||||
{
|
||||
foreach (var groupMember in group.GroupMembers)
|
||||
{
|
||||
currentUserGroupMembersListView.Items.Add(groupMember.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CurrentUserGroupsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
PopulateGroupMemberForSelectedGroup();
|
||||
}
|
||||
|
||||
private void SearchGroupNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
PopulateAllGroupsList();
|
||||
}
|
||||
|
||||
private void JoinGroupButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (allGroupsListView.SelectedItems.Count > 0)
|
||||
{
|
||||
bool userAlreadyInGroup = false;
|
||||
string selectedGroupName = allGroupsListView.SelectedItem.ToString();
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
foreach (var groupMember in profileNetworkInfoService.GetGroupByName(selectedGroupName).GroupMembers)
|
||||
{
|
||||
if (groupMember.Username == profile.User.Username)
|
||||
{
|
||||
userAlreadyInGroup = true;
|
||||
}
|
||||
}
|
||||
if (userAlreadyInGroup == false)
|
||||
{
|
||||
profileNetworkInfoService.AddGroupToCurrentUser(profile, profileNetworkInfoService.GetGroupByName(selectedGroupName));
|
||||
profileNetworkInfoService.GetGroupByName(selectedGroupName).GroupMembers.Add(profile.User);
|
||||
profileNetworkInfoService.SaveDataIntoXML();
|
||||
|
||||
PopulateGroupsForCurrentUser();
|
||||
PopulateGroupMemberForSelectedGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateGroupButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (newGroupNameTextBox.Text != string.Empty)
|
||||
{
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
bool alreadyExists = false;
|
||||
|
||||
foreach (var group in profileNetworkInfoService.GetAllGroupsService())
|
||||
{
|
||||
if (group.GroupName == newGroupNameTextBox.Text)
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (alreadyExists)
|
||||
{
|
||||
MessageBox.Show("Group with this name already exists", "Error creating new group");
|
||||
}
|
||||
else
|
||||
{
|
||||
List<User> groupMembers = new List<User>();
|
||||
groupMembers.Add(currentConnectedUser);
|
||||
|
||||
profileNetworkInfoService.CreateGroupToRepository(newGroupNameTextBox.Text, groupMembers);
|
||||
profile.Groups.Add(profileNetworkInfoService.GetGroupByName(newGroupNameTextBox.Text));
|
||||
profileNetworkInfoService.SaveDataIntoXML();
|
||||
|
||||
PopulateAllGroupsList();
|
||||
PopulateGroupsForCurrentUser();
|
||||
PopulateGroupMemberForSelectedGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddMemberToSpecificGroupButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (addMemberToSelectedGroupTextBox.Text != string.Empty && currentUserGroupsListView.SelectedItems.Count > 0)
|
||||
{
|
||||
string selectedGroup = currentUserGroupsListView.SelectedItem.ToString();
|
||||
|
||||
if (profileNetworkInfoService.GetUserByName(addMemberToSelectedGroupTextBox.Text) != null && profileNetworkInfoService.GetGroupByName(selectedGroup) != null)
|
||||
{
|
||||
UserProfileSocialNetworkInfo profile = profileNetworkInfoService.GetProfileSocialNetworkInfoCurrentUser(currentConnectedUser);
|
||||
|
||||
if (profileNetworkInfoService.AddMemberToGroup(selectedGroup, profileNetworkInfoService.GetUserByName(addMemberToSelectedGroupTextBox.Text)))
|
||||
{
|
||||
UserProfileSocialNetworkInfo addedMemberProfile = profileNetworkInfoService.GetProfileSocialNetworkInfoByUser(addMemberToSelectedGroupTextBox.Text);
|
||||
if (addedMemberProfile != null)
|
||||
{
|
||||
addedMemberProfile.Groups.Add(profileNetworkInfoService.GetGroupByName(selectedGroup));
|
||||
profileNetworkInfoService.AddMemberToGroupProfile(profile, selectedGroup, addMemberToSelectedGroupTextBox.Text);
|
||||
|
||||
profileNetworkInfoService.SaveDataIntoXML();
|
||||
|
||||
PopulateGroupMemberForSelectedGroup();
|
||||
PopulateGroupsForCurrentUser();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Profile of give user not found, try again", "error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user