增加Prism 框架

This commit is contained in:
chfei committed 2026-08-31 16:28:23 +08:00
1 parent 2cd6b8db86
commit 726eb6de16
99 files changed
+12527

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
<tf:FrameworkApplication
x:Class="Main.Test.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Main.Test"
xmlns:tf="Trade.Framework">
<Application.Resources />
</tf:FrameworkApplication>
+57
View File
@@ -0,0 +1,57 @@
using Main.Test.ViewModels;
using Main.Test.Views;
using MAX.Core.DependencyInjection;
using MAX.Core.Logger;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
using System.Configuration;
using System.Data;
using System.Windows;
using Trade.Framework;
using Trade.Framework.Extensions;
using Trade.Framework.Services;
namespace Main.Test;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : FrameworkApplication
{
public IScopedProvider CurrentScope => throw new NotImplementedException();
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
}
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// 严格模式:FrameworkApplication 已关闭 DryIoc 按需动态注册(WithConcreteTypeDynamicRegistrations),
// 所有被解析的类型必须显式注册,否则抛 ContainerException。
// 启动 Shell
containerRegistry.Register<MainWindow>();
// 窗口/控件 ViewModel(DISource 从容器解析)
containerRegistry.Register<MainViewModel>();
containerRegistry.Register<HeaderViewModel>();
// 对话框:RegisterDialog 只注册 View 本身,VM 由 ViewModelLocator 从容器解析,需单独注册
containerRegistry.RegisterDialog<bbbDialogView, bbbDialogViewModel>(nameof(bbbDialogView));
containerRegistry.Register<bbbDialogViewModel>();
// 服务:原先靠 DryIoc 动态注册(Transient),显式注册保持同样行为
//containerRegistry.Register<UserManager>();
// 若希望 UserManager 全局只实例化一次:
// containerRegistry.RegisterSingleton<UserManager>();
//containerRegistry.RegisterSingleton<ILoggerFacade, ConsoleLogger>();
}
}
+10
View File
@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
+24
View File
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>$(DefaultTargetFramework)-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Source\Trade.Framework\Trade.Framework.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Views\bbbDialogView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Views\HeaderView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
</Project>
+19
View File
@@ -0,0 +1,19 @@
<Window
x:Class="Main.Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Main.Test"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:Main.Test.Views"
Title="MainWindow"
xmlns:tf="Trade.Framework"
xmlns:vm="clr-namespace:Main.Test.ViewModels"
Width="800"
Height="450"
DataContext="{tf:DISource Type=vm:MainViewModel}"
mc:Ignorable="d">
<Grid>
<views:HeaderView />
</Grid>
</Window>
+22
View File
@@ -0,0 +1,22 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Main.Test;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
+30
View File
@@ -0,0 +1,30 @@
using CommunityToolkit.Mvvm.Input;
using Main.Test.Views;
using Prism.Commands;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Main.Test.ViewModels;
internal class HeaderViewModel
{
private readonly IDialogService _dialogService;
public HeaderViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
}
//public ICommand ccCommand => new AsyncDelegateCommand(cc);
[RelayCommand]
private async Task cc()
{
_dialogService.ShowDialog(nameof(bbbDialogView));
}
}
+20
View File
@@ -0,0 +1,20 @@
using MAX.Core.Logger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Trade.Framework.Services;
namespace Main.Test.ViewModels;
internal class MainViewModel
{
private readonly ILoggerFacade _logger;
public MainViewModel(ILoggerFacade logger, UserManager userManager)
{
_logger = logger;
_logger.Info("123123");
}
}
+16
View File
@@ -0,0 +1,16 @@
<UserControl
x:Class="Main.Test.Views.HeaderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Main.Test.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tf="Trade.Framework"
xmlns:vm="clr-namespace:Main.Test.ViewModels"
d:DesignHeight="450"
d:DesignWidth="800" DataContext="{tf:DISource Type=vm:HeaderViewModel}"
mc:Ignorable="d">
<Grid>
<Button Command="{Binding ccCommand}" Content="abc" />
</Grid>
</UserControl>
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Main.Test.Views;
/// <summary>
/// HeaderView.xaml 的交互逻辑
/// </summary>
public partial class HeaderView : UserControl
{
public HeaderView()
{
InitializeComponent();
}
}
+12
View File
@@ -0,0 +1,12 @@
<UserControl x:Class="Main.Test.Views.bbbDialogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Main.Test.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
+57
View File
@@ -0,0 +1,57 @@
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Trade.Framework.Services;
namespace Main.Test.Views;
/// <summary>
/// bbbDialogView.xaml 的交互逻辑
/// </summary>
public partial class bbbDialogView : UserControl
{
public bbbDialogView()
{
InitializeComponent();
}
}
public class bbbDialogViewModel : IDialogAware
{
private readonly IUserManager _user;
public bbbDialogViewModel(IUserManager user)
{
_user = user;
}
public string Title => "ttt";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
return;
}
public void OnDialogOpened(IDialogParameters parameters)
{
return;
}
}