Fix task-20.11 folder
This commit is contained in:
-1
Submodule task-20.11 deleted from 9c3e04c2e9
@@ -0,0 +1,34 @@
|
||||
# Common IntelliJ Platform excludes
|
||||
|
||||
# User specific
|
||||
**/.idea/**/workspace.xml
|
||||
**/.idea/**/tasks.xml
|
||||
**/.idea/shelf/*
|
||||
**/.idea/dictionaries
|
||||
**/.idea/httpRequests/
|
||||
|
||||
# Sensitive or high-churn files
|
||||
**/.idea/**/dataSources/
|
||||
**/.idea/**/dataSources.ids
|
||||
**/.idea/**/dataSources.xml
|
||||
**/.idea/**/dataSources.local.xml
|
||||
**/.idea/**/sqlDataSources.xml
|
||||
**/.idea/**/dynamic.xml
|
||||
|
||||
# Rider
|
||||
# Rider auto-generates .iml files, and contentModel.xml
|
||||
**/.idea/**/*.iml
|
||||
**/.idea/**/contentModel.xml
|
||||
**/.idea/**/modules.xml
|
||||
|
||||
*.suo
|
||||
*.user
|
||||
.vs/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
_UpgradeReport_Files/
|
||||
[Pp]ackages/
|
||||
|
||||
Thumbs.db
|
||||
Desktop.ini
|
||||
.DS_Store
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Rider ignored files
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.DemoCats.iml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
+1
@@ -0,0 +1 @@
|
||||
DemoCats
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoCats", "DemoCats\DemoCats.csproj", "{EE2D0DF2-EA86-45FB-9F87-F0EC0B53FAC7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EE2D0DF2-EA86-45FB-9F87-F0EC0B53FAC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE2D0DF2-EA86-45FB-9F87-F0EC0B53FAC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE2D0DF2-EA86-45FB-9F87-F0EC0B53FAC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE2D0DF2-EA86-45FB-9F87-F0EC0B53FAC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,10 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="DemoCats.App"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
@@ -0,0 +1,23 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace DemoCats;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<RootNamespace>DemoCatas</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="12.1.4"/>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="12.1.4"/>
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.1.4"/>
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.1.4"/>
|
||||
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3">
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="DemoCats.MainWindow"
|
||||
Title="DemoCat">
|
||||
<StackPanel Spacing="5" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
|
||||
<TextBlock Text="Введите логин"/>
|
||||
<TextBox Name="LoginBox"/>
|
||||
<TextBlock Text="Введите пароль"/>
|
||||
<TextBox Name="PasswordBox"/>
|
||||
<TextBlock Name="Error"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Войти" Click="LoginButton_OnClick"/>
|
||||
<Button Content="Войти как гость" Click="GuestButton_OnClick"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace DemoCats;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoginButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var email = LoginBox.Text;
|
||||
var password = PasswordBox.Text;
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
Error.Text = "Пароль или логин пустые";
|
||||
return;
|
||||
}
|
||||
var user = Users._users.FirstOrDefault(i => i.Email == email);
|
||||
if (user == null)
|
||||
{
|
||||
Error.Text = "Пользователь не найден";
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.Password != password)
|
||||
{
|
||||
Error.Text = "Неправильный пароль";
|
||||
return;
|
||||
}
|
||||
new UsersWindow(user).Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void GuestButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
new UsersWindow(null).Show();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace DemoCats;
|
||||
|
||||
class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
#if DEBUG
|
||||
.WithDeveloperTools()
|
||||
#endif
|
||||
.WithInterFont()
|
||||
.LogToTrace();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DemoCats;
|
||||
|
||||
public class Users
|
||||
{
|
||||
public static List<User> _users = [
|
||||
new User(1, "Кошка Кошковна", "koshka@mur.ru", "meow123", "admin"),
|
||||
new User(2, "Киса Мурлыковна", "kisa@meow.com", "purrfect99", "manager"),
|
||||
new User(3, "Кот Матроскин", "matroskin@prostokvasha.ru", "milk_lover", "user"),
|
||||
new User(4, "Мурка Цараповна", "murka@scratch.net", "fish_stealer", "user"),
|
||||
new User(5, "Барсик Пушистович", "barsik@fluffy.org", "sleep_all_day", "user"),
|
||||
new User(6, "Васька Сметанович", "vasya@sourcream.ru", "tasty_cream7", "admin")
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:model ="clr-namespace:DemoCats"
|
||||
x:Class="DemoCats.UsersWindow"
|
||||
Title="UsersWindow">
|
||||
<Grid RowDefinitions="Auto, *, Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox TextChanged="SearchBox_OnTextChanged" Width="300" Name="SearchBox"/>
|
||||
<ComboBox SelectionChanged="FilterBox_OnSelectionChanged" Width="200" Name="FilterBox">
|
||||
<ComboBoxItem>Без фильтрации</ComboBoxItem>
|
||||
<ComboBoxItem>.com</ComboBoxItem>
|
||||
<ComboBoxItem>.ru</ComboBoxItem>
|
||||
<ComboBoxItem>.net</ComboBoxItem>
|
||||
<ComboBoxItem>.org</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox SelectionChanged="SortBox_OnSelectionChanged" Width="200" Name="SortBox">
|
||||
<ComboBoxItem>Без сортировки</ComboBoxItem>
|
||||
<ComboBoxItem>По убыванию</ComboBoxItem>
|
||||
<ComboBoxItem>По возрастанию</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<ListBox Name="UserListBox" Grid.Row="1">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="model:User">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Id}"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
<TextBlock Text="{Binding Email}"/>
|
||||
<TextBlock Text="{Binding Password}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock Grid.Row="2" Name="UserProfile"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace DemoCats;
|
||||
public record User(int Id, string Name, string Email, string Password, string Role);
|
||||
|
||||
public partial class UsersWindow : Window
|
||||
{
|
||||
// Наблюдаемая коллекция, которая автоматически уведомляет интерфейс (ListBox) при изменении элементов
|
||||
private ObservableCollection<User> UsersCollecction = new();
|
||||
public UsersWindow(User? user)
|
||||
{
|
||||
InitializeComponent();
|
||||
// Привязка коллекции UsersCollecction как источника данных для элемента списка UserListBox
|
||||
UserListBox.ItemsSource = UsersCollecction;
|
||||
ShowUsers();
|
||||
switch (user?.Role)
|
||||
{
|
||||
case "admin":
|
||||
{
|
||||
UserProfile.Text = $"{user.Name} - Администратор";
|
||||
break;
|
||||
}
|
||||
case "user":
|
||||
{
|
||||
UserProfile.Text = $"{user.Name} - Ползователь";
|
||||
GuestOrUserView();
|
||||
break;
|
||||
}
|
||||
case "manger":
|
||||
{
|
||||
UserProfile.Text = $"{user.Name} - Менеджер";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
UserProfile.Text = $"Вы зашли как гость";
|
||||
GuestOrUserView();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Метод, который делает неактивными фильтр, сортировку и поиск
|
||||
private void GuestOrUserView()
|
||||
{
|
||||
FilterBox.IsEnabled = false;
|
||||
SortBox.IsEnabled = false;
|
||||
SearchBox.IsEnabled = false;
|
||||
}
|
||||
// Главный метод
|
||||
private void ShowUsers()
|
||||
{
|
||||
IEnumerable<User> users = Users._users;
|
||||
var filterItem = FilterBox.SelectionBoxItem as string;
|
||||
if (!string.IsNullOrWhiteSpace(filterItem) && filterItem != "Без фильтрации")
|
||||
{
|
||||
users = users.Where(u => u.Email.EndsWith(filterItem));
|
||||
}
|
||||
|
||||
// Проверяем, введено ли что-то в строку поиска
|
||||
var search = SearchBox.Text;
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
// Оставляем только тех, у кого в почте есть введенные буквы
|
||||
users = users.Where(u => u.Email.Contains(search));
|
||||
}
|
||||
|
||||
// Смотрим, какая выбрана сортировка, и меняем порядок пользователей по почте
|
||||
var sort = SortBox.SelectionBoxItem as string;
|
||||
switch (sort)
|
||||
{
|
||||
case "По возрастанию": users = users.OrderBy(u => u.Email); break;
|
||||
case "По убыванию": users = users.OrderByDescending(u => u.Email); break;
|
||||
}
|
||||
|
||||
// Очищаем старый список на экране
|
||||
UsersCollecction.Clear();
|
||||
// Заполняем экран новым, уже отфильтрованным списком
|
||||
foreach (var user in users) UsersCollecction.Add(user);
|
||||
}
|
||||
|
||||
private void FilterBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ShowUsers();
|
||||
}
|
||||
|
||||
private void SortBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ShowUsers();
|
||||
}
|
||||
|
||||
private void SearchBox_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
ShowUsers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<!-- This manifest is used on Windows only.
|
||||
Don't remove it as it might cause problems with window transparency and embedded controls.
|
||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||
<assemblyIdentity version="1.0.0.0" name="DemoCatas.Desktop"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user