Browse Source

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

ГаряевСА 1 month ago
parent
commit
8b1137f1a1

+ 25 - 0
Captcha.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}") = "Captcha", "Captcha\Captcha.csproj", "{11E09CFD-53CA-4828-876B-E6547901B19A}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{11E09CFD-53CA-4828-876B-E6547901B19A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{11E09CFD-53CA-4828-876B-E6547901B19A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{11E09CFD-53CA-4828-876B-E6547901B19A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{11E09CFD-53CA-4828-876B-E6547901B19A}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {5340157B-5777-44CC-82D9-2BF7B5208BBC}
+	EndGlobalSection
+EndGlobal

+ 16 - 0
Captcha/App.axaml

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

+ 29 - 0
Captcha/App.axaml.cs

@@ -0,0 +1,29 @@
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+using Captcha.ViewModels;
+using Captcha.Views;
+
+namespace Captcha
+{
+    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
Captcha/Assets/avalonia-logo.ico


+ 24 - 0
Captcha/Captcha.csproj

@@ -0,0 +1,24 @@
+<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>
+    <AvaloniaResource Include="Assets\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Avalonia" Version="11.1.0" />
+    <PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
+    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
+    <PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.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.1.0" />
+    <PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0" />
+  </ItemGroup>
+</Project>

+ 17 - 0
Captcha/Models/ModelClass.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Captcha.Models
+{
+    internal class ModelClass
+    {
+        static string _login = "timan_cool";
+        static string _password = "10082005";
+
+        public static string Login { get => _login; set => _login = value; }
+        public static string Password { get => _password; set => _password = value; }
+    }
+}

+ 24 - 0
Captcha/Program.cs

@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.ReactiveUI;
+using System;
+
+namespace Captcha
+{
+    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();
+    }
+}

+ 32 - 0
Captcha/StylesCaptcha.axaml

@@ -0,0 +1,32 @@
+<Styles xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+  <Design.PreviewWith>
+    <Border Padding="20">
+      <!-- Add Controls for Previewer Here -->
+    </Border>
+  </Design.PreviewWith>
+
+  <!-- Add Styles Here -->
+
+	<Style Selector="Button">
+		<Setter Property="Background" Value="DarkGreen"/>
+		<Setter Property="Foreground" Value="WhiteSmoke"/>
+	</Style>
+	<Style Selector="TextBlock">
+		<Setter Property="FontSize" Value="16"/>
+		<Setter Property="Foreground" Value="DarkGreen"/>
+		<Setter Property="FontWeight" Value="Bold"/>
+	</Style>
+	<Style Selector="Border.trash">
+		<Setter Property="Background" Value="White"/>
+		<Setter Property="BorderBrush" Value="LightGray"/>
+		<Setter Property="BorderThickness" Value="2"/>
+		<Setter Property="CornerRadius" Value="16"/>
+	</Style>
+	<Style Selector="Label">
+		<Setter Property="FontSize" Value="16"/>
+		<Setter Property="Foreground" Value="DarkGreen"/>
+		<Setter Property="FontWeight" Value="Bold"/>
+	</Style>
+	
+</Styles>

+ 34 - 0
Captcha/ViewLocator.cs

@@ -0,0 +1,34 @@
+using Avalonia.Controls;
+using Avalonia.Controls.Templates;
+using Captcha.ViewModels;
+using System;
+
+namespace Captcha
+{
+    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;
+        }
+    }
+}

+ 40 - 0
Captcha/ViewModels/MainWindowViewModel.cs

@@ -0,0 +1,40 @@
+using Captcha.Models;
+using ReactiveUI;
+using System.Numerics;
+
+namespace Captcha.ViewModels
+{
+    public class MainWindowViewModel : ViewModelBase
+    {
+#pragma warning disable CA1822 // Mark members as static
+        public MainWindowViewModel()
+        {
+        }
+            
+        string login = "";
+        string password = "";
+        string message = "";
+        bool butVis = true;
+
+        public string Message { get => message; set => this.RaiseAndSetIfChanged(ref message, value); }
+        public string Login { get => login; set => login = value; }
+        public string Password { get => password; set => password = value; }
+        public bool ButVis { get => butVis; set => this.RaiseAndSetIfChanged(ref butVis, value); }
+
+        public void Authorization()
+        {
+            if (login == ModelClass.Login && password == ModelClass.Password)
+            {
+                Message = "Авторизация прошла успешно";
+
+            }
+            else
+            {
+                Message = "Неверный логин или пароль";
+                ButVis = false;
+            }
+        }
+
+#pragma warning restore CA1822 // Mark members as static
+    }
+}

+ 9 - 0
Captcha/ViewModels/ViewModelBase.cs

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

+ 43 - 0
Captcha/Views/MainWindow.axaml

@@ -0,0 +1,43 @@
+<Window xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:vm="using:Captcha.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="Captcha.Views.MainWindow"
+        x:DataType="vm:MainWindowViewModel"
+        Icon="/Assets/avalonia-logo.ico"
+        Title="Captcha">
+
+    <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>
+
+	<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
+		<StackPanel Name="Login" Margin="20">
+			<Border Classes = "trash" Padding="40">
+				<StackPanel >
+					<StackPanel HorizontalAlignment="Center">
+						<TextBlock Margin="0,0,40,20" >
+							Авторизация
+						</TextBlock>
+					</StackPanel>
+					<StackPanel >
+						<TextBlock>Логин:</TextBlock>
+						<TextBox Text="{Binding Login}"></TextBox>
+						<TextBlock >Пароль:</TextBlock>
+						<TextBox Text="{Binding Password}" PasswordChar="*"/>
+						<Button HorizontalAlignment="Center" Content="Войти" Command="{Binding Authorization}" IsDefault="True" IsVisible="{Binding ButVis}"/>
+						<Label Content="{Binding Message}"/>
+					</StackPanel>
+				</StackPanel>
+			</Border>
+		</StackPanel>
+		<StackPanel Margin="20">
+			<Border Classes = "trash" Padding="40">
+			</Border>
+		</StackPanel>
+	</StackPanel>
+</Window>

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

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

+ 18 - 0
Captcha/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="Captcha.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>