refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+252
@@ -0,0 +1,252 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm.ModuleAlarmView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:alarm="clr-namespace:MECF.Framework.UI.Client.CenterViews.Alarms.Alarm"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:moduleAlarm="clr-namespace:MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
d:DesignHeight="625"
|
||||
d:DesignWidth="1200"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<moduleAlarm:TypeColorConverter x:Key="TypeColorConverter" />
|
||||
|
||||
<Style x:Key="localListBoxItem" TargetType="{x:Type xctk:SelectorItem}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Margin" Value="0,0,20,0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal">
|
||||
<Border
|
||||
Width="70"
|
||||
Height="40"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="Modules:" />
|
||||
</Border>
|
||||
<Border
|
||||
Width="60"
|
||||
Height="40"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,1,1,1">
|
||||
<CheckBox
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
Command="{Binding SelectAllChanged}"
|
||||
Content="All"
|
||||
FontSize="14"
|
||||
IsChecked="{Binding IsAllSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Border>
|
||||
<Border
|
||||
Width="800"
|
||||
Height="40"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,1,1,1">
|
||||
<xctk:CheckListBox
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
BorderThickness="0"
|
||||
Command="{Binding SelectionChanged}"
|
||||
DisplayMemberPath="ModuleName"
|
||||
FontSize="14"
|
||||
ItemContainerStyle="{DynamicResource localListBoxItem}"
|
||||
ItemsSource="{Binding AllModules}"
|
||||
SelectedItemsOverride="{Binding SelectedModules, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedMemberPath="IsSelected">
|
||||
<xctk:CheckListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel
|
||||
Margin="1,1,0,0"
|
||||
IsItemsHost="True"
|
||||
Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</xctk:CheckListBox.ItemsPanel>
|
||||
|
||||
</xctk:CheckListBox>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
Width="Auto"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
CanUserReorderColumns="False"
|
||||
CanUserSortColumns="False"
|
||||
FontSize="14"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding FilteredAlarms}"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<DataGrid.Columns>
|
||||
|
||||
|
||||
<DataGridTemplateColumn
|
||||
Width="90"
|
||||
CanUserSort="True"
|
||||
Header="Type"
|
||||
SortMemberPath="Type">
|
||||
<DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Type" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Label
|
||||
Background="{Binding Type, Converter={StaticResource TypeColorConverter}}"
|
||||
Content="{Binding Type}"
|
||||
FontSize="12" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="150"
|
||||
Binding="{Binding OccuringTime, Mode=OneWay}"
|
||||
CanUserSort="True"
|
||||
Header="Time"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Time" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="150"
|
||||
Binding="{Binding Source, Mode=OneWay}"
|
||||
CanUserSort="True"
|
||||
Header="Source"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Source" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTemplateColumn
|
||||
Width="*"
|
||||
CanUserSort="True"
|
||||
Header="Description"
|
||||
SortMemberPath="Description">
|
||||
<DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Description" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
Text="{Binding Description}"
|
||||
TextWrapping="Wrap" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
|
||||
<DataGridTemplateColumn Width="110">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button
|
||||
Width="100"
|
||||
Height="25"
|
||||
Content="Reset"
|
||||
FontSize="14">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="ResetAlarm">
|
||||
<micro:Parameter Value="{Binding}" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!--<GroupBox Header="Alarm List" Margin="5,0,12,5">
|
||||
<DataGrid Grid.Row="1" Margin="0,5,0,0"
|
||||
Width="Auto"
|
||||
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
HorizontalAlignment="Left"
|
||||
AutoGenerateColumns="False" Name="dataGrid1" ItemsSource="{Binding AlarmEvents,Mode=OneWay}"
|
||||
FontFamily="Arial,SimSun"
|
||||
CanUserReorderColumns="False" CanUserAddRows="False"
|
||||
CanUserSortColumns="False"
|
||||
IsReadOnly="True" FontSize="14">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Type" Width="90" CanUserSort="True" SortMemberPath="Type">
|
||||
<DataGridTemplateColumn.HeaderTemplate >
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Type" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.HeaderTemplate>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Label Content="{Binding Type}" Background="{Binding TextColor}" FontSize="12"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTextColumn Header="Time" Width="150" CanUserSort="True" IsReadOnly="True" Binding="{Binding OccuringTime,Mode=OneWay}">
|
||||
<DataGridTextColumn.HeaderTemplate >
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Time" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Description" Width="*" CanUserSort="True" IsReadOnly="True" Binding="{Binding Description,Mode=OneWay}">
|
||||
<DataGridTextColumn.HeaderTemplate >
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Description" />
|
||||
</DataTemplate>
|
||||
</DataGridTextColumn.HeaderTemplate>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</GroupBox>-->
|
||||
<!--<GroupBox Grid.Column="1" Header="Detail" Margin="0,0,5,5">
|
||||
<TextBlock x:Name="AnalysisText" FontSize="14" Margin="5" Background="White" TextWrapping="Wrap" Style="{x:Null}"/>
|
||||
</GroupBox>-->
|
||||
</UserControl>
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using Aitex.Core.UI.View.Common;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm
|
||||
{
|
||||
/// <summary>
|
||||
/// ModuleAlarmView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ModuleAlarmView : UserControl
|
||||
{
|
||||
public ModuleAlarmView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void listView1_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//if (e.AddedItems.Count == 1)
|
||||
//{
|
||||
// var item = e.AddedItems[0] as AlarmItem;
|
||||
// AnalysisText.Text = string.Format("Event Type:{0}\r\n\r\nEvent Name:{1}\r\n\r\nTime:{2}\r\n\r\nDescription:{3}",
|
||||
// item.Type,
|
||||
// item.EventEnum,
|
||||
// //item.EventId, Event Number:{ 2}\r\n\r\n
|
||||
// item.OccuringTime,
|
||||
// item.Description
|
||||
// //item.Solution \r\n\r\nSolution:{ 5}
|
||||
// );
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// AnalysisText.Text = string.Empty;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
|
||||
switch ((string)value)
|
||||
{
|
||||
case "Alarm": return Brushes.Red;
|
||||
case "Warning": return Brushes.Yellow;
|
||||
}
|
||||
|
||||
return Brushes.Transparent;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.UI.MVVM;
|
||||
using MECF.Framework.Common.CommonData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.Event;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Input;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm
|
||||
{
|
||||
public class ModuleAlarmViewModel : UiViewModelBase
|
||||
{
|
||||
public class UIModuleItem : NotifiableItem
|
||||
{
|
||||
public string ModuleName { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
|
||||
public class UIAlarmItem : NotifiableItem
|
||||
{
|
||||
public string OccuringTime { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
public int EventId { get; set; }
|
||||
public string EventEnum { get; set; }
|
||||
public string Explaination { get; set; }
|
||||
public string Solution { get; set; }
|
||||
public string Source { get; set; }
|
||||
|
||||
public bool IsEqualTo(UIAlarmItem item)
|
||||
{
|
||||
return item.OccuringTime == OccuringTime &&
|
||||
item.EventEnum == EventEnum &&
|
||||
item.Description == Description &&
|
||||
item.Source == Source &&
|
||||
item.Type == Type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<UIAlarmItem> FilteredAlarms { get; set; }
|
||||
|
||||
public ObservableCollection<UIModuleItem> AllModules { get; set; }
|
||||
public ObservableCollection<UIModuleItem> SelectedModules { get; set; }
|
||||
|
||||
public ICommand SelectionChanged { get; set; }
|
||||
public ICommand SelectAllChanged { get; set; }
|
||||
|
||||
public bool IsAllSelected { get; set; }
|
||||
|
||||
public ModuleAlarmViewModel()
|
||||
{
|
||||
Subscribe("System.ActiveAlarm");
|
||||
|
||||
SelectionChanged = new DelegateCommand<object>(DoSelectionChanged);
|
||||
SelectAllChanged = new DelegateCommand<object>(DoSelectAllChanged);
|
||||
|
||||
AllModules = new ObservableCollection<UIModuleItem>();
|
||||
|
||||
FilteredAlarms = new ObservableCollection<UIAlarmItem>();
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
var data = QueryDataClient.Instance.Service.GetData("System.Modules");
|
||||
if (data != null)
|
||||
{
|
||||
foreach (var module in (List<string>)data)
|
||||
{
|
||||
AllModules.Add(new UIModuleItem()
|
||||
{
|
||||
IsSelected = true,
|
||||
ModuleName = module,
|
||||
});
|
||||
}
|
||||
}
|
||||
//InvokePropertyChanged(nameof(AllModules));
|
||||
|
||||
IsAllSelected = true;
|
||||
|
||||
SelectedModules = new ObservableCollection<UIModuleItem>(AllModules);
|
||||
}
|
||||
|
||||
private void DoSelectAllChanged(object obj)
|
||||
{
|
||||
if (IsAllSelected)
|
||||
{
|
||||
var modules = new ObservableCollection<UIModuleItem>(AllModules);
|
||||
foreach (var uiModuleItem in modules)
|
||||
{
|
||||
uiModuleItem.IsSelected = true;
|
||||
}
|
||||
|
||||
SelectedModules = modules;
|
||||
NotifyOfPropertyChange(nameof(SelectedModules));
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedModules.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void DoSelectionChanged(object obj)
|
||||
{
|
||||
bool allSelected = true;
|
||||
foreach (var uiModuleItem in AllModules)
|
||||
{
|
||||
if (!uiModuleItem.IsSelected && uiModuleItem.ModuleName != "All")
|
||||
{
|
||||
allSelected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IsAllSelected = allSelected;
|
||||
NotifyOfPropertyChange(nameof(IsAllSelected));
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
}
|
||||
|
||||
public void ResetAlarm(UIAlarmItem item)
|
||||
{
|
||||
InvokeClient.Instance.Service.DoOperation("System.ResetAlarm", item.Source, item.EventEnum);
|
||||
}
|
||||
|
||||
protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
|
||||
{
|
||||
if (data.ContainsKey("System.ActiveAlarm"))
|
||||
UpdateAlarmEvent((List<AlarmEventItem>)data["System.ActiveAlarm"]);
|
||||
}
|
||||
|
||||
public void UpdateAlarmEvent(List<AlarmEventItem> evItems)
|
||||
{
|
||||
List<UIAlarmItem> removeList = new List<UIAlarmItem>();
|
||||
foreach (var filteredItem in FilteredAlarms)
|
||||
{
|
||||
if (SelectedModules.FirstOrDefault(x => x.ModuleName == filteredItem.Source) == null && !IsAllSelected)
|
||||
{
|
||||
removeList.Add(filteredItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!evItems.Exists(x => x.Source == filteredItem.Source && x.EventEnum == filteredItem.EventEnum))
|
||||
{
|
||||
removeList.Add(filteredItem);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var uiAlarmItem in removeList)
|
||||
{
|
||||
FilteredAlarms.Remove(uiAlarmItem);
|
||||
}
|
||||
|
||||
foreach (AlarmEventItem item in evItems)
|
||||
{
|
||||
var newItem = new UIAlarmItem()
|
||||
{
|
||||
Type = item.Level == EventLevel.Alarm ? "Alarm" : (item.Level == EventLevel.Information ? "Info" : "Warning"),
|
||||
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,
|
||||
Source = item.Source,
|
||||
};
|
||||
|
||||
if (FilteredAlarms.FirstOrDefault(x => x.IsEqualTo(newItem)) == null &&
|
||||
(SelectedModules.FirstOrDefault(x => x.ModuleName == newItem.Source) != null || IsAllSelected))
|
||||
{
|
||||
FilteredAlarms.Add(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user