首次上传
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable.CalibrationTableView"
|
||||
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:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<DataGrid Grid.Column="0" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
SelectedItem="{Binding CurrentSelection}"
|
||||
ItemsSource="{Binding CalibrationItems}" Margin="0,5,0,0" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Name" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas Grid.Row="0">
|
||||
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1,1,1,1" Background="{DynamicResource Table_BG_Title}" Grid.Row="1" Padding="5,1" Height="40" Width="120">
|
||||
<TextBlock Text="Calibration Item" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,1,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Row="1" Grid.Column="1" Padding="5,1" Canvas.Left="120" Height="40" Width="250">
|
||||
<TextBlock Text="{Binding CurrentSelection.DisplayName}" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
|
||||
<Button Content="Save" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="385" Canvas.Top="4" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Save">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button Content="Cancel" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="473" Canvas.Top="4" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Cancel">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Canvas>
|
||||
|
||||
<Canvas Grid.Row="1" VerticalAlignment="Bottom">
|
||||
<TextBlock Text="Feedback Value:" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center" Canvas.Left="1" Canvas.Top="-21" />
|
||||
|
||||
<TextBlock Text="Calibration Value:" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center" Canvas.Left="210" Canvas.Top="-21" />
|
||||
|
||||
</Canvas>
|
||||
|
||||
|
||||
<Canvas Grid.Row="2">
|
||||
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding Path=FeedbackValue, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" RenderTransformOrigin="3.857,1.5" Height="40" Width="160" Canvas.Left="1" />
|
||||
|
||||
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding Path=CalibrationValue, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" RenderTransformOrigin="3.857,1.5" Canvas.Left="208" Height="40" Width="160" />
|
||||
|
||||
<Button Content="Add" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="389" Canvas.Top="5" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Add">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Canvas>
|
||||
|
||||
|
||||
<DataGrid Grid.Row="3" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
ItemsSource="{Binding TableData}" Margin="0,5,0,0" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Feedback Value" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding FeedbackValue}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Calibration Value" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding CalibrationValue}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header=" " Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Content="Delete" Width="100" Height="25" FontSize="14">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="DeleteItem">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable
|
||||
{
|
||||
/// <summary>
|
||||
/// CalibrationTableView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CalibrationTableView : UserControl
|
||||
{
|
||||
public CalibrationTableView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.UI.MVVM;
|
||||
using Aitex.Core.Util;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using MECF.Framework.Common.CommonData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using SciChart.Core.Extensions;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable
|
||||
{
|
||||
|
||||
public interface ICalibrationTableViewModelParameter
|
||||
{
|
||||
List<CalibrationTableItem> Items { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationTableItem
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string ItemTableScName { get; set; }
|
||||
public string ItemEnableScName { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationTableViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public ICalibrationTableViewModelParameter CustomParameter { get; set; }
|
||||
|
||||
public class NotifiableCalibrationTableItem : NotifiableItem
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public float FeedbackValue { get; set; }
|
||||
|
||||
public float CalibrationValue { get; set; }
|
||||
}
|
||||
|
||||
public ObservableCollection<CalibrationTableItem> CalibrationItems { get; set; }
|
||||
|
||||
public ObservableCollection<NotifiableCalibrationTableItem> TableData { get; set; }
|
||||
|
||||
public string FeedbackValue { get; set; }
|
||||
|
||||
public string CalibrationValue { get; set; }
|
||||
|
||||
private CalibrationTableItem _currentSelection;
|
||||
|
||||
public CalibrationTableItem CurrentSelection
|
||||
{
|
||||
get { return _currentSelection; }
|
||||
set
|
||||
{
|
||||
_currentSelection = value;
|
||||
ChangeSelection(_currentSelection);
|
||||
|
||||
NotifyOfPropertyChange(nameof(CurrentSelection));
|
||||
}
|
||||
}
|
||||
|
||||
public CalibrationTableViewModel()
|
||||
{
|
||||
DisplayName = "Calibration Table ";
|
||||
|
||||
CalibrationItems = new ObservableCollection<CalibrationTableItem>();
|
||||
TableData = new ObservableCollection<NotifiableCalibrationTableItem>();
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
if (CustomParameter != null && CustomParameter.Items != null && CalibrationItems.IsEmpty())
|
||||
{
|
||||
foreach (var item in CustomParameter.Items)
|
||||
{
|
||||
CalibrationItems.Add(new CalibrationTableItem()
|
||||
{
|
||||
DisplayName = item.DisplayName,
|
||||
ItemEnableScName = item.ItemEnableScName,
|
||||
ItemTableScName = item.ItemTableScName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void ChangeSelection(CalibrationTableItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
TableData.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
var tableValues = QueryDataClient.Instance.Service.GetConfig(item.ItemTableScName);
|
||||
if (tableValues == null)
|
||||
return;
|
||||
|
||||
var scValue = (string) tableValues;
|
||||
|
||||
string[] items = scValue.Split(';');
|
||||
|
||||
|
||||
var tableData = new ObservableCollection<NotifiableCalibrationTableItem>();
|
||||
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
if (items.Length > i)
|
||||
{
|
||||
string itemValue = items[i];
|
||||
if (!string.IsNullOrEmpty(itemValue))
|
||||
{
|
||||
string[] pairValue = itemValue.Split('#');
|
||||
if (pairValue.Length == 2)
|
||||
{
|
||||
if (float.TryParse(pairValue[0], out float rangeItem1)
|
||||
&& float.TryParse(pairValue[1], out float rangeItem2))
|
||||
{
|
||||
tableData.Add(new NotifiableCalibrationTableItem()
|
||||
{
|
||||
FeedbackValue = rangeItem1,
|
||||
CalibrationValue = rangeItem2,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TableData = new ObservableCollection<NotifiableCalibrationTableItem>( tableData.OrderBy(x => x.FeedbackValue).ToList());
|
||||
|
||||
NotifyOfPropertyChange(nameof(TableData));
|
||||
}
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (CurrentSelection == null)
|
||||
return;
|
||||
|
||||
string data = "";
|
||||
foreach (var item in TableData)
|
||||
{
|
||||
data += $"{item.FeedbackValue}#{item.CalibrationValue};";
|
||||
}
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetConfig", CurrentSelection.ItemTableScName, data);
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
ChangeSelection(CurrentSelection);
|
||||
}
|
||||
|
||||
public void Add()
|
||||
{
|
||||
if (string.IsNullOrEmpty(FeedbackValue) || string.IsNullOrEmpty(CalibrationValue))
|
||||
{
|
||||
MessageBox.Show("Input value is empty");
|
||||
return;
|
||||
}
|
||||
if (!float.TryParse(FeedbackValue, out float feedback) ||
|
||||
!float.TryParse(CalibrationValue, out float calibrationValue))
|
||||
{
|
||||
MessageBox.Show("Input value not valid");
|
||||
return;
|
||||
}
|
||||
|
||||
FeedbackValue = "";
|
||||
CalibrationValue = "";
|
||||
NotifyOfPropertyChange(nameof(FeedbackValue));
|
||||
NotifyOfPropertyChange(nameof(CalibrationValue));
|
||||
|
||||
TableData.Add(new NotifiableCalibrationTableItem()
|
||||
{
|
||||
DisplayName = CurrentSelection.DisplayName,
|
||||
FeedbackValue = feedback,
|
||||
CalibrationValue = calibrationValue,
|
||||
});
|
||||
}
|
||||
|
||||
public void DeleteItem(NotifiableCalibrationTableItem item)
|
||||
{
|
||||
TableData.Remove(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user