refactor: 将Framework库和RT、UI放在同一个解决方案中。

This commit is contained in:
SL
2026-06-01 17:48:28 +08:00
parent 1948f4290d
commit b73d39a6b1
4331 changed files with 506148 additions and 49363 deletions
@@ -0,0 +1,133 @@
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.Connections.ConnectionView"
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:connections="clr-namespace:MECF.Framework.UI.Client.CenterViews.Maitenances.Connections"
mc:Ignorable="d" >
<UserControl.Resources>
<connections:BoolBackgroundConverter x:Key="BoolBackgroundConverter"/>
<SolidColorBrush x:Key="DataGrid_Cell_BD" Color="Gray"/>
<Style x:Key="Lamp-Button" TargetType="{x:Type connections:IoButton}">
<Setter Property="Width" Value="16"/>
<Setter Property="Height" Value="16"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type connections:IoButton}">
<Grid>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Content=""/>
<Ellipse Stroke="Gray" StrokeThickness="2"
Fill="DarkGray" />
<Ellipse x:Name="Highlight" Stroke="Gray" StrokeThickness="2"
Fill="Lime" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Visibility" TargetName="Highlight" Value="Visible"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Visibility" TargetName="Highlight" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Opacity" TargetName="Highlight" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Sepcial_ListBoxItem" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<Grid>
<Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Opacity" TargetName="Highlight" Value="1"/>
<Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
<Setter Property="Margin" TargetName="Highlight" Value="0,0,1,1"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ListBox.AlternationIndex" Value="0">
<Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
</Trigger>
<Trigger Property="ListBox.AlternationIndex" Value="1">
<Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
</Trigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="DOTemplate">
<Grid Margin="-1,-1,0,0" Height="45" Background="{Binding IsChecked, ElementName=ckHold, Converter={StaticResource BoolBackgroundConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="45"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="15"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
<TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
</Border>
<Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
<TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBlock>
</Border>
<Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
<connections:IoButton ON="{Binding Path=IsConnected}" Style="{StaticResource Lamp-Button}" IsChecked="{Binding IsConnected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Border>
<Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
<Button Content="Connect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListBox}}, Path=DataContext.ConnectCommand}" CommandParameter="{Binding Path=Name}" />
</Border>
<Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
<Button Content="Disconnect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListBox}}, Path=DataContext.DisconnectCommand}" CommandParameter="{Binding Path=Name}" />
</Border>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<ListBox ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" Width="1900" ItemsSource="{Binding ListConnections}" AlternationCount="2" ItemTemplate="{StaticResource DOTemplate}" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0" Margin="5,0" HorizontalAlignment="Center">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
</UserControl>
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.Connections
{
/// <summary>
/// Interaction logic for IOView.xaml
/// </summary>
public partial class ConnectionView : UserControl
{
public ConnectionView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using Aitex.Core.RT.DataCenter;
using Aitex.Core.UI.MVVM;
using MECF.Framework.Common.Communications;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.Connections
{
public class ConnectionViewModel : UiViewModelBase, ISupportMultipleSystem
{
protected override void OnInitialize()
{
base.OnInitialize();
}
protected override void OnActivate()
{
base.OnActivate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
}
public ObservableCollection<NotifiableConnectionItem> ListConnections { get; set; }
public ICommand ConnectCommand { get; set; }
public ICommand DisconnectCommand { get; set; }
public ConnectionViewModel()
{
ListConnections = new ObservableCollection<NotifiableConnectionItem>();
ConnectCommand = new DelegateCommand<string>(DoConnect);
DisconnectCommand = new DelegateCommand<string>(DoDisconnect);
}
private void DoConnect(string obj)
{
if (DialogBox.Confirm($"Are you sure you want to connect {obj}?"))
{
InvokeClient.Instance.Service.DoOperation($"Connection.Connect", obj);
}
}
private void DoDisconnect(string obj)
{
if (DialogBox.Confirm($"Are you sure you want to disconnect {obj}?"))
{
InvokeClient.Instance.Service.DoOperation($"Connection.Disconnect", obj);
}
}
protected override void Poll()
{
Application.Current.Dispatcher.Invoke(new Action(() =>
{
var connections = QueryDataClient.Instance.Service.GetData("Connection.List");
if (connections == null)
return;
List<NotifiableConnectionItem> items = connections as List<NotifiableConnectionItem>;
foreach (var item in items)
{
if (ListConnections.Count == 0 || (ListConnections.FirstOrDefault(x => x.Name == item.Name) == null))
{
ListConnections.Add(item);
}
else
{
var find = ListConnections.First(x => x.Name == item.Name);
find.IsConnected = find.IsConnected;
find.InvokePropertyChanged("IsConnected");
}
}
//InvokePropertyChanged("ListConnections");
}));
}
}
public class IoButton : ToggleButton
{
public static readonly DependencyProperty ONProperty;
static IoButton()
{
ONProperty = DependencyProperty.Register("ON", typeof(bool), typeof(IoButton));
}
public bool ON
{
get { return (bool)GetValue(ONProperty); }
set { SetValue(ONProperty, value); }
}
}
public class BoolBackgroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool? ret = (bool?)value;
return ret.HasValue && ret.Value ? "LightBlue" : "Transparent";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}