修改部分bug
This commit is contained in:
1 parent
499379e20b
commit
3135189ea3
18 files changed
+184
-364
No files matched your search
@@ -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")]
|
||||||
@@ -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<TParameter>(this IDialogService dialogService, string name, TParameter parameter, Action<IDialogResult> callback) where TParameter : class
|
|
||||||
{
|
|
||||||
dialogService.ShowDialog(name, new DialogParameters
|
|
||||||
{
|
|
||||||
{"parameter", parameter},
|
|
||||||
}, callback);
|
|
||||||
}
|
|
||||||
public static void Show<TParameter>(this IDialogService dialogService, string name, TParameter parameter, Action<IDialogResult> callback) where TParameter : class
|
|
||||||
{
|
|
||||||
dialogService.Show(name, new DialogParameters
|
|
||||||
{
|
|
||||||
{"parameter", parameter},
|
|
||||||
}, callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 确定取消对话框 ViewModel
|
|
||||||
/// </summary>
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//<UserControl.Resources>
|
|
||||||
// <SolidColorBrush x:Key="RegionBrush" Color="Red"/>
|
|
||||||
// </UserControl.Resources>
|
|
||||||
private SolidColorBrush _Underpaint = new SolidColorBrush(Color.FromRgb(238, 238, 238));
|
|
||||||
/// <summary>
|
|
||||||
/// 背景底色
|
|
||||||
/// </summary>
|
|
||||||
public SolidColorBrush Underpaint
|
|
||||||
{
|
|
||||||
get => _Underpaint;
|
|
||||||
set => SetProperty(ref _Underpaint, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Action<IDialogResult> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 错误提示
|
|
||||||
/// </summary>
|
|
||||||
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<DialogResult> Confirm()
|
|
||||||
{
|
|
||||||
return await Task.FromResult(new DialogResult(ButtonResult.OK));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IDialogClassParameters
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// 确定取消对话框
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TParameter">参数Model</typeparam>
|
|
||||||
public class ConfirmDialogViewModel<TParameter> : 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<TParameter, TResult> : 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<ConfirmDialogParameterViewModel.Parameter>
|
|
||||||
//{
|
|
||||||
// public abstract class Parameter;
|
|
||||||
//}
|
|
||||||
@@ -16,4 +16,8 @@
|
|||||||
<ProjectReference Include="..\MAX.Core\MAX.Core.csproj" />
|
<ProjectReference Include="..\MAX.Core\MAX.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Controls\Attach\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace MAX.Framework.Controls.Attach;
|
namespace Store.Management.Framework.Controls.Attach;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 弹出窗口属性值
|
/// 弹出窗口属性值
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
<local:WindowBase x:Class="Store.Management.Framework.Controls.DialogWindow"
|
<local:WindowBase
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
x:Class="Store.Management.Framework.Controls.DialogWindow"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
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:Store.Management.Framework.Controls"
|
xmlns:local="clr-namespace:Store.Management.Framework.Controls"
|
||||||
mc:Ignorable="d"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
Title="DialogWindow" Height="450" Width="800">
|
Title="DialogWindow"
|
||||||
<Grid>
|
Width="800"
|
||||||
|
Height="450"
|
||||||
</Grid>
|
mc:Ignorable="d">
|
||||||
|
<Grid />
|
||||||
</local:WindowBase>
|
</local:WindowBase>
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
using MAX.Framework.Controls;
|
|
||||||
using MAX.Framework.Controls.Attach;
|
|
||||||
using Prism.Services.Dialogs;
|
using Prism.Services.Dialogs;
|
||||||
using Store.Management.Framework.Controls;
|
using Store.Management.Framework.Controls;
|
||||||
using Store.Management.Framework.Controls.Attach;
|
using Store.Management.Framework.Controls.Attach;
|
||||||
@@ -91,6 +89,8 @@ public partial class DialogWindow : WindowBase, IDialogWindow
|
|||||||
if (newContent is UserControl control)
|
if (newContent is UserControl control)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
WindowStartupLocation = DialogWindowProperty.GetWindowStartupLocation(control);
|
||||||
|
|
||||||
Setter widthSetter = this.Style.Setters.OfType<Setter>().FirstOrDefault(a => a.Property == WidthProperty);
|
Setter widthSetter = this.Style.Setters.OfType<Setter>().FirstOrDefault(a => a.Property == WidthProperty);
|
||||||
if (widthSetter == null)
|
if (widthSetter == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Color x:Key="LightPrimaryColor">#F4EDF3</Color>
|
||||||
|
<Color x:Key="PrimaryColor">#98638F</Color>
|
||||||
|
<Color x:Key="DarkPrimaryColor">#784B70</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightDangerColor">#FBEFF0</Color>
|
||||||
|
<Color x:Key="DangerColor">#C35C64</Color>
|
||||||
|
<Color x:Key="DarkDangerColor">#A34A52</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightWarningColor">#FBF4E7</Color>
|
||||||
|
<Color x:Key="WarningColor">#A77725</Color>
|
||||||
|
<Color x:Key="DarkWarningColor">#855D1B</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightInfoColor">#F0F2F4</Color>
|
||||||
|
<Color x:Key="InfoColor">#69727D</Color>
|
||||||
|
<Color x:Key="DarkInfoColor">#59616B</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightSuccessColor">#EAF5F0</Color>
|
||||||
|
<Color x:Key="SuccessColor">#31856A</Color>
|
||||||
|
<Color x:Key="DarkSuccessColor">#276B55</Color>
|
||||||
|
|
||||||
|
<Color x:Key="PrimaryTextColor">#292731</Color>
|
||||||
|
<Color x:Key="SecondaryTextColor">#7C838C</Color>
|
||||||
|
<Color x:Key="ThirdlyTextColor">#A0A6AD</Color>
|
||||||
|
<Color x:Key="ReverseTextColor">#FFFFFF</Color>
|
||||||
|
<Color x:Key="TextIconColor">#FFFFFF</Color>
|
||||||
|
|
||||||
|
<Color x:Key="BorderColor">#E5E7EB</Color>
|
||||||
|
<Color x:Key="SecondaryBorderColor">#D1D5DB</Color>
|
||||||
|
<Color x:Key="BackgroundColor">#F5F6F7</Color>
|
||||||
|
<Color x:Key="RegionColor">#FFFFFF</Color>
|
||||||
|
<Color x:Key="SecondaryRegionColor">#F0F2F4</Color>
|
||||||
|
<Color x:Key="ThirdlyRegionColor">#FAFBFC</Color>
|
||||||
|
<Color x:Key="TitleColor">#98638F</Color>
|
||||||
|
<Color x:Key="SecondaryTitleColor">#784B70</Color>
|
||||||
|
|
||||||
|
<Color x:Key="DefaultColor">#FFFFFF</Color>
|
||||||
|
<Color x:Key="DarkDefaultColor">#F0F2F4</Color>
|
||||||
|
|
||||||
|
<Color x:Key="AccentColor">#98638F</Color>
|
||||||
|
<Color x:Key="DarkAccentColor">#784B70</Color>
|
||||||
|
|
||||||
|
<Color x:Key="DarkMaskColor">#20000000</Color>
|
||||||
|
<Color x:Key="DarkOpacityColor">#40000000</Color>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="TreeViewItemSelectedBrush" Color="#F3EAF1" />
|
||||||
|
<SolidColorBrush x:Key="TreeViewItemSelectedBrush2" Color="#784B70" />
|
||||||
|
|
||||||
|
<Color x:Key="BackgrondColor1">#F7F8F9</Color>
|
||||||
|
<Color x:Key="BackgrondColor2">#F0F2F4</Color>
|
||||||
|
<Color x:Key="BackgrondColor3">#E5E7EB</Color>
|
||||||
|
<Color x:Key="BackgrondColor4">#D1D5DB</Color>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="Background1" Color="{StaticResource BackgrondColor1}" />
|
||||||
|
<SolidColorBrush x:Key="Background2" Color="{StaticResource BackgrondColor2}" />
|
||||||
|
<SolidColorBrush x:Key="Background3" Color="{StaticResource BackgrondColor3}" />
|
||||||
|
<SolidColorBrush x:Key="Background4" Color="{StaticResource BackgrondColor4}" />
|
||||||
|
|
||||||
|
<Color x:Key="FunctionTypeColor">#98638F</Color>
|
||||||
|
<Color x:Key="VariableTypeColor">#31856A</Color>
|
||||||
|
<Color x:Key="ConstTypeColor">#A77725</Color>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="FunctionTypeBrush" Color="{StaticResource FunctionTypeColor}" />
|
||||||
|
<SolidColorBrush x:Key="VariableTypeBrush" Color="{StaticResource VariableTypeColor}" />
|
||||||
|
<SolidColorBrush x:Key="ConstTypeBrush" Color="{StaticResource ConstTypeColor}" />
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -1,6 +1,27 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary
|
||||||
<ResourceDictionary.MergedDictionaries>
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:f="clr-namespace:Store.Management.Framework.Controls">
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="/Store.Management.Framework;component/Controls/DataGridEx/DataGridEx.xaml" />
|
<ResourceDictionary Source="/Store.Management.Framework;component/Controls/DataGridEx/DataGridEx.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style
|
||||||
|
x:Key="WindowBase"
|
||||||
|
BasedOn="{StaticResource WindowWin10}"
|
||||||
|
TargetType="f:WindowBase">
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
</Style>
|
||||||
|
<Style
|
||||||
|
x:Key="DialogWindowStyle"
|
||||||
|
BasedOn="{StaticResource WindowBase}"
|
||||||
|
TargetType="f:DialogWindow">
|
||||||
|
<Setter Property="Tag" Value="Default" />
|
||||||
|
<Setter Property="ResizeMode" Value="NoResize" />
|
||||||
|
<Setter Property="ShowInTaskbar" Value="False" />
|
||||||
|
<Setter Property="WindowChrome.GlassFrameThickness" Value="-1" />
|
||||||
|
</Style>
|
||||||
|
<Style BasedOn="{StaticResource WindowBase}" TargetType="f:WindowBase" />
|
||||||
|
<Style BasedOn="{StaticResource DialogWindowStyle}" TargetType="f:DialogWindow" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceDictionary Source="/Store.Management.Framework;component/Controls/DataGridEx/DataGridEx.xaml"/>
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -5,16 +5,14 @@
|
|||||||
xmlns:mf="clr-namespace:Store.Management.Framework;assembly=Store.Management.Framework">
|
xmlns:mf="clr-namespace:Store.Management.Framework;assembly=Store.Management.Framework">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<SolidColorBrush x:Key="PrimaryBrush" Color="#3267C8" />
|
<SolidColorBrush x:Key="PrimaryBrush" Color="{DynamicResource PrimaryColor}" />
|
||||||
<SolidColorBrush x:Key="TextIconBrush" Color="#FFFFFF" />
|
<SolidColorBrush x:Key="TextIconBrush" Color="{DynamicResource TextIconColor}" />
|
||||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#FFFFFF" />
|
<SolidColorBrush x:Key="BackgroundBrush" Color="{DynamicResource BackgroundColor}" />
|
||||||
<Style x:Key="DialogWindowStyle" TargetType="Window">
|
|
||||||
<Setter Property="ResizeMode" Value="NoResize" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="pack://application:,,,/Store.Management.Framework;component/Resources/HandyControlBasic.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Store.Management.Framework;component/Resources/HandyControlBasic.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
|
<ResourceDictionary Source="/Store.Management.Framework;component/Resources/Colors.xaml" />
|
||||||
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/Store.Management.Framework;component/Resources/FrameworkTheme.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Store.Management.Framework;component/Resources/FrameworkTheme.xaml" />
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ public partial class App : FrameworkApplication
|
|||||||
|
|
||||||
public App() { }
|
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
|
private StoreApiClient CreateApiClient() => _apiClient ?? new(new ApiClientOptions
|
||||||
{
|
{
|
||||||
@@ -66,25 +69,25 @@ public partial class App : FrameworkApplication
|
|||||||
containerRegistry.RegisterDialog<DataGridTestView, DataGridTestViewModel>();
|
containerRegistry.RegisterDialog<DataGridTestView, DataGridTestViewModel>();
|
||||||
|
|
||||||
ViewModelLocationProvider.Register<MainWindow, MainWindowViewModel>();
|
ViewModelLocationProvider.Register<MainWindow, MainWindowViewModel>();
|
||||||
|
containerRegistry.RegisterDialog<LoginWindow, LoginViewModel>();
|
||||||
|
|
||||||
//registry.RegisterInstance(CreateApiClient());
|
//registry.RegisterInstance(CreateApiClient());
|
||||||
// registry.Register<LoginViewModel>(provider => new LoginViewModel(provider.Resolve<StoreApiClient>().Auth));
|
// registry.Register<LoginViewModel>(provider => new LoginViewModel(provider.Resolve<StoreApiClient>().Auth));
|
||||||
// registry.RegisterSingleton<SingletonProbe>();
|
// registry.RegisterSingleton<SingletonProbe>();
|
||||||
// registry.Register<TransientProbe>();
|
// registry.Register<TransientProbe>();
|
||||||
// registry.RegisterSingleton<NotificationExampleState>();
|
// registry.RegisterSingleton<NotificationExampleState>();
|
||||||
// registry.Register<IPublisher>(provider => new NotificationPublisher(
|
// registry.Register<IPublisher>(provider => new NotificationPublisher(
|
||||||
// new PrismNotificationServiceProvider(provider)));
|
// new PrismNotificationServiceProvider(provider)));
|
||||||
// // 显式提供处理器集合,展示一条通知分发给多个业务模块。
|
// // 显式提供处理器集合,展示一条通知分发给多个业务模块。
|
||||||
// registry.Register<IEnumerable<INotificationHandler<ProductSavedNotification>>>(provider =>
|
// registry.Register<IEnumerable<INotificationHandler<ProductSavedNotification>>>(provider =>
|
||||||
// new INotificationHandler<ProductSavedNotification>[]
|
// new INotificationHandler<ProductSavedNotification>[]
|
||||||
// {
|
// {
|
||||||
// new ProductCacheHandler(provider.Resolve<NotificationExampleState>()),
|
// new ProductCacheHandler(provider.Resolve<NotificationExampleState>()),
|
||||||
// new ProductAuditHandler(provider.Resolve<NotificationExampleState>())
|
// new ProductAuditHandler(provider.Resolve<NotificationExampleState>())
|
||||||
// });
|
// });
|
||||||
// registry.RegisterDialog<LoginWindow, LoginViewModel>();
|
// registry.RegisterDialog<LoginWindow, LoginViewModel>();
|
||||||
// registry.RegisterDialog<FrameworkTestDialog, FrameworkTestDialogViewModel>();
|
// registry.RegisterDialog<FrameworkTestDialog, FrameworkTestDialogViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,10 +11,21 @@
|
|||||||
MinHeight="560"
|
MinHeight="560"
|
||||||
WindowStartupLocation="CenterScreen">
|
WindowStartupLocation="CenterScreen">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<!-- 控件测试入口 -->
|
<!-- 控件测试入口 -->
|
||||||
<Button DockPanel.Dock="Top" Content="打开 DataGrid 测试"
|
<Button
|
||||||
Command="{Binding OpenDataGridTestCommand, Mode=OneWay}"
|
Margin="16,12"
|
||||||
HorizontalAlignment="Left" Margin="16,12" Padding="16,6" />
|
Padding="16,6"
|
||||||
<views:FrameworkTestPage />
|
HorizontalAlignment="Left"
|
||||||
</DockPanel>
|
Command="{Binding OpenDataGridTestCommand, Mode=OneWay}"
|
||||||
|
Content="打开 DataGrid 测试"
|
||||||
|
DockPanel.Dock="Top" />
|
||||||
|
<Button
|
||||||
|
Margin="16,12"
|
||||||
|
Padding="16,6"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Command="{Binding OpenLoginCommand, Mode=OneWay}"
|
||||||
|
Content="登录 测试"
|
||||||
|
DockPanel.Dock="Top" />
|
||||||
|
<views:FrameworkTestPage />
|
||||||
|
</DockPanel>
|
||||||
</f:WindowBase>
|
</f:WindowBase>
|
||||||
@@ -16,7 +16,11 @@ public class MainWindowViewModel(IDialogService dialogService) : BindableBase
|
|||||||
public DelegateCommand OpenDataGridTestCommand => field ??= new(() =>
|
public DelegateCommand OpenDataGridTestCommand => field ??= new(() =>
|
||||||
dialogService.ShowDialog(nameof(DataGridTestView), new DialogParameters(), _ => { }));
|
dialogService.ShowDialog(nameof(DataGridTestView), new DialogParameters(), _ => { }));
|
||||||
|
|
||||||
private string _title="TTTT";
|
|
||||||
|
public DelegateCommand OpenLoginCommand => field ??= new(() =>
|
||||||
|
dialogService.ShowDialog(nameof(LoginWindow), new DialogParameters(), _ => { }));
|
||||||
|
|
||||||
|
private string _title="TTTT";
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
get => _title;
|
get => _title;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Bogus;
|
using Bogus;
|
||||||
using ConfirmDialogViewModel = MAX.Framework.Controls.ConfirmDialogViewModel;
|
|
||||||
using Prism.Commands;
|
using Prism.Commands;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
using Store.Management.Framework.Controls;
|
using Store.Management.Framework.Controls;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using MAX.Framework.Controls;
|
|
||||||
using Prism.Services.Dialogs;
|
using Prism.Services.Dialogs;
|
||||||
|
using Store.Management.Framework.Controls;
|
||||||
namespace Store.Management.ViewModels;
|
namespace Store.Management.ViewModels;
|
||||||
public sealed class FrameworkTestDialogViewModel : ConfirmDialogViewModel
|
public sealed class FrameworkTestDialogViewModel : ConfirmDialogViewModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Prism.Commands;
|
using Prism.Commands;
|
||||||
using MAX.Framework.Controls;
|
|
||||||
using Prism.Services.Dialogs;
|
using Prism.Services.Dialogs;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Store.Management.Api.Authentication;
|
using Store.Management.Api.Authentication;
|
||||||
using Store.Management.Api.Transport;
|
using Store.Management.Api.Transport;
|
||||||
using Store.Management.Framework.ViewModels;
|
using Store.Management.Framework.ViewModels;
|
||||||
|
using Store.Management.Framework.Controls;
|
||||||
|
|
||||||
namespace Store.Management.ViewModels;
|
namespace Store.Management.ViewModels;
|
||||||
|
|
||||||
/// <summary>登录校验、认证请求和窗口生命周期内的请求取消。</summary>
|
/// <summary>登录校验、认证请求和窗口生命周期内的请求取消。</summary>
|
||||||
public sealed class LoginViewModel(IAuthApi auth) : ConfirmDialogViewModel, IDisposable
|
public sealed class LoginViewModel() : ConfirmDialogViewModel, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IAuthApi _auth = auth ?? throw new ArgumentNullException(nameof(auth));
|
//private readonly IAuthApi _auth = auth ?? throw new ArgumentNullException(nameof(auth));
|
||||||
private readonly CancellationTokenSource _lifetime = new();
|
private readonly CancellationTokenSource _lifetime = new();
|
||||||
private string _userName = "";
|
private string _userName = "";
|
||||||
private string _passwordHash = "";
|
private string _passwordHash = "";
|
||||||
@@ -73,16 +73,16 @@ public sealed class LoginViewModel(IAuthApi auth) : ConfirmDialogViewModel, IDis
|
|||||||
NotifyStateChanged();
|
NotifyStateChanged();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _auth.LoginAsync(new LoginRequest
|
//await _auth.LoginAsync(new LoginRequest
|
||||||
{
|
//{
|
||||||
UserName = UserName.Trim(),
|
// UserName = UserName.Trim(),
|
||||||
Password = _passwordHash
|
// Password = _passwordHash
|
||||||
}, _lifetime.Token);
|
//}, _lifetime.Token);
|
||||||
if (!_disposed)
|
//if (!_disposed)
|
||||||
{
|
//{
|
||||||
_authenticated = true;
|
// _authenticated = true;
|
||||||
OnRequestClose(new DialogResult(ButtonResult.OK));
|
// OnRequestClose(new DialogResult(ButtonResult.OK));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) when (_disposed)
|
catch (OperationCanceledException) when (_disposed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,16 +3,15 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:dialog="clr-namespace:MAX.Framework.Controls.Attach;assembly=MAX.Framework"
|
|
||||||
xmlns:f="Store.Management.Framework"
|
xmlns:f="Store.Management.Framework"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:vm="clr-namespace:Store.Management.ViewModels"
|
xmlns:vm="clr-namespace:Store.Management.ViewModels"
|
||||||
d:DataContext="{d:DesignInstance Type=vm:DataGridTestViewModel}"
|
d:DataContext="{d:DesignInstance Type=vm:DataGridTestViewModel}"
|
||||||
d:DesignHeight="760"
|
d:DesignHeight="760"
|
||||||
d:DesignWidth="1280"
|
d:DesignWidth="1280"
|
||||||
dialog:DialogWindowProperty.Height="800"
|
f:DialogWindowProperty.Height="800"
|
||||||
dialog:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
|
f:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
|
||||||
dialog:DialogWindowProperty.Width="1360"
|
f:DialogWindowProperty.Width="1360"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:DataGridTestViewModel />
|
<vm:DataGridTestViewModel />
|
||||||
|
|||||||
@@ -61,13 +61,12 @@
|
|||||||
Target="{Binding ElementName=PasswordBox, Mode=OneWay}" />
|
Target="{Binding ElementName=PasswordBox, Mode=OneWay}" />
|
||||||
<PasswordBox
|
<PasswordBox
|
||||||
x:Name="PasswordBox"
|
x:Name="PasswordBox"
|
||||||
PasswordChanged="OnPasswordChanged"
|
|
||||||
Height="40"
|
Height="40"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
AutomationProperties.Name="密码"
|
AutomationProperties.Name="密码"
|
||||||
IsEnabled="{Binding CanEdit, Mode=OneWay}"
|
IsEnabled="{Binding CanEdit, Mode=OneWay}"
|
||||||
MaxLength="{x:Static vm:LoginViewModel.InputMaxLength}"
|
MaxLength="{x:Static vm:LoginViewModel.InputMaxLength}"
|
||||||
/>
|
PasswordChanged="OnPasswordChanged" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="0,12,0,0"
|
Margin="0,12,0,0"
|
||||||
|
|||||||
Reference in new issue
Block a user