Răsfoiți Sursa

Добавьте файлы проекта.

ПроваленкоЛН 2 săptămâni în urmă
părinte
comite
16f542cd53
29 a modificat fișierele cu 819 adăugiri și 0 ștergeri
  1. 25 0
      AvaloniaApplication2.sln
  2. 15 0
      AvaloniaApplication2/App.axaml
  3. 29 0
      AvaloniaApplication2/App.axaml.cs
  4. BIN
      AvaloniaApplication2/Assets/avalonia-logo.ico
  5. 30 0
      AvaloniaApplication2/AvaloniaApplication2.csproj
  6. 13 0
      AvaloniaApplication2/Models/Role.cs
  7. 21 0
      AvaloniaApplication2/Models/User.cs
  8. 69 0
      AvaloniaApplication2/Models/_43pProvalenko2Context.cs
  9. 24 0
      AvaloniaApplication2/Program.cs
  10. 34 0
      AvaloniaApplication2/ViewLocator.cs
  11. 114 0
      AvaloniaApplication2/ViewModels/AdminRegVM.cs
  12. 31 0
      AvaloniaApplication2/ViewModels/AuthVM.cs
  13. 48 0
      AvaloniaApplication2/ViewModels/MainWindowViewModel.cs
  14. 20 0
      AvaloniaApplication2/ViewModels/PersonalVM.cs
  15. 116 0
      AvaloniaApplication2/ViewModels/RegVM.cs
  16. 8 0
      AvaloniaApplication2/ViewModels/ViewModelBase.cs
  17. 28 0
      AvaloniaApplication2/Views/AdminReg.axaml
  18. 15 0
      AvaloniaApplication2/Views/AdminReg.axaml.cs
  19. 10 0
      AvaloniaApplication2/Views/Auth.axaml
  20. 13 0
      AvaloniaApplication2/Views/Auth.axaml.cs
  21. 16 0
      AvaloniaApplication2/Views/AuthAndReg.axaml
  22. 13 0
      AvaloniaApplication2/Views/AuthAndReg.axaml.cs
  23. 22 0
      AvaloniaApplication2/Views/MainWindow.axaml
  24. 12 0
      AvaloniaApplication2/Views/MainWindow.axaml.cs
  25. 10 0
      AvaloniaApplication2/Views/Personal.axaml
  26. 21 0
      AvaloniaApplication2/Views/Personal.axaml.cs
  27. 31 0
      AvaloniaApplication2/Views/RegUser.axaml
  28. 13 0
      AvaloniaApplication2/Views/RegUser.axaml.cs
  29. 18 0
      AvaloniaApplication2/app.manifest

+ 25 - 0
AvaloniaApplication2.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35219.272
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaApplication2", "AvaloniaApplication2\AvaloniaApplication2.csproj", "{0A9C50EC-F3A7-4199-9F47-E338FFC6DC46}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0A9C50EC-F3A7-4199-9F47-E338FFC6DC46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0A9C50EC-F3A7-4199-9F47-E338FFC6DC46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0A9C50EC-F3A7-4199-9F47-E338FFC6DC46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0A9C50EC-F3A7-4199-9F47-E338FFC6DC46}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {32E6F72A-5B78-4E27-8DC2-ABC66B67B169}
+	EndGlobalSection
+EndGlobal

+ 15 - 0
AvaloniaApplication2/App.axaml

@@ -0,0 +1,15 @@
+<Application xmlns="https://github.com/avaloniaui"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             x:Class="AvaloniaApplication2.App"
+             xmlns:local="using:AvaloniaApplication2"
+             RequestedThemeVariant="Default">
+             <!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
+
+    <Application.DataTemplates>
+        <local:ViewLocator/>
+    </Application.DataTemplates>
+  
+    <Application.Styles>
+        <FluentTheme />
+    </Application.Styles>
+</Application>

+ 29 - 0
AvaloniaApplication2/App.axaml.cs

@@ -0,0 +1,29 @@
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.ViewModels;
+using AvaloniaApplication2.Views;
+
+namespace AvaloniaApplication2
+{
+    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
+                {
+                    DataContext = new MainWindowViewModel(),
+                };
+            }
+
+            base.OnFrameworkInitializationCompleted();
+        }
+    }
+}

BIN
AvaloniaApplication2/Assets/avalonia-logo.ico


+ 30 - 0
AvaloniaApplication2/AvaloniaApplication2.csproj

@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net8.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
+    <ApplicationManifest>app.manifest</ApplicationManifest>
+    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Folder Include="Models\" />
+    <AvaloniaResource Include="Assets\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Avalonia" Version="11.2.0" />
+    <PackageReference Include="Avalonia.Desktop" Version="11.2.0" />
+    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.0" />
+    <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.0" />
+    <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
+    <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.0" />
+    <PackageReference Include="Avalonia.ReactiveUI" Version="11.2.0" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
+  </ItemGroup>
+</Project>

+ 13 - 0
AvaloniaApplication2/Models/Role.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace AvaloniaApplication2.Models;
+
+public partial class Role
+{
+    public long Id { get; set; }
+
+    public string? Role1 { get; set; }
+
+    public virtual ICollection<User> Users { get; set; } = new List<User>();
+}

+ 21 - 0
AvaloniaApplication2/Models/User.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace AvaloniaApplication2.Models;
+
+public partial class User
+{
+    public long Id { get; set; }
+
+    public string? Fio { get; set; }
+
+    public string? Login { get; set; }
+
+    public byte[]? Password { get; set; }
+
+    public long Role { get; set; }
+
+    public byte[]? Image { get; set; }
+
+    public virtual Role RoleNavigation { get; set; } = null!;
+}

+ 69 - 0
AvaloniaApplication2/Models/_43pProvalenko2Context.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
+
+namespace AvaloniaApplication2.Models;
+
+public partial class _43pProvalenko2Context : DbContext
+{
+    public _43pProvalenko2Context()
+    {
+    }
+
+    public _43pProvalenko2Context(DbContextOptions<_43pProvalenko2Context> options)
+        : base(options)
+    {
+    }
+
+    public virtual DbSet<Role> Roles { get; set; }
+
+    public virtual DbSet<User> Users { get; set; }
+
+    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
+        => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=43P_Provalenko2;Username=43P;Password=444444");
+
+    protected override void OnModelCreating(ModelBuilder modelBuilder)
+    {
+        modelBuilder.Entity<Role>(entity =>
+        {
+            entity.HasKey(e => e.Id).HasName("role_pk");
+
+            entity.ToTable("role");
+
+            entity.Property(e => e.Id).HasColumnName("id");
+            entity.Property(e => e.Role1)
+                .HasColumnType("character varying")
+                .HasColumnName("role");
+        });
+
+        modelBuilder.Entity<User>(entity =>
+        {
+            entity.HasKey(e => e.Id).HasName("users_pk");
+
+            entity.ToTable("users");
+
+            entity.Property(e => e.Id).HasColumnName("id");
+            entity.Property(e => e.Fio)
+                .HasColumnType("character varying")
+                .HasColumnName("fio");
+            entity.Property(e => e.Image).HasColumnName("image");
+            entity.Property(e => e.Login)
+                .HasColumnType("character varying")
+                .HasColumnName("login");
+            entity.Property(e => e.Password).HasColumnName("password");
+            entity.Property(e => e.Role)
+                .ValueGeneratedOnAdd()
+                .HasColumnName("role");
+
+            entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Users)
+                .HasForeignKey(d => d.Role)
+                .OnDelete(DeleteBehavior.ClientSetNull)
+                .HasConstraintName("users_role_fk");
+        });
+
+        OnModelCreatingPartial(modelBuilder);
+    }
+
+    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+}

+ 24 - 0
AvaloniaApplication2/Program.cs

@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.ReactiveUI;
+using System;
+
+namespace AvaloniaApplication2
+{
+    internal sealed 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()
+                .WithInterFont()
+                .LogToTrace()
+                .UseReactiveUI();
+    }
+}

+ 34 - 0
AvaloniaApplication2/ViewLocator.cs

@@ -0,0 +1,34 @@
+using Avalonia.Controls;
+using Avalonia.Controls.Templates;
+using AvaloniaApplication2.ViewModels;
+using System;
+
+namespace AvaloniaApplication2
+{
+    public class ViewLocator : IDataTemplate
+    {
+
+        public Control? Build(object? data)
+        {
+            if (data is null)
+                return null;
+
+            var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
+            var type = Type.GetType(name);
+
+            if (type != null)
+            {
+                var control = (Control)Activator.CreateInstance(type)!;
+                control.DataContext = data;
+                return control;
+            }
+
+            return new TextBlock { Text = "Not Found: " + name };
+        }
+
+        public bool Match(object? data)
+        {
+            return data is ViewModelBase;
+        }
+    }
+}

+ 114 - 0
AvaloniaApplication2/ViewModels/AdminRegVM.cs

@@ -0,0 +1,114 @@
+using AvaloniaApplication2.Models;
+using ReactiveUI;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Security.Cryptography;
+using System.Text.RegularExpressions;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Platform.Storage;
+using Avalonia;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    internal class AdminRegVM : ViewModelBase
+    {
+        public void Reg()
+        {           
+            if (_visible)
+            {
+                bool valid = IsPasswordValid(_pass);
+                if (valid)
+                {
+                    if (_pass != string.Empty)
+                    {
+                        NewUser.Password = MD5.HashData(Encoding.ASCII.GetBytes(_pass));
+                    }
+                    NewUser.Role = 2;
+                    MainWindowViewModel.myconnection.Users.Add(NewUser);
+                    MainWindowViewModel.myconnection.SaveChanges();
+                    MainWindowViewModel.Instance.Page = new AuthAndReg();
+                }
+            }
+            Visible = true;            
+        }
+
+        public async Task AddPhoto()
+        {
+            if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desctop || desctop.MainWindow?.StorageProvider is not { } provider) throw new NullReferenceException("провайдер отсутствует");
+
+            var file = await provider.OpenFilePickerAsync(
+                new FilePickerOpenOptions()
+                {
+                    Title = "Выберите изображение",
+                    AllowMultiple = false,
+                    FileTypeFilter = [FilePickerFileTypes.All, FilePickerFileTypes.ImageAll]
+                }
+                );
+            if (file != null)
+            {
+                await using var readStream = await file[0].OpenReadAsync();
+                byte[] buffer = new byte[readStream.Length];
+                readStream.ReadAtLeast(buffer, 1);
+                NewUser.Image = buffer;
+                Addimage = "Изображение выбрано";
+            }
+        }
+
+        private bool _visible = false;
+
+        public bool Visible { get => _visible; set => this.RaiseAndSetIfChanged(ref _visible, value); }
+        public User NewUser { get => _NewUser; set => this.RaiseAndSetIfChanged(ref _NewUser, value); }
+
+        User _NewUser = new User();
+
+        string _pass;
+        string _errorMessage;
+        string _addimage;
+        public string Pass { get => _pass; set => _pass = value; }
+        public string ErrorMessage { get => _errorMessage; set => this.RaiseAndSetIfChanged(ref _errorMessage,value); }
+        public string Addimage { get => _addimage; set => this.RaiseAndSetIfChanged(ref _addimage, value); }
+
+        private bool IsPasswordValid(string password)
+        {
+            string pattern = @"^(?=.*[A-Z].*[A-Z])(?=.*[a-z].*[a-z].*[a-z])(?=.*\d.*\d)(?!\d)[A-Za-z\d!""#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]{8,}$";
+            Regex regex = new Regex(pattern);
+
+            if (string.IsNullOrEmpty(password))
+            {
+                ErrorMessage = "Пароль не может быть пустым.";
+                return false;
+            }
+
+            if (!regex.IsMatch(password))
+            {
+                if (password.Length < 8)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 8 символов.";
+                }
+                else if (password[0] >= '0' && password[0] <= '9')
+                {
+                    ErrorMessage = "Пароль не должен начинаться с цифры.";
+                }
+                else if (Regex.Matches(password, @"[A-Z]").Count < 2)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 2 заглавных латинских символов.";
+                }
+                else if (Regex.Matches(password, @"[a-z]").Count < 3)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 3 строчных латинских символов.";
+                }
+                else if (Regex.Matches(password, @"\d").Count < 2)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 2 цифр.";
+                }
+
+                return false;
+            }
+
+            return true;
+        }
+    }
+}

+ 31 - 0
AvaloniaApplication2/ViewModels/AuthVM.cs

@@ -0,0 +1,31 @@
+using AvaloniaApplication2.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    internal class AuthVM:ViewModelBase
+    {
+        string _login = "";
+        string _password = "";
+
+        public string Login { get => _login; set => _login = value; }
+        public string Password { get => _password; set => _password = value; }
+
+        public void AutoUser()
+        {
+            byte[] _hashPassword = MD5.HashData(Encoding.ASCII.GetBytes(_password));
+            User user = MainWindowViewModel.myconnection.Users.Include(x => x.RoleNavigation).FirstOrDefault(x => x.Login == _login && x.Password == _hashPassword);
+            if (user != null)
+            {
+                MainWindowViewModel.Instance.Page = new Personal(user);
+            }
+
+        }
+    }
+}

+ 48 - 0
AvaloniaApplication2/ViewModels/MainWindowViewModel.cs

@@ -0,0 +1,48 @@
+using Avalonia.Collections;
+using Avalonia.Controls;
+using AvaloniaApplication2.Models;
+using Microsoft.VisualBasic;
+using ReactiveUI;
+using System.Linq;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    public class MainWindowViewModel : ViewModelBase
+    {
+        public static _43pProvalenko2Context myconnection = new _43pProvalenko2Context();
+
+        public static MainWindowViewModel Instance;
+
+        public MainWindowViewModel()
+        {
+            Instance = this;
+
+            if (AdminExists())
+            {
+                Page = new AuthAndReg(); // Если администратор есть, открываем страницу Auth
+            }
+            else
+            {
+                Page = new AdminReg(); // Если администратора нет, открываем страницу AdminReg
+            }
+        }
+        private UserControl page;
+
+        public UserControl Page { get => page; set => this.RaiseAndSetIfChanged(ref page, value); }
+
+        public void Reg()
+        {
+            Page = new RegUser();
+        }
+
+        public void Auth()
+        {
+            Page = new Auth();
+        }
+
+        private bool AdminExists()
+        {
+            return myconnection.Users.Any(user => user.Role == 2); 
+        }
+    }
+}

+ 20 - 0
AvaloniaApplication2/ViewModels/PersonalVM.cs

@@ -0,0 +1,20 @@
+using AvaloniaApplication2.Models;
+using ReactiveUI;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    internal class PersonalVM : ViewModelBase
+    {
+        User _user;
+        public User User { get => _user; set => this.RaiseAndSetIfChanged(ref _user, value); }
+        public PersonalVM(User user)
+        {
+            User = user;
+        }
+    }
+}

+ 116 - 0
AvaloniaApplication2/ViewModels/RegVM.cs

@@ -0,0 +1,116 @@
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Platform.Storage;
+using AvaloniaApplication2.Models;
+using ReactiveUI;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    internal class RegVM : ViewModelBase
+    {
+        public void Reg()
+        {
+            bool valid = IsPasswordValid(_pass);
+            
+                if (!MainWindowViewModel.myconnection.Users.Any(user => user.Login == NewUser.Login))
+                {
+                if (valid)
+                {
+                    if (_pass != string.Empty)
+                    {
+                        NewUser.Password = MD5.HashData(Encoding.ASCII.GetBytes(_pass));
+                    }
+                    NewUser.Role = 1;
+                    MainWindowViewModel.myconnection.Users.Add(NewUser);
+                    MainWindowViewModel.myconnection.SaveChanges();
+                    MainWindowViewModel.Instance.Page = new AuthAndReg();
+                }
+                else
+                {
+                    ErrorMessage = "Логин занят";
+                }
+            }
+        }
+
+        public async Task AddPhoto()
+        {
+            if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desctop || desctop.MainWindow?.StorageProvider is not { } provider) throw new NullReferenceException("провайдер отсутствует");
+
+            var file = await provider.OpenFilePickerAsync(
+                new FilePickerOpenOptions()
+                {
+                    Title = "Выберите изображение",
+                    AllowMultiple = false,
+                    FileTypeFilter = [FilePickerFileTypes.All, FilePickerFileTypes.ImageAll]
+                }
+                );
+            if (file != null)
+            {
+                await using var readStream = await file[0].OpenReadAsync();
+                byte[] buffer = new byte[readStream.Length];
+                readStream.ReadAtLeast(buffer, 1);
+                NewUser.Image = buffer;
+                Addimage = "Изображение выбрано";
+            }
+        }
+    
+        public User NewUser { get => _NewUser; set => this.RaiseAndSetIfChanged(ref _NewUser, value); }
+
+        User _NewUser = new User();
+
+        string _pass;
+        string _errorMessage;
+        string _addimage;
+        public string Pass { get => _pass; set => _pass = value; }
+        public string ErrorMessage { get => _errorMessage; set => this.RaiseAndSetIfChanged(ref _errorMessage, value); }
+        public string Addimage { get => _addimage; set => this.RaiseAndSetIfChanged(ref _addimage, value); }
+
+        private bool IsPasswordValid(string password)
+        {
+            string pattern = @"^(?=.*[A-Z].*[A-Z])(?=.*[a-z].*[a-z].*[a-z])(?=.*\d.*\d)(?!\d)[A-Za-z\d!""#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]{8,}$";
+            Regex regex = new Regex(pattern);
+
+            if (string.IsNullOrEmpty(password))
+            {
+                ErrorMessage = "Пароль не может быть пустым.";
+                return false;
+            }
+
+            if (!regex.IsMatch(password))
+            {
+                if (password.Length < 8)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 8 символов.";
+                }
+                else if (password[0] >= '0' && password[0] <= '9')
+                {
+                    ErrorMessage = "Пароль не должен начинаться с цифры.";
+                }
+                else if (Regex.Matches(password, @"[A-Z]").Count < 2)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 2 заглавных латинских символов.";
+                }
+                else if (Regex.Matches(password, @"[a-z]").Count < 3)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 3 строчных латинских символов.";
+                }
+                else if (Regex.Matches(password, @"\d").Count < 2)
+                {
+                    ErrorMessage = "Пароль должен содержать не менее 2 цифр.";
+                }
+
+                return false;
+            }
+
+            return true;
+        }
+    }
+}
+

+ 8 - 0
AvaloniaApplication2/ViewModels/ViewModelBase.cs

@@ -0,0 +1,8 @@
+using ReactiveUI;
+
+namespace AvaloniaApplication2.ViewModels
+{
+    public class ViewModelBase : ReactiveObject
+    {
+    }
+}

+ 28 - 0
AvaloniaApplication2/Views/AdminReg.axaml

@@ -0,0 +1,28 @@
+<UserControl 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:vm="using:AvaloniaApplication2.ViewModels"
+			 x:DataType="vm:AdminRegVM"
+             x:Class="AvaloniaApplication2.AdminReg">
+ 
+	<Grid>
+		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+			<TextBlock Text="{Binding ErrorMessage}"></TextBlock>
+			<TextBox Text="{Binding NewUser.Fio}" IsVisible="{Binding Visible}" Watermark="ФИО"></TextBox>
+			<TextBox Text="{Binding NewUser.Login}" IsVisible="{Binding Visible}" Watermark="Логин"></TextBox>
+			<TextBox Text="{Binding Pass}" IsVisible="{Binding Visible}" Watermark="Пароль"></TextBox>
+			<TextBlock Text="{Binding Addimage}" IsVisible="{Binding Visible}"></TextBlock>
+			<Button  IsVisible="{Binding Visible}" Command="{Binding AddPhoto}">
+				<TextBlock Text="Добавить изображение">
+				</TextBlock>
+			</Button>
+			<Button Command="{Binding Reg}">
+				<TextBlock Text="Зарегистрировать администратора">
+					</TextBlock>
+			</Button>
+		</StackPanel>
+	</Grid>
+	
+</UserControl>

+ 15 - 0
AvaloniaApplication2/Views/AdminReg.axaml.cs

@@ -0,0 +1,15 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.ViewModels;
+
+namespace AvaloniaApplication2;
+
+public partial class AdminReg : UserControl
+{
+    public AdminReg()
+    {
+        InitializeComponent();
+        DataContext = new AdminRegVM();
+    }
+}

+ 10 - 0
AvaloniaApplication2/Views/Auth.axaml

@@ -0,0 +1,10 @@
+<UserControl xmlns="https://github.com/avaloniaui"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+			 xmlns:vm="using:AvaloniaApplication2.ViewModels"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+			 x:DataType="vm:AuthVM"
+             x:Class="AvaloniaApplication2.Auth">
+  
+</UserControl>

+ 13 - 0
AvaloniaApplication2/Views/Auth.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace AvaloniaApplication2;
+
+public partial class Auth : UserControl
+{
+    public Auth()
+    {
+        InitializeComponent();
+    }
+}

+ 16 - 0
AvaloniaApplication2/Views/AuthAndReg.axaml

@@ -0,0 +1,16 @@
+<UserControl 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:vm="using:AvaloniaApplication2.ViewModels"
+			 x:DataType="vm:MainWindowViewModel"
+             x:Class="AvaloniaApplication2.AuthAndReg">
+
+	<Grid>
+		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+			<Button Command="{Binding Auth}"><TextBlock Text="Авторизация"></TextBlock></Button>
+			<Button Command="{Binding Reg}"><TextBlock Text="Регистрация"></TextBlock></Button>
+		</StackPanel>
+		</Grid>
+</UserControl>

+ 13 - 0
AvaloniaApplication2/Views/AuthAndReg.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace AvaloniaApplication2;
+
+public partial class AuthAndReg : UserControl
+{
+    public AuthAndReg()
+    {
+        InitializeComponent();
+    }
+}

+ 22 - 0
AvaloniaApplication2/Views/MainWindow.axaml

@@ -0,0 +1,22 @@
+<Window xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:vm="using:AvaloniaApplication2.ViewModels"
+        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="AvaloniaApplication2.Views.MainWindow"
+        x:DataType="vm:MainWindowViewModel"
+        Icon="/Assets/avalonia-logo.ico"
+        Title="AvaloniaApplication2">
+
+    <Design.DataContext>
+        <!-- This only sets the DataContext for the previewer in an IDE,
+             to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
+        <vm:MainWindowViewModel/>
+    </Design.DataContext>
+
+	<UserControl Content="{Binding Page}">
+
+	</UserControl>
+
+</Window>

+ 12 - 0
AvaloniaApplication2/Views/MainWindow.axaml.cs

@@ -0,0 +1,12 @@
+using Avalonia.Controls;
+
+namespace AvaloniaApplication2.Views
+{
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 10 - 0
AvaloniaApplication2/Views/Personal.axaml

@@ -0,0 +1,10 @@
+<UserControl 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"
+             xmlns:vm="using:AvaloniaApplication2.ViewModels"			
+			 mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+             x:Class="AvaloniaApplication2.Personal"
+			 x:DataType="vm:PersonalVM">
+ 
+</UserControl>

+ 21 - 0
AvaloniaApplication2/Views/Personal.axaml.cs

@@ -0,0 +1,21 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.Models;
+using AvaloniaApplication2.ViewModels;
+
+namespace AvaloniaApplication2;
+
+public partial class Personal : UserControl
+{
+    public Personal()
+    {
+        InitializeComponent();
+    }
+
+    public Personal(User user)
+    {
+        InitializeComponent();
+        DataContext = new PersonalVM(user);
+    }
+}

+ 31 - 0
AvaloniaApplication2/Views/RegUser.axaml

@@ -0,0 +1,31 @@
+<UserControl 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"
+			 xmlns:vm="using:AvaloniaApplication2.ViewModels"
+             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+			 x:DataType="vm:RegVM"
+             x:Class="AvaloniaApplication2.RegUser">
+
+	<Grid>
+		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+			<Grid>
+				<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+					<TextBlock Text="{Binding ErrorMessage}"></TextBlock>
+					<TextBox Text="{Binding NewUser.Fio}" Watermark="ФИО"></TextBox>
+					<TextBox Text="{Binding NewUser.Login}"  Watermark="Логин"></TextBox>
+					<TextBox Text="{Binding Pass}"  Watermark="Пароль"></TextBox>
+					<TextBlock Text="{Binding Addimage}" ></TextBlock>
+					<Button Command="{Binding AddPhoto}">
+						<TextBlock Text="Добавить изображение">
+						</TextBlock>
+					</Button>
+					<Button Command="{Binding Reg}">
+						<TextBlock Text="Зарегистрироватьcя">
+						</TextBlock>
+					</Button>
+				</StackPanel>
+			</Grid>
+		</StackPanel>
+	</Grid>
+</UserControl>

+ 13 - 0
AvaloniaApplication2/Views/RegUser.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace AvaloniaApplication2;
+
+public partial class RegUser : UserControl
+{
+    public RegUser()
+    {
+        InitializeComponent();
+    }
+}

+ 18 - 0
AvaloniaApplication2/app.manifest

@@ -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="AvaloniaApplication2.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>