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,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>
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B