修改部分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,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace MAX.Framework.Controls.Attach;
|
||||
|
||||
/// <summary>
|
||||
/// 弹出窗口属性值
|
||||
/// </summary>
|
||||
public class DialogWindowProperty
|
||||
{
|
||||
public static readonly DependencyProperty WindowStartupLocationProperty = DependencyProperty.RegisterAttached(
|
||||
"WindowStartupLocation", typeof(WindowStartupLocation), typeof(DialogWindowProperty), new PropertyMetadata(WindowStartupLocation.CenterScreen));
|
||||
public static void SetWindowStartupLocation(DependencyObject element, WindowStartupLocation value)
|
||||
=> element.SetValue(WindowStartupLocationProperty, value);
|
||||
public static WindowStartupLocation GetWindowStartupLocation(DependencyObject element)
|
||||
=> (WindowStartupLocation)element.GetValue(WindowStartupLocationProperty);
|
||||
|
||||
|
||||
public static readonly DependencyProperty ResizeModeProperty = DependencyProperty.RegisterAttached(
|
||||
"ResizeMode", typeof(ResizeMode), typeof(DialogWindowProperty), new PropertyMetadata(ResizeMode.CanResize));
|
||||
public static void SetResizeMode(DependencyObject element, ResizeMode value)
|
||||
=> element.SetValue(ResizeModeProperty, value);
|
||||
public static ResizeMode GetResizeMode(DependencyObject element)
|
||||
=> (ResizeMode)element.GetValue(ResizeModeProperty);
|
||||
|
||||
|
||||
|
||||
public static readonly DependencyProperty WidthProperty = DependencyProperty.RegisterAttached(
|
||||
"Width", typeof(double), typeof(DialogWindowProperty), new PropertyMetadata(double.NaN));
|
||||
public static void SetWidth(DependencyObject element, double value)
|
||||
=> element.SetValue(WidthProperty, value);
|
||||
public static double GetWidth(DependencyObject element)
|
||||
=> (double)element.GetValue(WidthProperty);
|
||||
|
||||
|
||||
|
||||
public static readonly DependencyProperty HeightProperty = DependencyProperty.RegisterAttached(
|
||||
"Height", typeof(double), typeof(DialogWindowProperty), new PropertyMetadata(double.NaN));
|
||||
public static void SetHeight(DependencyObject element, double value)
|
||||
=> element.SetValue(HeightProperty, value);
|
||||
public static double GetHeight(DependencyObject element)
|
||||
=> (double)element.GetValue(HeightProperty);
|
||||
}
|
||||
@@ -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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controls\Attach\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user