首次上传
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.Alarms.Alarm.AlarmView"
|
||||
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:lex="http://wpflocalizeextension.codeplex.com"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.Alarms.Alarm"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="325"
|
||||
d:DesignWidth="1200"
|
||||
lex:LocalizeDictionary.DesignCulture="zh"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<local:EventLevelToBackgroundConverter x:Key="EventLevelToBackgroundConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="7*" />
|
||||
<ColumnDefinition Width="5*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Margin="5,0,12,5" Header="{lex:Loc ID_TXT_Alarm}">
|
||||
<DataGrid
|
||||
Name="eventList"
|
||||
Margin="5"
|
||||
AutoGenerateColumns="False"
|
||||
Background="White"
|
||||
BorderThickness="0.1"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
FontFamily="Arial,SimSun"
|
||||
FontSize="13"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding AlarmEvents, Mode=OneWay}"
|
||||
SelectionChanged="listView1_SelectionChanged"
|
||||
SelectionMode="Single"
|
||||
SelectionUnit="FullRow">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn
|
||||
Width="75"
|
||||
CanUserSort="True"
|
||||
Header="Type"
|
||||
SortMemberPath="Type">
|
||||
<DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{lex:Loc ID_TXT_Type}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="-2" Background="{Binding Level, Converter={StaticResource EventLevelToBackgroundConverter}}">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Text="{Binding LevelString}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!--<DataGridTemplateColumn Header="Ack" Width="40" CanUserSort="True" SortMemberPath="Type">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox IsChecked="{Binding IsAcknowledged, Mode=OneWay}"
|
||||
IsHitTestVisible="False"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>-->
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="75"
|
||||
Binding="{Binding Source, Mode=OneWay}"
|
||||
CanUserSort="True"
|
||||
Header="{lex:Loc ID_TXT_Source}"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="150"
|
||||
Binding="{Binding OccuringTime, Mode=OneWay}"
|
||||
CanUserSort="True"
|
||||
Header="Time"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="{lex:Loc ID_TXT_Date}"
|
||||
TextAlignment="Center" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Binding="{Binding Description, Mode=OneWay}"
|
||||
CanUserSort="True"
|
||||
Header="Description"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock VerticalAlignment="Center" Text="{lex:Loc ID_TXT_Description}" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</GroupBox>
|
||||
<GroupBox
|
||||
Grid.Column="1"
|
||||
Margin="0,0,5,5"
|
||||
Header="{lex:Loc ID_TXT_Detail}">
|
||||
<TextBlock
|
||||
x:Name="AnalysisText"
|
||||
Margin="5"
|
||||
Background="White"
|
||||
FontSize="14"
|
||||
Style="{x:Null}"
|
||||
TextWrapping="Wrap" />
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using Aitex.Core.UI.View.Common;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Alarms.Alarm
|
||||
{
|
||||
/// <summary>
|
||||
/// AlarmView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AlarmView : UserControl
|
||||
{
|
||||
public AlarmView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void listView1_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count == 1 && e.AddedItems[0] is AlarmItem item)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.Append("Event Type:");
|
||||
sb.Append(item.LevelString);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append("Event Source:");
|
||||
sb.Append(item.Source);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append("Event Name:");
|
||||
sb.Append(item.EventEnum);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append("Time:");
|
||||
sb.Append(item.OccuringTime);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append("Description:");
|
||||
sb.Append(item.Description);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append("Possible Solution:");
|
||||
sb.Append(item.Solution);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
//sb.Append("Acknowledged:");
|
||||
//sb.Append(item.IsAcknowledged ? "Yes" : "No");
|
||||
//sb.AppendLine();
|
||||
//sb.AppendLine();
|
||||
|
||||
//sb.Append("Acknowledged Time:");
|
||||
//sb.Append(item.AcknowledgeTime.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
//sb.AppendLine();
|
||||
//sb.AppendLine();
|
||||
|
||||
|
||||
AnalysisText.Text = sb.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
AnalysisText.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.UI.View.Common;
|
||||
using Aitex.Core.Utilities;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Alarms.Alarm
|
||||
{
|
||||
|
||||
public class AlarmViewModel : UiViewModelBase
|
||||
{
|
||||
[IgnorePropertyChange]
|
||||
public List<AlarmItem> AlarmEvents { get; set; }
|
||||
|
||||
|
||||
public AlarmViewModel()
|
||||
{
|
||||
Subscribe("System.LiveAlarmEvent");
|
||||
}
|
||||
|
||||
protected override void Poll()
|
||||
{
|
||||
base.Poll();
|
||||
}
|
||||
|
||||
protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
|
||||
{
|
||||
if (data.TryGetValue("System.LiveAlarmEvent", out var value))
|
||||
UpdateAlarmEvent((List<EventItem>)value);
|
||||
}
|
||||
|
||||
public void UpdateAlarmEvent(List<EventItem> alarmsFromRt)
|
||||
{
|
||||
var alarmEvents = new List<AlarmItem>();
|
||||
foreach (var item in alarmsFromRt)
|
||||
{
|
||||
|
||||
var alarmItem = new AlarmItem()
|
||||
{
|
||||
Level = item.Level,
|
||||
Source = item.Source,
|
||||
OccuringTime = item.OccuringTime.ToString("yyyy/MM/dd HH:mm:ss"),
|
||||
Description = item.Description,
|
||||
EventEnum = item.EventEnum,
|
||||
EventId = item.Id,
|
||||
Explaination = item.Explaination,
|
||||
Solution = item.Solution,
|
||||
IsAcknowledged = item.IsAcknowledged,
|
||||
AcknowledgeTime = item.AcknowledgedTime
|
||||
};
|
||||
alarmEvents.Add(alarmItem);
|
||||
}
|
||||
if (AlarmEvents == null || (alarmEvents.Count != AlarmEvents.Count))
|
||||
{
|
||||
AlarmEvents = alarmEvents;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isEqual = true;
|
||||
if (alarmEvents.Count == AlarmEvents.Count)
|
||||
{
|
||||
for (int i = 0; i < alarmEvents.Count; i++)
|
||||
{
|
||||
if (!alarmEvents[i].IsEqualTo(AlarmEvents[i]))
|
||||
{
|
||||
isEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isEqual)
|
||||
AlarmEvents = alarmEvents;
|
||||
}
|
||||
|
||||
NotifyOfPropertyChange(nameof(AlarmEvents));
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Brushes = System.Drawing.Brushes;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Alarms.Alarm
|
||||
{
|
||||
public class EventLevelToBackgroundConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is EventLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case EventLevel.Alarm:
|
||||
return new SolidColorBrush(Colors.Red);
|
||||
case EventLevel.Warning:
|
||||
return new SolidColorBrush(Colors.Yellow);
|
||||
case EventLevel.Information:
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
default:
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user