avalonia test
This commit is contained in:
parent
b5cf2a0415
commit
f2e26e95a3
@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObservableCollections.R3",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObservableCollections.R3.Tests", "tests\ObservableCollections.R3.Tests\ObservableCollections.R3.Tests.csproj", "{1205F414-EE6D-49C6-9500-3E62E2120EAF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObservableCollections.R3.Tests", "tests\ObservableCollections.R3.Tests\ObservableCollections.R3.Tests.csproj", "{1205F414-EE6D-49C6-9500-3E62E2120EAF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaApp", "sandbox\AvaloniaApp\AvaloniaApp.csproj", "{48D7CA5F-9956-4CF0-908E-1DECA7FE4257}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -57,6 +59,10 @@ Global
|
|||||||
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1205F414-EE6D-49C6-9500-3E62E2120EAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{48D7CA5F-9956-4CF0-908E-1DECA7FE4257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{48D7CA5F-9956-4CF0-908E-1DECA7FE4257}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{48D7CA5F-9956-4CF0-908E-1DECA7FE4257}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{48D7CA5F-9956-4CF0-908E-1DECA7FE4257}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -69,6 +75,7 @@ Global
|
|||||||
{B84027E4-9B39-4FB6-B888-C55CE4C79152} = {B6D0425C-7902-4EFB-B0EA-99F164C20835}
|
{B84027E4-9B39-4FB6-B888-C55CE4C79152} = {B6D0425C-7902-4EFB-B0EA-99F164C20835}
|
||||||
{D5950521-C5B3-4B92-834E-3B12CDDD8DD6} = {8F60DC54-F617-4841-8C79-6B0137500D1C}
|
{D5950521-C5B3-4B92-834E-3B12CDDD8DD6} = {8F60DC54-F617-4841-8C79-6B0137500D1C}
|
||||||
{1205F414-EE6D-49C6-9500-3E62E2120EAF} = {B6D0425C-7902-4EFB-B0EA-99F164C20835}
|
{1205F414-EE6D-49C6-9500-3E62E2120EAF} = {B6D0425C-7902-4EFB-B0EA-99F164C20835}
|
||||||
|
{48D7CA5F-9956-4CF0-908E-1DECA7FE4257} = {FD836539-75F1-4707-BCFF-751B95DAE19C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {4156A725-69F4-469F-9BBB-0EE9921CA83E}
|
SolutionGuid = {4156A725-69F4-469F-9BBB-0EE9921CA83E}
|
||||||
|
10
sandbox/AvaloniaApp/App.axaml
Normal file
10
sandbox/AvaloniaApp/App.axaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="AvaloniaApp.App"
|
||||||
|
RequestedThemeVariant="Default">
|
||||||
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
|
<Application.Styles>
|
||||||
|
<FluentTheme />
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
24
sandbox/AvaloniaApp/App.axaml.cs
Normal file
24
sandbox/AvaloniaApp/App.axaml.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace AvaloniaApp
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
sandbox/AvaloniaApp/AvaloniaApp.csproj
Normal file
28
sandbox/AvaloniaApp/AvaloniaApp.csproj
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="R3Extensions.Avalonia" Version="1.2.5" />
|
||||||
|
</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" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\ObservableCollections.R3\ObservableCollections.R3.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\ObservableCollections\ObservableCollections.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
13
sandbox/AvaloniaApp/MainWindow.axaml
Normal file
13
sandbox/AvaloniaApp/MainWindow.axaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<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="AvaloniaApp.MainWindow"
|
||||||
|
Title="AvaloniaApp">
|
||||||
|
<StackPanel>
|
||||||
|
<ListBox ItemsSource="{Binding ItemsView}" x:CompileBindings="False" />
|
||||||
|
<Button Content="Add" Command="{Binding AddCommand}" x:CompileBindings="False" />
|
||||||
|
<Button Content="Clear" Command="{Binding ClearCommand}" x:CompileBindings="False" />
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
62
sandbox/AvaloniaApp/MainWindow.axaml.cs
Normal file
62
sandbox/AvaloniaApp/MainWindow.axaml.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using ObservableCollections;
|
||||||
|
using R3;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace AvaloniaApp
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.DataContext = new ViewModel();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewModel
|
||||||
|
{
|
||||||
|
private ObservableList<int> observableList { get; } = new ObservableList<int>();
|
||||||
|
public INotifyCollectionChangedSynchronizedView<int> ItemsView { get; }
|
||||||
|
public ReactiveCommand<Unit> AddCommand { get; } = new ReactiveCommand<Unit>();
|
||||||
|
public ReactiveCommand<Unit> ClearCommand { get; } = new ReactiveCommand<Unit>();
|
||||||
|
|
||||||
|
public ViewModel()
|
||||||
|
{
|
||||||
|
observableList.Add(1);
|
||||||
|
observableList.Add(2);
|
||||||
|
|
||||||
|
//ItemsView = observableList.CreateView(x => x).ToNotifyCollectionChanged(SynchronizationContextCollectionEventDispatcher.Current);
|
||||||
|
|
||||||
|
ItemsView = observableList.CreateView(x => x).ToNotifyCollectionChanged();
|
||||||
|
|
||||||
|
//var test = ItemsView.ToArray();
|
||||||
|
//INotifyCollectionChangedSynchronizedView<int>
|
||||||
|
// ItemsView = observableList.CreateView(x => x).ToNotifyCollectionChanged();
|
||||||
|
|
||||||
|
// BindingOperations.EnableCollectionSynchronization(ItemsView, new object());
|
||||||
|
|
||||||
|
AddCommand.Subscribe(_ =>
|
||||||
|
{
|
||||||
|
ThreadPool.QueueUserWorkItem(_ =>
|
||||||
|
{
|
||||||
|
observableList.Add(Random.Shared.Next());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// var iii = 10;
|
||||||
|
ClearCommand.Subscribe(_ =>
|
||||||
|
{
|
||||||
|
// observableList.Add(iii++);
|
||||||
|
observableList.Clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
sandbox/AvaloniaApp/Program.cs
Normal file
23
sandbox/AvaloniaApp/Program.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AvaloniaApp
|
||||||
|
{
|
||||||
|
internal 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()
|
||||||
|
.UseR3();
|
||||||
|
}
|
||||||
|
}
|
18
sandbox/AvaloniaApp/app.manifest
Normal file
18
sandbox/AvaloniaApp/app.manifest
Normal file
@ -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="AvaloniaApp.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>
|
Loading…
x
Reference in New Issue
Block a user