Demo
@@ -1,31 +1,52 @@
|
||||
using AvaloniaPostrgresApp.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AvaloniaPostrgresApp;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<UserInfo> Users { get; set; } = null!;
|
||||
public DbSet<Tovar> Tovars { get; set; } = null!;
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
string connectionString = "Host=127.0.0.1;Port=5432;Database=postgres;Username=postgres;Password=mysecretpassword;Timeout=15;Command Timeout=15;Trust Server Certificate=true;SSL Mode=Prefer";
|
||||
string connectionString =
|
||||
"Host=127.0.0.1;Port=5432;Database=postgres;Username=postgres;Password=mysecretpassword;Timeout=15;Command Timeout=15;Trust Server Certificate=true;SSL Mode=Prefer";
|
||||
optionsBuilder.UseNpgsql(connectionString);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
modelBuilder.Entity<UserInfo>().ToTable("UserInfo");
|
||||
|
||||
modelBuilder.Entity<UserInfo>().ToTable("UserInfo");
|
||||
modelBuilder.Entity<UserInfo>().Property(u => u.Id).HasColumnName("id");
|
||||
modelBuilder.Entity<UserInfo>().Property(u => u.Fio).HasColumnName("fio");
|
||||
modelBuilder.Entity<UserInfo>().Property(u => u.Login).HasColumnName("login");
|
||||
modelBuilder.Entity<UserInfo>().Property(u => u.Password).HasColumnName("password");
|
||||
modelBuilder.Entity<UserInfo>().Property(u => u.RoleId).HasColumnName("role_id");
|
||||
|
||||
modelBuilder.Entity<UserInfo>().Ignore(u => u.Orders);
|
||||
modelBuilder.Entity<UserInfo>().Ignore(u => u.Role);
|
||||
|
||||
modelBuilder.Entity<Tovar>().ToTable("tovar");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Id).HasColumnName("id");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Art).HasColumnName("art");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.IdCategory).HasColumnName("id_category");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.IdSection).HasColumnName("id_section");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.IdManufacturer).HasColumnName("id_manufacturer");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.IdSupplier).HasColumnName("id_supplier");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Cost).HasColumnName("cost");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Discount).HasColumnName("discount");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Amount).HasColumnName("amount");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Description).HasColumnName("description");
|
||||
modelBuilder.Entity<Tovar>().Property(t => t.Photo).HasColumnName("photo");
|
||||
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.IdCategoryNavigation);
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.IdManufacturerNavigation);
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.IdSectionNavigation);
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.IdSupplierNavigation);
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.OrderDetails);
|
||||
modelBuilder.Entity<Tovar>().Ignore(t => t.ProductBitmap);
|
||||
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 68 KiB |
@@ -2,12 +2,12 @@ using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using AvaloniaPostrgresApp.Models;
|
||||
using System.Linq;
|
||||
namespace AvaloniaPostrgresApp;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Npgsql;
|
||||
using System;
|
||||
|
||||
namespace AvaloniaPostrgresApp;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
@@ -15,7 +15,6 @@ public partial class MainWindow : Window
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private async void SignInClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string login = LoginInput.Text ?? string.Empty;
|
||||
@@ -23,48 +22,57 @@ public partial class MainWindow : Window
|
||||
|
||||
if (string.IsNullOrWhiteSpace(login) || string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
StatusText.Text = "Заполните все поля!";
|
||||
StatusText.Foreground = Brushes.Red;
|
||||
ShowStatus("Заполните все поля!", Brushes.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var db = new AppDbContext();
|
||||
|
||||
using (var db = new PostgresContext())
|
||||
var user = await db.Users
|
||||
.FirstOrDefaultAsync(u => u.Login == login && u.Password == password);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
UserInfo? user = await db.UserInfos
|
||||
.FirstOrDefaultAsync(u => u.Login == login && u.Password == password);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
StatusText.Text = $"Успешно! Добро пожаловать, {user.Fio}.";
|
||||
StatusText.Foreground = Brushes.Green;
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText.Text = "Неверный логин или пароль.";
|
||||
StatusText.Foreground = Brushes.Red;
|
||||
}
|
||||
ShowStatus("Неверный логин или пароль.", Brushes.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenCatalogWindow();
|
||||
}
|
||||
catch (NpgsqlException)
|
||||
{
|
||||
StatusText.Text = "Ошибка подключения. Проверьте строку в PostgresContext.cs или Docker.";
|
||||
StatusText.Foreground = Brushes.Red;
|
||||
ShowStatus("Ошибка подключения. Проверьте строку в AppDbContext.cs или Docker.", Brushes.Red);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
StatusText.Text = ex.InnerException?.Message ?? ex.Message;
|
||||
StatusText.Foreground = Brushes.Red;
|
||||
ShowStatus(ex.InnerException?.Message ?? ex.Message, Brushes.Red);
|
||||
}
|
||||
}
|
||||
|
||||
private void GuestSignInClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StatusText.Text = "Вы вошли в систему как Гость.";
|
||||
LoginInput.Text = string.Empty;
|
||||
PasswordInput.Text = string.Empty;
|
||||
OpenCatalogWindow();
|
||||
}
|
||||
|
||||
private void OpenCatalogWindow()
|
||||
{
|
||||
var window1 = new Window1();
|
||||
|
||||
if (Avalonia.Application.Current?.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = window1;
|
||||
}
|
||||
|
||||
window1.Show();
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
private void ShowStatus(string message, IBrush color)
|
||||
{
|
||||
StatusText.Text = message;
|
||||
StatusText.Foreground = color;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Avalonia.Media.Imaging;
|
||||
using System.IO;
|
||||
|
||||
namespace AvaloniaPostrgresApp.Models;
|
||||
|
||||
@@ -27,6 +30,36 @@ public partial class Tovar
|
||||
|
||||
public string? Photo { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Bitmap? ProductBitmap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Photo)) return null;
|
||||
try
|
||||
{
|
||||
string localPath = Path.Combine(AppContext.BaseDirectory, "Assets", Photo);
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
return new Bitmap(localPath);
|
||||
}
|
||||
|
||||
string projectPath = Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "Assets", Photo);
|
||||
if (File.Exists(projectPath))
|
||||
{
|
||||
return new Bitmap(projectPath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual Category IdCategoryNavigation { get; set; } = null!;
|
||||
|
||||
public virtual Manufacturer IdManufacturerNavigation { get; set; } = null!;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<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"
|
||||
xmlns:models="clr-namespace:AvaloniaPostrgresApp.Models"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="AvaloniaPostrgresApp.Window1"
|
||||
Title="Tables">
|
||||
|
||||
<Grid RowDefinitions="Auto, *" Margin="20">
|
||||
|
||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto" ColumnSpacing="10" Margin="0,0,0,20">
|
||||
<TextBox Grid.Column="0" Watermark="Поиск" HorizontalAlignment="Stretch"/>
|
||||
<ComboBox Grid.Column="1" PlaceholderText="Сортировка" MinWidth="120" HorizontalAlignment="Stretch"/>
|
||||
<ComboBox Grid.Column="2" PlaceholderText="Фильтрация" MinWidth="120" HorizontalAlignment="Stretch"/>
|
||||
</Grid>
|
||||
|
||||
<ListBox Grid.Row="1" x:Name="ProductList">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="models:Tovar">
|
||||
<Grid ColumnDefinitions="Auto, *" Margin="4">
|
||||
|
||||
<Image Grid.Column="0"
|
||||
Source="{Binding ProductBitmap}"
|
||||
Width="80"
|
||||
Height="80"
|
||||
Stretch="UniformToFill"
|
||||
VerticalAlignment="Top"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Spacing="4" Margin="12,0,0,0">
|
||||
|
||||
<TextBlock Text="{Binding Art}" FontWeight="SemiBold" FontSize="16" />
|
||||
|
||||
<TextBlock Text="{Binding Description}" FontSize="14" Foreground="#333333" TextWrapping="Wrap"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="15" Margin="0,4,0,0">
|
||||
<TextBlock Text="{Binding Cost, StringFormat='{}{0:C}'}" Foreground="Green" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Amount, StringFormat='В наличии: {0} шт.'}" Foreground="Gray" FontSize="12" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using AvaloniaPostrgresApp.Models;
|
||||
|
||||
namespace AvaloniaPostrgresApp;
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadProducts();
|
||||
}
|
||||
|
||||
private void LoadProducts()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var context = new AppDbContext();
|
||||
var products = context.Tovars.ToList();
|
||||
ProductList.ItemsSource = products;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Title = $"Ошибка загрузки БД: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListApp", "ListApp\ListApp.csproj", "{79FB404D-DE61-4F19-BF98-589E9D1D7827}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaPostrgresApp", "..\AvaloniaPostrgresApp\AvaloniaPostrgresApp\AvaloniaPostrgresApp.csproj", "{8860ABEC-BE2A-4F19-959E-4D01329A13EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{79FB404D-DE61-4F19-BF98-589E9D1D7827}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79FB404D-DE61-4F19-BF98-589E9D1D7827}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79FB404D-DE61-4F19-BF98-589E9D1D7827}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79FB404D-DE61-4F19-BF98-589E9D1D7827}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8860ABEC-BE2A-4F19-959E-4D01329A13EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8860ABEC-BE2A-4F19-959E-4D01329A13EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8860ABEC-BE2A-4F19-959E-4D01329A13EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8860ABEC-BE2A-4F19-959E-4D01329A13EC}.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="ListApp.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 ListApp;
|
||||
|
||||
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,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</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>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.13" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\AvaloniaPostrgresApp\AvaloniaPostrgresApp\AvaloniaPostrgresApp.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,64 @@
|
||||
<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"
|
||||
xmlns:models="clr-namespace:AvaloniaPostrgresApp.Models"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
|
||||
x:Class="ListApp.MainWindow"
|
||||
Title="Магазин обуви"
|
||||
Width="900" Height="650"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Grid RowDefinitions="Auto, *" Margin="20">
|
||||
|
||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto" ColumnSpacing="10" Margin="0,0,0,20">
|
||||
<TextBox Grid.Column="0"
|
||||
Watermark="Введите для поиска" />
|
||||
|
||||
<ComboBox Grid.Column="1"
|
||||
PlaceholderText="Сортировка"
|
||||
MinWidth="120"
|
||||
HorizontalAlignment="Stretch" />
|
||||
|
||||
<ComboBox Grid.Column="2"
|
||||
PlaceholderText="Фильтрация"
|
||||
MinWidth="120"
|
||||
HorizontalAlignment="Stretch" />
|
||||
</Grid>
|
||||
|
||||
<ListBox Grid.Row="1" x:Name="ProductList">
|
||||
<ListBox.ItemTemplate>
|
||||
<!-- 1. Добавляем DataType="models:Tovar" -->
|
||||
<DataTemplate DataType="models:Tovar">
|
||||
<Grid ColumnDefinitions="Auto, *" Margin="4">
|
||||
|
||||
<Border Grid.Column="0" Width="80" Height="80" CornerRadius="4" Background="#E0E0E0" VerticalAlignment="Top">
|
||||
<TextBlock Text="Фото" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#666666"/>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="1" Spacing="4" Margin="12,0,0,0">
|
||||
|
||||
<TextBlock Text="{Binding Art}" FontWeight="SemiBold" FontSize="16" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="10">
|
||||
|
||||
<TextBlock Text="{Binding Cost, StringFormat='{}{0:C}'}" Foreground="Green" FontWeight="Bold" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="15">
|
||||
|
||||
<TextBlock Text="{Binding IdManufacturer, StringFormat='ID Производителя: {0}'}" Foreground="Gray" FontSize="12" />
|
||||
<TextBlock Text="{Binding IdCategory, StringFormat='ID Категории: {0}'}" Foreground="Gray" FontSize="12" />
|
||||
<TextBlock Text="{Binding IdSupplier, StringFormat='ID Поставщика: {0}'}" Foreground="Gray" FontSize="12" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using AvaloniaPostrgresApp;
|
||||
using AvaloniaPostrgresApp.Models;
|
||||
namespace ListApp;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoadProducts()
|
||||
{
|
||||
using (var context = new AppDbContext())
|
||||
{
|
||||
var products = context.Set<Tovar>()
|
||||
.Include("Supplier")
|
||||
.Include("Manufacturer")
|
||||
.Include("Category")
|
||||
.ToList();
|
||||
|
||||
ProductList.ItemsSource = products;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace ListApp;
|
||||
|
||||
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,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="ListApp.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>
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo", "demo\demo.csproj", "{2AEE39AC-5343-4687-8954-6520BE8FE985}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2AEE39AC-5343-4687-8954-6520BE8FE985}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2AEE39AC-5343-4687-8954-6520BE8FE985}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2AEE39AC-5343-4687-8954-6520BE8FE985}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2AEE39AC-5343-4687-8954-6520BE8FE985}.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="demo.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 demo;
|
||||
|
||||
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,9 @@
|
||||
<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="demo.MainWindow"
|
||||
Title="demo">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace demo;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace demo;
|
||||
|
||||
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,9 @@
|
||||
<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="demo.Window1"
|
||||
Title="Window1">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace demo;
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -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="demo.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>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</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>
|
||||