设备编辑管理界面
This commit is contained in:
21
UIShare/PubEvent/AddDialogTabEvent.cs
Normal file
21
UIShare/PubEvent/AddDialogTabEvent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UIShare.UIViewModel;
|
||||
|
||||
namespace UIShare.PubEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 其他模块向弹窗管理器添加 Tab 的事件。
|
||||
/// 发布方:任何需要将弹窗托管到 DialogManagerView 的模块。
|
||||
/// 订阅方:<c>DialogMangerViewModel</c>(仅一处订阅)。
|
||||
/// <code>
|
||||
/// // 示例:在某个 ViewModel 中发布
|
||||
/// _eventAggregator.GetEvent<AddDialogTabEvent>().Publish(new DialogTabInfo
|
||||
/// {
|
||||
/// Title = "设备配置",
|
||||
/// Content = new DeviceConfigView()
|
||||
/// });
|
||||
/// </code>
|
||||
/// </summary>
|
||||
public class AddDialogTabEvent : PubSubEvent<DialogTabInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
UIShare/PubEvent/CancelMinimizeEvent.cs
Normal file
12
UIShare/PubEvent/CancelMinimizeEvent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UIShare.PubEvent
|
||||
{
|
||||
public class CancelMinimizeEvent:PubSubEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,6 @@
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
|
||||
<!--自定义style-->
|
||||
<ResourceDictionary Source="/UIShare;component/Styles/WindowStyle.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="/UIShare;component/Styles/DialogControlStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
63
UIShare/Styles/DialogControlStyle.xaml
Normal file
63
UIShare/Styles/DialogControlStyle.xaml
Normal file
@@ -0,0 +1,63 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="CmdBtn" TargetType="Button" BasedOn="{StaticResource MaterialDesignRaisedButton}">
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="12,0"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Margin" Value="4,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WarnBtn" TargetType="Button" BasedOn="{StaticResource MaterialDesignRaisedButton}">
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="12,0"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Margin" Value="4,0"/>
|
||||
<Setter Property="Background" Value="#EF6C00"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="NumInput" TargetType="TextBox" BasedOn="{StaticResource MaterialDesignOutlinedTextBox}">
|
||||
<Setter Property="Width" Value="100"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="5,0"/>
|
||||
<Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="6,2,6,2"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Margin" Value="4,0"/>
|
||||
<Setter Property="materialDesign:HintAssist.IsFloating" Value="False"/>
|
||||
<Setter Property="materialDesign:HintAssist.Hint" Value=""/>
|
||||
|
||||
<Setter Property="AutomationProperties.Name" Value=""/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="MeasureBox" TargetType="TextBox" BasedOn="{StaticResource MaterialDesignOutlinedTextBox}">
|
||||
<Setter Property="Width" Value="110"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="5,0"/>
|
||||
<Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="6,2,6,2"/>
|
||||
<Setter Property="IsReadOnly" Value="True"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Margin" Value="4,0"/>
|
||||
<Setter Property="Background" Value="#F5F5F5"/>
|
||||
<Setter Property="materialDesign:HintAssist.IsFloating" Value="False"/>
|
||||
<Setter Property="materialDesign:HintAssist.Hint" Value=""/>
|
||||
|
||||
<Setter Property="AutomationProperties.Name" Value=""/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ParamLabel" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Margin" Value="0,0,4,0"/>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,5 +1,5 @@
|
||||
<ResourceDictionary 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" >
|
||||
|
||||
<Style x:Key="DialogUserManageStyle"
|
||||
TargetType="Window">
|
||||
@@ -19,4 +19,5 @@
|
||||
Value="WidthAndHeight" />
|
||||
</Style>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
19
UIShare/UIViewModel/DialogTabInfo.cs
Normal file
19
UIShare/UIViewModel/DialogTabInfo.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 弹窗 Tab 信息载体(事件负载,轻量 POCO)。
|
||||
/// 其他模块发布 <c>AddDialogTabEvent</c> 时填充此对象,
|
||||
/// DialogMangerViewModel 接收后创建对应的 Tab 项。
|
||||
/// </summary>
|
||||
public class DialogTabInfo
|
||||
{
|
||||
/// <summary>Tab 标题(显示在标签页上)。</summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Tab 内容:传入一个已实例化的 <see cref="System.Windows.FrameworkElement"/>(通常是 UserControl),
|
||||
/// 由 ContentControl 直接承载展示。
|
||||
/// </summary>
|
||||
public object? Content { get; set; }
|
||||
}
|
||||
}
|
||||
60
UIShare/UIViewModel/DialogTabItemVM.cs
Normal file
60
UIShare/UIViewModel/DialogTabItemVM.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
|
||||
namespace DeviceEditModule.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 弹窗管理器中单个 Tab 项的 ViewModel。
|
||||
/// 由 <see cref="DialogMangerViewModel"/> 在收到 AddDialogTabEvent 时创建,
|
||||
/// 通过构造函数注入选中/关闭的回调,保持与父 ViewModel 的低耦合。
|
||||
/// </summary>
|
||||
public class DialogTabItemVM : BindableBase
|
||||
{
|
||||
#region 属性
|
||||
|
||||
private string _title = string.Empty;
|
||||
/// <summary>Tab 标签页上显示的标题。</summary>
|
||||
public string Title
|
||||
{
|
||||
get => _title;
|
||||
set => SetProperty(ref _title, value);
|
||||
}
|
||||
|
||||
private object? _content;
|
||||
/// <summary>Tab 内容区域(通常为 UserControl 实例)。</summary>
|
||||
public object? Content
|
||||
{
|
||||
get => _content;
|
||||
set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
/// <summary>是否为当前激活 Tab(用于切换选中态样式)。</summary>
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => SetProperty(ref _isSelected, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
|
||||
/// <summary>点击 Tab 标题激活该 Tab。</summary>
|
||||
public DelegateCommand SelectCommand { get; }
|
||||
|
||||
/// <summary>点击 Tab 上的 × 关闭并移除该 Tab。</summary>
|
||||
public DelegateCommand CloseCommand { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <param name="onSelect">父 VM 提供的激活回调。</param>
|
||||
/// <param name="onClose">父 VM 提供的关闭回调。</param>
|
||||
public DialogTabItemVM(Action<DialogTabItemVM> onSelect, Action<DialogTabItemVM> onClose)
|
||||
{
|
||||
SelectCommand = new DelegateCommand(() => onSelect(this));
|
||||
CloseCommand = new DelegateCommand(() => onClose(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user