添加项目文件。
This commit is contained in:
parent
0294880038
commit
c3438c6a99
55
BaseFrame.sln
Normal file
55
BaseFrame.sln
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36221.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseFrame", "BaseFrame\BaseFrame.csproj", "{FC10E4D4-0AA3-487B-B023-F8D2949E45ED}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{6D9764D9-B4DA-43E2-A9D7-40A6C871A6B3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logger", "Logger\Logger.csproj", "{9150C6A9-AE8D-42C9-8B2D-9DD04A3E7E74}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ORM", "ORM\ORM.csproj", "{4DE5DC6C-7121-4EB9-B8A8-90C694F451E2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service.csproj", "{D8209B91-D7D0-444B-B569-D3FA74D191DD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{6C684FE1-C773-4B9D-89F1-9266C7B32DC0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FC10E4D4-0AA3-487B-B023-F8D2949E45ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FC10E4D4-0AA3-487B-B023-F8D2949E45ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FC10E4D4-0AA3-487B-B023-F8D2949E45ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FC10E4D4-0AA3-487B-B023-F8D2949E45ED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6D9764D9-B4DA-43E2-A9D7-40A6C871A6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6D9764D9-B4DA-43E2-A9D7-40A6C871A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6D9764D9-B4DA-43E2-A9D7-40A6C871A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6D9764D9-B4DA-43E2-A9D7-40A6C871A6B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9150C6A9-AE8D-42C9-8B2D-9DD04A3E7E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9150C6A9-AE8D-42C9-8B2D-9DD04A3E7E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9150C6A9-AE8D-42C9-8B2D-9DD04A3E7E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9150C6A9-AE8D-42C9-8B2D-9DD04A3E7E74}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4DE5DC6C-7121-4EB9-B8A8-90C694F451E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4DE5DC6C-7121-4EB9-B8A8-90C694F451E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4DE5DC6C-7121-4EB9-B8A8-90C694F451E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DE5DC6C-7121-4EB9-B8A8-90C694F451E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D8209B91-D7D0-444B-B569-D3FA74D191DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8209B91-D7D0-444B-B569-D3FA74D191DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8209B91-D7D0-444B-B569-D3FA74D191DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8209B91-D7D0-444B-B569-D3FA74D191DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C684FE1-C773-4B9D-89F1-9266C7B32DC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C684FE1-C773-4B9D-89F1-9266C7B32DC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C684FE1-C773-4B9D-89F1-9266C7B32DC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C684FE1-C773-4B9D-89F1-9266C7B32DC0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {22BD9235-6581-454D-97D8-F4E932F80888}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
30
BaseFrame/App.xaml
Normal file
30
BaseFrame/App.xaml
Normal file
@ -0,0 +1,30 @@
|
||||
<prism:PrismApplication x:Class="BaseFrame.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:BaseFrame"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:prism="http://prismlibrary.com/">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!--MaterialDesign: MahApps Compatibility-->
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Flyout.xaml" />
|
||||
|
||||
<!--MahApps-->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
|
||||
|
||||
<!--MaterialDesign-->
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
|
||||
|
||||
<!--自定义style-->
|
||||
<ResourceDictionary Source="Resources\Styles\WindowStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</prism:PrismApplication>
|
||||
43
BaseFrame/App.xaml.cs
Normal file
43
BaseFrame/App.xaml.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using BaseFrame.ViewModels;
|
||||
using BaseFrame.ViewModels.Dialogs;
|
||||
using BaseFrame.Views;
|
||||
using BaseFrame.Views.Dialogs;
|
||||
using Castle.DynamicProxy;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace BaseFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : PrismApplication
|
||||
{
|
||||
protected override Window CreateShell()
|
||||
{
|
||||
return Container.Resolve<ShellView>();
|
||||
}
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
var regionManager = Container.Resolve<IRegionManager>();
|
||||
regionManager.RequestNavigate("ShellViewManager", "MainView");
|
||||
}
|
||||
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
//注册视图
|
||||
containerRegistry.RegisterForNavigation<MainView>("MainView");
|
||||
//注册弹窗
|
||||
containerRegistry.RegisterDialog<MessageBoxView, MessageBoxViewModel>("MessageBox");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
10
BaseFrame/AssemblyInfo.cs
Normal file
10
BaseFrame/AssemblyInfo.cs
Normal 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)
|
||||
)]
|
||||
64
BaseFrame/BaseFrame.csproj
Normal file
64
BaseFrame/BaseFrame.csproj
Normal file
@ -0,0 +1,64 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Noto\NotoSans-Bold.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Noto\NotoSans-BoldItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Noto\NotoSans-Italic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Noto\NotoSans-Regular.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Black.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-BlackItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Bold.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-BoldItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Italic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Light.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-LightItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Medium.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-MediumItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Regular.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-Thin.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\Roboto-ThinItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-Bold.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-BoldItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-Italic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-Light.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-LightItalic.ttf" />
|
||||
<Content Remove="C:\Users\23560\.nuget\packages\materialdesignthemes\5.3.0\contentFiles\any\net8.0-windows7.0\Resources\Roboto\RobotoCondensed-Regular.ttf" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MaterialDesignColors" Version="5.3.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="5.3.0" />
|
||||
<PackageReference Include="MaterialDesignThemes.MahApps" Version="5.3.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="Prism.Unity" Version="9.0.537" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Common.csproj" />
|
||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
<ProjectReference Include="..\ORM\ORM.csproj" />
|
||||
<ProjectReference Include="..\Service\Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Resources\Images\error.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\Images\info.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\Images\warning.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
BIN
BaseFrame/Resources/Images/error.png
Normal file
BIN
BaseFrame/Resources/Images/error.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
BIN
BaseFrame/Resources/Images/info.png
Normal file
BIN
BaseFrame/Resources/Images/info.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
BIN
BaseFrame/Resources/Images/warning.png
Normal file
BIN
BaseFrame/Resources/Images/warning.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
20
BaseFrame/Resources/Styles/WindowStyle.xaml
Normal file
20
BaseFrame/Resources/Styles/WindowStyle.xaml
Normal file
@ -0,0 +1,20 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="DialogUserManageStyle"
|
||||
TargetType="Window">
|
||||
<Setter Property="WindowStyle"
|
||||
Value="None" />
|
||||
<Setter Property="ResizeMode"
|
||||
Value="NoResize" />
|
||||
<Setter Property="ShowInTaskbar"
|
||||
Value="False" />
|
||||
<Setter Property="AllowsTransparency"
|
||||
Value="true" />
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="SizeToContent"
|
||||
Value="WidthAndHeight" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
122
BaseFrame/ViewModels/Dialogs/MessageBoxViewModel.cs
Normal file
122
BaseFrame/ViewModels/Dialogs/MessageBoxViewModel.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using Common.PubEvent;
|
||||
using ControlzEx.Standard;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace BaseFrame.ViewModels.Dialogs
|
||||
{
|
||||
public class MessageBoxViewModel : BindableBase, IDialogAware
|
||||
{
|
||||
#region 属性
|
||||
|
||||
private string _Title;
|
||||
public string Title
|
||||
{
|
||||
get => _Title;
|
||||
set => SetProperty(ref _Title, value);
|
||||
}
|
||||
|
||||
private string _Message = "";
|
||||
public string Message
|
||||
{
|
||||
get => _Message;
|
||||
set => SetProperty(ref _Message, value);
|
||||
}
|
||||
|
||||
private string _Icon= $"pack://siteoforigin:,,,/Resources/Images/info.png";
|
||||
public string Icon
|
||||
{
|
||||
get => _Icon;
|
||||
set => SetProperty(ref _Icon, value);
|
||||
}
|
||||
|
||||
private bool _ShowYes;
|
||||
public bool ShowYes
|
||||
{
|
||||
get => _ShowYes;
|
||||
set => SetProperty(ref _ShowYes, value);
|
||||
}
|
||||
|
||||
private bool _ShowNo;
|
||||
public bool ShowNo
|
||||
{
|
||||
get => _ShowNo;
|
||||
set => SetProperty(ref _ShowNo, value);
|
||||
}
|
||||
|
||||
private bool _ShowOk;
|
||||
public bool ShowOk
|
||||
{
|
||||
get => _ShowOk;
|
||||
set => SetProperty(ref _ShowOk, value);
|
||||
}
|
||||
|
||||
private bool _ShowCancel;
|
||||
public bool ShowCancel
|
||||
{
|
||||
get => _ShowCancel;
|
||||
set => SetProperty(ref _ShowCancel, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
public ICommand YesCommand { get; set; }
|
||||
public ICommand NoCommand { get; set; }
|
||||
public ICommand OkCommand { get; set; }
|
||||
public ICommand CancelCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
public DialogCloseListener RequestClose { get; set; }
|
||||
private IEventAggregator _eventAggregator;
|
||||
public MessageBoxViewModel(IEventAggregator eventAggregator)
|
||||
{
|
||||
_eventAggregator= eventAggregator;
|
||||
YesCommand = new DelegateCommand(OnYes);
|
||||
NoCommand = new DelegateCommand(OnNo);
|
||||
OkCommand = new DelegateCommand(OnOk);
|
||||
CancelCommand = new DelegateCommand(OnCancel);
|
||||
}
|
||||
|
||||
private void CloseDialog(ButtonResult result)
|
||||
{
|
||||
var parameters = new DialogParameters();
|
||||
RequestClose.Invoke(new DialogResult(result));
|
||||
}
|
||||
|
||||
private void OnYes() => CloseDialog(ButtonResult.Yes);
|
||||
private void OnNo() => CloseDialog(ButtonResult.No);
|
||||
private void OnOk() => CloseDialog(ButtonResult.OK);
|
||||
private void OnCancel() => CloseDialog(ButtonResult.Cancel);
|
||||
|
||||
#region Prism Dialog 规范
|
||||
public bool CanCloseDialog() => true;
|
||||
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
_eventAggregator.GetEvent<OverlayEvent>().Publish(false);
|
||||
}
|
||||
|
||||
public void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
Title = parameters.GetValue<string>("Title");
|
||||
Message = parameters.GetValue<string>("Message");
|
||||
var iconKey = parameters.GetValue<string>("Icon"); // info / error / warn
|
||||
Icon = iconKey switch
|
||||
{
|
||||
"info" => $"pack://siteoforigin:,,,/Resources/Images/info.png",
|
||||
"error" => $"pack://siteoforigin:,,,/Resources/Images/error.png",
|
||||
"warn" => $"pack://siteoforigin:,,,/Resources/Images/warning.png",
|
||||
_ => $"pack://siteoforigin:,,,/Resources/Images/info.png" // 默认
|
||||
};
|
||||
|
||||
|
||||
ShowYes = parameters.GetValue<bool>("ShowYes");
|
||||
ShowNo = parameters.GetValue<bool>("ShowNo");
|
||||
ShowOk = parameters.GetValue<bool>("ShowOk");
|
||||
ShowCancel = parameters.GetValue<bool>("ShowCancel");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
84
BaseFrame/ViewModels/MainViewModel.cs
Normal file
84
BaseFrame/ViewModels/MainViewModel.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Common.PubEvent;
|
||||
using Common.PubEvents;
|
||||
using NLog;
|
||||
using Prism.Dialogs;
|
||||
using Prism.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace BaseFrame.ViewModels
|
||||
{
|
||||
public class MainViewModel : BindableBase,INavigationAware,IDialogAware
|
||||
{
|
||||
#region 属性
|
||||
|
||||
|
||||
#endregion
|
||||
#region 命令
|
||||
public ICommand testcommand { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
public DialogCloseListener RequestClose { get; set; }
|
||||
private IEventAggregator _eventAggregator;
|
||||
private IDialogService _dialogService;
|
||||
public MainViewModel(IEventAggregator eventAggregator, IDialogService dialogService)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
_eventAggregator = eventAggregator;
|
||||
testcommand = new DelegateCommand(test);
|
||||
|
||||
}
|
||||
private void test()
|
||||
{
|
||||
//_eventAggregator.GetEvent<OverlayEvent>().Publish(true);
|
||||
//var parameters = new DialogParameters
|
||||
//{
|
||||
// { "Title", "提示" },
|
||||
// { "Message", "操作成功!" },
|
||||
// { "Icon", "info" },
|
||||
// { "ShowOk", true }
|
||||
//};
|
||||
//_dialogService.ShowDialog("MessageBox",parameters);
|
||||
}
|
||||
|
||||
#region 导航
|
||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 弹窗
|
||||
public bool CanCloseDialog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
66
BaseFrame/ViewModels/ShellViewModel.cs
Normal file
66
BaseFrame/ViewModels/ShellViewModel.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using BaseFrame.Views;
|
||||
using Common.PubEvents;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace BaseFrame.ViewModels
|
||||
{
|
||||
public class ShellViewModel : BindableBase
|
||||
{
|
||||
#region 属性
|
||||
private bool _IsLeftDrawerOpen;
|
||||
|
||||
public bool IsLeftDrawerOpen
|
||||
{
|
||||
get => _IsLeftDrawerOpen;
|
||||
set => SetProperty(ref _IsLeftDrawerOpen, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 命令
|
||||
public ICommand LeftDrawerOpenCommand { get; set; }
|
||||
public ICommand MinimizeCommand { get; set; }
|
||||
public ICommand MaximizeCommand { get; set; }
|
||||
public ICommand CloseCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
private IEventAggregator _eventAggregator;
|
||||
public ShellViewModel(IEventAggregator eventAggregator, IContainerProvider containerProvider)
|
||||
{
|
||||
_eventAggregator= eventAggregator;
|
||||
LeftDrawerOpenCommand = new DelegateCommand(LeftDrawerOpen);
|
||||
MinimizeCommand = new DelegateCommand<Window>(MinimizeWindow);
|
||||
MaximizeCommand = new DelegateCommand<Window>(MaximizeWindow);
|
||||
CloseCommand = new DelegateCommand<Window>(CloseWindow);
|
||||
}
|
||||
|
||||
private void LeftDrawerOpen()
|
||||
{
|
||||
IsLeftDrawerOpen = true;
|
||||
}
|
||||
private void MinimizeWindow(Window window)
|
||||
{
|
||||
if (window != null)
|
||||
window.WindowState = WindowState.Minimized;
|
||||
}
|
||||
|
||||
private void MaximizeWindow(Window window)
|
||||
{
|
||||
if (window != null)
|
||||
{
|
||||
window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseWindow(Window window)
|
||||
{
|
||||
window?.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
BaseFrame/Views/Dialogs/MessageBoxView.xaml
Normal file
85
BaseFrame/Views/Dialogs/MessageBoxView.xaml
Normal file
@ -0,0 +1,85 @@
|
||||
<UserControl x:Class="BaseFrame.Views.Dialogs.MessageBoxView"
|
||||
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:BaseFrame.Views.Dialogs"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
Background="Transparent"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
Height="250"
|
||||
Width="300">
|
||||
<prism:Dialog.WindowStyle>
|
||||
<Style BasedOn="{StaticResource DialogUserManageStyle}"
|
||||
TargetType="Window" />
|
||||
</prism:Dialog.WindowStyle>
|
||||
<Border CornerRadius="20" Background="white">
|
||||
<Grid Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="15 5 5 5"
|
||||
FontSize="18"
|
||||
FontWeight="Bold"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Title}"
|
||||
Foreground="#333" />
|
||||
|
||||
<StackPanel HorizontalAlignment="Center"
|
||||
Grid.Row="1">
|
||||
<!-- Icon -->
|
||||
<Image
|
||||
Width="100"
|
||||
Height="100"
|
||||
VerticalAlignment="Top"
|
||||
Margin="5 15 0 0"
|
||||
Source="{Binding Icon}" />
|
||||
<!-- Message -->
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
Margin="15 0 0 0"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding Message}" />
|
||||
</StackPanel>
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Row="2"
|
||||
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
|
||||
<Button Content="Yes"
|
||||
Width="80"
|
||||
Margin="10 10"
|
||||
Visibility="{Binding ShowYes, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Command="{Binding YesCommand}" />
|
||||
|
||||
<Button Content="No"
|
||||
Width="80"
|
||||
Margin="10 10"
|
||||
Visibility="{Binding ShowNo, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Command="{Binding NoCommand}" />
|
||||
|
||||
<Button Content="OK"
|
||||
Width="80"
|
||||
Margin="10 10"
|
||||
Visibility="{Binding ShowOk, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Command="{Binding OkCommand}" />
|
||||
|
||||
<Button Content="Cancel"
|
||||
Width="80"
|
||||
Margin="10 10"
|
||||
Visibility="{Binding ShowCancel, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Command="{Binding CancelCommand}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
28
BaseFrame/Views/Dialogs/MessageBoxView.xaml.cs
Normal file
28
BaseFrame/Views/Dialogs/MessageBoxView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
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 BaseFrame.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// MessageBoxView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MessageBoxView : UserControl
|
||||
{
|
||||
public MessageBoxView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
15
BaseFrame/Views/MainView.xaml
Normal file
15
BaseFrame/Views/MainView.xaml
Normal file
@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="BaseFrame.Views.MainView"
|
||||
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:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
d:DesignHeight="1080"
|
||||
d:DesignWidth="1920">
|
||||
<Grid>
|
||||
<Button Command="{Binding testcommand}" Width="150" Height='150'/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
30
BaseFrame/Views/MainView.xaml.cs
Normal file
30
BaseFrame/Views/MainView.xaml.cs
Normal file
@ -0,0 +1,30 @@
|
||||
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 BaseFrame.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MainView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
23
BaseFrame/Views/ProgressView.xaml
Normal file
23
BaseFrame/Views/ProgressView.xaml
Normal file
@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="BaseFrame.Views.ProgressView"
|
||||
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:BaseFrame.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
<Grid Background="Transparent">
|
||||
<StackPanel Width="150"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 0 100"
|
||||
>
|
||||
<ProgressBar Width="80"
|
||||
Height="80"
|
||||
Margin="20"
|
||||
IsIndeterminate="True"
|
||||
Style="{StaticResource MaterialDesignCircularProgressBar}" />
|
||||
<TextBlock FontSize="30" Text="加载中......" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
27
BaseFrame/Views/ProgressView.xaml.cs
Normal file
27
BaseFrame/Views/ProgressView.xaml.cs
Normal 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.Shapes;
|
||||
|
||||
namespace BaseFrame.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// ProgressView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProgressView : UserControl
|
||||
{
|
||||
public ProgressView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
227
BaseFrame/Views/ShellView.xaml
Normal file
227
BaseFrame/Views/ShellView.xaml
Normal file
@ -0,0 +1,227 @@
|
||||
<Window x:Class="BaseFrame.Views.ShellView"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Topmost="false"
|
||||
mc:Ignorable="d"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
WindowStyle="None"
|
||||
Title="ShellView"
|
||||
d:DesignHeight="1080"
|
||||
d:DesignWidth="1920">
|
||||
|
||||
|
||||
<materialDesign:DrawerHost x:Name="MainDrawerHost"
|
||||
IsLeftDrawerOpen="{Binding IsLeftDrawerOpen, Mode=TwoWay}">
|
||||
|
||||
<!-- ✅ 左侧抽屉内容 -->
|
||||
<materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<StackPanel Width="220"
|
||||
Background="{DynamicResource MaterialDesignPaper}">
|
||||
<TextBlock Text="导航菜单"
|
||||
FontSize="18"
|
||||
Margin="16"
|
||||
Foreground="{DynamicResource PrimaryHueMidBrush}" />
|
||||
<Separator Margin="0,0,0,8" />
|
||||
<Button Content="首页"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Margin="8" />
|
||||
<Button Content="系统设置"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Margin="8" />
|
||||
<Button Content="数据管理"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Margin="8" />
|
||||
<Button Content="更新信息"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Margin="8" />
|
||||
<Button Content="关于"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Margin="8" />
|
||||
</StackPanel>
|
||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 顶部工具栏 -->
|
||||
<materialDesign:ColorZone Mode="PrimaryMid">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Menu Grid.Column="0"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
VerticalAlignment="Center">
|
||||
<!-- 文件菜单 -->
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="菜单"
|
||||
Foreground="White"
|
||||
Command="{Binding DataContext.LeftDrawerOpenCommand, RelativeSource={RelativeSource AncestorType=Window}}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Menu"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="文件"
|
||||
FontSize="13"
|
||||
Height="50"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="File"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="新建"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="打开"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="保存"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="另存为"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="设置默认程序"
|
||||
Foreground="Black" />
|
||||
</MenuItem>
|
||||
|
||||
<!-- 工具菜单 -->
|
||||
<MenuItem Header="工具"
|
||||
FontSize="13"
|
||||
Height="50"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Tools"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="系统设置"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="数据"
|
||||
Foreground="Black">
|
||||
<MenuItem Header="数据查询"
|
||||
Foreground="Black" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="同星CAN"
|
||||
Foreground="Black">
|
||||
<MenuItem Header="连接/断开"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="通道映射"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="加载数据库"
|
||||
Foreground="Black" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="调试"
|
||||
Foreground="Black">
|
||||
<MenuItem Header="自动运行"
|
||||
Foreground="Black" />
|
||||
<MenuItem Header="清空数据库"
|
||||
Foreground="Black" />
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
|
||||
<!-- 程序运行控制 -->
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="运行"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Play"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="单步执行"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="ArrowRight"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="停止"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Stop"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="复位"
|
||||
Foreground="White">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Restart"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Menu Grid.Column="2"
|
||||
Margin="0 0 20 0">
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="最小化"
|
||||
Foreground="White"
|
||||
Command="{Binding MinimizeCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Minimize"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="最大化"
|
||||
Foreground="White"
|
||||
Command="{Binding MaximizeCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Maximize"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem FontSize="13"
|
||||
Height="50"
|
||||
Header="关闭"
|
||||
Foreground="White"
|
||||
Command="{Binding CloseCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Close"
|
||||
Foreground="White" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
</Grid>
|
||||
<!-- 左侧菜单 -->
|
||||
|
||||
|
||||
|
||||
</materialDesign:ColorZone>
|
||||
|
||||
<materialDesign:DialogHost Grid.Row="1" x:Name="DialogHost"
|
||||
DialogBackground="Transparent"
|
||||
Background="Transparent"
|
||||
Identifier="Root">
|
||||
<!-- 主内容区 -->
|
||||
<Grid >
|
||||
<ContentControl prism:RegionManager.RegionName="ShellViewManager" />
|
||||
</Grid>
|
||||
</materialDesign:DialogHost>
|
||||
</Grid>
|
||||
</materialDesign:DrawerHost>
|
||||
|
||||
</Window>
|
||||
47
BaseFrame/Views/ShellView.xaml.cs
Normal file
47
BaseFrame/Views/ShellView.xaml.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using Common.PubEvent;
|
||||
using Common.PubEvents;
|
||||
using Prism.Events;
|
||||
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.Shapes;
|
||||
|
||||
namespace BaseFrame.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// ShellView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ShellView : Window
|
||||
{
|
||||
public ShellView(IEventAggregator eventAggregator)
|
||||
{
|
||||
InitializeComponent();
|
||||
//注册等待消息窗口
|
||||
eventAggregator.GetEvent<WaitingEvent>().Subscribe(ShowWaiting);
|
||||
//注册灰度遮罩层
|
||||
eventAggregator.GetEvent<OverlayEvent>().Subscribe(ShowOverlay);
|
||||
}
|
||||
|
||||
private void ShowOverlay(bool arg)
|
||||
{
|
||||
DialogHost.IsOpen = arg;
|
||||
}
|
||||
|
||||
private void ShowWaiting(bool arg)
|
||||
{
|
||||
DialogHost.IsOpen = arg;
|
||||
|
||||
if (DialogHost.IsOpen)
|
||||
DialogHost.DialogContent = new ProgressView();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Common/Common.csproj
Normal file
14
Common/Common.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Prism.Unity" Version="9.0.537" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
36
Common/Converters/BooleanToVisibilityConverter.cs
Normal file
36
Common/Converters/BooleanToVisibilityConverter.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Common.Converters
|
||||
{
|
||||
public class BooleanToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool input = value is bool b && b;
|
||||
bool invert = parameter?.ToString()?.ToLower() == "invert";
|
||||
|
||||
if (invert)
|
||||
input = !input;
|
||||
|
||||
return input ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool output = value is Visibility v && v == Visibility.Visible;
|
||||
bool invert = parameter?.ToString()?.ToLower() == "invert";
|
||||
|
||||
if (invert)
|
||||
output = !output;
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Common/PubEvent/OverlayEvent.cs
Normal file
12
Common/PubEvent/OverlayEvent.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.PubEvent
|
||||
{
|
||||
public class OverlayEvent : PubSubEvent<bool>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Common/PubEvent/WaitingEvent.cs
Normal file
12
Common/PubEvent/WaitingEvent.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.PubEvents
|
||||
{
|
||||
public class WaitingEvent: PubSubEvent<bool>
|
||||
{
|
||||
}
|
||||
}
|
||||
19
Logger/Logger.csproj
Normal file
19
Logger/Logger.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="6.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Nlog.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
42
Logger/LoggerHelper.cs
Normal file
42
Logger/LoggerHelper.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
public static class LoggerHelper
|
||||
{
|
||||
public static readonly ILogger Logger = LogManager.GetLogger("InfoLogger");
|
||||
public static readonly ILogger sqlLogger = LogManager.GetLogger("SqlLogger");
|
||||
|
||||
// 解析堆栈,找到项目文件路径和行号
|
||||
public static string GetProjectStackLine(string stackTrace)
|
||||
{
|
||||
if (string.IsNullOrEmpty(stackTrace))
|
||||
return "未知位置";
|
||||
|
||||
var lines = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var line in lines)
|
||||
{
|
||||
// 匹配你项目的命名空间路径
|
||||
if (line.Contains("BaseFrame"))
|
||||
{
|
||||
// 提取 "in 文件路径:line 行号"
|
||||
var match = Regex.Match(line, @"in (.+?):line (\d+)");
|
||||
if (match.Success)
|
||||
{
|
||||
return match.Value; // 返回类似 C:\...\MainViewModel.cs:line 37
|
||||
}
|
||||
return line.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return lines[0].Trim(); // 如果找不到就返回第一条
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Logger/Nlog.config
Normal file
37
Logger/Nlog.config
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<!-- 定义目标 -->
|
||||
<targets>
|
||||
<!-- SQL 日志 -->
|
||||
<target name="sqlLog" xsi:type="File"
|
||||
fileName="Logs/${shortdate}_sql.txt"
|
||||
layout="${longdate} [${level}] [ThreadId:${threadid}] ${message} ${exception}"
|
||||
encoding="utf-8" />
|
||||
|
||||
<!-- Info 日志 -->
|
||||
<target name="infoLog" xsi:type="File"
|
||||
fileName="Logs/${shortdate}_info.txt"
|
||||
layout="${longdate} [${level}] [ThreadId:${threadid}] ${message} ${exception}"
|
||||
encoding="utf-8" />
|
||||
|
||||
<!-- Warn 日志 -->
|
||||
<target name="warnLog" xsi:type="File"
|
||||
fileName="Logs/${shortdate}_warn.txt"
|
||||
layout="${longdate} [${level}] [ThreadId:${threadid}] ${message} ${exception}"
|
||||
encoding="utf-8" />
|
||||
</targets>
|
||||
|
||||
<!-- 定义日志规则 -->
|
||||
<rules>
|
||||
<!-- SQL 日志规则 -->
|
||||
<logger name="SqlLogger" minlevel="Info" writeTo="sqlLog" />
|
||||
|
||||
<!-- Info 日志规则 -->
|
||||
<logger name="InfoLogger" minlevel="Info" maxlevel="Info" writeTo="infoLog" />
|
||||
|
||||
<!-- Warn 日志规则 -->
|
||||
<logger name="*" minlevel="Warn" writeTo="warnLog" />
|
||||
</rules>
|
||||
</nlog>
|
||||
9
Model/Model.csproj
Normal file
9
Model/Model.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
97
ORM/DatabaseConfig.cs
Normal file
97
ORM/DatabaseConfig.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ORM
|
||||
{
|
||||
public static class DatabaseConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前数据库类型
|
||||
/// </summary>
|
||||
public static DbType DbConnectionType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库连接字符串
|
||||
/// </summary>
|
||||
public static string DbConnectionString { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认 SQLite 文件路径(仅记录,不自动启用)
|
||||
/// </summary>
|
||||
public static string DefaultDbFilePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户 Id
|
||||
/// </summary>
|
||||
public static int TenantId { get; private set; }
|
||||
|
||||
public static int SnowFlakeDatacenterId { get; private set; }
|
||||
public static int SnowFlakeWorkId { get; private set; }
|
||||
|
||||
static DatabaseConfig()
|
||||
{
|
||||
InitDefaultDbPath(); // 只生成路径,不指定 DB 类型/连接
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成默认 DB 路径 EXE目录/SQLDB/Data.db
|
||||
/// </summary>
|
||||
private static void InitDefaultDbPath()
|
||||
{
|
||||
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
string folder = Path.Combine(baseDir, "SQLDB");
|
||||
if (!Directory.Exists(folder))
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
DefaultDbFilePath = Path.Combine(folder, "Data.db");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动设置数据库连接
|
||||
/// </summary>
|
||||
public static void SetConnection(string conn, DbType dbType)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(conn))
|
||||
throw new Exception("数据库连接字符串为空");
|
||||
|
||||
DbConnectionString = conn;
|
||||
DbConnectionType = dbType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果未 SetConnection,默认使用 SQLite + 默认路径
|
||||
/// </summary>
|
||||
public static void EnsureConnection()
|
||||
{
|
||||
if (string.IsNullOrEmpty(DbConnectionString))
|
||||
{
|
||||
DbConnectionString = $"Data Source={DefaultDbFilePath};";
|
||||
DbConnectionType = DbType.Sqlite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置租户并计算雪花算法节点
|
||||
/// </summary>
|
||||
public static void SetTenant(int tenantId)
|
||||
{
|
||||
if (tenantId <= 10000)
|
||||
throw new Exception("数据租户Id值需大于10000");
|
||||
|
||||
TenantId = tenantId;
|
||||
|
||||
int snowId = (tenantId - 10000) % 1024;
|
||||
|
||||
if (snowId is < 0 or > 1023)
|
||||
throw new Exception("雪花算法机器码值范围0至1023");
|
||||
|
||||
SnowFlakeDatacenterId = snowId >> 5;
|
||||
SnowFlakeWorkId = snowId & 31;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
ORM/ORM.csproj
Normal file
18
ORM/ORM.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.206" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
19
Service/Service.csproj
Normal file
19
Service/Service.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
<ProjectReference Include="..\ORM\ORM.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user