From 3135189ea3706abebf511d3dacf3483f07936f2f Mon Sep 17 00:00:00 2001 From: chfei Date: Wed, 28 Oct 2026 17:56:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Core/MAX.Framework/AssemblyInfo.cs | 8 + .../MAX.Framework/Controls/ConfirmDialog.cs | 290 ------------------ .../Core/MAX.Framework/MAX.Framework.csproj | 4 + .../Controls/Attach/DialogWindowProperty.cs | 2 +- .../Controls/DialogWindow.xaml | 23 +- .../Controls/DialogWindow.xaml.cs | 4 +- .../Resources/Colors.xaml | 68 ++++ .../Resources/FrameworkTheme.xaml | 25 +- .../Themes/Generic.xaml | 5 - Source/Store.Management/App.xaml | 12 +- Source/Store.Management/App.xaml.cs | 39 +-- Source/Store.Management/MainWindow.xaml | 23 +- Source/Store.Management/MainWindow.xaml.cs | 6 +- .../ViewModels/DataGridTestViewModel.cs | 1 - .../FrameworkTestDialogViewModel.cs | 2 +- .../ViewModels/LoginViewModel.cs | 26 +- .../Views/DataGridTestView.xaml | 7 +- .../Store.Management/Views/LoginWindow.xaml | 3 +- 18 files changed, 184 insertions(+), 364 deletions(-) create mode 100644 Source/Core/MAX.Framework/AssemblyInfo.cs delete mode 100644 Source/Core/MAX.Framework/Controls/ConfirmDialog.cs rename Source/{Core/MAX.Framework => Store.Management.Framework}/Controls/Attach/DialogWindowProperty.cs (97%) create mode 100644 Source/Store.Management.Framework/Resources/Colors.xaml delete mode 100644 Source/Store.Management.Framework/Themes/Generic.xaml diff --git a/Source/Core/MAX.Framework/AssemblyInfo.cs b/Source/Core/MAX.Framework/AssemblyInfo.cs new file mode 100644 index 0000000..b860b65 --- /dev/null +++ b/Source/Core/MAX.Framework/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Windows.Markup; + +[assembly: XmlnsDefinition("MAX.Framework", "MAX.Framework")] +[assembly: XmlnsDefinition("MAX.Framework", "MAX.Framework.Extensions")] +[assembly: XmlnsDefinition("MAX.Framework", "MAX.Framework.Controls")] +[assembly: XmlnsDefinition("MAX.Framework", "MAX.Framework.Controls.Attach")] + +[assembly: XmlnsPrefix("MAX.Framework", "mf")] diff --git a/Source/Core/MAX.Framework/Controls/ConfirmDialog.cs b/Source/Core/MAX.Framework/Controls/ConfirmDialog.cs deleted file mode 100644 index 610d819..0000000 --- a/Source/Core/MAX.Framework/Controls/ConfirmDialog.cs +++ /dev/null @@ -1,290 +0,0 @@ -using MAX.Core.Commons; -using Prism.Commands; -using Prism.Mvvm; -using Prism.Services.Dialogs; -using System; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media; - -namespace MAX.Framework.Controls; - -public static class IDialogServiceExtension -{ - public static void ShowDialog(this IDialogService dialogService, string name, TParameter parameter, Action callback) where TParameter : class - { - dialogService.ShowDialog(name, new DialogParameters - { - {"parameter", parameter}, - }, callback); - } - public static void Show(this IDialogService dialogService, string name, TParameter parameter, Action callback) where TParameter : class - { - dialogService.Show(name, new DialogParameters - { - {"parameter", parameter}, - }, callback); - } -} - - -/// -/// 确定取消对话框 ViewModel -/// -public class ConfirmDialogViewModel : BindableBase, IDialogAware -{ - public ConfirmDialogViewModel() - { - - } - - private string title = ""; - private bool _enableConfirm = true; - private bool _ShowConfirm = true; - private bool _ShowCancel = true; - private bool _ShowErrorMsg = true; - private string _ErrorMsg = ""; - private string confirmText = "确定"; - private string cancelText = "取消"; - private string backText = "返回"; - private bool allowEscape = true; - private bool allowEnter = true; - private bool isLoading = false; - - public string Title - { - get => title; - protected set => SetProperty(ref title, value); - } - - public bool AllowEscape - { - get => allowEscape; - set => SetProperty(ref allowEscape, value); - } - - public bool AllowEnter - { - get => allowEnter; - set => SetProperty(ref allowEnter, value); - } - - public bool IsLoading - { - get => isLoading; - set => SetProperty(ref isLoading, value, () => - { - AllowEscape = !value; - AllowEnter = !value; - EnableConfirm = !value; - }); - } - // - // - // - private SolidColorBrush _Underpaint = new SolidColorBrush(Color.FromRgb(238, 238, 238)); - /// - /// 背景底色 - /// - public SolidColorBrush Underpaint - { - get => _Underpaint; - set => SetProperty(ref _Underpaint, value); - } - - public event Action RequestClose; - protected void OnRequestClose(IDialogResult result) - { - RequestClose?.Invoke(result); - } - - public virtual bool CanCloseDialog() - { - return true; - } - - public virtual void OnDialogClosed() - { - - } - - public virtual void OnDialogOpened(IDialogParameters parameters) - { - - } - - public bool EnableConfirm - { - get => _enableConfirm; - set => SetProperty(ref _enableConfirm, value); - } - - public bool ShowConfirm - { - get => _ShowConfirm; - set => SetProperty(ref _ShowConfirm, value); - } - public bool ShowCancel - { - get => _ShowCancel; - set => SetProperty(ref _ShowCancel, value); - } - public bool ShowErrorMsg - { - get => _ShowErrorMsg; - set => SetProperty(ref _ShowErrorMsg, value); - } - - public string ConfirmText - { - get => confirmText; - set => SetProperty(ref confirmText, value); - } - public string CancelText - { - get => cancelText; - set => SetProperty(ref cancelText, value); - } - public string BackText - { - get => backText; - set => SetProperty(ref backText, value); - } - - /// - /// 错误提示 - /// - public string ErrorMsg - { - get => _ErrorMsg; - set => SetProperty(ref _ErrorMsg, value); - } - - public virtual ICommand ConfirmCommand => new DelegateCommand(_Confirm); - - protected virtual void _Confirm() - { - DialogResult ret = Confirm(); - if (ret != null) - { - RequestClose?.Invoke(ret); - } - } - - protected virtual DialogResult Confirm() - { - return new DialogResult(ButtonResult.OK); - } - - public virtual ICommand CancelCommand => new DelegateCommand(_Cancel); - - protected virtual void _Cancel() - { - DialogResult ret = Cancel(); - if (ret != null) - { - RequestClose?.Invoke(ret); - } - else - { - RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); - } - } - protected virtual DialogResult Cancel() - { - return new DialogResult(ButtonResult.Cancel); - } - - public virtual void Loaded(object content) - { - var bb = Application.Current.TryFindResource("BackgroundBrush") as SolidColorBrush; - if (bb != null) - { - Underpaint = bb; - } - - - } - - public class AsyncConfirmDialogViewModel : ConfirmDialogViewModel - { - public override ICommand ConfirmCommand => new AsyncDelegateCommand(_Confirm); - - protected new async Task _Confirm() - { - DialogResult ret = await Confirm(); - if (ret != null) - { - OnRequestClose(ret); - } - } - - protected new virtual async Task Confirm() - { - return await Task.FromResult(new DialogResult(ButtonResult.OK)); - } - } - - public interface IDialogClassParameters - { - - } -} -/// 确定取消对话框 -/// -/// 参数Model -public class ConfirmDialogViewModel : ConfirmDialogViewModel where TParameter : class -{ - protected TParameter Args { get; set; } - public override void OnDialogOpened(IDialogParameters parameters) - { - base.OnDialogOpened(parameters); - if (parameters.TryGetValue("parameter", out TParameter parameter)) - { - Args = parameter; - } - } -} - -public abstract class ConfirmDialogViewModel : ConfirmDialogViewModel where TParameter : class where TResult : DialogResult/*, new()*/ -{ - protected TParameter Args { get; set; } - public override void OnDialogOpened(IDialogParameters parameters) - { - base.OnDialogOpened(parameters); - if (parameters.TryGetValue("parameter", out TParameter parameter)) - { - Args = parameter; - } - } - protected override void _Confirm() - { - TResult ret = Confirm(); - if (ret != null) - { - base.OnRequestClose(ret); - } - } - protected new abstract TResult Confirm(); - - protected override void _Cancel() - { - TResult ret = Cancel(); - if (ret != null) - { - base.OnRequestClose(ret); - } - else - { - base.OnRequestClose(new DialogResult(ButtonResult.Cancel)); - } - } - protected new abstract TResult Cancel(); -} - - -//public abstract class ConfirmDialogParameterViewModel : ConfirmDialogViewModel -//{ -// public abstract class Parameter; -//} \ No newline at end of file diff --git a/Source/Core/MAX.Framework/MAX.Framework.csproj b/Source/Core/MAX.Framework/MAX.Framework.csproj index df16ed7..8967b64 100644 --- a/Source/Core/MAX.Framework/MAX.Framework.csproj +++ b/Source/Core/MAX.Framework/MAX.Framework.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/Source/Core/MAX.Framework/Controls/Attach/DialogWindowProperty.cs b/Source/Store.Management.Framework/Controls/Attach/DialogWindowProperty.cs similarity index 97% rename from Source/Core/MAX.Framework/Controls/Attach/DialogWindowProperty.cs rename to Source/Store.Management.Framework/Controls/Attach/DialogWindowProperty.cs index de2308b..29e3890 100644 --- a/Source/Core/MAX.Framework/Controls/Attach/DialogWindowProperty.cs +++ b/Source/Store.Management.Framework/Controls/Attach/DialogWindowProperty.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; -namespace MAX.Framework.Controls.Attach; +namespace Store.Management.Framework.Controls.Attach; /// /// 弹出窗口属性值 diff --git a/Source/Store.Management.Framework/Controls/DialogWindow.xaml b/Source/Store.Management.Framework/Controls/DialogWindow.xaml index cd9e2cd..2a7ad9a 100644 --- a/Source/Store.Management.Framework/Controls/DialogWindow.xaml +++ b/Source/Store.Management.Framework/Controls/DialogWindow.xaml @@ -1,12 +1,13 @@ - - - - + + diff --git a/Source/Store.Management.Framework/Controls/DialogWindow.xaml.cs b/Source/Store.Management.Framework/Controls/DialogWindow.xaml.cs index a400668..98d192d 100644 --- a/Source/Store.Management.Framework/Controls/DialogWindow.xaml.cs +++ b/Source/Store.Management.Framework/Controls/DialogWindow.xaml.cs @@ -1,6 +1,4 @@  -using MAX.Framework.Controls; -using MAX.Framework.Controls.Attach; using Prism.Services.Dialogs; using Store.Management.Framework.Controls; using Store.Management.Framework.Controls.Attach; @@ -91,6 +89,8 @@ public partial class DialogWindow : WindowBase, IDialogWindow if (newContent is UserControl control) { + WindowStartupLocation = DialogWindowProperty.GetWindowStartupLocation(control); + Setter widthSetter = this.Style.Setters.OfType().FirstOrDefault(a => a.Property == WidthProperty); if (widthSetter == null) { diff --git a/Source/Store.Management.Framework/Resources/Colors.xaml b/Source/Store.Management.Framework/Resources/Colors.xaml new file mode 100644 index 0000000..745ab3b --- /dev/null +++ b/Source/Store.Management.Framework/Resources/Colors.xaml @@ -0,0 +1,68 @@ + + #F4EDF3 + #98638F + #784B70 + + #FBEFF0 + #C35C64 + #A34A52 + + #FBF4E7 + #A77725 + #855D1B + + #F0F2F4 + #69727D + #59616B + + #EAF5F0 + #31856A + #276B55 + + #292731 + #7C838C + #A0A6AD + #FFFFFF + #FFFFFF + + #E5E7EB + #D1D5DB + #F5F6F7 + #FFFFFF + #F0F2F4 + #FAFBFC + #98638F + #784B70 + + #FFFFFF + #F0F2F4 + + #98638F + #784B70 + + #20000000 + #40000000 + + + + + #F7F8F9 + #F0F2F4 + #E5E7EB + #D1D5DB + + + + + + + #98638F + #31856A + #A77725 + + + + + + + \ No newline at end of file diff --git a/Source/Store.Management.Framework/Resources/FrameworkTheme.xaml b/Source/Store.Management.Framework/Resources/FrameworkTheme.xaml index 42ddc62..096fbfa 100644 --- a/Source/Store.Management.Framework/Resources/FrameworkTheme.xaml +++ b/Source/Store.Management.Framework/Resources/FrameworkTheme.xaml @@ -1,6 +1,27 @@ - - + + + + + + + + + - + + diff --git a/Source/Store.Management/App.xaml.cs b/Source/Store.Management/App.xaml.cs index 8b4d3f3..aad4075 100644 --- a/Source/Store.Management/App.xaml.cs +++ b/Source/Store.Management/App.xaml.cs @@ -16,7 +16,10 @@ public partial class App : FrameworkApplication public App() { } - public App(StoreApiClient apiClient) => _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); + public App(StoreApiClient apiClient) + { + _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); + } private StoreApiClient CreateApiClient() => _apiClient ?? new(new ApiClientOptions { @@ -66,25 +69,25 @@ public partial class App : FrameworkApplication containerRegistry.RegisterDialog(); ViewModelLocationProvider.Register(); - + containerRegistry.RegisterDialog(); //registry.RegisterInstance(CreateApiClient()); - // registry.Register(provider => new LoginViewModel(provider.Resolve().Auth)); - // registry.RegisterSingleton(); - // registry.Register(); - // registry.RegisterSingleton(); - // registry.Register(provider => new NotificationPublisher( - // new PrismNotificationServiceProvider(provider))); - // // 显式提供处理器集合,展示一条通知分发给多个业务模块。 - // registry.Register>>(provider => - // new INotificationHandler[] - // { - // new ProductCacheHandler(provider.Resolve()), - // new ProductAuditHandler(provider.Resolve()) - // }); - // registry.RegisterDialog(); - // registry.RegisterDialog(); - } + // registry.Register(provider => new LoginViewModel(provider.Resolve().Auth)); + // registry.RegisterSingleton(); + // registry.Register(); + // registry.RegisterSingleton(); + // registry.Register(provider => new NotificationPublisher( + // new PrismNotificationServiceProvider(provider))); + // // 显式提供处理器集合,展示一条通知分发给多个业务模块。 + // registry.Register>>(provider => + // new INotificationHandler[] + // { + // new ProductCacheHandler(provider.Resolve()), + // new ProductAuditHandler(provider.Resolve()) + // }); + // registry.RegisterDialog(); + // registry.RegisterDialog(); + } protected override void OnExit(ExitEventArgs e) { diff --git a/Source/Store.Management/MainWindow.xaml b/Source/Store.Management/MainWindow.xaml index d36dde8..bb6e025 100644 --- a/Source/Store.Management/MainWindow.xaml +++ b/Source/Store.Management/MainWindow.xaml @@ -11,10 +11,21 @@ MinHeight="560" WindowStartupLocation="CenterScreen"> - -