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,16 @@
using MECF.Framework.Common.CommonData;
using System.Collections.ObjectModel;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
public class ChamberTypeItem : NotifiableItem
{
public string ChamberType { get; set; }
public ObservableCollection<ProcessTypeFileItem> FileListByChamberType { get; set; }
public ChamberTypeItem()
{
FileListByChamberType = new ObservableCollection<ProcessTypeFileItem>();
}
}
}
@@ -0,0 +1,29 @@
using System.Windows;
using System.Windows.Controls;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
public class FolderOrFileTemplateSelector : DataTemplateSelector
{
public DataTemplate FolderTemplate
{
get;
set;
}
public DataTemplate FileTemplate
{
get;
set;
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
FileNode file = (FileNode)item;
if (!file.IsFile)
return FolderTemplate;
else
return FileTemplate;
}
}
}
@@ -0,0 +1,47 @@
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Editors.InputFileNameDialogView"
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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Border BorderBrush="Gray" BorderThickness="0,1,0,0" Background="{DynamicResource Tab_BG}">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Title}" Padding="5,1">
<TextBlock Text="Name" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="16" FontFamily="Arial" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,1,1,1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
<controls:TextBoxEx x:Name="tbName" FontSize="14" Height="35" TextWrapping="NoWrap" AllowBackgroundChange="False" Text="{Binding FileName}" Width="300" />
</Border>
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Margin="0,10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="OK" Width="90" Height="30">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="OK">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Content="Cancel" Margin="10,0,0,0" Width="90" Height="30">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Cancel">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,20 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
/// <summary>
/// InputFileNameDialogView.xaml 的交互逻辑
/// </summary>
public partial class InputFileNameDialogView : UserControl
{
public InputFileNameDialogView()
{
InitializeComponent();
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}
@@ -0,0 +1,34 @@
using System.Windows.Input;
using OpenSEMI.ClientBase;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
public class InputFileNameDialogViewModel : DialogViewModel<string>
{
public InputFileNameDialogViewModel(string dialogName = "")
{
this.DisplayName = dialogName;
}
public string FileName { get; set; }
public void Cancel()
{
IsCancel = true;
TryClose(false);
}
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
InputFileNameDialogView v = (InputFileNameDialogView)view;
FocusManager.SetFocusedElement(v, v.tbName);
}
public void OK()
{
this.DialogResult = FileName;
IsCancel = false;
TryClose(true);
}
}
}
@@ -0,0 +1,96 @@
using System.Collections.ObjectModel;
using MECF.Framework.Common.CommonData;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
public class ProcessTypeFileItem : NotifiableItem
{
#region Variablers
private ObservableCollection<FileNode> _fileListByProcessType;
#endregion
#region Constructors
public ProcessTypeFileItem()
{
FileListByProcessType = new ObservableCollection<FileNode>();
}
public ProcessTypeFileItem(RecipeType type) : this()
{
ProcessType = type;
}
#endregion
#region Properties
public RecipeType ProcessType { get; set; }
public ObservableCollection<FileNode> FileListByProcessType
{
get => _fileListByProcessType;
set
{
_fileListByProcessType = value;
InvokePropertyChanged(nameof(FileListByProcessType));
}
}
#endregion
#region Methods
/// <summary>
/// 根据指定的工艺文件类型获取工艺文件前缀。
/// </summary>
/// <param name="fileTypes"></param>
/// <returns></returns>
public static string GetProcessFilesPrefix(string fileTypes)
{
if (string.IsNullOrEmpty(fileTypes))
return string.Empty;
switch (fileTypes.ToLower())
{
case "process":
return GetProcessFilesPrefix(RecipeType.Process);
case "routine":
return GetProcessFilesPrefix(RecipeType.Routine);
case "clean":
return GetProcessFilesPrefix(RecipeType.Clean);
default:
return string.Empty;
}
}
/// <summary>
/// 根据指定的工艺文件类型获取工艺文件前缀。
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static string GetProcessFilesPrefix(RecipeType type)
{
switch (type)
{
case RecipeType.Process:
return "Sic\\Process";
case RecipeType.Routine:
return "Sic\\Routine";
case RecipeType.Clean:
return "Sic\\Clean";
default:
return string.Empty;
}
}
#endregion
}
}
@@ -0,0 +1,207 @@
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.PopSettingDialogView"
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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:editors="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors.Recipe"
mc:Ignorable="d"
Width="600"
Height="800">
<UserControl.Resources>
<HierarchicalDataTemplate x:Key="FolderTemplate" ItemsSource="{Binding Files}" >
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}, Path=DataContext}">
<Image x:Name="ExpandImage" Source="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Close.png" Width="14" Height="12" Margin="2,0,0,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Image.Source" TargetName="ExpandImage" Value="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Unable.png"/>
</Trigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="FileTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}, Path=DataContext}">
<Path Data="M0.5,5.125 L5.125,5.125 5.125,0.5 M5.1,0.5 L15.5,0.5 15.5,19.5 0.5,19.5 C0.5,14.7 0.5,10 0.5,5.1 2,3.6 3.6,2 5.1,0.5 z M8.1,8.5 L8.2,8.5 z M8.1,11.5 L8.2,11.5 z M8.1,14.5 L8.2,14.5 z" Fill="#FFF3F3F3" HorizontalAlignment="Left" Stretch="Fill" Stroke="#FF454545" Width="13" Height="16"/>
<TextBlock Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</HierarchicalDataTemplate>
<editors:FolderOrFileTemplateSelector x:Key="FolderFileTemplateSelector" FolderTemplate="{StaticResource FolderTemplate}" FileTemplate="{StaticResource FileTemplate}"/>
<DataTemplate x:Key="template_TextBox">
<controls:TextBoxEx Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}"
EditBoxMode="Decimal"
TextSaved="{Binding IsSaved,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
FontSize="14"
FontFamily="Arial"
Width="300"
IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate >
<DataTemplate x:Key="template_TextBoxString">
<controls:TextBoxEx Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}"
EditBoxMode="Default"
TextSaved="{Binding IsSaved,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
FontSize="14"
FontFamily="Arial"
Width="300"
IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate >
<DataTemplate x:Key="template_ComboBox">
<controls:ComboBoxExt Style="{StaticResource ResourceKey={x:Type ComboBox}}"
Visibility="{Binding Visible}"
ComboBoxSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding IsEnabled}"
DisplayMemberPath="DisplayName"
SelectedValuePath="ControlName"
SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Options}"/>
</DataTemplate>
<local:TemplateSelector x:Key="Template"
TextBoxTemplate="{StaticResource template_TextBox}"
TextBoxTemplateString="{StaticResource template_TextBoxString}"
ComboBoxTemplate="{StaticResource template_ComboBox}"
/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="Auto" ></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto" ></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" ></ColumnDefinition>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Background="CadetBlue" >
<TextBlock Text="Endpoint Control Parameters" HorizontalAlignment="Center" Height="18" Width="210"></TextBlock>
</StackPanel>
<Border Grid.Row="1" Grid.ColumnSpan="2">
<DataGrid ItemsSource="{Binding Path=ControlParameters}"
CanUserAddRows="False"
AutoGenerateColumns="False"
RowHeaderWidth="0"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
Width="591"
HorizontalAlignment="Center"
VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" >
<DataGrid.Columns>
<DataGridTemplateColumn Width="289" Header="Parameters" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}"
FontFamily="Arial" FontSize="14"
Foreground="{DynamicResource FG_Black}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
ToolTip="{Binding RelativeSource={RelativeSource Self},
Path=Text}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="setting" CellTemplateSelector="{StaticResource Template}" Width="300"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<Border Grid.Row="2" Grid.ColumnSpan="2" Margin="0,5" Visibility="{Binding BandVisibility}">
<DataGrid ItemsSource="{Binding Path=BandParameters}"
CanUserAddRows="False"
AutoGenerateColumns="False"
RowHeaderWidth="0"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
Width="590"
HorizontalAlignment="Center"
VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" >
<DataGrid.Columns>
<DataGridTemplateColumn Width="228" Header="Parameters" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}"
FontFamily="Arial" FontSize="14"
Foreground="{DynamicResource FG_Black}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
ToolTip="{Binding RelativeSource={RelativeSource Self},
Path=Text}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="180" Header="Wavelength (nm)">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<controls:TextBoxEx Text="{Binding WavelengthDoubleParam.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}"
EditBoxMode="Decimal"
TextSaved="{Binding IsSaved,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
FontSize="14"
FontFamily="Arial"
Width="300"
IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="180" Header="Bandwidth (nm)">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<controls:TextBoxEx Text="{Binding BandwidthDoubleParam.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}"
EditBoxMode="Decimal"
TextSaved="{Binding IsSaved,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
FontSize="14"
FontFamily="Arial"
Width="300"
IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="-4,10,10,10" Width="190">
<Button Content="OK" Width="90" Height="30">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="OK">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Content="Cancel" Margin="10,0,0,0" Width="90" Height="30">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Cancel">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// PopSettingDialogView.xaml 的交互逻辑
/// </summary>
public partial class PopSettingDialogView : UserControl
{
public PopSettingDialogView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,102 @@
using OpenSEMI.ClientBase;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public class TemplateSelector : DataTemplateSelector
{
private DataTemplate _textBoxTemplate = null;
public DataTemplate TextBoxTemplate
{
get { return _textBoxTemplate; }
set { _textBoxTemplate = value; }
}
private DataTemplate _textBoxTemplateString = null;
public DataTemplate TextBoxTemplateString
{
get { return _textBoxTemplateString; }
set { _textBoxTemplateString = value; }
}
private DataTemplate _comboBoxTemplate = null;
public DataTemplate ComboBoxTemplate
{
get { return _comboBoxTemplate; }
set { _comboBoxTemplate = value; }
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is Param)
{
return (item as Param).GetType().Name == "ComboxParam" ? _comboBoxTemplate : ((item as Param).GetType().Name == "StringParam" ? _textBoxTemplateString : _textBoxTemplate);
}
return base.SelectTemplate(item, container);
}
}
public class BandParam : Param
{
public Param WavelengthDoubleParam
{
get;
set;
}
public Param BandwidthDoubleParam
{
get;
set;
}
}
/// <summary>
///
/// </summary>
public class PublicPopSettingDialogViewModel : DialogViewModel<RecipeStep>
{
public RecipeStep Parameters
{
get;
set;
}
public RecipeStep ControlParameters
{
get;
set;
}
public ObservableCollection<BandParam> BandParameters
{
get;
set;
}
public Visibility BandVisibility => BandParameters == null || BandParameters.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
public void OK()
{
this.DialogResult = Parameters;
IsCancel = false;
TryClose(true);
}
public void Cancel()
{
IsCancel = true;
TryClose(false);
}
}
}
@@ -0,0 +1,35 @@
using System;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
internal class RecipeCellAccessPermissionWhitelistInfo
{
public RecipeCellAccessPermissionWhitelistInfo(string recipeName, string stepUid, string controlName, DateTime whenSet, string whoSet = "")
{
RecipeName = recipeName;
StepUid = stepUid;
ControlName = controlName;
WhenSet = whenSet;
WhoSet = whoSet;
Uuid = Guid.NewGuid().ToString("N");
}
public string Uuid { get; }
public string RecipeName { get; }
public string StepUid { get; }
public string ControlName { get; }
public string WhoSet { get; }
public DateTime WhenSet { get; }
public override string ToString()
{
return $"'{Uuid}', '{RecipeName}', '{StepUid}', '{ControlName}', '{WhoSet}', '{WhenSet}'";
}
}
}
@@ -0,0 +1,352 @@
<UserControl
x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeCompareView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
xmlns:converters="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.Converters"
xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dgExtension="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.DGExtension"
xmlns:dgExtension1="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.DGExtension"
xmlns:editors="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:uiClientCtrl="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Controls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
d:DesignHeight="1000"
d:DesignWidth="1900"
lex:LocalizeDictionary.DesignCulture="en"
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
mc:Ignorable="d">
<UserControl.Resources>
<HierarchicalDataTemplate x:Key="FolderTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<Image
x:Name="ExpandImage"
Width="14"
Height="12"
Margin="2,0,0,0"
VerticalAlignment="Center"
Source="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Close.png" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ExpandImage" Property="Image.Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Unable.png" />
</Trigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="FileTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, Delay=10}" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
</HierarchicalDataTemplate>
<editors:FolderOrFileTemplateSelector
x:Key="FolderFileTemplateSelector"
FileTemplate="{StaticResource FileTemplate}"
FolderTemplate="{StaticResource FolderTemplate}" />
<Storyboard
x:Key="MenuOpen"
Storyboard.TargetName="border"
Storyboard.TargetProperty="RenderTransform.X">
<DoubleAnimation
From="-370"
To="0"
Duration="0:0:1">
<DoubleAnimation.EasingFunction>
<!-- 设置缓动模式和振荡次数 -->
<BackEase Amplitude="0.5" EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Storyboard
x:Key="MenuClose"
Storyboard.TargetName="border"
Storyboard.TargetProperty="RenderTransform.X">
<DoubleAnimation
From="0"
To="-370"
Duration="0:0:0.6" />
</Storyboard>
</UserControl.Resources>
<Grid>
<Grid Name="rootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<!-- 顶层按钮和Lab标签 Content="Show Menu" -->
<StackPanel Orientation="Horizontal">
<Image
Width="40"
Height="40"
Margin="10,0,0,0"
ToolTip="显示菜单">
<Image.Triggers>
<EventTrigger RoutedEvent="PreviewMouseLeftButtonDown">
<BeginStoryboard Storyboard="{StaticResource MenuOpen}" />
</EventTrigger>
</Image.Triggers>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/menu1.png" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/menu2.png" />
</Trigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock
Margin="20,0"
VerticalAlignment="Center"
FontSize="16">
<Run FontSize="12" Text="{lex:Loc ID_TXT_SelectRecipeName}" /><Run FontSize="12" Text="{Binding LabSelectRecipeNames}" />
</TextBlock>
</StackPanel>
<!-- 侧边栏 -->
<Border
x:Name="border"
Grid.Row="1"
Width="335"
Margin="10"
HorizontalAlignment="Left"
Panel.ZIndex="1000"
Background="#FF9FBEDE">
<!-- 位移效果 -->
<Border.RenderTransform>
<TranslateTransform X="-370" />
</Border.RenderTransform>
<Border.Effect>
<DropShadowEffect
Direction="300"
Opacity="0.6"
ShadowDepth="1"
Color="Black" />
</Border.Effect>
<Border.Triggers>
<!-- 鼠标的左键按下事件来触发退出动画 -->
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<!-- 退出动画 -->
<Storyboard Storyboard.TargetProperty="X">
<DoubleAnimation
From="0"
To="-370"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<StackPanel
Grid.Row="1"
Width="330"
HorizontalAlignment="Left">
<Image
Width="40"
Height="40"
Margin="10,0,0,0"
HorizontalAlignment="Right"
ToolTip="隐藏">
<Image.Triggers>
<EventTrigger RoutedEvent="PreviewMouseLeftButtonDown">
<BeginStoryboard Storyboard="{StaticResource MenuClose}" />
</EventTrigger>
</Image.Triggers>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/return1.png" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/return2.png" />
</Trigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<Border
Height="500"
Background="{DynamicResource Tab_BG}"
BorderBrush="Gray"
BorderThickness="0,1,0,0">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Border
Background="Transparent"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0">
<TabControl
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ItemsSource="{Binding ProcessTypeFileList}"
SelectedIndex="{Binding ProcessTypeIndexSelection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProcessType}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<TreeView
x:Name="RecipeTree1"
Height="{Binding Path=ActualHeight, ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0"
VerticalAlignment="Stretch"
ItemTemplateSelector="{StaticResource FolderFileTemplateSelector}"
ItemsSource="{Binding FileListByProcessType}"
Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<TreeView.ItemContainerStyle>
<Style BasedOn="{StaticResource TreeViewItemExtend}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style>
</TreeView.ItemContainerStyle>
<i:Interaction.Triggers>
<!--<i:EventTrigger EventName="SelectedItemChanged">
<micro:ActionMessage MethodName="TreeSelectChanged">
<micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
</micro:ActionMessage>
</i:EventTrigger>-->
<!--<i:EventTrigger EventName="MouseRightButtonDown">
<micro:ActionMessage MethodName="TreeRightMouseDown">
<micro:Parameter Value="$eventargs" />
</micro:ActionMessage>
</i:EventTrigger>-->
<i:EventTrigger EventName="MouseDoubleClick">
<micro:ActionMessage MethodName="TreeSelectChanged">
<micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
<!--<TreeView.ContextMenu>
<ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Command="{Binding RecipeHistoryCommand}" Header="RecipeHistory" />
</ContextMenu>
</TreeView.ContextMenu>-->
</TreeView>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Border>
</Grid>
</Border>
<Grid>
<Button
Width="80"
Height="35"
Margin="10"
HorizontalAlignment="Left"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
micro:Message.Attach="RefreshRecipe()"
Content="{lex:Loc ID_BTN_Refresh_Content}"
FontSize="13"
IsEnabled="{Binding IsSelectButtonEnable}" />
<Button
Width="80"
Height="35"
Margin="10"
HorizontalAlignment="Right"
micro:Message.Attach="ComperSelectRecipe()"
Content="{lex:Loc ID_BTN_Compare_Content}"
FontSize="13"
IsEnabled="{Binding IsSelectButtonEnable}">
<!--<Button.Triggers>
-->
<!-- 用按钮的鼠标进入事件来触发进入动画 -->
<!--
<EventTrigger RoutedEvent="PreviewMouseLeftButtonDown">
<BeginStoryboard Storyboard="{StaticResource MenuClose}" />
</EventTrigger>
</Button.Triggers>-->
</Button>
</Grid>
</StackPanel>
</Border>
<!-- 对比内容展示 -->
<Grid Grid.Row="1" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="335" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<dgExtension1:DataGridRecipe
AllowDragToFill="False"
FrozenColumnCount="6"
IsEnabled="{Binding IsPermission}"
Recipe="{Binding ComparRecipeHeader, Mode=OneWay}"
ScrollViewerOffset="{Binding ScrollViewerOffset, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<dgExtension1:DataGridRecipe
Grid.Column="1"
AllowDragToFill="False"
ComperHeadersVisibility="None"
FrozenColumnCount="6"
IsEnabled="{Binding IsPermission}"
Recipe="{Binding ComparRecipe1, Mode=OneWay}"
ScrollViewerOffset="{Binding ScrollViewerOffset, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<dgExtension1:DataGridRecipe
Grid.Column="2"
AllowDragToFill="False"
ComperHeadersVisibility="None"
FrozenColumnCount="6"
IsEnabled="{Binding IsPermission}"
Recipe="{Binding ComparRecipe2, Mode=OneWay}"
ScrollViewerOffset="{Binding ScrollViewerOffset, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</Grid>
</Grid>
<uiClientCtrl:PanelLocker
x:Name="editorLocker"
Grid.RowSpan="2"
LockTarget="{Binding ElementName=rootGrid}"
Visibility="Collapsed" />
</Grid>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// RecipeComparisonView.xaml 的交互逻辑
/// </summary>
public partial class RecipeCompareView : UserControl
{
public RecipeCompareView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,514 @@
using Aitex.Core.RT.Log;
using Caliburn.Micro;
using DocumentFormat.OpenXml.EMMA;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.UI.Client.CenterViews.Configs.Roles;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
using MECF.Framework.UI.Client.ClientBase;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
using MECF.Framework.UI.Core.Accounts;
using OpenSEMI.ClientBase;
using OpenSEMI.ClientBase.Command;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public class RecipeCompareViewModel : UiViewModelBase, ISupportMultipleSystem
{
private readonly RecipeType _fileTypes;
private readonly bool _isFolderOnly;
private readonly bool _isShowRootNode;
private FileNode _currentFileNode;
private readonly RecipeProvider _recipeProvider;
public object View { get; set; }
public ObservableCollection<string> Chambers { get; set; }
private string labSelectRecipeNames;
public string LabSelectRecipeNames
{
get => labSelectRecipeNames;
set
{
labSelectRecipeNames = value;
NotifyOfPropertyChange();
}
}
private RecipeData _recipeHeaders;
/// <summary>
/// Recipe表头
/// </summary>
public RecipeData RecipeHeaders
{
get => _recipeHeaders;
set
{
_recipeHeaders = value;
NotifyOfPropertyChange();
}
}
private RecipeData _comparRecipeHeader;
/// <summary>
/// Recipe表头
/// </summary>
public RecipeData ComparRecipeHeader
{
get => _comparRecipeHeader;
set
{
_comparRecipeHeader = value;
NotifyOfPropertyChange();
}
}
private RecipeData _comparRecipe1;
/// <summary>
/// 选择要Recipe-1
/// </summary>
public RecipeData ComparRecipe1
{
get => _comparRecipe1;
set
{
_comparRecipe1 = value;
NotifyOfPropertyChange();
}
}
private RecipeData _comparRecipe2;
/// <summary>
/// 选择要Recipe-2
/// </summary>
public RecipeData ComparRecipe2
{
get => _comparRecipe2;
set
{
_comparRecipe2 = value;
NotifyOfPropertyChange();
}
}
private double[] _scrollViewerOffset;
/// <summary>
/// ScrollViewer滑动偏移
/// </summary>
public double[] ScrollViewerOffset
{
get => _scrollViewerOffset;
set
{
_scrollViewerOffset = value;
NotifyOfPropertyChange();
}
}
public RecipeHistory RecipeHistory { get; set; }
private ICommand _recipeHistoryCommand;
public ICommand RecipeHistoryCommand
{
get
{
if (_recipeHistoryCommand == null)
_recipeHistoryCommand = new BaseCommand(() => RecipeHistoryViewShow());
return _recipeHistoryCommand;
}
}
public int ProcessTypeIndexSelection { get; set; }
public RecipeType CurrentProcessType => ProcessTypeFileList[ProcessTypeIndexSelection].ProcessType;
public string CurrentChamberType { get; set; }
public string SelectedChamber { get; set; }
public ObservableCollection<FileNode> SelectRecipeNameList { get; set; } = new ObservableCollection<FileNode>();
public FileNode DGSelectRecipeName { get; set; }
public List<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
public RecipeCompareViewModel()
{
_fileTypes = RecipeType.Process | RecipeType.Routine;
_isFolderOnly = false;
_isShowRootNode = false;
_recipeProvider = new RecipeProvider();
}
protected override void OnViewLoaded(object view)
{
View = view;
base.OnViewLoaded(view);
}
protected override void OnActivate()
{
base.OnActivate();
RefreshRecipe();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
// 锁定编辑器
((RecipeCompareView)View).editorLocker.Lock();
}
protected override void OnInitialize()
{
base.OnInitialize();
CurrentChamberType = (string)QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
BuildFileTree(_isShowRootNode, _isFolderOnly, _fileTypes);
UpdateRecipeFormat();
}
public void RefreshRecipe()
{
ReloadRecipeFileList(CurrentChamberType, CurrentProcessType, "", false);
}
private void ReloadRecipeFileList(string chamberType, RecipeType processType, string selectedFile,
bool selectionIsFolder)
{
var item = ProcessTypeFileList.FirstOrDefault(x => x.ProcessType == processType);
if (item == null)
{
LOG.Write("error reload recipe file list, type = " + processType);
}
var prefix = $"{CurrentChamberType}\\{SystemName}\\{item.ProcessType}";
var recipes = _recipeProvider.GetXmlRecipeList(prefix);
item.FileListByProcessType =
RecipeSequenceTreeBuilder.BuildFileNode(prefix, selectedFile, selectionIsFolder, recipes)[0].Files;
item.InvokePropertyChanged();
}
private void StoryboardClose()
{
var getString = (Storyboard)((RecipeCompareView)View).FindResource("MenuClose");
getString.Begin();
}
private void RecipeHistoryViewShow()
{
if (_currentFileNode == null)
return;
var dialog = new RecipeHistoryViewModel(_currentFileNode.FullPath.Replace("\\", "-"));
var wm = new WindowManager();
dynamic settings = new ExpandoObject();
settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
settings.Title = "Recipe历史数据对比,选择一个(选择项和当前使用项对比),选择两个(两个选择项对比)";
settings.ResizeMode = ResizeMode.NoResize;
settings.ShowInTaskbar = false;
StoryboardClose();
var bret = wm.ShowDialog(dialog, null, settings);
if ((bool)bret)
{
if (dialog.SelectRecipeMemorieList.Count == 1)
RecipeSelectAndHistory(dialog.SelectRecipeMemorieList[0]);
else if (dialog.SelectRecipeMemorieList.Count == 2)
RecipeBothHistory(dialog.SelectRecipeMemorieList);
}
}
private async void RecipeSelectAndHistory(RecipeHistory recipeHistory)
{
RecipeHistory = recipeHistory;
LabSelectRecipeNames = _currentFileNode.FullPath + " / " + RecipeHistory.RecipeName + ": " + RecipeHistory.CreateTime;
await LoadRecipe(ComparRecipe1, _currentFileNode.PrefixPath, _currentFileNode.FullPath);
await LoadRecipe(ComparRecipe2, RecipeHistory);
StartComper(ComparRecipe1, ComparRecipe2);
}
private async void RecipeBothHistory(List<RecipeHistory> recipeHistoryList)
{
LabSelectRecipeNames = recipeHistoryList[0].RecipeName + ": " + recipeHistoryList[0].CreateTime + " / " + recipeHistoryList[1].RecipeName + ": " + recipeHistoryList[1].CreateTime;
await LoadRecipe(ComparRecipe1, recipeHistoryList[0]);
await LoadRecipe(ComparRecipe2, recipeHistoryList[1]);
StartComper(ComparRecipe1, ComparRecipe2);
}
public void TreeSelectChanged(FileNode file)
{
_currentFileNode = file;
RecipeHistoryViewShow();
}
public void TreeRightMouseDown(MouseButtonEventArgs e)
{
var item = GetParentObjectEx<TreeViewItem>(e.OriginalSource as DependencyObject) as TreeViewItem;
if (item != null)
{
item.Focus();
}
}
private TreeViewItem GetParentObjectEx<TreeViewItem>(DependencyObject obj) where TreeViewItem : FrameworkElement
{
var parent = VisualTreeHelper.GetParent(obj);
while (parent != null)
{
if (parent is TreeViewItem)
{
return (TreeViewItem)parent;
}
parent = VisualTreeHelper.GetParent(parent);
}
return null;
}
private void BuildFileTree(bool isShowRootNode, bool isFolderOnly, RecipeType fileType)
{
var recipeProvider = new RecipeProvider();
var scProcessType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType").ToString();
var ProcessType = new ObservableCollection<string>(((string)(scProcessType)).Split(','));
var processTypeFileList = new List<ProcessTypeFileItem>();
for (var i = 0; i < ProcessType.Count; i++)
{
Enum.TryParse(ProcessType[i], true, out RecipeType rType);
var type = new ProcessTypeFileItem
{
ProcessType = rType
};
var prefix = $"{CurrentChamberType}\\{SystemName}\\{ProcessType[i]}";
var recipes = recipeProvider.GetXmlRecipeList(prefix);
type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes, isFolderOnly, isShowRootNode)[0].Files;
processTypeFileList.Add(type);
}
this.ProcessTypeFileList = processTypeFileList;
}
public void UpdateRecipeFormat()
{
var chamber = QueryDataClient.Instance.Service.GetConfig("System.Recipe.ChamberModules");
if (chamber == null)
{
chamber = "PM1";
}
Chambers = new ObservableCollection<string>(((string)chamber).Split(','));
if (Chambers.Count > 1)
{
for (var i = 0; i < Chambers.Count; i++)
{
var isPmInstall =
(bool)QueryDataClient.Instance.Service.GetConfig(
$"System.SetUp.Is{Chambers[i].ToString()}Installed");
{
if (!isPmInstall)
{
Chambers.RemoveAt(i);
}
}
}
}
if (Chambers.Count == 0)
{
Chambers = new ObservableCollection<string>(new string[] { "PM1" });
}
SelectedChamber = Chambers[0];
#region Create RecipeData
ComparRecipeHeader = CreateRecipe();
ComparRecipeHeader.AddStep();
ComparRecipe1 = CreateRecipe();
ComparRecipe2 = CreateRecipe();
#endregion Create RecipeData
}
private RecipeData CreateRecipe()
{
var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId);
var recipeData = new RecipeData(null, CurrentProcessType);
recipeData.BuildFormat($"{CurrentChamberType}\\{CurrentProcessType}", SystemName, role);
//得到当前登录的RoleItem
//var role = _roleManager.GetRoleByName(BaseApp.Instance.UserContext.RoleName);
return recipeData;
}
private async Task LoadRecipe(RecipeData recipeData, string prefixPath, string recipeName)
{
recipeData.Clear();
recipeData.Steps.Save(); // 重置为已保存状态
var recipeContent = _recipeProvider.ReadRecipeFile(prefixPath, recipeName);
if (string.IsNullOrEmpty(recipeContent))
{
MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.",
"Error",
MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId);
await recipeData.LoadFile(prefixPath, recipeName, recipeContent, SelectedChamber, role,
GetLoadingDispatcher());
}
private async Task LoadRecipe(RecipeData recipeData, RecipeHistory recipeHistory)
{
recipeData.Clear();
recipeData.Steps.Save(); // 重置为已保存状态
var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId);
await recipeData.LoadFile(recipeHistory, SelectedChamber, role,
GetLoadingDispatcher());
}
private static Dispatcher GetLoadingDispatcher()
{
// 判断Step呈现方式
var isCascadeLoading = (bool)QueryDataClient.Instance.Service.GetConfig("System.RecipeCascadeLoading");
var dispatcher = isCascadeLoading ? Dispatcher.CurrentDispatcher : null;
return dispatcher;
}
public async void ComperSelectRecipe()
{
SelectRecipeNameList.Clear();
foreach (var ProcessTypeFile in ProcessTypeFileList)
{
GetSelectRecipeName(ProcessTypeFile.FileListByProcessType);
}
if (SelectRecipeNameList.Count != 2)
{
DialogBox.ShowError("Only 2 comparisons are supported");
return;
}
StoryboardClose();
LabSelectRecipeNames = SelectRecipeNameList[0].Name + " / " + SelectRecipeNameList[1].Name;
await LoadRecipe(ComparRecipe1, GetRecipeFullPath(SelectRecipeNameList[0]), SelectRecipeNameList[0].Name);
await LoadRecipe(ComparRecipe2, GetRecipeFullPath(SelectRecipeNameList[1]), SelectRecipeNameList[1].Name);
StartComper(ComparRecipe1, ComparRecipe2);
}
/// <summary>
/// 递归获取选择的Recipe
/// </summary>
/// <param name="fileNodes"></param>
private void GetSelectRecipeName(ObservableCollection<FileNode> fileNodes)
{
foreach (var item in fileNodes)
{
if (item.Files != null && item.Files.Count > 0)
GetSelectRecipeName(item.Files);
if (item.IsSelected)
SelectRecipeNameList.Add(item);
}
}
private string GetRecipeFullPath(FileNode fileNodes)
{
return fileNodes.PrefixPath + (fileNodes.Parent.FullPath == "" ? "" : "\\" + fileNodes.Parent.FullPath);
}
public void StartComper(RecipeData recipeData1, RecipeData recipeData2)
{
int stepsCount = 0;//缓存较短Recipe步数
RecipeData recipeDataExcess;//缓存较长步数Recipe
if (recipeData1.Steps.Count <= recipeData2.Steps.Count)
{
stepsCount = recipeData1.Steps.Count;
recipeDataExcess = recipeData2;
}
else
{
stepsCount = recipeData2.Steps.Count;
recipeDataExcess = recipeData1;
}
for (int i = 0; i < stepsCount; i++)
{
RecipeStep recipe1step = recipeData1.Steps[i];
RecipeStep recipe2step = recipeData2.Steps[i];
for (int j = 0; j < recipe1step.Count; j++)
{
object obj1 = GetValue(recipe1step[j]);//获取单元格中的数值,object类型
object obj2 = GetValue(recipe2step[j]);
if (!(Object.Equals(obj1, obj2)))
{
//recipe1step[j].Highlight();//不同部分高亮
//recipe2step[j].Highlight();
recipe1step[j].CompareDifferent();
recipe2step[j].CompareDifferent();
}
}
}
//步数多余部分高亮显示 使用缓存步数和缓存Recipe
for (int i = stepsCount; i < recipeDataExcess.Steps.Count; i++)
{
for (int j = 0; j < recipeDataExcess.Steps[i].Count; j++)
{
recipeDataExcess.Steps[i][j].CompareDifferent();
}
}
}
private object GetValue(Param param)
{
object Value = null;
if (param is IValueParam vp)
Value = vp.GetValue();
return Value;
}
}
}
@@ -0,0 +1,84 @@
<Window x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeEditorValidationDetailWindow"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Recipe Validation Overview"
Height="450" Width="800"
Topmost="{Binding ElementName=cbxTopMost, Path=IsChecked, FallbackValue=False}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="StackPanel">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="Margin" Value="5 0"/>
</Style>
</Grid.Resources>
<StackPanel HorizontalAlignment="Left">
<StackPanel.Resources>
<Style TargetType="RadioButton">
<Setter Property="Margin" Value="0 0 10 0"/>
<Setter Property="GroupName" Value="InfoCategory"/>
</Style>
</StackPanel.Resources>
<RadioButton Content="All"/>
<RadioButton Content="Errors" IsChecked="True">
<RadioButton.ContentTemplate>
<DataTemplate DataType="{x:Type RadioButton}">
<Border CornerRadius="2" Background="#FFDC6262" Padding="5 0">
<TextBlock Text="{TemplateBinding Content}" Foreground="#FF980000"/>
</Border>
</DataTemplate>
</RadioButton.ContentTemplate>
</RadioButton>
<RadioButton Content="Changed">
<RadioButton.ContentTemplate>
<DataTemplate DataType="{x:Type RadioButton}">
<Border CornerRadius="2" Background="#FFBDFFB4" Padding="5 0">
<TextBlock Text="{TemplateBinding Content}" Foreground="#FF1A7F1C"/>
</Border>
</DataTemplate>
</RadioButton.ContentTemplate>
</RadioButton>
</StackPanel>
<StackPanel Grid.Row="0" HorizontalAlignment="Right">
<CheckBox x:Name="cbxTopMost" Content="Always On Top"/>
</StackPanel>
<ListView
Grid.Row="1"
x:Name="listView">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="MouseDoubleClick" Handler="EventSetter_OnHandler"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="#" Width="35" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image
Source="/MECF.Framework.UI.Core;component/Resources/SystemLog/Alarm.png"
Width="16"
Height="16"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Step No." DisplayMemberBinding="{Binding StepNo}"/>
<GridViewColumn Header="Param" DisplayMemberBinding="{Binding ParamCaption}"/>
<GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" Width="100"/>
<GridViewColumn Header="Error" Width="350" DisplayMemberBinding="{Binding Message}"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
@@ -0,0 +1,57 @@
using System;
using System.Windows;
using System.Windows.Input;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using Sicentury.Core.Collections;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// Interaction logic for RecipeEditorValidationDetailWindow.xaml
/// </summary>
public partial class RecipeEditorValidationDetailWindow : Window
{
#region Variables
/// <summary>
/// 窗口加载时在屏幕中的位置。
/// </summary>
private readonly Point? _location = null;
#endregion
public RecipeEditorValidationDetailWindow(ObservableRangeCollection<RecipeStepValidationInfo> errorInfo, Point? location = null)
{
InitializeComponent();
_location = location;
listView.ItemsSource = errorInfo;
SourceInitialized += OnSourceInitialized;
}
private void OnSourceInitialized(object sender, EventArgs e)
{
if (!_location.HasValue)
{
// 如果未指定显示位置,则默认显示在右下角。
var desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width - 20;
Top = desktopWorkingArea.Bottom - Height - 30;
}
else
{
Left = _location.Value.X;
Top = _location.Value.Y;
}
}
private void EventSetter_OnHandler(object sender, MouseButtonEventArgs e)
{
if (!(DataContext is RecipeEditorViewModel vm))
return;
if(listView.SelectedItem is RecipeStepValidationInfo info && info.Param != null)
vm.FocusToParam(info.Param);
}
}
}
@@ -0,0 +1,29 @@
using System.Windows;
using MECF.Framework.UI.Client.Ctrlib.Controls;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// Interaction logic for RecipePM1View.xaml
/// </summary>
public partial class RecipeEditorView
{
public RecipeEditorView()
{
InitializeComponent();
}
EditorDataGridTemplateColumnBase _PreColumn = null;
private void btnLock_Click(object sender, RoutedEventArgs e)
{
editorLocker.Lock();
}
private void btnChangePassword_Click(object sender, RoutedEventArgs e)
{
var dlg = new PanelLockerPasswordChanger();
dlg.ShowDialog();
}
}
}
@@ -0,0 +1,114 @@
<UserControl
x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeHistoryView"
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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors.Recipe"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<local:RowToIndexConverter x:Key="rowToIndexConverter" />
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<DataGrid
Grid.Column="3"
AlternationCount="2"
AutoGenerateColumns="False"
CanUserAddRows="False"
FontSize="13"
IsReadOnly="True"
ItemsSource="{Binding RecipeMemorieList}"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectedItem="{Binding SelectRecipeHistory}">
<DataGrid.Columns>
<DataGridTemplateColumn Width="20">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SelChanged">
<micro:Parameter Value="{Binding Path=IsChecked, RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="30"
Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Converter={StaticResource rowToIndexConverter}}"
Header="ID" />
<DataGridTextColumn
Width="100"
Binding="{Binding RoleName}"
Header="RoleName" />
<DataGridTextColumn
Width="Auto"
Binding="{Binding RecipeName}"
Header="RecipeName" />
<DataGridTextColumn
Width="100"
Binding="{Binding ProcessType}"
Header="ProcessType" />
<DataGridTextColumn
Width="200"
Binding="{Binding CreateTime}"
Header="Time" />
<!--<DataGridTemplateColumn Width="100" Header="Compare">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Margin="10,0" Content="Statr">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="StatrCompare" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
</DataGrid.Columns>
</DataGrid>
<StackPanel
Grid.Row="1"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button
Width="90"
Height="30"
Content="OK">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="OK" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="Cancel">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Cancel" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public partial class RecipeHistoryView : UserControl
{
public RecipeHistoryView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,99 @@
using Caliburn.Micro;
using DocumentFormat.OpenXml.Drawing.Diagrams;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using OpenSEMI.ClientBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using Xceed.Wpf.Toolkit;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public class RecipeHistoryViewModel : DialogViewModel<string>
{
private RecipeHistory recipeMemory;
public bool isCompare;
public List<RecipeHistory> RecipeMemorieList { get; set; }
public List<RecipeHistory> SelectRecipeMemorieList { get; set; }
public RecipeHistory SelectRecipeHistory { get; set; }
public RecipeHistoryViewModel(string recipeName)
{
recipeMemory = new RecipeHistory();
RecipeMemorieList = recipeMemory.QueryDB(recipeName);
SelectRecipeMemorieList = new List<RecipeHistory>() ;
}
public RecipeHistory GetXML(RecipeHistory recipeHistory)
{
return recipeHistory.QueryDB(recipeHistory) ?? null;
}
public void SelChanged(bool selItems)
{
if (selItems)
{
SelectRecipeMemorieList.Add(SelectRecipeHistory);
}
else
{
if (SelectRecipeMemorieList.Contains(SelectRecipeHistory))
SelectRecipeMemorieList.Remove(SelectRecipeHistory);
}
}
public void OK()
{
if (SelectRecipeMemorieList.Count > 2)
{
MessageBox.Show("Only 2 comparisons are supported");
return;
}
if (SelectRecipeMemorieList.Count>0)
{
for (int i = 0; i < SelectRecipeMemorieList.Count; i++)
{
SelectRecipeMemorieList[i] = GetXML(SelectRecipeMemorieList[i]);
}
}
IsCancel = false;
TryClose(true);
}
public void Cancel()
{
//SelectRecipeMemorieList.Clear();
IsCancel = true;
TryClose(false);
}
}
/// <summary>
/// datagrid 自动生成行号
/// </summary>
public class RowToIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
DataGridRow row = value as DataGridRow;
if (row != null)
return row.GetIndex() + 1;
else
return -1;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,208 @@
<UserControl
x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeSelectDialogView"
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:editors="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
Width="350"
Height="500"
lex:LocalizeDictionary.DesignCulture="en"
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
mc:Ignorable="d">
<UserControl.Resources>
<HierarchicalDataTemplate x:Key="FolderTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<Image
x:Name="ExpandImage"
Width="14"
Height="12"
Margin="2,0,0,0"
VerticalAlignment="Center"
Source="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Close.png" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ExpandImage" Property="Image.Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Unable.png" />
</Trigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="FileTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<Path
Width="13"
Height="16"
HorizontalAlignment="Left"
Data="M0.5,5.125 L5.125,5.125 5.125,0.5 M5.1,0.5 L15.5,0.5 15.5,19.5 0.5,19.5 C0.5,14.7 0.5,10 0.5,5.1 2,3.6 3.6,2 5.1,0.5 z M8.1,8.5 L8.2,8.5 z M8.1,11.5 L8.2,11.5 z M8.1,14.5 L8.2,14.5 z"
Fill="#FFF3F3F3"
Stretch="Fill"
Stroke="#FF454545" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
</HierarchicalDataTemplate>
<editors:FolderOrFileTemplateSelector
x:Key="FolderFileTemplateSelector"
FileTemplate="{StaticResource FileTemplate}"
FolderTemplate="{StaticResource FolderTemplate}" />
</UserControl.Resources>
<Border
Background="{DynamicResource Tab_BG}"
BorderBrush="Gray"
BorderThickness="0,1,0,0">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0 0 0 3">
<Label
Margin="5,0,0,0"
VerticalAlignment="Center"
Content="{lex:Loc ID_TXT_Filter}"
FontSize="16" />
<TextBox
Width="226"
Height="26"
Margin="0,0,5,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding CurrentCriteria, UpdateSourceTrigger=PropertyChanged}" />
<Button
Width="30"
Height="30"
Margin="0,0,5,0"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<Button.Content>
<Path
Width="15"
Height="15"
Margin="0,3"
Data="M5.5,0 L8.5,0 8.5,5.5 14,5.5 14,8.5 8.5,8.5 8.5,14 5.5,14 5.5,8.5 0,8.5 0,5.5 5.5,5.5 z"
Fill="Black"
RenderTransformOrigin="0.5,0.5"
Stretch="Fill"
StrokeThickness="3">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="45" />
<TranslateTransform />
</TransformGroup>
</Path.RenderTransform>
</Path>
</Button.Content>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="ClearFilter" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<Border
Grid.Row="1"
Background="Transparent"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0">
<TabControl
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ItemsSource="{Binding ProcessTypeFileList}"
SelectedIndex="{Binding ProcessTypeIndexSelection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProcessType}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<TreeView
x:Name="RecipeTree1"
Height="{Binding Path=ActualHeight, ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0"
VerticalAlignment="Stretch"
ItemTemplateSelector="{StaticResource FolderFileTemplateSelector}"
ItemsSource="{Binding FileListByProcessType}"
Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<TreeView.ItemContainerStyle>
<Style BasedOn="{StaticResource TreeViewItemExtend}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="Visibility" Value="{Binding IsMatch, Mode=TwoWay}" />
</Style>
</TreeView.ItemContainerStyle>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<micro:ActionMessage MethodName="TreeSelectChanged">
<micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
</micro:ActionMessage>
</i:EventTrigger>
<i:EventTrigger EventName="MouseDoubleClick">
<micro:ActionMessage MethodName="TreeMouseDoubleClick">
<micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TreeView>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Border>
<StackPanel
Grid.Row="2"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button
Width="90"
Height="30"
Content="OK">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="OK" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="Cancel">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Cancel" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// RecipeSequenceSelectDialogView.xaml 的交互逻辑
/// </summary>
public partial class RecipeSelectDialogView : UserControl
{
public RecipeSelectDialogView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Data;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using OpenSEMI.ClientBase;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public class RecipeSelectDialogViewModel : DialogViewModel<string>
{
#region Variables
private readonly RecipeType _fileTypes;
private readonly bool _isFolderOnly;
private readonly bool _isShowRootNode;
private FileNode _currentFileNode;
#endregion
#region Constructors
public RecipeSelectDialogViewModel(string model = null)
{
_fileTypes = RecipeType.Process | RecipeType.Routine | RecipeType.Clean;
_isFolderOnly = false;
_isShowRootNode = false;
BuildFileTree(_isShowRootNode, _isFolderOnly, _fileTypes, model);
}
public RecipeSelectDialogViewModel(bool isShowRootNode, bool isFolderOnly, RecipeType fileType, string model=null)
{
_fileTypes = fileType;
_isFolderOnly = isFolderOnly;
_isShowRootNode = isShowRootNode;
BuildFileTree(isShowRootNode, isFolderOnly, fileType, model);
}
#endregion
#region Properties
public List<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
public FileNode CurrentFileNode { get; set; }
public int ProcessTypeIndexSelection { get; set; }
public ObservableCollection<FileNode> Files { get; set; }
public ListCollectionView FileView { get; set; }
private string _currentCriteria = string.Empty;
public string CurrentCriteria
{
get => _currentCriteria;
set
{
if (value == _currentCriteria)
return;
_currentCriteria = value;
NotifyOfPropertyChange(nameof(CurrentCriteria));
ApplyFilter();
}
}
#endregion
#region Private Methods
private void BuildFileTree(bool isShowRootNode, bool isFolderOnly, RecipeType fileType, string model=null)
{
string modelName = model == null ? "" : "\\" + model;
var recipeProvider = new RecipeProvider();
var scProcessType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType").ToString();
var supportedRecipeType = new List<RecipeType>(new[] { RecipeType.Process, RecipeType.Routine });
if (!string.IsNullOrEmpty(scProcessType))
{
supportedRecipeType.Clear();
if (fileType.HasFlag(RecipeType.Process) && scProcessType.Contains(RecipeType.Process.ToString()))
supportedRecipeType.Add(RecipeType.Process);
if (fileType.HasFlag(RecipeType.Routine) && scProcessType.Contains(RecipeType.Routine.ToString()))
supportedRecipeType.Add(RecipeType.Routine);
if (fileType.HasFlag(RecipeType.Clean) && scProcessType.Contains(RecipeType.Clean.ToString()))
supportedRecipeType.Add(RecipeType.Clean);
}
var processTypeFileList = new List<ProcessTypeFileItem>();
for (var i = 0; i < supportedRecipeType.Count; i++)
{
var type = new ProcessTypeFileItem
{
ProcessType = supportedRecipeType[i]
};
var prefix = $"Sic{modelName}\\{supportedRecipeType[i]}";
var recipes = recipeProvider.GetXmlRecipeList(prefix);
type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes, isFolderOnly, isShowRootNode)[0].Files;
processTypeFileList.Add(type);
}
this.ProcessTypeFileList = processTypeFileList;
}
#endregion
#region Methods
private void ApplyFilter()
{
foreach (var node in ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType)
node.ApplyCriteria(CurrentCriteria, new Stack<FileNode>());
}
public void ClearFilter()
{
CurrentCriteria = "";
}
public void TreeSelectChanged(FileNode file)
{
_currentFileNode = file;
}
public void TreeMouseDoubleClick(FileNode file)
{
_currentFileNode = file;
OK();
}
public void OK()
{
if (this._currentFileNode == null)
return;
if (_isFolderOnly)
{
if (this._currentFileNode.IsFile)
return;
this.DialogResult = _currentFileNode.PrefixPath + "\\" + _currentFileNode.FullPath;
IsCancel = false;
TryClose(true);
}
else
{
if (!this._currentFileNode.IsFile)
return;
this.DialogResult = _currentFileNode.PrefixPath + "\\" + _currentFileNode.FullPath;
IsCancel = false;
TryClose(true);
}
}
public void Cancel()
{
IsCancel = true;
TryClose(false);
}
#endregion
}
}
@@ -0,0 +1,121 @@
<UserControl
x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.SaveToDialogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate x:Key="ChamberSelectTemplate">
<Grid Height="23" Margin="-1,-1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
</Grid.ColumnDefinitions>
<Border
Padding="5,1"
BorderBrush="{DynamicResource DataGrid_Cell_BD}"
BorderThickness="1">
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding Name}"
IsChecked="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding IsEnabled}" />
</Border>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Border
Background="{DynamicResource Tab_BG}"
BorderBrush="Gray"
BorderThickness="0,1,0,0">
<Grid
Margin="50"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160" />
<ColumnDefinition Width="220" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="1">
<TextBlock
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Foreground="{DynamicResource FG_Black}"
Text="Copy To Chamber"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Column="1"
Padding="5,1"
VerticalAlignment="Stretch"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<ListBox
x:Name="ListBoxChamber"
Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
BorderThickness="0"
ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}"
ItemTemplate="{StaticResource ChamberSelectTemplate}"
ItemsSource="{Binding Chambers}"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel
Margin="1,1,0,0"
IsItemsHost="True"
Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Border>
<StackPanel
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<Button
Width="90"
Height="30"
Content="OK">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="OK" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="Cancel">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="Cancel" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,16 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// InputFileNameDialogView.xaml 的交互逻辑
/// </summary>
public partial class SaveToDialogView : UserControl
{
public SaveToDialogView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using MECF.Framework.Common.CommonData;
using OpenSEMI.ClientBase;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
public class ChamberItem : NotifiableItem
{
public string Name { get; set; }
public bool IsChecked { get; set; }
public bool IsEnabled { get; set; }
}
public class SaveToDialogViewModel : DialogViewModel<string>
{
public string Chamber { get; set; }
public ObservableCollection<ChamberItem> Chambers { get; set; }
public SaveToDialogViewModel(string dialogName, string chamber, List<string> chambers)
{
this.DisplayName = dialogName;
Chambers = new ObservableCollection<ChamberItem>();
foreach (var chamber1 in chambers)
{
Chambers.Add(new ChamberItem()
{
IsChecked = false,
IsEnabled = chamber1!=chamber,
Name = chamber1,
});
}
}
public void Cancel()
{
IsCancel = true;
TryClose(false);
}
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
SaveToDialogView v = (SaveToDialogView)view;
FocusManager.SetFocusedElement(v, v.ListBoxChamber);
}
public void OK()
{
this.DialogResult = Chamber;
IsCancel = false;
TryClose(true);
}
}
}
@@ -0,0 +1,252 @@
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Editors.RecipeConfig.RecipeConfigView"
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="900" d:DesignWidth="1500">
<Grid >
<TabControl>
<TabItem Header="Step Parameter">
<ListView ItemsSource="{Binding Path=StepParameters}" ItemContainerStyle="{DynamicResource NoSelection-ListViewItem}"
Width="960" HorizontalAlignment="Left"
VerticalAlignment="Top" >
<ListView.View>
<GridView>
<GridViewColumn Width="200"
Header="Parameter"
DisplayMemberBinding="{Binding Path=DisplayName}" />
<GridViewColumn Width="120" Header="Default">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding DefaultValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="Min">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MinValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMinValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Max">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MaxValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMaxValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Warn(%)">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding WarnValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableWarnValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Alarm(%)">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding AlarmValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableAlarmValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="90" Header="">
<GridViewColumn.CellTemplate>
<DataTemplate >
<Button Content="Set" FontSize="12" Height="25" Margin="1" Width="65" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SetStepParameter">
<micro:Parameter Value="{Binding }" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</TabItem>
<TabItem Header="OES" Visibility="{Binding OesVisibility}">
<ListView ItemsSource="{Binding Path=OesParameters}"
ItemContainerStyle="{DynamicResource NoSelection-ListViewItem}"
Width="960" HorizontalAlignment="Left"
VerticalAlignment="Top" >
<ListView.View>
<GridView>
<GridViewColumn Width="200"
Header="Parameter"
DisplayMemberBinding="{Binding Path=DisplayName}" />
<GridViewColumn Width="120" Header="Default">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding DefaultValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="Min">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MinValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMinValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Max">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MaxValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMaxValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="90" Header="">
<GridViewColumn.CellTemplate>
<DataTemplate >
<Button Content="Set" FontSize="12" Height="25" Margin="1" Width="65" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SetOesParameter">
<micro:Parameter Value="{Binding }" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</TabItem>
<TabItem Header="VAT" Visibility="{Binding VatVisibility}">
<ListView ItemsSource="{Binding Path=VatParameters}"
ItemContainerStyle="{DynamicResource NoSelection-ListViewItem}"
Width="960" HorizontalAlignment="Left"
VerticalAlignment="Top" >
<ListView.View>
<GridView>
<GridViewColumn Width="200"
Header="Parameter"
DisplayMemberBinding="{Binding Path=DisplayName}" />
<GridViewColumn Width="120" Header="Default">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding DefaultValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="Min">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MinValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMinValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Max">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MaxValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMaxValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="90" Header="">
<GridViewColumn.CellTemplate>
<DataTemplate >
<Button Content="Set" FontSize="12" Height="25" Margin="1" Width="65" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SetVatParameter">
<micro:Parameter Value="{Binding }" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</TabItem>
<TabItem Header="Fine Tuning" Visibility="{Binding FineTuningVisibility}">
<ListView ItemsSource="{Binding Path=FineTuningParameters}"
ItemContainerStyle="{DynamicResource NoSelection-ListViewItem}"
Width="960" HorizontalAlignment="Left"
VerticalAlignment="Top" >
<ListView.View>
<GridView>
<GridViewColumn Width="200"
Header="Parameter"
DisplayMemberBinding="{Binding Path=DisplayName}" />
<GridViewColumn Width="120" Header="Default">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding DefaultValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableDefaultValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="Min">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MinValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMinValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="Max">
<GridViewColumn.CellTemplate>
<DataTemplate >
<controls:TextBoxEx Text="{Binding MaxValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" EditBoxMode="Decimal"
TextSaved="{Binding ValueSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" FontSize="14" FontFamily="Arial" Width="110" IsEnabled="{Binding EnableMaxValue}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="90" Header="">
<GridViewColumn.CellTemplate>
<DataTemplate >
<Button Content="Set" FontSize="12" Height="25" Margin="1" Width="65" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SetVatParameter">
<micro:Parameter Value="{Binding }" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</TabItem>
</TabControl>
</Grid>
</UserControl>
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors.RecipeConfig
{
/// <summary>
/// Interaction logic for RecipeConfigView.xaml
/// </summary>
public partial class RecipeConfigView : UserControl
{
public RecipeConfigView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,290 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Aitex.Core.RT.Log;
using Caliburn.Micro;
using Caliburn.Micro.Core;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
using MECF.Framework.UI.Client.ClientBase;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
using OpenSEMI.ClientBase;
using OpenSEMI.ClientBase.Command;
using SciChart.Core.Extensions;
namespace MECF.Framework.UI.Client.CenterViews.Editors.RecipeConfig
{
public class RecipeConfigViewModel : BaseModel
{
public class RecipeConfigItem : NotifiableItem
{
public string ControlName { get; set; }
public string DisplayName { get; set; }
public string UnitName { get; set; }
public float DefaultValue { get; set; }
public float MinValue { get; set; }
public float MaxValue { get; set; }
public float WarnValue { get; set; }
public float AlarmValue { get; set; }
public bool EnableDefaultValue { get; set; }
public bool EnableMinValue { get; set; }
public bool EnableMaxValue { get; set; }
public bool EnableWarnValue { get; set; }
public bool EnableAlarmValue { get; set; }
public RecipeConfigItem()
{
EnableDefaultValue = true;
EnableMinValue = true;
EnableMaxValue = true;
EnableWarnValue = true;
EnableAlarmValue = true;
}
}
public ObservableCollection<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
public RecipeData CurrentRecipe { get; private set; }
public FileNode CurrentFileNode { get; set; }
private bool IsChanged
{
get
{
return editMode == EditMode.Edit || CurrentRecipe.IsChanged;
}
}
public List<EditorDataGridTemplateColumnBase> Columns { get; set; }
public bool EnableNew { get; set; }
public bool EnableReName { get; set; }
public bool EnableCopy { get; set; }
public bool EnableDelete { get; set; }
public bool EnableSave { get; set; }
public bool EnableStep { get; set; }
public bool EnableReload { get; set; }
public bool EnableSaveToAll { get; set; }
public bool EnableSaveTo { get; set; }
private RecipeFormatBuilder _columnBuilder = new RecipeFormatBuilder();
private EditMode editMode;
private RecipeProvider _recipeProvider = new RecipeProvider();
public ObservableCollection<RecipeConfigItem> StepParameters { get; set; }
public ObservableCollection<RecipeConfigItem> OesParameters { get; set; }
public ObservableCollection<RecipeConfigItem> VatParameters { get; set; }
public ObservableCollection<RecipeConfigItem> FineTuningParameters { get; set; }
public ObservableCollection<string> ChamberType { get; set; }
public int ChamberTypeIndexSelection { get; set; }
public string CurrentChamberType
{
get
{
return ChamberType[ChamberTypeIndexSelection];
}
}
public Visibility OesVisibility { get; set; }
public Visibility VatVisibility { get; set; }
public Visibility FineTuningVisibility { get; set; }
protected override void OnInitialize()
{
base.OnInitialize();
var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
if (chamberType == null)
{
ChamberType = new ObservableCollection<string>() { "Default" };
}
else
{
ChamberType = new ObservableCollection<string>(((string)(chamberType)).Split(','));
}
ChamberTypeIndexSelection = 0;
this.Columns = this._columnBuilder.Build(CurrentChamberType, "Normal");
OesVisibility = _columnBuilder.OesConfig.Count > 0 ? Visibility.Visible : Visibility.Hidden;
VatVisibility = _columnBuilder.VatConfig.Count > 0 ? Visibility.Visible : Visibility.Hidden;
FineTuningVisibility = _columnBuilder.FineTuningConfig.Count > 0 ? Visibility.Visible : Visibility.Hidden;
this.CurrentRecipe = new RecipeData(null, RecipeType.Process);
CurrentRecipe.RecipeChamberType = _columnBuilder.RecipeChamberType;
CurrentRecipe.RecipeVersion = _columnBuilder.RecipeVersion;
this.editMode = EditMode.None;
InitStepParameter();
InitOesParameter();
InitVatParameter();
InitFineTuningParameter();
}
private void InitStepParameter()
{
//name1,default,min,max,warn,alarm; name2,default,min,max,warn,alarm;
StepParameters = new ObservableCollection<RecipeConfigItem>();
var stepParameterConfig = QueryDataClient.Instance.Service.GetConfig($"System.Recipe.StepParameter_{CurrentChamberType}");
var stepParameterValues = new Dictionary<string, string[]>();
if (stepParameterConfig != null)
{
string[] parameters = stepParameterConfig.ToString().Split(';');
foreach (var parameter in parameters)
{
string[] values = parameter.Split(',');
if (values.Length != 6)
continue;
stepParameterValues[values[0]] = values;
}
}
foreach (var col in Columns)
{
if (col.ControlName.IsNullOrEmpty())
continue;
if (!col.EnableConfig)
continue;
var item = new RecipeConfigItem();
item.ControlName = col.ControlName;
item.DisplayName = col.DisplayName;
item.UnitName = col.UnitName;
if (stepParameterValues.ContainsKey(item.ControlName))
{
string[] values = stepParameterValues[item.ControlName];
if (float.TryParse(values[1], out float defaultValue))
item.DefaultValue = defaultValue;
if (float.TryParse(values[1], out float minValue))
item.MinValue = minValue;
if (float.TryParse(values[1], out float maxValue))
item.MaxValue = maxValue;
if (float.TryParse(values[1], out float warnValue))
item.WarnValue = warnValue;
if (float.TryParse(values[1], out float alarmValue))
item.AlarmValue = alarmValue;
}
StepParameters.Add(item);
}
}
private void InitOesParameter()
{
OesParameters = GetParameters(QueryDataClient.Instance.Service.GetConfig($"System.Recipe.OesParameter_{CurrentChamberType}"), _columnBuilder.OesConfig);
}
private void InitVatParameter()
{
VatParameters = GetParameters(QueryDataClient.Instance.Service.GetConfig($"System.Recipe.VatParameter_{CurrentChamberType}"), _columnBuilder.VatConfig);
}
private void InitFineTuningParameter()
{
FineTuningParameters = GetParameters(QueryDataClient.Instance.Service.GetConfig($"System.Recipe.FineTuningParameter_{CurrentChamberType}"), _columnBuilder.FineTuningConfig);
}
private ObservableCollection<RecipeConfigItem> GetParameters(object config, ObservableCollection<Param> Configs)
{
//name1,default,min,max,warn,alarm; name2,default,min,max,warn,alarm;
ObservableCollection<RecipeConfigItem> Parameters = new ObservableCollection<RecipeConfigItem>();
var dicConfig = new Dictionary<string, string[]>();
if (config != null)
{
string[] parameters = config.ToString().Split(';');
foreach (var parameter in parameters)
{
string[] values = parameter.Split(',');
if (values.Length != 6)
continue;
dicConfig[values[0]] = values;
}
}
foreach (var col in Configs)
{
var item = new RecipeConfigItem();
item.ControlName = col.ControlName;
item.DisplayName = col.DisplayName;
if (dicConfig.ContainsKey(item.ControlName))
{
string[] values = dicConfig[item.ControlName];
if (float.TryParse(values[1], out float defaultValue))
item.DefaultValue = defaultValue;
if (float.TryParse(values[1], out float minValue))
item.MinValue = minValue;
if (float.TryParse(values[1], out float maxValue))
item.MaxValue = maxValue;
if (float.TryParse(values[1], out float warnValue))
item.WarnValue = warnValue;
if (float.TryParse(values[1], out float alarmValue))
item.AlarmValue = alarmValue;
}
Parameters.Add(item);
}
return Parameters;
}
protected override void OnActivate()
{
base.OnActivate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
}
private void ClearData()
{
this.editMode = EditMode.None;
this.CurrentRecipe.Clear();
this.CurrentRecipe.Name = string.Empty;
this.CurrentRecipe.Description = string.Empty;
}
}
}
@@ -0,0 +1,272 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using Aitex.Core.UI.View.Common;
using Caliburn.Micro.Core;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
public class FileNode : PropertyChangedBase
{
#region Variables
private string _name = string.Empty;
#endregion
#region Constructors
public FileNode()
{
this.Files = new ObservableCollection<FileNode>();
this.IsFile = false;
}
#endregion
#region Properties
public string Name
{
get { return _name; }
set { _name = value; NotifyOfPropertyChange("Name"); }
}
public string FullPath { get; set; }
public FileNode Parent { get; set; }
public ObservableCollection<FileNode> Files { get; set; }
public bool IsFile { get; set; }
public string PrefixPath { get; set; }
public bool IsSelected { get; set; }
private bool _isExpanded;
public bool IsExpanded
{
get { return _isExpanded; }
set { _isExpanded = value; NotifyOfPropertyChange("IsExpanded"); }
}
private Visibility _isMatch;
public Visibility IsMatch
{
get { return _isMatch; }
set { _isMatch = value; NotifyOfPropertyChange("IsMatch"); }
}
#endregion
#region Methods
/// <summary>
/// 将数中的节点转换为节点数组。
/// </summary>
/// <param name="terminalOnly">是否仅枚举最末端节点。</param>
/// <para>更新子节点的Selected属性时,需要同时更新中间节点的属性;更新父节点时,只评估终端节点的Selected属性。</para>
/// <returns></returns>
private List<FileNode> Flatten(bool terminalOnly)
{
if (Files == null || Files.Count <= 0)
return new List<FileNode>(new[] { this });
var lst = Files.SelectMany(x => x.Flatten(terminalOnly)).ToList();
if (!terminalOnly)
lst.Add(this);
return lst;
}
/// <summary>
/// 选择指定的节点。
/// </summary>
/// <param name="fullPath"></param>
public void Select(string fullPath)
{
var flattenList = Flatten(true);
flattenList.ForEach(x => { x.IsSelected = x.FullPath == fullPath; });
Refresh();
}
private bool IsCriteriaMatched(string criteria)
{
bool matched = string.IsNullOrEmpty(criteria) || _name.ToLower().Contains(criteria.ToLower());
if (matched)
return true;
return false;
}
public void ApplyCriteria(string criteria, Stack<FileNode> ancestors)
{
if (IsCriteriaMatched(criteria))
{
IsMatch = Visibility.Visible;
foreach (var ancestor in ancestors)
{
ancestor.IsMatch = Visibility.Visible;
ancestor.IsExpanded = !string.IsNullOrEmpty(criteria);
}
IsExpanded = true;
}
else
IsMatch = Visibility.Collapsed;
ancestors.Push(this);
foreach (var child in Files)
child.ApplyCriteria(criteria, ancestors);
ancestors.Pop();
}
#endregion
}
public class RecipeSequenceTreeBuilder
{
public static List<FileNode> GetFiles(string prefixPath, List<string> filenames)
{
List<FileNode> folders = new List<FileNode>();
FileNode root = new FileNode() { Name = "Files", IsFile = false, FullPath = "", PrefixPath = prefixPath };
folders.Add(root);
foreach (string filename in filenames)
{
string[] filesplits = filename.Split('\\');
FileNode parent = root;
if (filesplits.Length > 1)
{
for (var index = 0; index < filesplits.Length - 1; index++)
{
bool found = false;
for (var j = 0; j < parent.Files.Count; j++)
{
if (parent.Files[j].Name == filesplits[index] && !parent.Files[j].IsFile)
{
found = true;
parent = parent.Files[j];
break;
}
}
if (!found)
{
FileNode folder = new FileNode() { Name = filesplits[index], IsFile = false, PrefixPath = prefixPath };
folder.FullPath = (parent.FullPath == string.Empty ? filesplits[index] : parent.FullPath + "\\" + filesplits[index]);
folder.Parent = parent;
parent.Files.Add(folder);
parent = folder;
}
}
}
FileNode file = new FileNode() { Name = filesplits[filesplits.Length - 1], IsFile = true, PrefixPath = prefixPath };
file.FullPath = (parent.FullPath == string.Empty ? filesplits[filesplits.Length - 1] : parent.FullPath + "\\" + filesplits[filesplits.Length - 1]);
file.Parent = parent;
parent.Files.Add(file);
}
return folders;
}
public static void CreateTreeViewItems(XmlElement curElementNode, FileNode parent, string prefixPath, string selectionName, bool selectionIsFolder, bool isFolderNodeOnly)
{
foreach (XmlElement ele in curElementNode.ChildNodes)
{
if (ele.Name == "File" && !isFolderNodeOnly)
{
var fileName = ele.Attributes["Name"].Value;
fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
var fullPath = string.IsNullOrEmpty(parent.FullPath)
? fileName
: parent.FullPath + "\\" + fileName;
var file = new FileNode()
{
Name = fileName,
IsFile = true,
PrefixPath = prefixPath,
Parent = parent,
FullPath = fullPath,
};
if (!selectionIsFolder && selectionName == file.FullPath)
{
file.IsSelected = true;
var node = file.Parent;
while (node.FullPath.Contains("\\"))
{
node.IsExpanded = true;
node = node.Parent;
}
}
parent.Files.Add(file);
}
else if (ele.Name == "Folder")
{
var folderName = ele.Attributes["Name"].Value;
folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
var fullPath = string.IsNullOrEmpty(parent.FullPath)
? folderName
: parent.FullPath + "\\" + folderName;
var folder = new FileNode()
{
Name = folderName,
IsFile = false,
PrefixPath = prefixPath,
Parent = parent,
FullPath = fullPath,
IsExpanded = !fullPath.Contains("\\"),
};
parent.Files.Add(folder);
if (selectionIsFolder && selectionName == folder.FullPath)
{
folder.IsSelected = true;
var node = folder;
while (node.FullPath.Contains("\\"))
{
node.IsExpanded = true;
node = node.Parent;
}
}
CreateTreeViewItems(ele, folder, prefixPath, selectionName, selectionIsFolder, isFolderNodeOnly);
}
}
}
/// <summary>
/// 创建Recipe文件树。
/// </summary>
/// <param name="prefixPath"></param>
/// <param name="selectionName"></param>
/// <param name="selectionIsFolder"></param>
/// <param name="fileListInXml"></param>
/// <param name="isFolderNodeOnly">是否仅显示文件夹</param>
/// <param name="isShowRoot">是否显示根节点</param>
/// <returns></returns>
public static List<FileNode> BuildFileNode(string prefixPath, string selectionName, bool selectionIsFolder, string fileListInXml, bool isFolderNodeOnly = false, bool isShowRoot = false)
{
var folders = new List<FileNode>();
var root = new FileNode() { Name = "Files", IsFile = false, FullPath = "", PrefixPath = prefixPath };
folders.Add(root);
// 是否显示根目录节点
if (isShowRoot)
{
root.Files.Add(new FileNode()
{ Name = "\\", IsExpanded = true, PrefixPath = prefixPath, IsFile = false, FullPath = "", });
root = root.Files[0];
}
var doc = new XmlDocument();
doc.LoadXml(fileListInXml);
CreateTreeViewItems(doc.DocumentElement, root, prefixPath, selectionName, selectionIsFolder, isFolderNodeOnly);
return folders;
}
}
}
@@ -0,0 +1,184 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using DocumentFormat.OpenXml.Spreadsheet;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
public class SequenceColumnBuilder
{
public ObservableCollection<EditorDataGridTemplateColumnBase> Build()
{
var temp = RecipeClient.Instance.Service.GetSequenceFormatXml();
var doc = new XmlDocument();
doc.LoadXml(temp);
var columns = new ObservableCollection<EditorDataGridTemplateColumnBase>();
EditorDataGridTemplateColumnBase col;
//step number
col = new StepColumn()
{
DisplayName = "Step",
ControlName = "Step",
StringCellTemplate = "TemplateStep",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
columns.Add(col);
var nodes = doc.SelectNodes("TableSequenceFormat/Catalog/Item");
foreach (XmlNode node in nodes)
{
switch (node.Attributes["InputType"].Value)
{
case "TextInput":
col = new TextBoxColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
StringCellTemplate = "TemplateText",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
columns.Add(col);
break;
case "ReadOnly":
col = new TextBoxColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
StringCellTemplate = "TemplateText",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
columns.Add(col);
break;
case "NumInput":
col = new NumColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
//Minimun = int.Parse(node.Attributes["Min"].Value),
//Maximun = int.Parse(node.Attributes["Max"].Value),
StringCellTemplate = "TemplateSignInteger",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
columns.Add(col);
break;
case "RecipeSelection":
col = new RecipeSelectColumn()
{
IsReadOnly = true,
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
RecipeProcessType = node.Attributes["Parameter"].Value,
StringCellTemplate = "TemplateRecipeSelection",
StringHeaderTemplate = "SequenceColumnHeaderTemplate",
};
columns.Add(col);
break;
case "EditableSelection":
case "ReadOnlySelection":
if (node.Attributes["Name"].Value == "Position")
{
col = new PositionColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
StringCellTemplate = "TemplateCombox",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
var items = node.SelectNodes("Selection");
if (items == null)
break;
foreach (XmlElement item in items)
{
var controlName = item.Attributes["Name"].Value;
var displayName = item.Attributes["DisplayName"].Value;
var param = string.Empty;
if (item.HasAttribute("Parameter"))
param = item.Attributes["Parameter"].Value;
var opt = new ComboxColumn.Option(controlName, displayName, param);
((PositionColumn)col).Options.Add(opt);
}
}
else
{
col = new ComboxColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
StringCellTemplate = "TemplateCombox",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
var items = node.SelectNodes("Selection");
if (items == null)
break;
foreach (XmlElement item in items)
{
var controlName = item.Attributes["Name"].Value;
var displayName = item.Attributes["DisplayName"].Value;
var param = string.Empty;
if (item.HasAttribute("Parameter"))
param = item.Attributes["Parameter"].Value;
var opt = new ComboxColumn.Option(controlName, displayName, param);
((ComboxColumn)col).Options.Add(opt);
}
}
columns.Add(col);
break;
case "MultiSelection":
col = new MultipleSelectColumn()
{
ControlName = node.Attributes["Name"].Value,
DisplayName = node.Attributes["DisplayName"].Value,
StringCellTemplate = "TemplateMultiSelection",
StringHeaderTemplate = "SequenceColumnHeaderTemplate"
};
var multiSelItems = node.SelectNodes("Selection");
if (multiSelItems == null)
break;
foreach (XmlNode item in multiSelItems)
{
var opt = new MultipleSelectColumn.Option();
opt.IsChecked = false;
opt.ControlName = item.Attributes["Name"].Value;
opt.DisplayName = item.Attributes["DisplayName"].Value;
if (item.Attributes["Parameter"] != null)
opt.RelatedParameters = item.Attributes["Parameter"].Value;
((MultipleSelectColumn)col).Options.Add(opt);
}
columns.Add(col);
break;
}
}
return columns;
}
public static void ApplyTemplate(UserControl uc, ObservableCollection<EditorDataGridTemplateColumnBase> columns)
{
columns.ToList().ForEach(col =>
{
col.CellTemplate = (DataTemplate)uc.FindResource(col.StringCellTemplate);
col.HeaderTemplate = (DataTemplate)uc.FindResource(col.StringHeaderTemplate);
});
}
}
}
@@ -0,0 +1,316 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Xml;
using Caliburn.Micro.Core;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
public class SequenceData : PropertyChangedBase
{
public SequenceData()
{
Steps = new RecipeStepCollection();
}
public RecipeStepCollection Steps { get; set; }
public RecipeStep CreateStep(ObservableCollection<EditorDataGridTemplateColumnBase> columns, XmlNode step = null)
{
PositionParam posParam = null;
var posValue = string.Empty;
var Params = new RecipeStep(null);
foreach (var col in columns)
{
Param param = null;
var value = string.Empty;
if (!(col is ExpanderColumn) && step != null && !(col is StepColumn))
{
if (step.Attributes[col.ControlName] != null)
value = step.Attributes[col.ControlName].Value;
}
if (col is StepColumn)
{
param = new StepParam()
{
ControlName = col.ControlName
};
}
else if (col is TextBoxColumn)
{
param = new StringParam()
{
ControlName = col.ControlName,
Value = value,
IsEnabled = !col.IsReadOnly
};
}
else if (col is NumColumn)
{
if (!string.IsNullOrEmpty(value))
param = new IntParam() { ControlName = col.ControlName, Value = int.Parse(value), IsEnabled = !col.IsReadOnly };
else
param = new IntParam() { ControlName = col.ControlName, Value = 0, IsEnabled = !col.IsReadOnly };
}
else if (col is ComboxColumn)
{
var options = ((ComboxColumn)col).Options;
param = new ComboxParam(options, col.ControlName, value, col.Default);
}
else if (col is PositionColumn)
{
posParam = new PositionParam()
{
ControlName = col.ControlName,
Options = ((PositionColumn)col).Options,
IsEnabled = !col.IsReadOnly
};
param = posParam;
posValue = value;
}
else if (col is ExpanderColumn)
{
param = new ExpanderParam() { };
}
else if (col is RecipeSelectColumn)
{
var path = ((RecipeSelectColumn) col).RecipeProcessType;
if (!string.IsNullOrEmpty(path) && value.StartsWith(path))
{
value = value.Substring(path.Length + 1);
}
param = new PathFileParam(col.ControlName, !col.IsReadOnly, ((RecipeSelectColumn)col).RecipeProcessType)
{
Value = value,
};
}
else if (col is MultipleSelectColumn)
{
param = new MultipleSelectParam((MultipleSelectColumn)col) { ControlName = col.ControlName, IsEnabled = !col.IsReadOnly };
var opts = value.Split(',');
((MultipleSelectParam)param).Options.Apply(opt => {
for(var index = 0; index < opts.Length; index++)
{
if (opt.ControlName == opts[index])
{
opt.IsChecked = true;
break;
}
}
});
}
param.Save();
param.Parent = Params;
param.ColumnOwner = col;
Params.Add(param);
}
posParam.Value = posValue;
return Params;
}
public RecipeStep CloneStep(ObservableCollection<EditorDataGridTemplateColumnBase> columns, RecipeStep sourceStep)
{
var targetParams = this.CreateStep(columns);
PositionParam posParam = null;
var posValue = string.Empty;
for (var index = 0; index < sourceStep.Count; index++)
{
if (sourceStep[index] is PositionParam)
{
posParam = (PositionParam)targetParams[index];
posValue = ((PositionParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is StringParam)
{
((StringParam)targetParams[index]).Value = ((StringParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is PathFileParam)
{
((PathFileParam)targetParams[index]).Value = ((PathFileParam)sourceStep[index]).Value;
((PathFileParam)targetParams[index]).PrefixPath = ((PathFileParam)sourceStep[index]).PrefixPath;
}
else if (sourceStep[index] is IntParam)
{
((IntParam)targetParams[index]).Value = ((IntParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is ComboxParam)
{
((ComboxParam)targetParams[index]).Value = ((ComboxParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is BoolParam)
{
((BoolParam)targetParams[index]).Value = ((BoolParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is IntParam)
{
((IntParam)targetParams[index]).Value = ((IntParam)sourceStep[index]).Value;
}
else if (sourceStep[index] is DoubleParam)
{
((DoubleParam)targetParams[index]).Value = ((DoubleParam)sourceStep[index]).Value;
}
targetParams[index].Parent = targetParams;
}
posParam.Value = posValue;
return targetParams;
}
public void LoadSteps(ObservableCollection<EditorDataGridTemplateColumnBase> _columns, XmlNodeList _steps)
{
foreach (XmlNode _step in _steps)
{
this.Steps.Add(this.CreateStep(_columns, _step));
}
}
public void Load(ObservableCollection<EditorDataGridTemplateColumnBase> _columns, XmlDocument doc)
{
var node = doc.SelectSingleNode("Aitex/TableSequenceData");
if (node.Attributes["CreatedBy"] != null)
this.Creator = node.Attributes["CreatedBy"].Value;
if (node.Attributes["CreationTime"] != null)
this.CreateTime = DateTime.Parse(node.Attributes["CreationTime"].Value);
if (node.Attributes["LastRevisedBy"] != null)
this.Revisor = node.Attributes["LastRevisedBy"].Value;
if (node.Attributes["LastRevisionTime"] != null)
this.ReviseTime = DateTime.Parse(node.Attributes["LastRevisionTime"].Value);
if (node.Attributes["Description"] != null)
this.Description = node.Attributes["Description"].Value;
foreach (XmlNode _step in doc.SelectNodes("Aitex/TableSequenceData/Step"))
{
Steps.Add(this.CreateStep(_columns, _step));
}
}
public string ToXml()
{
var builder = new StringBuilder();
builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
builder.Append(string.Format("<Aitex><TableSequenceData CreatedBy=\"{0}\" CreationTime=\"{1}\" LastRevisedBy=\"{2}\" LastRevisionTime=\"{3}\" Description=\"{4}\" >", this.Creator, this.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), this.Revisor, this.ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"), this.Description));
foreach (var parameters in Steps)
{
builder.Append("<Step ");
foreach (var parameter in parameters)
{
if (parameter.Visible == System.Windows.Visibility.Visible)
{
if (parameter is IntParam)
builder.Append(parameter.ControlName + "=\"" + ((IntParam)parameter).Value + "\" ");
else if (parameter is DoubleParam)
builder.Append(parameter.ControlName + "=\"" + ((DoubleParam)parameter).Value + "\" ");
else if (parameter is StringParam)
builder.Append(parameter.ControlName + "=\"" + ((StringParam)parameter).Value + "\" ");
else if (parameter is PathFileParam)
builder.Append(parameter.ControlName + "=\"" + ((PathFileParam)parameter).Value + "\" ");
else if (parameter is ComboxParam)
builder.Append(parameter.ControlName + "=\"" + ((ComboxParam)parameter).Value + "\" ");
else if (parameter is PositionParam)
builder.Append(parameter.ControlName + "=\"" + ((PositionParam)parameter).Value + "\" ");
else if (parameter is BoolParam)
builder.Append(parameter.ControlName + "=\"" + ((BoolParam)parameter).Value + "\" ");
else if (parameter is MultipleSelectParam)
{
var selected = new List<string>();
((MultipleSelectParam)parameter).Options.Apply(
opt =>
{
if (opt.IsChecked)
selected.Add(opt.ControlName);
}
);
builder.Append(parameter.ControlName + "=\"" + string.Join(",", selected) + "\" ");
}
}
}
builder.Append("/>");
}
builder.Append("</TableSequenceData></Aitex>");
return builder.ToString();
}
private string name;
public string Name
{
get { return this.name; }
set
{
this.name = value;
this.NotifyOfPropertyChange("Name");
}
}
private string creator;
public string Creator
{
get { return this.creator; }
set
{
this.creator = value;
this.NotifyOfPropertyChange("Creator");
}
}
private DateTime createTime;
public DateTime CreateTime
{
get { return this.createTime; }
set
{
this.createTime = value;
this.NotifyOfPropertyChange("CreateTime");
}
}
private string description;
public string Description
{
get { return this.description; }
set
{
this.description = value;
this.NotifyOfPropertyChange("Description");
}
}
private string devisor;
public string Revisor
{
get { return this.devisor; }
set
{
this.devisor = value;
this.NotifyOfPropertyChange("Revisor");
}
}
private DateTime deviseTime;
public DateTime ReviseTime
{
get { return this.deviseTime; }
set
{
this.deviseTime = value;
this.NotifyOfPropertyChange("ReviseTime");
}
}
}
}
@@ -0,0 +1,87 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using OpenSEMI.ClientBase.ServiceProvider;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
public class SequenceDataProvider : IProvider
{
private static SequenceDataProvider _Instance = null;
public static SequenceDataProvider Instance
{
get
{
if (_Instance == null)
_Instance = new SequenceDataProvider();
return _Instance;
}
}
public void Create()
{
}
public bool CreateSequenceFolder(string foldername)
{
return RecipeClient.Instance.Service.CreateSequenceFolder(foldername);
}
public bool DeleteSequenceFolder(string foldername)
{
return RecipeClient.Instance.Service.DeleteSequenceFolder(foldername);
}
public bool Save(SequenceData seq)
{
return RecipeClient.Instance.Service.SaveSequence(seq.Name, seq.ToXml());
}
public List<string> GetSequences()
{
return RecipeClient.Instance.Service.GetSequenceNameList();
}
public List<string> GetRecipes(ModuleName modulename)
{
return RecipeClient.Instance.Service.GetRecipes(modulename, true).ToList();
}
public SequenceData GetSequenceByName(ObservableCollection<EditorDataGridTemplateColumnBase> _columns, string name)
{
string content = RecipeClient.Instance.Service.GetSequence(name);
SequenceData seq = new SequenceData();
XmlDocument doc = new XmlDocument();
doc.LoadXml(content);
seq.Name = name;
seq.Load(_columns, doc);
return seq;
}
public bool Rename(string beforename, string currentname)
{
return RecipeClient.Instance.Service.RenameSequence(beforename, currentname);
}
public bool Delete(string name)
{
return RecipeClient.Instance.Service.DeleteSequence(name);
}
public bool SaveAs(string name, SequenceData seq)
{
return RecipeClient.Instance.Service.SaveAsSequence(name, seq.ToXml());
}
public string GetSequenceFromXml()
{
string template = RecipeClient.Instance.Service.GetSequenceFormatXml();
return template;
}
}
}
@@ -0,0 +1,802 @@
<UserControl
x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Sequence.SequenceView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dgExtension="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.DGExtension"
xmlns:editors="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:sequence="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors.Sequence"
d:Background="LightSteelBlue"
d:DataContext="{d:DesignInstance Type=sequence:SequenceViewModel,
IsDesignTimeCreatable=False}"
d:DesignHeight="450"
d:DesignWidth="1900"
lex:LocalizeDictionary.DesignCulture="en"
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate x:Key="SequenceColumnHeaderTemplate">
<Grid Width="250" Margin="0,5">
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<TextBlock
Margin="5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Text="{Binding DisplayName}" />
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateTextBlock">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Height="30"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<TextBlock
Width="Auto"
FontSize="14"
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding Visible}" />
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateStep">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Height="30"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<controls:CheckBoxExt
Margin="0,4"
CheckBoxSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsChecked="{Binding IsChecked}" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14"
Text="{Binding Value}"
Visibility="{Binding Visible}" />
</StackPanel>
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateText">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Height="30"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<controls:TextBoxEx
Width="Auto"
FontSize="14"
IsEnabled="{Binding IsEnabled}"
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding Visible}" />
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateSignInteger">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<controls:TextBoxEx
Width="Auto"
EditBoxMode="SignInteger"
FontSize="14"
IsEnabled="{Binding IsEnabled}"
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding Visible}" />
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateRecipeSelection">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Height="30"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<controls:TextBoxEx
Width="Auto"
IsReadOnly="True"
Text="{Binding FileName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextSaved="True"
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
Visibility="{Binding Visible}" />
<Button
Grid.Column="1"
Width="25"
Height="23"
Margin="3,0,0,0"
Content="..."
Focusable="False"
FontSize="10"
Visibility="{Binding Visible}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SelectRecipe">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateCombox">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
Width="150"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<controls:ComboBoxExt
ComboBoxSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="DisplayName"
IsEnabled="{Binding IsEnabled}"
ItemsSource="{Binding Options}"
SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="ControlName"
Style="{StaticResource ResourceKey={x:Type ComboBox}}"
Visibility="{Binding Visible}" />
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateMultiSelection">
<Grid>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
<Border
MinHeight="30"
Padding="5,1"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<ListBox ItemsSource="{Binding Options}" Visibility="{Binding Visible}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="5,5" Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel
Width="139"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="ParamExpander">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding DisplayName}" />
<Expander
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Stretch"
IsExpanded="{Binding IsExpanded}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Expanded">
<micro:ActionMessage MethodName="ParamsExpanded">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
<i:EventTrigger EventName="Collapsed">
<micro:ActionMessage MethodName="ParamsCollapsed">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Expander>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>
</Grid>
</DataTemplate>
<DataTemplate x:Key="TemplateExpander">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14">
<TextBlock.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</TextBlock.LayoutTransform>
</TextBlock>
</DataTemplate>
<HierarchicalDataTemplate x:Key="FolderTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<Image
x:Name="ExpandImage"
Width="14"
Height="12"
Margin="2,0,0,0"
VerticalAlignment="Center"
Source="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Close.png" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
<StackPanel.ContextMenu>
<ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Command="{Binding NewSequenceCommand}" Header="Create Sequence" />
<Separator />
<MenuItem Command="{Binding NewFolderCommand}" Header="Create Folder" />
<MenuItem Command="{Binding DeleteFolderCommand}" Header="Delete Folder" />
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ExpandImage" Property="Image.Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Unable.png" />
</Trigger>
<!--<DataTrigger Binding="{Binding HasItems}" Value="True">
<Setter Property="Image.Source" TargetName="ExpandImage" Value="Folder_Open.png"/>
</DataTrigger>-->
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="FileTemplate" ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
<Path
Width="13"
Height="16"
HorizontalAlignment="Left"
Data="M0.5,5.125 L5.125,5.125 5.125,0.5 M5.1,0.5 L15.5,0.5 15.5,19.5 0.5,19.5 C0.5,14.7 0.5,10 0.5,5.1 2,3.6 3.6,2 5.1,0.5 z M8.1,8.5 L8.2,8.5 z M8.1,11.5 L8.2,11.5 z M8.1,14.5 L8.2,14.5 z"
Fill="#FFF3F3F3"
Stretch="Fill"
Stroke="#FF454545" />
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Name}" />
<StackPanel.ContextMenu>
<ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Command="{Binding SaveAsCommand}" Header="Save As..." />
<MenuItem Command="{Binding RenameCommand}" Header="Rename Sequence" />
<MenuItem Command="{Binding DeleteSequenceCommand}" Header="Delete Sequence" />
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
</HierarchicalDataTemplate>
<editors:FolderOrFileTemplateSelector
x:Key="FolderFileTemplateSelector"
FileTemplate="{StaticResource FileTemplate}"
FolderTemplate="{StaticResource FolderTemplate}" />
</UserControl.Resources>
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="275" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<GridSplitter
Width="5"
Margin="0,0,-5,0"
HorizontalAlignment="Right"
BorderThickness="0,8">
<GridSplitter.Background>
<SolidColorBrush />
</GridSplitter.Background>
</GridSplitter>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="740" />
</Grid.RowDefinitions>
<StackPanel IsEnabled="{Binding IsPermission}" Orientation="Horizontal">
<Button
Width="76"
Height="30"
Content="{lex:Loc ID_BTN_New_Content}"
IsEnabled="{Binding EnableNew}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="NewSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="76"
Height="30"
Margin="2,0,0,0"
Content="{lex:Loc ID_BTN_Rename_Content}"
IsEnabled="{Binding EnableReName}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="RenameSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="76"
Height="30"
Margin="2,0,0,0"
Content="{lex:Loc ID_BTN_Delete_Content}"
IsEnabled="{Binding EnableDelete}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="DeleteSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="76"
Height="30"
Margin="2,0,0,0"
Content="{lex:Loc ID_BTN_Refresh_Content}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="RefreshSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<Border
Grid.Row="1"
Margin="0,5,0,0"
Background="{DynamicResource Tab_BG}"
BorderBrush="{DynamicResource Tab_BD}"
BorderThickness="1">
<TreeView
x:Name="PART_TREE"
Grid.Row="1"
Height="{Binding Path=ActualHeight, ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Margin="5"
ItemTemplateSelector="{StaticResource FolderFileTemplateSelector}"
ItemsSource="{Binding Files[0].Files}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<!-- Height should add for VirtualizingPanel, otherwise the App will be slow -->
<TreeView.ItemContainerStyle>
<Style BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
</Style>
</TreeView.ItemContainerStyle>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<micro:ActionMessage MethodName="TreeSelectChanged">
<micro:Parameter Value="{Binding SelectedItem, ElementName=PART_TREE}" />
</micro:ActionMessage>
</i:EventTrigger>
<i:EventTrigger EventName="MouseRightButtonDown">
<micro:ActionMessage MethodName="TreeRightMouseDown">
<micro:Parameter Value="$eventargs" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding NewSequenceInParentCommand}" Header="New Sequence" />
<Separator />
<!--<MenuItem Header="New Folder" Command="{Binding NewFolderInParentCommand}">
</MenuItem>-->
</ContextMenu>
</TreeView.ContextMenu>
</TreeView>
</Border>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid
Width="1600"
Margin="10,0,0,0"
HorizontalAlignment="Left"
IsEnabled="{Binding IsPermission}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="8*" />
<ColumnDefinition Width="8*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="1">
<TextBlock
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Foreground="{DynamicResource FG_Black}"
Text="{lex:Loc ID_TXT_Name}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Column="1"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<controls:TextBoxEx
Width="Auto"
MinWidth="100"
VerticalAlignment="Center"
AllowBackgroundChange="False"
IsEnabled="false"
Text="{Binding CurrentSequence.Name}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Column="2"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Foreground="{DynamicResource FG_Black}"
Text="{lex:Loc ID_TXT_Create}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Column="3"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
Width="Auto"
MinWidth="100"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding CurrentSequence.Creator}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Column="4"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,1,1,1">
<TextBlock
Width="Auto"
MinWidth="100"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding CurrentSequence.CreateTime}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Row="1"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="1,0,1,1">
<TextBlock
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Foreground="{DynamicResource FG_Black}"
Text="{lex:Loc ID_TXT_Description}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Row="1"
Grid.Column="1"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<controls:TextBoxEx
Width="Auto"
MinWidth="100"
VerticalAlignment="Center"
Text="{Binding CurrentSequence.Description}"
TextSaved="{Binding IsSavedDesc, Mode=TwoWay}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Row="1"
Grid.Column="2"
Padding="5,1"
Background="{DynamicResource Table_BG_Title}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<TextBlock
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="16"
Foreground="{DynamicResource FG_Black}"
Text="{lex:Loc ID_TXT_Revise}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Row="1"
Grid.Column="3"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<TextBlock
Width="120"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding CurrentSequence.Revisor}"
TextWrapping="Wrap" />
</Border>
<Border
Grid.Row="1"
Grid.Column="4"
Padding="5,1"
Background="{DynamicResource Table_BG_Content}"
BorderBrush="{DynamicResource Table_BD}"
BorderThickness="0,0,1,1">
<TextBlock
MinWidth="140"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Foreground="{DynamicResource FG_Black}"
Text="{Binding CurrentSequence.ReviseTime}"
TextWrapping="Wrap" />
</Border>
</Grid>
<Grid Grid.Row="1" Margin="10,10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid>
<StackPanel IsEnabled="{Binding IsPermission}" Orientation="Horizontal">
<Button
Width="90"
Height="30"
Content="{lex:Loc ID_BTN_Append_Content}"
IsEnabled="{Binding EnableStep}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="AddStep" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="{lex:Loc ID_BTN_Insert_Content}"
IsEnabled="{Binding EnableStep}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="AppendStep" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="{lex:Loc ID_BTN_Copy_Content}"
IsEnabled="{Binding EnableStep}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="CopyStep" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="{lex:Loc ID_BTN_Paste_Content}"
IsEnabled="{Binding EnableStep}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="PasteStep" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="{lex:Loc ID_BTN_Delete_Content}"
IsEnabled="{Binding EnableStep}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="DeleteStep" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="200,0,0,0"
Content="{lex:Loc ID_BTN_Reload_Content}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="ReloadSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="{lex:Loc ID_BTN_Save_Content}"
IsEnabled="{Binding EnableSave}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SaveSequence" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Grid>
<Grid
Grid.Row="1"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<dgExtension:XDataGrid
x:Name="dgCustom"
AlternationCount="2"
AutoGenerateColumns="False"
Background="#00FFFFFF"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="None"
HeadersVisibility="Column"
IsEnabled="{Binding IsPermission}"
UseHorizontalScrolling="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<dgExtension:XDataGrid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</dgExtension:XDataGrid.LayoutTransform>
</dgExtension:XDataGrid>
</ScrollViewer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="263" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle
Height="1"
VerticalAlignment="Top"
Fill="{DynamicResource Table_BD}" />
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
/// <summary>
/// SequenceView.xaml 的交互逻辑
/// </summary>
public partial class SequenceView : UserControl
{
public SequenceView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,961 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.VisualStyles;
using System.Windows.Input;
using System.Windows.Media;
using Caliburn.Micro;
using Caliburn.Micro.Core;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
using MECF.Framework.UI.Client.ClientBase;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
using OpenSEMI.ClientBase;
using OpenSEMI.ClientBase.Command;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
public class SequenceViewModel : BaseModel
{
public ObservableCollection<FileNode> Files { get; set; }
protected override void OnInitialize()
{
base.OnInitialize();
CurrentSequence = new SequenceData();
Columns = columnBuilder.Build();
editMode = EditMode.None;
IsSavedDesc = true;
var names = provider.GetSequences();
Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles("", names));
CurrentFileNode = Files[0];
SelectDefault(CurrentFileNode);
}
protected override void OnActivate()
{
base.OnActivate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
if (IsChanged)
{
if (DialogBox.Confirm("This sequence is changed,do you want to save it?"))
SaveSequence();
LoadData(CurrentSequence.Name);
}
}
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
SequenceColumnBuilder.ApplyTemplate((UserControl)view, Columns);
var u = (SequenceView)view;
Columns.Apply((c) =>
{
c.Header = c;
u.dgCustom.Columns.Add(c);
});
u.dgCustom.ItemsSource = CurrentSequence.Steps;
UpdateView();
}
#region Sequence selection
public void TreeSelectChanged(FileNode file)
{
if (file != null && file.IsFile)
{
if (IsChanged)
if (DialogBox.Confirm("This sequence is changed,do you want to save it?"))
Save(CurrentSequence);
LoadData(file.FullPath);
CurrentFileNode = file;
}
else
{
ClearData();
editMode = EditMode.None;
CurrentSequence.Steps.Clear();
}
UpdateView();
}
private TreeViewItem GetParentObjectEx<TreeViewItem>(DependencyObject obj) where TreeViewItem : FrameworkElement
{
var parent = VisualTreeHelper.GetParent(obj);
while (parent != null)
{
if (parent is TreeViewItem)
{
return (TreeViewItem)parent;
}
parent = VisualTreeHelper.GetParent(parent);
}
return null;
}
public void TreeRightMouseDown(MouseButtonEventArgs e)
{
var item = GetParentObjectEx<TreeViewItem>(e.OriginalSource as DependencyObject) as TreeViewItem;
if (item != null)
{
item.Focus();
}
}
#endregion
private ICommand _NotImplementCommand;
public ICommand NotImplementCommand
{
get
{
if (_NotImplementCommand == null)
_NotImplementCommand = new BaseCommand(() => NotImplement());
return _NotImplementCommand;
}
}
public void NotImplement()
{
DialogBox.ShowInfo("Not Implement");
}
#region Sequence operation
private ICommand _NewFolderCommand;
public ICommand NewFolderCommand
{
get
{
if (_NewFolderCommand == null)
_NewFolderCommand = new BaseCommand(() => NewFolder());
return _NewFolderCommand;
}
}
public void NewFolder()
{
if (!CurrentFileNode.IsFile)
{
var dialog = new InputFileNameDialogViewModel("Input Folder Name");
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if (!(bool)bret)
return;
var fullpath = (CurrentFileNode.FullPath == "" ? dialog.DialogResult : CurrentFileNode.FullPath + "\\" + dialog.DialogResult);
if (provider.CreateSequenceFolder(fullpath))
{
var folder = new FileNode();
folder.Name = dialog.DialogResult;
folder.FullPath = fullpath;
folder.Parent = CurrentFileNode;
CurrentFileNode.Files.Add(folder);
}
else
DialogBox.ShowError("Create folder failed!");
}
}
private ICommand _NewFolderInParentCommand;
public ICommand NewFolderInParentCommand
{
get
{
if (_NewFolderInParentCommand == null)
_NewFolderInParentCommand = new BaseCommand(() => NewFolderInParent());
return _NewFolderInParentCommand;
}
}
public void NewFolderInParent()
{
var dialog = new InputFileNameDialogViewModel("Input Folder Name");
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if (!(bool)bret)
return;
var fullpath = dialog.DialogResult;
if (provider.CreateSequenceFolder(fullpath))
{
var folder = new FileNode();
folder.Name = dialog.DialogResult;
folder.FullPath = fullpath;
folder.Parent = Files[0];
Files[0].Files.Add(folder);
}
else
DialogBox.ShowError("Create folder failed!");
}
private ICommand _NewSequenceInParentCommand;
public ICommand NewSequenceInParentCommand
{
get
{
if (_NewSequenceInParentCommand == null)
_NewSequenceInParentCommand = new BaseCommand(() => NewSequenceInParent());
return _NewSequenceInParentCommand;
}
}
public void NewSequenceInParent()
{
var dialog = new InputFileNameDialogViewModel("Input New Sequence Name");
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if ((bool)bret)
{
if (IsChanged)
{
if (DialogBox.Confirm("This sequence is changed,do you want to save it?"))
{
CurrentSequence.Revisor = BaseApp.Instance.UserContext.LoginName;
CurrentSequence.ReviseTime = DateTime.Now;
Save(CurrentSequence);
}
}
else
{
var fullpath = dialog.DialogResult;
if (string.IsNullOrEmpty(fullpath))
{
DialogBox.ShowError("SequenceName cannot be null or empty!");
return;
}
if (IsExist(fullpath))
{
DialogBox.ShowError("Sequence already existed!");
}
else
{
var sequence = new SequenceData
{
Name = fullpath,
Creator = BaseApp.Instance.UserContext.LoginName,
CreateTime = DateTime.Now,
Revisor = BaseApp.Instance.UserContext.LoginName,
ReviseTime = DateTime.Now,
Description = string.Empty
};
if (Save(sequence))
{
CurrentSequence.Name = sequence.Name;
CurrentSequence.Creator = sequence.Creator;
CurrentSequence.CreateTime = sequence.CreateTime;
CurrentSequence.Revisor = sequence.Revisor;
CurrentSequence.ReviseTime = sequence.ReviseTime;
CurrentSequence.Description = sequence.Description;
CurrentSequence.Steps.Clear();
var file = new FileNode();
file.Name = dialog.DialogResult;
file.FullPath = CurrentSequence.Name;
file.IsFile = true;
file.Parent = Files[0];
Files[0].Files.Insert(findInsertPosition(Files[0].Files), file);
editMode = EditMode.Normal;
UpdateView();
}
}
}
}
}
public int findInsertPosition(ObservableCollection<FileNode> files)
{
var pos = -1;
if (files.Count == 0)
pos = 0;
else
{
var foundfolder = false;
for (var index = 0; index < files.Count; index++)
{
if (!files[index].IsFile)
{
foundfolder = true;
pos = index;
break;
}
}
if (!foundfolder)
pos = files.Count;
}
return pos;
}
private ICommand _SaveAsCommand;
public ICommand SaveAsCommand
{
get
{
if (_SaveAsCommand == null)
_SaveAsCommand = new BaseCommand(() => SaveAsSequence());
return _SaveAsCommand;
}
}
public void SaveAsSequence()
{
if (CurrentFileNode.IsFile)
{
var dialog = new InputFileNameDialogViewModel("SaveAs Sequence");
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if (!(bool)bret)
return;
var fullpath = (CurrentFileNode.Parent.FullPath == "" ? dialog.DialogResult : CurrentFileNode.Parent.FullPath + "\\" + dialog.DialogResult);
if (string.IsNullOrEmpty(fullpath))
{
DialogBox.ShowError("SequenceName cannot be null or empty!");
return;
}
if (IsExist(fullpath))
{
DialogBox.ShowError("Sequence already existed!");
}
else
{
if (IsChanged)
{
if (DialogBox.Confirm("This sequence is changed,do you want to save it?"))
{
Save(CurrentSequence);
}
}
CurrentSequence.Revisor = BaseApp.Instance.UserContext.LoginName;
CurrentSequence.ReviseTime = DateTime.Now;
var tempName = CurrentSequence.Name;
CurrentSequence.Name = fullpath;
if (provider.SaveAs(fullpath, CurrentSequence))
{
var node = new FileNode
{
Parent = CurrentFileNode.Parent,
Name = dialog.DialogResult,
FullPath = fullpath,
IsFile = true
};
CurrentFileNode.Parent.Files.Add(node);
}
else
{
CurrentSequence.Name = tempName;
DialogBox.ShowError("SaveAs failed!");
}
}
}
}
private ICommand _DeleteFolderCommand;
public ICommand DeleteFolderCommand
{
get
{
if (_DeleteFolderCommand == null)
_DeleteFolderCommand = new BaseCommand(() => DeleteFolder());
return _DeleteFolderCommand;
}
}
public void DeleteFolder()
{
if (!CurrentFileNode.IsFile && CurrentFileNode.FullPath != "")
{
if (DialogBox.Confirm("Do you want to delete this folder? this operation will delete all files in this folder."))
{
if (provider.DeleteSequenceFolder(CurrentFileNode.FullPath))
{
CurrentFileNode.Parent.Files.Remove(CurrentFileNode);
}
else
DialogBox.ShowInfo("Delete folder failed!");
}
}
}
private ICommand _NewSequenceCommand;
public ICommand NewSequenceCommand
{
get
{
if (_NewSequenceCommand == null)
_NewSequenceCommand = new BaseCommand(() => NewSequence());
return _NewSequenceCommand;
}
}
public void NewSequence()
{
var dialog = new InputFileNameDialogViewModel("Input New Sequence Name");
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if ((bool)bret)
{
if (IsChanged)
{
if (DialogBox.Confirm("This sequence is changed,do you want to save it?"))
{
CurrentSequence.Revisor = BaseApp.Instance.UserContext.LoginName;
CurrentSequence.ReviseTime = DateTime.Now;
Save(CurrentSequence);
}
}
else
{
var fullpath = dialog.DialogResult;
if (CurrentFileNode.IsFile)
fullpath = (string.IsNullOrEmpty(CurrentFileNode.Parent.FullPath) ? dialog.DialogResult : CurrentFileNode.Parent.FullPath + "\\" + dialog.DialogResult);
else
fullpath = (string.IsNullOrEmpty(CurrentFileNode.FullPath) ? dialog.DialogResult : CurrentFileNode.FullPath + "\\" + dialog.DialogResult);
if (string.IsNullOrEmpty(fullpath))
{
DialogBox.ShowError("SequenceName cannot be null or empty!");
return;
}
if (IsExist(fullpath))
{
DialogBox.ShowError("Sequence already existed!");
}
else
{
var sequence = new SequenceData
{
Name = fullpath,
Creator = BaseApp.Instance.UserContext.LoginName,
CreateTime = DateTime.Now,
Revisor = BaseApp.Instance.UserContext.LoginName,
ReviseTime = DateTime.Now,
Description = string.Empty
};
if (Save(sequence))
{
CurrentSequence.Name = sequence.Name;
CurrentSequence.Creator = sequence.Creator;
CurrentSequence.CreateTime = sequence.CreateTime;
CurrentSequence.Revisor = sequence.Revisor;
CurrentSequence.ReviseTime = sequence.ReviseTime;
CurrentSequence.Description = sequence.Description;
CurrentSequence.Steps.Clear();
var file = new FileNode();
file.Name = dialog.DialogResult;
file.FullPath = CurrentSequence.Name;
file.IsFile = true;
file.Parent = CurrentFileNode.IsFile ? CurrentFileNode.Parent : CurrentFileNode;
if (CurrentFileNode.IsFile)
CurrentFileNode.Parent.Files.Insert(findInsertPosition(CurrentFileNode.Parent.Files), file);
else
CurrentFileNode.Files.Insert(findInsertPosition(CurrentFileNode.Files), file);
editMode = EditMode.Normal;
UpdateView();
// 自动选中新增节点
Files[0].Select(file.FullPath);
InvokeClient.Instance.Service.DoOperation($"GEM_PPChange",@"Sequence\" + dialog.DialogResult + ".seq", 1);
}
}
}
}
}
private ICommand _RenameCommand;
public ICommand RenameCommand
{
get
{
if (_RenameCommand == null)
_RenameCommand = new BaseCommand(() => RenameSequence());
return _RenameCommand;
}
}
public void RenameSequence()
{
if (CurrentFileNode.IsFile)
{
var dialog = new InputFileNameDialogViewModel("Rename Sequence");
var wm = new WindowManager();
dialog.FileName = CurrentFileNode.Name;
var bret = wm.ShowDialog(dialog);
if (!(bool)bret)
return;
var fullpath = CurrentFileNode.Parent.FullPath == "" ? dialog.DialogResult : CurrentFileNode.Parent.FullPath + "\\" + dialog.DialogResult;
if (string.IsNullOrEmpty(fullpath))
{
DialogBox.ShowError("SequenceName cannot be null or empty!");
return;
}
if (IsExist(fullpath))
{
DialogBox.ShowError("Sequence already existed!");
}
else
{
if (IsChanged)
{
if (DialogBox.Confirm("This sequence is changed,do you want to save it?", "") == true)
{
Save(CurrentSequence);
}
}
CurrentSequence.Revisor = BaseApp.Instance.UserContext.LoginName;
CurrentSequence.ReviseTime = DateTime.Now;
if (provider.Rename(CurrentSequence.Name, fullpath))
{
CurrentFileNode.Name = dialog.DialogResult;
CurrentFileNode.FullPath = fullpath;
CurrentSequence.Name = fullpath;
}
else
DialogBox.ShowError("Rename failed!");
}
}
}
public void SaveSequence()
{
if (IsChanged)
{
Save(CurrentSequence);
InvokeClient.Instance.Service.DoOperation($"GEM_PPChange", @"Sequence\" + CurrentSequence.Name + ".seq", 2);
}
}
private ICommand _DeleteCommand;
public ICommand DeleteSequenceCommand
{
get
{
if (_DeleteCommand == null)
_DeleteCommand = new BaseCommand(() => DeleteSequence());
return _DeleteCommand;
}
}
public void DeleteSequence()
{
if (CurrentFileNode.IsFile)
{
if (DialogBox.Confirm("Do you want to delete this sequence?"))
{
string sequenceName = CurrentSequence.Name + ".seq";
if (provider.Delete(CurrentSequence.Name))
{
CurrentFileNode.Parent.Files.Remove(CurrentFileNode);
InvokeClient.Instance.Service.DoOperation($"GEM_PPChange", @"Sequence\" + sequenceName, 3);
}
}
}
}
private ICommand _RefreshCommand;
public ICommand RefreshSequenceCommand
{
get
{
if (_RefreshCommand == null)
_RefreshCommand = new BaseCommand(() => RefreshSequence());
return _RefreshCommand;
}
}
public void RefreshSequence()
{
var names = provider.GetSequences();
Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles("", names));
CurrentFileNode = Files[0];
SelectDefault(CurrentFileNode);
Refresh();
}
public void ReloadSequence()
{
if (editMode == EditMode.Normal || editMode == EditMode.Edit)
{
LoadData(CurrentSequence.Name);
UpdateView();
}
}
private bool Save(SequenceData seq)
{
var result = false;
if (string.IsNullOrEmpty(seq.Name))
{
DialogBox.ShowError("Sequence name can't be empty");
return false;
}
string ruleCheckMessage = null;
if (!ValidateSequenceRules(seq, ref ruleCheckMessage))
{
DialogBox.ShowError(string.Format($"{seq.Name} rules check failed, don't allow to save: {ruleCheckMessage}"));
return false;
}
seq.Revisor = BaseApp.Instance.UserContext.LoginName;
seq.ReviseTime = DateTime.Now;
result = provider.Save(seq);
if (result)
{
foreach (var parameters in seq.Steps)
{
parameters.Apply(param => param.Save());
}
editMode = EditMode.Normal;
IsSavedDesc = true;
NotifyOfPropertyChange("IsSavedDesc");
UpdateView();
}
else
DialogBox.ShowError("Save failed!");
return result;
}
private bool IsExist(string sequenceName)
{
var existed = false;
var fileNode = CurrentFileNode.IsFile ? CurrentFileNode.Parent : CurrentFileNode;
for (var index = 0; index < fileNode.Files.Count; index++)
{
if (string.Equals(fileNode.Files[index].FullPath, sequenceName, StringComparison.CurrentCultureIgnoreCase))
{
existed = true;
break;
}
}
return existed;
}
private static bool ValidateSequenceRules(SequenceData currentSequence, ref string ruleCheckMessage)
{
//foreach (var stepInfo in currentSequence.Steps)
//{
// if (string.IsNullOrEmpty((stepInfo[1] as PositionParam).Value))
// {
// ruleCheckMessage = $"Step{(stepInfo[0] as StepParam).Value}, Position Is Empty";
// return false;
// }
// //if (((stepInfo[4] as PathFileParam).Visible == Visibility.Visible && string.IsNullOrEmpty((stepInfo[4] as PathFileParam).Value)) ||
// // ((stepInfo[5] as PathFileParam).Visible == Visibility.Visible && string.IsNullOrEmpty((stepInfo[5] as PathFileParam).Value)))
// //{
// // ruleCheckMessage = $"Step{(stepInfo[0] as StepParam).Value}, Recipe Is Empty";
// // return false;
// //}
//}
return true;
}
#endregion
#region Steps operation
public void AddStep()
{
CurrentSequence.Steps.Add(CurrentSequence.CreateStep(Columns));
if (editMode != EditMode.New && editMode != EditMode.ReName)
editMode = EditMode.Edit;
UpdateView();
}
public void AppendStep()
{
var index = -1;
var found = false;
for (var i = 0; i < CurrentSequence.Steps.Count; i++)
{
if (CurrentSequence.Steps[i][0] is StepParam && ((StepParam)CurrentSequence.Steps[i][0]).IsChecked)
{
index = i;
found = true;
break;
}
}
if (found)
{
if (editMode != EditMode.New && editMode != EditMode.ReName)
editMode = EditMode.Edit;
CurrentSequence.Steps.Insert(index, CurrentSequence.CreateStep(Columns));
}
}
private RecipeStepCollection copySteps = new RecipeStepCollection();
public void CopyStep()
{
copySteps.Clear();
for (var i = 0; i < CurrentSequence.Steps.Count; i++)
{
if (CurrentSequence.Steps[i][0] is StepParam && ((StepParam)CurrentSequence.Steps[i][0]).IsChecked)
{
copySteps.Add(CurrentSequence.CloneStep(Columns, CurrentSequence.Steps[i]));
}
}
}
public void PasteStep()
{
if (copySteps.Count > 0)
{
if (editMode != EditMode.New && editMode != EditMode.ReName)
editMode = EditMode.Edit;
for (var i = 0; i < CurrentSequence.Steps.Count; i++)
{
if (CurrentSequence.Steps[i][0] is StepParam && ((StepParam)CurrentSequence.Steps[i][0]).IsChecked)
{
for (var copyindex = 0; copyindex < copySteps.Count; copyindex++)
{
CurrentSequence.Steps.Insert(i, CurrentSequence.CloneStep(Columns, copySteps[copyindex]));
i++;
}
break;
}
}
UpdateView();
}
}
public void DeleteStep()
{
if (editMode != EditMode.New && editMode != EditMode.ReName)
editMode = EditMode.Edit;
var steps = CurrentSequence.Steps.ToList();
for (var i = 0; i < steps.Count; i++)
{
if (steps[i][0] is StepParam && ((StepParam)steps[i][0]).IsChecked)
{
CurrentSequence.Steps.Remove(steps[i]);
}
}
}
public void SelectRecipe(PathFileParam param)
{
var parameters = param.Parent;
var model = (PositionParam)parameters.First(p => p.ControlName == "Position");
var dialog = new RecipeSelectDialogViewModel(false, false, RecipeType.Process, model.Value);
dialog.DisplayName = "Select Recipe";
PositionParam posParam = null;
for (var index = 0; index < parameters.Count; index++)
{
if (parameters[index] is PositionParam)
{
posParam = parameters[index] as PositionParam;
break;
}
}
var lstFiles = RecipeClient.Instance.Service.GetRecipesByPath(param.PrefixWithSysName, false).ToList();
dialog.Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles("", lstFiles));
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if ((bool)bret)
{
param.Value = dialog.DialogResult;
/*var path = param.Value;
var index = path.LastIndexOf("\\", StringComparison.Ordinal);
if (index > -1)
{
// Remove the prefix "Sic\Process\" and show folder name in recipe selection text box.
param.FileName = seqFullPrefix.Replace($"{seqFullPrefix}\\", "");
}
else
{
param.FileName = path;
}*/
}
}
#endregion
private void SelectDefault(FileNode node)
{
if (!node.IsFile)
{
if (node.Files.Count > 0)
{
foreach (var file in node.Files)
{
if (file.IsFile)
{
TreeSelectChanged(file);
//break;
}
}
}
}
}
private void LoadData(string newSeqName)
{
var Sequence = provider.GetSequenceByName(Columns, newSeqName);
CurrentSequence.Name = Sequence.Name;
CurrentSequence.Creator = Sequence.Creator;
CurrentSequence.CreateTime = Sequence.CreateTime;
CurrentSequence.Revisor = Sequence.Revisor;
CurrentSequence.ReviseTime = Sequence.ReviseTime;
CurrentSequence.Description = Sequence.Description;
CurrentSequence.Steps.Clear();
Sequence.Steps.ToList().ForEach(step =>
CurrentSequence.Steps.Add(step));
//int index = 1;
//foreach (RecipeStep parameters in this.CurrentSequence.Steps)
//{
// (parameters[0] as StepParam).Value = index.ToString();
// index++;
// foreach (var para in parameters)
// {
// var pathFile = para as PathFileParam;
// if (pathFile != null)
// {
// pathFile.Value = pathFile.Value.Replace($"{pathFile.PrefixPath}\\", "");
// }
// }
//}
IsSavedDesc = true;
NotifyOfPropertyChange("IsSavedDesc");
editMode = EditMode.Normal;
}
private void ClearData()
{
editMode = EditMode.None;
CurrentSequence.Steps.Clear();
CurrentSequence.Name = string.Empty;
CurrentSequence.Description = string.Empty;
IsSavedDesc = true;
NotifyOfPropertyChange("IsSavedGroup");
NotifyOfPropertyChange("IsSavedDesc");
}
public void UpdateView()
{
EnableSequenceName = false;
NotifyOfPropertyChange("EnableSequenceName");
EnableNew = true;
EnableReName = true;
EnableCopy = true;
EnableDelete = true;
EnableSave = true;
EnableStep = true;
NotifyOfPropertyChange("EnableNew");
NotifyOfPropertyChange("EnableReName");
NotifyOfPropertyChange("EnableCopy");
NotifyOfPropertyChange("EnableDelete");
NotifyOfPropertyChange("EnableSave");
NotifyOfPropertyChange("EnableStep");
if (editMode == EditMode.None)
{
EnableNew = true;
EnableReName = false;
EnableCopy = false;
EnableDelete = false;
EnableStep = false;
EnableSave = false;
NotifyOfPropertyChange("EnableNew");
NotifyOfPropertyChange("EnableReName");
NotifyOfPropertyChange("EnableCopy");
NotifyOfPropertyChange("EnableDelete");
NotifyOfPropertyChange("EnableSave");
NotifyOfPropertyChange("EnableStep");
}
}
private bool IsChanged
{
get
{
var changed = false;
if (!IsSavedDesc || editMode == EditMode.Edit)
changed = true;
else
{
foreach (var parameters in CurrentSequence.Steps)
{
if (parameters.Where(param => param.IsSaved == false && param.ControlName != "Step").Count() > 0)
{
changed = true;
break;
}
}
}
return changed;
}
}
public bool EnableNew { get; set; }
public bool EnableReName { get; set; }
public bool EnableCopy { get; set; }
public bool EnableDelete { get; set; }
public bool EnableSave { get; set; }
public bool EnableStep { get; set; }
public bool IsSavedDesc { get; set; }
public FileNode CurrentFileNode { get; private set; }
public SequenceData CurrentSequence { get; private set; }
public ObservableCollection<EditorDataGridTemplateColumnBase> Columns { get; set; }
public bool EnableSequenceName { get; set; }
private string selectedSequenceName = string.Empty;
private string SequenceNameBeforeRename = string.Empty;
private string lastSequenceName = string.Empty;
private SequenceColumnBuilder columnBuilder = new SequenceColumnBuilder();
private EditMode editMode;
private SequenceDataProvider provider = new SequenceDataProvider();
}
}
@@ -0,0 +1,126 @@
<Window x:Class="MECF.Framework.UI.Client.CenterViews.Editors.SlotEditorDialogBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="450" Height="200" WindowStyle="ToolWindow"
WindowStartupLocation="CenterScreen"
Title="{Binding DeviceTitle}">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="50" />
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Arial,SimSun" />
<Setter Property="FontSize" Value="13" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="25" />
</Style>
</Window.Resources>
<Border
Background="#FFDAE5F1"
BorderBrush="Gray"
BorderThickness="0,1,0,0">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Border
Background="White"
BorderBrush="#FF505050"
BorderThickness="1">
<Canvas>
<TextBlock
Canvas.Left="80"
Canvas.Top="22"
FontFamily="Arial"
FontSize="12"
Foreground="Black"
Text="Recipe Name:" />
<TextBox x:Name="txtRecipeName"
Canvas.Left="200"
Canvas.Top="16"
Width="135"
Height="28" IsReadOnly="True"/>
<Button Canvas.Left="340"
Canvas.Top="17"
Width="50"
Height="26"
Content="Select" Click="RecipeSelect_Click">
</Button>
<TextBlock
Canvas.Left="80"
Canvas.Top="65"
FontFamily="Arial"
FontSize="12"
Foreground="Black"
Text="Tray Process Count:" />
<TextBox x:Name="txtTrayProcessCount"
Canvas.Left="200"
Canvas.Top="59"
Width="135"
Height="28" />
</Canvas>
</Border>
<StackPanel
Grid.Row="1"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button
Width="90"
Height="30"
Content="OK" Click="ButtonSet_Click" IsDefault="True">
</Button>
<Button
Width="90"
Height="30"
Margin="10,0,0,0"
Content="Cancel" Click="ButtonCancel_Click">
</Button>
</StackPanel>
</Grid>
</Border>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="TrayPrcoessCount" />
<Label Grid.Row="1" Grid.Column="1" Content="RecipeName" />
<Label Grid.Row="2" Grid.Column="1" Content="Max" />
<Label Grid.Row="3" Grid.Column="1" Content="Default" />
<Label Grid.Row="4" Grid.Column="1" Content="Feedback" />
<Label Grid.Row="5" Grid.Column="1" Content="SetPoint" />
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=DeviceName}" Width="150" Height="28" HorizontalAlignment="Left" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" VerticalContentAlignment="Center" />
<Label Grid.Row="1" Grid.Column="2" Content="{Binding Path=Unit}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="2" Grid.Column="2" Content="{Binding Path=MaxValue}" ContentStringFormat="F1" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="3" Grid.Column="2" Content="{Binding Path=DefaultValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=RealValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="2" x:Name="inputBox" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBox_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center" />
<Button Grid.Row="6" Grid.ColumnSpan="2" Content="Set" x:Name="buttonSet" Click="ButtonSet_Click" Width="80" Height="26" VerticalAlignment="Top" Grid.Column="1" Margin="5,3,0,0" />
<Button Grid.Row="6" Grid.Column="2" Content="Cancel" Click="ButtonCancel_Click" Width="80" Height="26" VerticalAlignment="Top" Margin="44,3,0,0" />
</Grid>-->
</Window>
@@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Globalization;
using Aitex.Core.RT.Log;
using Aitex.Core.Common;
using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
using System.Collections.ObjectModel;
using Caliburn.Micro;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
/// <summary>
/// Interaction logic for InputDialogBox.xaml
/// </summary>
public partial class SlotEditorDialogBox : Window
{
public SlotEditorDialogBox()
{
InitializeComponent();
DataContext = this;
}
public static readonly DependencyProperty ModuleIDProperty = DependencyProperty.Register(
"ModuleID", typeof(string), typeof(SlotEditorDialogBox),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty RecipeNameProperty = DependencyProperty.Register(
"RecipeName", typeof(string), typeof(SlotEditorDialogBox),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty TrayProcessCountProperty = DependencyProperty.Register(
"TrayProcessCount", typeof(int), typeof(SlotEditorDialogBox),
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SlotIDProperty = DependencyProperty.Register(
"SlotID", typeof(int), typeof(SlotEditorDialogBox),
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
public string TrayBelongTo { get; set; }
public string ModuleID
{
get
{
return (string)this.GetValue(ModuleIDProperty);
}
set
{
this.SetValue(ModuleIDProperty, value);
}
}
public int TrayProcessCount
{
get
{
return (int)this.GetValue(TrayProcessCountProperty);
}
set
{
this.SetValue(TrayProcessCountProperty, value);
}
}
public string RecipeName
{
get
{
return (string)this.GetValue(RecipeNameProperty);
}
set
{
this.SetValue(RecipeNameProperty, value);
}
}
public int SlotID
{
get
{
return (int)this.GetValue(SlotIDProperty);
}
set
{
this.SetValue(SlotIDProperty, value);
}
}
private void RecipeSelect_Click(object sender, RoutedEventArgs e)
{
try
{
if (!TrayBelongTo.Contains("PM"))
{
DialogBox.ShowDialog(DialogButton.OK, DialogType.WARNING,
"Recipe follow PM,tray not set PM, Please set TrayInfo");
return;
}
var dialog = new RecipeSelectDialogViewModel(TrayBelongTo);
dialog.DisplayName = "Select Recipe";
var wm = new WindowManager();
var bret = wm.ShowDialog(dialog);
if ((bool)bret)
{
RecipeName = dialog.DialogResult;
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonSet_Click(object sender, RoutedEventArgs e)
{
try
{
int processCount = TrayProcessCount;
Int32.TryParse(txtTrayProcessCount.Text, out processCount);
InvokeClient.Instance.Service.DoOperation("AlterWaferInfo", ModuleID, SlotID, RecipeName, processCount);
this.DialogResult = true;
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
protected override void OnRender(DrawingContext drawingContext)
{
this.txtRecipeName.Text = RecipeName;
this.txtTrayProcessCount.Text = TrayProcessCount.ToString();
base.OnRender(drawingContext);
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
namespace MECF.Framework.UI.Client.CenterViews.Editors
{
public enum EditMode
{
None,
New,
ReName,
Edit,
Normal,
EditWhitelist
}
[Flags]
public enum RecipeType
{
Process = 0x1 << 0,
Routine = 0x1 << 1,
Clean = 0x1 << 2
}
public static class Utils
{
public static List<RecipeType> GetRecipeTypeList()
{
return new List<RecipeType>(new[] { RecipeType.Process });//移除RecipeType.Routine RecipeType.Clean
}
}
}