feat: add prism sample.
This commit is contained in:
7
Ursa.sln
7
Ursa.sln
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.Browser", "demo\U
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismExtension", "src\Ursa.PrismExtension\Ursa.PrismExtension.csproj", "{2E934F60-F5DF-4856-B05A-B949C7F9D948}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismExtension", "src\Ursa.PrismExtension\Ursa.PrismExtension.csproj", "{2E934F60-F5DF-4856-B05A-B949C7F9D948}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismDialogDemo", "demo\Ursa.PrismDialogDemo\Ursa.PrismDialogDemo.csproj", "{F99B3D07-4560-4B05-892C-0FF2757FEF2E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -56,6 +58,10 @@ Global
|
|||||||
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F99B3D07-4560-4B05-892C-0FF2757FEF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F99B3D07-4560-4B05-892C-0FF2757FEF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F99B3D07-4560-4B05-892C-0FF2757FEF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F99B3D07-4560-4B05-892C-0FF2757FEF2E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{407A91FD-A88B-459B-8DCE-8C6AA98279FE} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
{407A91FD-A88B-459B-8DCE-8C6AA98279FE} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
@@ -63,5 +69,6 @@ Global
|
|||||||
{B6BAB821-A9FE-44F3-B9CD-06E27FDB63F6} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
{B6BAB821-A9FE-44F3-B9CD-06E27FDB63F6} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
{94C2BBD9-8B57-4AE9-AAFD-7D4335B15A8E} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
{94C2BBD9-8B57-4AE9-AAFD-7D4335B15A8E} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
{D1942476-8473-4608-BB9F-5AC01083BBDA} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
{D1942476-8473-4608-BB9F-5AC01083BBDA} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
|
{F99B3D07-4560-4B05-892C-0FF2757FEF2E} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
12
demo/Ursa.PrismDialogDemo/App.axaml
Normal file
12
demo/Ursa.PrismDialogDemo/App.axaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:u-semi="https://irihi.tech/ursa/themes/semi"
|
||||||
|
x:Class="Ursa.PrismDialogDemo.App"
|
||||||
|
RequestedThemeVariant="Default">
|
||||||
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
|
<Application.Styles>
|
||||||
|
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
|
||||||
|
<u-semi:SemiTheme Locale="zh-CN"/>
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
||||||
29
demo/Ursa.PrismDialogDemo/App.axaml.cs
Normal file
29
demo/Ursa.PrismDialogDemo/App.axaml.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Prism.DryIoc;
|
||||||
|
using Prism.Ioc;
|
||||||
|
using Ursa.PrismExtension;
|
||||||
|
|
||||||
|
namespace Ursa.PrismDialogDemo;
|
||||||
|
|
||||||
|
public partial class App : PrismApplication
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
base.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
containerRegistry.Register<MainWindow>();
|
||||||
|
containerRegistry.RegisterUrsaDialogService();
|
||||||
|
containerRegistry.RegisterUrsaDialogView<DefaultDialog>("Default");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AvaloniaObject CreateShell()
|
||||||
|
{
|
||||||
|
return Container.Resolve<MainWindow>();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
demo/Ursa.PrismDialogDemo/DefaultDialog.axaml
Normal file
8
demo/Ursa.PrismDialogDemo/DefaultDialog.axaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<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"
|
||||||
|
x:Class="Ursa.PrismDialogDemo.DefaultDialog">
|
||||||
|
Welcome to Ursa Avalonia Dialog!
|
||||||
|
</UserControl>
|
||||||
13
demo/Ursa.PrismDialogDemo/DefaultDialog.axaml.cs
Normal file
13
demo/Ursa.PrismDialogDemo/DefaultDialog.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Ursa.PrismDialogDemo;
|
||||||
|
|
||||||
|
public partial class DefaultDialog : UserControl
|
||||||
|
{
|
||||||
|
public DefaultDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
demo/Ursa.PrismDialogDemo/MainWindow.axaml
Normal file
15
demo/Ursa.PrismDialogDemo/MainWindow.axaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<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:u="https://irihi.tech/ursa"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Ursa.PrismDialogDemo.MainWindow"
|
||||||
|
Title="Ursa.PrismDialogDemo">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel>
|
||||||
|
<Button Click="Button_OnClick">Show Dialog</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<u:OverlayDialogHost/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
21
demo/Ursa.PrismDialogDemo/MainWindow.axaml.cs
Normal file
21
demo/Ursa.PrismDialogDemo/MainWindow.axaml.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using DryIoc;
|
||||||
|
using Ursa.PrismExtension;
|
||||||
|
|
||||||
|
namespace Ursa.PrismDialogDemo;
|
||||||
|
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
private IUrsaOverlayDialogService _ursa;
|
||||||
|
public MainWindow(IUrsaOverlayDialogService ursa)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_ursa = ursa;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_ursa.ShowModal("Default", null, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
demo/Ursa.PrismDialogDemo/Program.cs
Normal file
21
demo/Ursa.PrismDialogDemo/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ursa.PrismDialogDemo;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
28
demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.csproj
Normal file
28
demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.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>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.0.7"/>
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.7"/>
|
||||||
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.7"/>
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.7"/>
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.7"/>
|
||||||
|
<PackageReference Include="Prism.DryIoc.Avalonia" Version="8.1.97.11072" />
|
||||||
|
<PackageReference Include="Semi.Avalonia" Version="11.0.7" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Ursa.PrismExtension\Ursa.PrismExtension.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
18
demo/Ursa.PrismDialogDemo/app.manifest
Normal file
18
demo/Ursa.PrismDialogDemo/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 embeded controls.
|
||||||
|
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="Ursa.PrismDialogDemo.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>
|
||||||
@@ -1,6 +1,15 @@
|
|||||||
namespace Ursa.PrismExtension;
|
using Avalonia.Controls;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
public interface IUrsaDialogService
|
public interface IUrsaDialogService
|
||||||
{
|
{
|
||||||
|
public void ShowCustom(string viewName, object? vm, Window? owner = null, DialogOptions? options = null);
|
||||||
|
|
||||||
|
public Task<DialogResult> ShowModal(string viewName, object? vm, Window? owner = null,
|
||||||
|
DialogOptions? options = null);
|
||||||
|
|
||||||
|
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, Window? owner = null,
|
||||||
|
DialogOptions? options = null);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
namespace Ursa.PrismExtension;
|
using Avalonia.Controls;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
public class IUrsaOverlayDialogService
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public interface IUrsaOverlayDialogService
|
||||||
{
|
{
|
||||||
|
public void Show(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null);
|
||||||
|
|
||||||
|
public void ShowCustom(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null);
|
||||||
|
|
||||||
|
public Task<DialogResult> ShowModal(string viewName, object? vm, string? hostId = null,
|
||||||
|
OverlayDialogOptions? options = null);
|
||||||
|
|
||||||
|
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, string? hostId = null,
|
||||||
|
OverlayDialogOptions? options = null);
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ public static class UrsaDialogServiceExtension
|
|||||||
{
|
{
|
||||||
internal const string UrsaDialogViewPrefix = "URSA_DIALOG_VIEW_";
|
internal const string UrsaDialogViewPrefix = "URSA_DIALOG_VIEW_";
|
||||||
|
|
||||||
public static void RegisterDialogService(this IContainerRegistry containerRegistry)
|
public static void RegisterUrsaDialogService(this IContainerRegistry containerRegistry)
|
||||||
{
|
{
|
||||||
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
||||||
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
||||||
|
|||||||
Reference in New Issue
Block a user