Quellcode durchsuchen

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

БатраковаВВ vor 22 Stunden
Ursprung
Commit
7980052b62

+ 25 - 0
Capcha.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}") = "Capcha", "Capcha\Capcha.csproj", "{96BE0218-6D9B-4F63-A233-5666C94EAC5C}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{96BE0218-6D9B-4F63-A233-5666C94EAC5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{96BE0218-6D9B-4F63-A233-5666C94EAC5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{96BE0218-6D9B-4F63-A233-5666C94EAC5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{96BE0218-6D9B-4F63-A233-5666C94EAC5C}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {7C90F890-9C0E-4B9D-A325-E31C503629E0}
+	EndGlobalSection
+EndGlobal

+ 15 - 0
Capcha/App.axaml

@@ -0,0 +1,15 @@
+<Application xmlns="https://github.com/avaloniaui"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             x:Class="Capcha.App"
+             xmlns:local="using:Capcha"
+             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
Capcha/App.axaml.cs

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


+ 24 - 0
Capcha/Capcha.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>

+ 14 - 0
Capcha/Models/Users.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Capcha.Models
+{
+    internal class Users
+    {
+        public static string UserLogin = "admin";
+        public static string UserPassword = "adminadmin";
+    }
+}

+ 24 - 0
Capcha/Program.cs

@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.ReactiveUI;
+using System;
+
+namespace Capcha
+{
+    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
Capcha/ViewLocator.cs

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

+ 32 - 0
Capcha/ViewModels/MainWindowViewModel.cs

@@ -0,0 +1,32 @@
+using Capcha.Models;
+using ReactiveUI;
+
+namespace Capcha.ViewModels
+{
+    public class MainWindowViewModel : ViewModelBase
+    {
+
+        public MainWindowViewModel()
+        {
+
+        }
+#pragma warning disable CA1822 // Mark members as static
+        public string Greeting => "Welcome to Avalonia!";
+#pragma warning restore CA1822 // Mark members as static
+
+        private string _name = "";
+        private string _password = "";
+
+        public string _name {  get; set; }
+
+        
+        public void Check()
+        {
+              
+        }
+        public void LogIn()
+        {
+            
+        }
+    }
+}

+ 8 - 0
Capcha/ViewModels/ViewModelBase.cs

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

+ 27 - 0
Capcha/Views/MainWindow.axaml

@@ -0,0 +1,27 @@
+<Window xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:vm="using:Capcha.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="Capcha.Views.MainWindow"
+        x:DataType="vm:MainWindowViewModel"
+        Icon="/Assets/avalonia-logo.ico"
+        Title="Capcha">
+
+    <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" >
+	<!--<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
+	
+	<Label>Логин: </Label>
+	<TextBox Text="{Binding Check}" Margin="10"/>
+	<TextBlock  IsVisible="False"></TextBlock>
+	<Label>Пароль: </Label>
+    <TextBox Name="Password" Margin="10"/>
+	<Button Command="{Binding LogIn}"  Margin="10">Авторизоваться</Button>
+	</StackPanel>
+</Window>

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

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

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