School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,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>
@@ -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());
}
}
}
}
@@ -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>
@@ -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;
}
}
}
}
@@ -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>
@@ -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;
}
}
}
@@ -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>
@@ -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();
}
}
}
@@ -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>
@@ -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();
}
}
}