2025-09-14 19:13:40 +08:00
|
|
|
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.TriggerDialog"
|
2025-09-22 22:58:51 +08:00
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
|
|
|
|
xmlns:enums="clr-namespace:DMS.Core.Models.Triggers;assembly=DMS.Core"
|
|
|
|
|
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
|
|
|
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
|
|
|
|
xmlns:ex="clr-namespace:DMS.Extensions"
|
|
|
|
|
xmlns:converters="clr-namespace:DMS.WPF.Converters"
|
|
|
|
|
Title="{Binding Title}"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
d:DesignHeight="600"
|
|
|
|
|
d:DesignWidth="600"
|
|
|
|
|
d:DataContext="{d:DesignInstance vmd:TriggerDialogViewModel}"
|
|
|
|
|
MinWidth="500"
|
|
|
|
|
MinHeight="500"
|
|
|
|
|
PrimaryButtonText="{Binding PrimaryButText}"
|
|
|
|
|
CloseButtonText="取消"
|
|
|
|
|
PrimaryButtonCommand="{Binding SaveCommand}"
|
|
|
|
|
CloseButtonCommand="{Binding CancelCommand}"
|
|
|
|
|
DefaultButton="Primary">
|
|
|
|
|
|
2025-09-14 19:13:40 +08:00
|
|
|
<ui:ContentDialog.Resources>
|
2025-09-22 22:58:51 +08:00
|
|
|
<converters:EnumToVisibilityConverter x:Key="LocalEnumToVisibilityConverter" />
|
|
|
|
|
<ex:EnumBindingSource x:Key="ConditionTypeEnum"
|
|
|
|
|
EnumType="{x:Type enums:ConditionType}" />
|
|
|
|
|
<ex:EnumBindingSource x:Key="ActionTypeEnum"
|
|
|
|
|
EnumType="{x:Type enums:ActionType}" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</ui:ContentDialog.Resources>
|
|
|
|
|
|
|
|
|
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
|
|
|
|
<StackPanel Margin="10">
|
|
|
|
|
<!-- Basic Info Section -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<GroupBox Header="基本信息"
|
|
|
|
|
Padding="5">
|
2025-09-14 19:13:40 +08:00
|
|
|
<StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
<StackPanel Orientation="Horizontal">
|
|
|
|
|
<StackPanel>
|
|
|
|
|
<hc:TextBox hc:InfoElement.Title="搜索变量:"
|
|
|
|
|
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged }">
|
|
|
|
|
</hc:TextBox>
|
|
|
|
|
<DataGrid
|
|
|
|
|
AutoGenerateColumns="False"
|
|
|
|
|
CanUserAddRows="False"
|
|
|
|
|
ItemsSource="{Binding SelectedVariables}">
|
|
|
|
|
<DataGrid.Columns>
|
|
|
|
|
<DataGridTextColumn Binding="{Binding Name}" Header="变量名"></DataGridTextColumn>
|
|
|
|
|
</DataGrid.Columns>
|
|
|
|
|
</DataGrid>
|
|
|
|
|
|
|
|
|
|
</StackPanel>
|
|
|
|
|
|
|
|
|
|
</StackPanel>
|
|
|
|
|
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="描述:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.Description, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="300"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<CheckBox Content="激活"
|
|
|
|
|
IsChecked="{Binding Trigger.IsActive}"
|
|
|
|
|
Margin="0,0,0,5" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</StackPanel>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
|
|
|
|
|
<!-- Condition Section -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<GroupBox Header="触发条件"
|
|
|
|
|
Padding="5"
|
|
|
|
|
Margin="0,10,0,0">
|
2025-09-14 19:13:40 +08:00
|
|
|
<StackPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="条件类型:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
2025-09-14 19:13:40 +08:00
|
|
|
<ComboBox ItemsSource="{Binding Source={StaticResource ConditionTypeEnum}}"
|
|
|
|
|
SelectedItem="{Binding Trigger.Condition}"
|
2025-09-22 22:58:51 +08:00
|
|
|
Width="200"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
|
|
|
|
|
<!-- Conditional Fields based on Condition Type -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=GreaterThan}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="阈值:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.Threshold, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=LessThan}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="阈值:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.Threshold, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=EqualTo}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="阈值:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.Threshold, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=NotEqualTo}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="阈值:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.Threshold, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=InRange}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="下限:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.LowerBound, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="上限:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.UpperBound, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Condition, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=OutOfRange}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="下限:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.LowerBound, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="上限:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox Text="{Binding Trigger.UpperBound, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
|
|
|
|
|
<!-- Action Section -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<GroupBox Header="触发动作"
|
|
|
|
|
Padding="5"
|
|
|
|
|
Margin="0,10,0,0">
|
2025-09-14 19:13:40 +08:00
|
|
|
<StackPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="动作类型:"
|
|
|
|
|
Width="100"
|
|
|
|
|
VerticalAlignment="Center" />
|
2025-09-14 19:13:40 +08:00
|
|
|
<ComboBox ItemsSource="{Binding Source={StaticResource ActionTypeEnum}}"
|
|
|
|
|
SelectedItem="{Binding Trigger.Action}"
|
2025-09-22 22:58:51 +08:00
|
|
|
Width="200"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
|
|
|
|
|
<!-- Conditional Fields based on Action Type -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Action, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=SendEmail}">
|
2025-09-14 19:13:40 +08:00
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="收件人 (分号分隔):"
|
|
|
|
|
Width="150"
|
|
|
|
|
VerticalAlignment="Top" />
|
|
|
|
|
<TextBox
|
|
|
|
|
Text="{Binding EmailRecipients, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
|
|
|
|
|
AcceptsReturn="True"
|
|
|
|
|
TextWrapping="Wrap"
|
|
|
|
|
Width="350"
|
|
|
|
|
Height="60"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="邮件主题模板:"
|
|
|
|
|
Width="150"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox
|
|
|
|
|
Text="{Binding EmailSubjectTemplate, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
|
|
|
|
|
Width="350"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="邮件内容模板:"
|
|
|
|
|
Width="150"
|
|
|
|
|
VerticalAlignment="Top" />
|
|
|
|
|
<TextBox
|
|
|
|
|
Text="{Binding EmailBodyTemplate, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
|
|
|
|
|
AcceptsReturn="True"
|
|
|
|
|
TextWrapping="Wrap"
|
|
|
|
|
Width="350"
|
|
|
|
|
Height="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
2025-09-14 19:13:40 +08:00
|
|
|
<!-- Add placeholders for other action types if needed -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Action, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=ActivateAlarm}">
|
|
|
|
|
<TextBlock Text="配置激活报警动作..."
|
|
|
|
|
Margin="5" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</StackPanel>
|
2025-09-22 22:58:51 +08:00
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Visibility="{Binding Trigger.Action, Converter={StaticResource LocalEnumToVisibilityConverter}, ConverterParameter=WriteToLog}">
|
|
|
|
|
<TextBlock Text="配置写入日志动作..."
|
|
|
|
|
Margin="5" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</StackPanel>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
|
|
|
|
|
<!-- Suppression Section -->
|
2025-09-22 22:58:51 +08:00
|
|
|
<GroupBox Header="抑制设置"
|
|
|
|
|
Padding="5"
|
|
|
|
|
Margin="0,10,0,0">
|
2025-09-14 19:13:40 +08:00
|
|
|
<StackPanel>
|
|
|
|
|
<DockPanel Margin="0,0,0,5">
|
2025-09-22 22:58:51 +08:00
|
|
|
<Label Content="抑制持续时间 (秒):"
|
|
|
|
|
Width="150"
|
|
|
|
|
VerticalAlignment="Center" />
|
|
|
|
|
<TextBox
|
|
|
|
|
Text="{Binding Trigger.SuppressionDuration, Converter={StaticResource NullableTimeSpanToSecondsConverter}, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Width="100"
|
|
|
|
|
HorizontalAlignment="Left" />
|
2025-09-14 19:13:40 +08:00
|
|
|
</DockPanel>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</ScrollViewer>
|
|
|
|
|
</ui:ContentDialog>
|