Merge pull request #91 from irihitech/prism
Add Prism extension library to support Ursa dialog in Prism dialog system.
This commit is contained in:
13
Ursa.sln
13
Ursa.sln
@@ -16,6 +16,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.iOS", "demo\Ursa.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.Browser", "demo\Ursa.Demo.Browser\Ursa.Demo.Browser.csproj", "{D1942476-8473-4608-BB9F-5AC01083BBDA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismExtension", "src\Ursa.PrismExtension\Ursa.PrismExtension.csproj", "{2E934F60-F5DF-4856-B05A-B949C7F9D948}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismDialogDemo", "demo\Ursa.PrismDialogDemo\Ursa.PrismDialogDemo.csproj", "{F99B3D07-4560-4B05-892C-0FF2757FEF2E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -50,6 +54,14 @@ Global
|
||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Debug|Any CPU.ActiveCfg = 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.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
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{407A91FD-A88B-459B-8DCE-8C6AA98279FE} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||
@@ -57,5 +69,6 @@ Global
|
||||
{B6BAB821-A9FE-44F3-B9CD-06E27FDB63F6} = {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}
|
||||
{F99B3D07-4560-4B05-892C-0FF2757FEF2E} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||
EndGlobalSection
|
||||
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>
|
||||
7
global.json
Normal file
7
global.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.0",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
}
|
||||
15
src/Ursa.PrismExtension/IUrsaDialogService.cs
Normal file
15
src/Ursa.PrismExtension/IUrsaDialogService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Avalonia.Controls;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.PrismExtension;
|
||||
|
||||
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);
|
||||
}
|
||||
17
src/Ursa.PrismExtension/IUrsaOverlayDialogService.cs
Normal file
17
src/Ursa.PrismExtension/IUrsaOverlayDialogService.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Avalonia.Controls;
|
||||
using Ursa.Controls;
|
||||
|
||||
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);
|
||||
}
|
||||
18
src/Ursa.PrismExtension/Ursa.PrismExtension.csproj
Normal file
18
src/Ursa.PrismExtension/Ursa.PrismExtension.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ursa\Ursa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Prism.Core" Version="8.1.97" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
26
src/Ursa.PrismExtension/UrsaDialogService.cs
Normal file
26
src/Ursa.PrismExtension/UrsaDialogService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Avalonia.Controls;
|
||||
using Prism.Ioc;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.PrismExtension;
|
||||
|
||||
public class UrsaDialogService(IContainerExtension container) : IUrsaDialogService
|
||||
{
|
||||
public void ShowCustom(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
Dialog.ShowCustom(v, vm, owner, options);
|
||||
}
|
||||
|
||||
public Task<DialogResult> ShowModal(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
return Dialog.ShowModal(v, vm, owner, options);
|
||||
}
|
||||
|
||||
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
return Dialog.ShowCustomModal<TResult>(v, vm, owner, options);
|
||||
}
|
||||
}
|
||||
20
src/Ursa.PrismExtension/UrsaDialogServiceExtension.cs
Normal file
20
src/Ursa.PrismExtension/UrsaDialogServiceExtension.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Avalonia.Controls;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Ursa.PrismExtension;
|
||||
|
||||
public static class UrsaDialogServiceExtension
|
||||
{
|
||||
internal const string UrsaDialogViewPrefix = "URSA_DIALOG_VIEW_";
|
||||
|
||||
public static void RegisterUrsaDialogService(this IContainerRegistry containerRegistry)
|
||||
{
|
||||
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
||||
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
||||
}
|
||||
|
||||
public static void RegisterUrsaDialogView<T>(this IContainerRegistry containerRegistry, string name) where T : Control
|
||||
{
|
||||
containerRegistry.Register<Control, T>(UrsaDialogViewPrefix+name);
|
||||
}
|
||||
}
|
||||
32
src/Ursa.PrismExtension/UrsaOverlayDialogService.cs
Normal file
32
src/Ursa.PrismExtension/UrsaOverlayDialogService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Avalonia.Controls;
|
||||
using Prism.Ioc;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.PrismExtension;
|
||||
|
||||
public class UrsaOverlayDialogService(IContainerExtension container): IUrsaOverlayDialogService
|
||||
{
|
||||
public void Show(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
OverlayDialog.Show(v, vm, hostId, options);
|
||||
}
|
||||
|
||||
public void ShowCustom(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
OverlayDialog.ShowCustom(v, vm, hostId, options);
|
||||
}
|
||||
|
||||
public Task<DialogResult> ShowModal(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
return OverlayDialog.ShowModal(v, vm, hostId, options);
|
||||
}
|
||||
|
||||
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||
{
|
||||
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||
return OverlayDialog.ShowCustomModal<TResult>(v, vm, hostId, options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user