添加项目文件。

This commit is contained in:
chfei committed 2026-10-26 18:21:42 +08:00
1 parent 54c7b83029
commit ef50fa0620
84 files changed
+9188

No files matched your search

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Store.Management.Framework.Controls.Attach;
public class DataGridHelper
{
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string GetNoDataTips(DependencyObject obj)
{
return (string)obj.GetValue(NoDataTipsProperty);
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <param name="value"></param>
public static void SetNoDataTips(DependencyObject obj, string value)
{
obj.SetValue(NoDataTipsProperty, value);
}
public static readonly DependencyProperty NoDataTipsProperty =
DependencyProperty.RegisterAttached("NoDataTips", typeof(string), typeof(DataGridHelper),new PropertyMetadata("无数据"));
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static bool GetIsActive(DependencyObject obj)
{
return (bool)obj.GetValue(IsActiveProperty);
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <param name="value"></param>
public static void SetIsActive(DependencyObject obj, bool value)
{
obj.SetValue(IsActiveProperty, value);
}
public static readonly DependencyProperty IsActiveProperty =
DependencyProperty.RegisterAttached("IsActive", typeof(bool), typeof(DataGridHelper));
}
@@ -0,0 +1,12 @@
<local:WindowBase x:Class="Store.Management.Framework.Controls.DialogWindow"
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:local="clr-namespace:Store.Management.Framework.Controls"
mc:Ignorable="d"
Title="DialogWindow" Height="450" Width="800">
<Grid>
</Grid>
</local:WindowBase>
@@ -0,0 +1,137 @@
using MAX.Framework.Controls;
using MAX.Framework.Controls.Attach;
using Prism.Services.Dialogs;
using Store.Management.Framework.Controls;
using Store.Management.Framework.Controls.Attach;
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;
using MAX.Framework.Extensions;
namespace Store.Management.Framework.Controls;
/// <summary>
/// DialogWindow.xaml 的交互逻辑
/// </summary>
public partial class DialogWindow : WindowBase, IDialogWindow
{
private readonly Style dialogWindowStyle;
/// <summary>
/// The <see cref="IDialogResult"/> of the dialog.
/// </summary>
public IDialogResult Result { get; set; }
private bool isConstructorSuccessful = false;
public DialogWindow()
{
InitializeComponent();
Owner = Application.Current.MainWindow;
isConstructorSuccessful = true;
dialogWindowStyle = (Style)TryFindResource("DialogWindowStyle");
{
RoutedCommand escapeCommand = new RoutedCommand();
CommandBindings.Add(new CommandBinding(escapeCommand, new ExecutedRoutedEventHandler((s, e) =>
{
if (DataContext is ConfirmDialogViewModel vm && vm.AllowEscape)
{
vm.CancelCommand?.Execute(null);
}
})));
InputBindings.Add(new InputBinding(escapeCommand, new KeyGesture(Key.Escape)));
}
{
RoutedCommand enterCommand = new RoutedCommand();
CommandBindings.Add(new CommandBinding(enterCommand, new ExecutedRoutedEventHandler((s, e) =>
{
if (DataContext is ConfirmDialogViewModel vm && vm.AllowEnter)
{
vm.ConfirmCommand?.Execute(null);
}
})));
InputBindings.Add(new InputBinding(enterCommand, new KeyGesture(Key.Enter)));
}
Loaded += DialogWindow_Loaded;
}
private void DialogWindow_Loaded(object sender, RoutedEventArgs e)
{
Loaded -= DialogWindow_Loaded;
if (DataContext is ConfirmDialogViewModel viewModel)
{
viewModel.Loaded(Content);
}
}
protected override void OnContentChanged(object oldContent, object newContent)
{
this.Style = dialogWindowStyle;
if (newContent is UserControl control)
{
Setter widthSetter = this.Style.Setters.OfType<Setter>().FirstOrDefault(a => a.Property == WidthProperty);
if (widthSetter == null)
{
if (double.IsNaN(control.Width))
{
this.Width = DialogWindowProperty.GetWidth(control);
}
else
{
this.Width = control.Width;
control.Width = double.NaN;
}
}
Setter heightSetter = this.Style.Setters.OfType<Setter>().FirstOrDefault(a => a.Property == HeightProperty);
if (heightSetter == null)
{
if (double.IsNaN(control.Height))
{
this.Height = DialogWindowProperty.GetHeight(control);
}
else
{
this.Height = control.Height;
control.Height = double.NaN;
}
}
ResizeMode resizeExt = DialogWindowProperty.GetResizeMode(control);
if (resizeExt != ResizeMode.CanResize)
{
this.ResizeMode = resizeExt;
}
}
base.OnContentChanged(oldContent, newContent);
}
protected override void OnStyleChanged(Style oldStyle, Style newStyle)
{
if (newStyle.TargetType == typeof(Window))
{
if (isConstructorSuccessful)
{
dialogWindowStyle.Merge(newStyle);
}
return;
}
base.OnStyleChanged(oldStyle, newStyle);
}
}
@@ -0,0 +1,17 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace Store.Management.Framework.Controls;
public class UserControlBase: UserControl
{
public UserControlBase()
{
ViewModelLocator.SetAutoWireViewModel(this, true);
}
}
@@ -0,0 +1,22 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
namespace Store.Management.Framework.Controls;
public class WindowBase : HandyControl.Controls.Window
{
public WindowBase()
{
NonClientAreaBackground = FindResource("PrimaryBrush") as Brush;
NonClientAreaForeground = FindResource("TextIconBrush") as Brush;
CloseButtonForeground = FindResource("TextIconBrush") as Brush;
OtherButtonForeground = FindResource("TextIconBrush") as Brush;
BorderThickness = new Thickness(0);
}
}