<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeEditorView"
    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: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="900"
    d:DesignWidth="1500"
    lex:LocalizeDictionary.DesignCulture="en"
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
    mc:Ignorable="d">
    <UserControl.Resources>

        <cv:BoolReverseConverter x:Key="BoolReverseConverter" />
        <cv:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />

        <converters:IsCellAccessPermEditModeToButtonContent x:Key="CellPermButtonContent" />
        <converters:IsSavedToNameMarkVisibilityConverter x:Key="IsSavedToNameMarkVisibilityConverter" />
        <converters:SelectedRecipeStepsToListConverter x:Key="SelectedRecipeStepsToList" />


        <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}}">
                        <Label
                            Margin="0"
                            Content="{Binding CurrentFileNode.FullPath}"
                            FontWeight="Black" />
                        <Separator />
                        <MenuItem
                            Command="{Binding NewRecipeCommand}"
                            Header="New Recipe"
                            IsEnabled="{Binding IsPermission}" />
                        <MenuItem
                            Command="{Binding DeleteRecipeCommand}"
                            Header="Delete Recipe"
                            IsEnabled="False" />
                        <MenuItem
                            Command="{Binding RenameRecipeCommand}"
                            Header="Rename Recipe"
                            IsEnabled="False" />
                        <MenuItem
                            Command="{Binding SaveAsRecipeCommand}"
                            Header="Save As Recipe"
                            IsEnabled="False" />
                        <Separator />
                        <MenuItem Command="{Binding NewFolderCommand}" Header="New Folder" />
                        <MenuItem Command="{Binding DeleteFolderCommand}" Header="Delete Folder" />
                        <MenuItem Command="{Binding RenameFolderCommand}" Header="Rename 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>
            </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}}">
                        <Label
                            Margin="0"
                            Content="{Binding CurrentFileNode.FullPath}"
                            FontWeight="Black" />
                        <Separator />
                        <MenuItem
                            Command="{Binding NewRecipeCommand}"
                            Header="New Recipe"
                            IsEnabled="{Binding IsPermission}" />
                        <MenuItem
                            Command="{Binding DeleteRecipeCommand}"
                            Header="Delete Recipe"
                            IsEnabled="{Binding IsPermission}" />
                        <MenuItem
                            Command="{Binding RenameRecipeCommand}"
                            Header="Rename Recipe"
                            IsEnabled="{Binding IsPermission}" />
                        <MenuItem
                            Command="{Binding SaveAsRecipeCommand}"
                            Header="Save As Recipe"
                            IsEnabled="{Binding IsPermission}" />
                        <Separator />
                        <MenuItem Command="{Binding NewFolderCommand}" Header="New Folder" />
                        <MenuItem
                            Command="{Binding DeleteFolderCommand}"
                            Header="Delete Folder"
                            IsEnabled="False" />
                        <MenuItem
                            Command="{Binding RenameFolderCommand}"
                            Header="Rename Folder"
                            IsEnabled="False" />
                    </ContextMenu>
                </StackPanel.ContextMenu>
            </StackPanel>
        </HierarchicalDataTemplate>

        <editors:FolderOrFileTemplateSelector
            x:Key="FolderFileTemplateSelector"
            FileTemplate="{StaticResource FileTemplate}"
            FolderTemplate="{StaticResource FolderTemplate}" />

    </UserControl.Resources>
    <Grid>

        <Grid Name="rootGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="270" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>
                <StackPanel Margin="0,5,5,0" IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}">
                    <StackPanel IsEnabled="{Binding IsPermission}" Orientation="Horizontal">
                        <Button
                            Width="50"
                            Height="25"
                            Margin="0,0,0,0"
                            Content="{lex:Loc ID_BTN_New_Content}"
                            FontSize="10"
                            IsEnabled="True">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="NewRecipe" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                        <Button
                            Width="50"
                            Height="25"
                            Margin="2,0,0,0"
                            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                            Content="{lex:Loc ID_BTN_Rename_Content}"
                            FontSize="10"
                            IsEnabled="{Binding EnableReName}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="RenameRecipe" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                        <Button
                            Width="50"
                            Height="25"
                            Margin="2,0,0,0"
                            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                            Content="{lex:Loc ID_BTN_Delete_Content}"
                            FontSize="10"
                            IsEnabled="{Binding EnableDelete}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="DeleteRecipe" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                        <Button
                            Width="50"
                            Height="25"
                            Margin="2,0,0,0"
                            Content="{lex:Loc ID_BTN_Refresh_Content}"
                            FontSize="10"
                            IsEnabled="{Binding EnableRefreshRecipeList}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="RefreshRecipe" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                        <Button
                            Width="50"
                            Height="25"
                            Margin="2,0,0,0"
                            Content="{Binding Expand}"
                            FontSize="10">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="IsExpandAllNodes" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </StackPanel>
                </StackPanel>
                <StackPanel
                    Grid.Row="1"
                    IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}"
                    Orientation="Horizontal">
                    <Label
                        Margin="5,0,0,0"
                        VerticalAlignment="Center"
                        Content="{lex:Loc ID_TXT_Filter}"
                        FontSize="16" />
                    <TextBox
                        Width="156"
                        Height="26"
                        Margin="0,0,5,0"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Center"
                        IsEnabled="{Binding EnableFilterTreeList}"
                        Text="{Binding Path=CurrentCriteria, UpdateSourceTrigger=PropertyChanged}" />
                    <Button
                        Width="30"
                        Height="30"
                        Margin="0,0,5,0"
                        Padding="0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        IsEnabled="{Binding EnableFilterTreeList}">
                        <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="2"
                    Margin="0,0,13,0"
                    Background="Transparent"
                    BorderBrush="{DynamicResource Tab_BD}"
                    BorderThickness="0"
                    IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}">
                    <TabControl
                        Padding="0"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch"
                        VerticalContentAlignment="Stretch"
                        IsEnabled="{Binding EnableLeftTabPanel}"
                        ItemsSource="{Binding ProcessTypeFileList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        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"
                                    ItemTemplateSelector="{StaticResource FolderFileTemplateSelector}"
                                    ItemsSource="{Binding FileListByProcessType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    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="MouseRightButtonDown">
                                            <micro:ActionMessage MethodName="TreeRightMouseDown">
                                                <micro:Parameter Value="$eventargs" />
                                            </micro:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <TreeView.ContextMenu>
                                        <ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
                                            <!--<Label Content=".\" FontWeight="Black" Margin="0"/>-->
                                            <Separator />

                                            <MenuItem
                                                Command="{Binding NewRecipeRootCommand}"
                                                Header="New Recipe"
                                                IsEnabled="{Binding IsPermission}" />
                                            <MenuItem
                                                Command="{Binding DeleteRecipeCommand}"
                                                Header="Delete Recipe"
                                                IsEnabled="False" />
                                            <MenuItem
                                                Command="{Binding RenameRecipeCommand}"
                                                Header="Rename Recipe"
                                                IsEnabled="False" />
                                            <MenuItem
                                                Command="{Binding SaveAsRecipeCommand}"
                                                Header="Save As Recipe"
                                                IsEnabled="False" />
                                            <Separator />
                                            <MenuItem
                                                Command="{Binding NewFolderRootCommand}"
                                                Header="New Folder"
                                                IsEnabled="{Binding IsPermission}" />
                                            <MenuItem
                                                Command="{Binding DeleteFolderCommand}"
                                                Header="Delete Folder"
                                                IsEnabled="False" />
                                            <MenuItem
                                                Command="{Binding RenameFolderCommand}"
                                                Header="Rename Folder"
                                                IsEnabled="False" />
                                        </ContextMenu>
                                    </TreeView.ContextMenu>
                                </TreeView>
                            </DataTemplate>
                        </TabControl.ContentTemplate>

                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <micro:ActionMessage MethodName="TabSelectionChanged" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                    </TabControl>
                </Border>

                <Grid
                    Grid.Row="3"
                    Margin="0,0,13,0"
                    IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Button
                        Margin="3"
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                        micro:Message.Attach="ImportRecipe()"
                        Content="{lex:Loc ID_BTN_Import_Content}"
                        IsEnabled="{Binding EnableImportExport}"
                        ToolTip="Import recipes from files" />
                    <Button
                        Grid.Column="1"
                        Margin="3"
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                        micro:Message.Attach="ExportRecipe()"
                        Content="{lex:Loc ID_BTN_Export_Content}"
                        IsEnabled="{Binding EnableImportExport}"
                        ToolTip="Export recipes to files." />
                </Grid>
            </Grid>
            <GridSplitter
                Grid.Column="0"
                Width="10"
                Margin="0,55,0,0"
                HorizontalAlignment="Right"
                VerticalAlignment="Stretch"
                Background="Transparent"
                Style="{DynamicResource VerticalGridSplitterStyle}" />
            <Grid
                Grid.Column="1"
                Margin="0,0,0,0"
                HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Border IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}">

                    <Grid IsEnabled="{Binding IsPermission}">
                        <Grid.ColumnDefinitions>

                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="220" />
                            <ColumnDefinition Width="220" />
                            <ColumnDefinition Width="430" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="200" />

                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40" />
                        </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="1,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,1,1,1">
                            <Border
                                Padding="5,0"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="1,1,1,1">
                                <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                                    <TextBlock
                                        Margin="0,0,5,0"
                                        Text="*"
                                        Visibility="{Binding CurrentRecipe.IsChanged, Converter={StaticResource IsSavedToNameMarkVisibilityConverter}}" />
                                    <TextBlock
                                        Width="Auto"
                                        MinWidth="200"
                                        HorizontalAlignment="Left"
                                        FontFamily="Arial"
                                        FontSize="18"
                                        Text="{Binding CurrentRecipe.Name}"
                                        TextTrimming="CharacterEllipsis"
                                        TextWrapping="NoWrap" />
                                </StackPanel>
                            </Border>
                        </Border>
                        <Border
                            Grid.Column="2"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,1,1,1">
                            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                                <Button
                                    Width="90"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    HorizontalAlignment="Right"
                                    Content="{lex:Loc ID_BTN_Reload_Content}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="ReloadRecipe" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                                <Button
                                    Width="95"
                                    Height="30"
                                    Margin="10,0,10,0"
                                    Content="{lex:Loc ID_BTN_SaveToAll_Content}"
                                    IsEnabled="{Binding EnableSaveToAll}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="SaveToAll" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </Border>

                        <Border
                            Grid.Column="3"
                            Grid.ColumnSpan="3"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,1,1,1">
                            <StackPanel Orientation="Horizontal" Visibility="{Binding MultiChamberVisibility}">
                                <TextBlock
                                    VerticalAlignment="Center"
                                    FontFamily="Arial"
                                    FontSize="16"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="Chamber"
                                    Visibility="Hidden" />

                                <ComboBox
                                    Width="80"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    ItemsSource="{Binding Chambers}"
                                    SelectedItem="{Binding SelectedChamber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    Visibility="Hidden">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="SelectionChanged">
                                            <micro:ActionMessage MethodName="ChamberSelectionChanged" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </ComboBox>
                                <Button
                                    Width="120"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    HorizontalAlignment="Right"
                                    Content="Save"
                                    IsEnabled="{Binding EnableSave}"
                                    Visibility="Hidden">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="SaveRecipe" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                                <Button
                                    Width="120"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    Content="Save To..."
                                    IsEnabled="{Binding EnableSaveTo}"
                                    Visibility="Collapsed">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="SaveTo" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>

                            </StackPanel>
                        </Border>

                        <StackPanel
                            Grid.Column="4"
                            Grid.ColumnSpan="2"
                            Margin="0,0,10,0"
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">
                            <Button
                                x:Name="btnLock"
                                Grid.Column="5"
                                Width="95"
                                Height="30"
                                Margin="0,0,7,0"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Click="btnLock_Click"
                                Content="{lex:Loc ID_BTN_Lock_Content}" />
                            <Button
                                x:Name="btnChangePassword"
                                Grid.Column="5"
                                Width="153"
                                Height="30"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                Click="btnChangePassword_Click"
                                Content="{lex:Loc ID_BTN_ChangePassword_Content}" />
                        </StackPanel>
                    </Grid>
                </Border>
                <TabControl
                    Grid.Row="1"
                    Margin="0,5,0,0"
                    IsEnabled="{Binding EditorEnable}"
                    Visibility="{Binding EditorEnableV}">
                    <TabItem>
                        <TabItem.Header>
                            <TextBlock lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview" Text="{lex:Loc ID_TXT_Header}" />
                        </TabItem.Header>
                        <Grid HorizontalAlignment="Left" IsEnabled="{Binding IsPermission}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="150" />
                                <ColumnDefinition Width="280" />
                                <ColumnDefinition Width="200" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                                <RowDefinition Height="40" />
                            </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="Stretch"
                                    AllowBackgroundChange="False"
                                    IsEnabled="False"
                                    Text="{Binding CurrentRecipe.Name}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="0"
                                Grid.Column="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,1,1,1" />

                            <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="Stretch"
                                    Text="{Binding CurrentRecipe.Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    TextSaved="{Binding CurrentRecipe.IsSavedDesc, Mode=TwoWay}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="1"
                                Grid.Column="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1" />

                            <Border
                                Grid.Row="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Title}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="1,0,1,1">
                                <TextBlock
                                    VerticalAlignment="Center"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                    FontFamily="Arial"
                                    FontSize="16"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="{lex:Loc ID_TXT_ChamberType}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="2"
                                Grid.Column="1"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1">
                                <TextBlock
                                    Width="Auto"
                                    MinWidth="100"
                                    VerticalAlignment="Stretch"
                                    IsEnabled="False"
                                    Text="{Binding CurrentRecipe.RecipeChamberType}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="2"
                                Grid.Column="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1" />


                            <Border
                                Grid.Row="3"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Title}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="1,0,1,1">
                                <TextBlock
                                    VerticalAlignment="Center"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                    FontFamily="Arial"
                                    FontSize="16"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="{lex:Loc ID_TXT_FormatVersion}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="3"
                                Grid.Column="1"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1">
                                <TextBlock
                                    Width="Auto"
                                    MinWidth="100"
                                    VerticalAlignment="Stretch"
                                    Text="{Binding CurrentRecipe.RecipeVersion}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="3"
                                Grid.Column="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1" />

                            <Border
                                Grid.Row="4"
                                Grid.Column="0"
                                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_Create}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="4"
                                Grid.Column="1"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1">
                                <TextBlock
                                    Width="Auto"
                                    MinWidth="100"
                                    VerticalAlignment="Stretch"
                                    FontFamily="Arial"
                                    FontSize="14"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="{Binding CurrentRecipe.Creator}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="4"
                                Grid.Column="2"
                                Padding="5,1"
                                Background="{DynamicResource Table_BG_Content}"
                                BorderBrush="{DynamicResource Table_BD}"
                                BorderThickness="0,0,1,1">
                                <TextBlock
                                    Width="Auto"
                                    MinWidth="100"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Center"
                                    FontFamily="Arial"
                                    FontSize="14"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="{Binding CurrentRecipe.CreateTime}"
                                    TextWrapping="Wrap" />
                            </Border>

                            <Border
                                Grid.Row="5"
                                Grid.Column="0"
                                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_Revise}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="5"
                                Grid.Column="1"
                                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 CurrentRecipe.Revisor}"
                                    TextWrapping="Wrap" />
                            </Border>
                            <Border
                                Grid.Row="5"
                                Grid.Column="2"
                                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 CurrentRecipe.ReviseTime}"
                                    TextWrapping="Wrap" />
                            </Border>
                        </Grid>

                    </TabItem>

                    <TabItem IsSelected="True">
                        <TabItem.Header>
                            <TextBlock lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview" Text="{lex:Loc ID_TXT_Steps}" />
                        </TabItem.Header>
                        <Grid
                            Grid.Row="1"
                            Margin="0,0,0,0"
                            IsEnabled="{Binding IsPermission}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="97*" />
                                <ColumnDefinition Width="1041*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="50" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <StackPanel
                                Grid.ColumnSpan="2"
                                Margin="200,0,0,0"
                                IsEnabled="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}"
                                Orientation="Horizontal">
                                <TextBlock
                                    MinWidth="160"
                                    Margin="0,0,20,0"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                    FontFamily="Arial"
                                    FontSize="16"
                                    Foreground="{DynamicResource FG_Black}"
                                    TextAlignment="Right">
                                    <Run FontSize="12" Text="{lex:Loc ID_TXT_TotalTime}" /><Run FontSize="12" Text="{Binding CurrentRecipe.RecipeTotalTime, StringFormat=:{0}s}" />
                                </TextBlock>

                                <Button
                                    Width="90"
                                    Height="30"
                                    Margin="0,0,0,0"
                                    micro:Message.Attach="AddStep()"
                                    Content="{lex:Loc ID_BTN_Add_Content}"
                                    IsEnabled="{Binding EnableStep}" />
                                <Button
                                    Width="90"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    micro:Message.Attach="InsertStepToLeft()"
                                    Content="{lex:Loc ID_BTN_Insert_Content}"
                                    IsEnabled="{Binding EnableStep}" />
                                <Button
                                    Width="90"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    micro:Message.Attach="CopyStep()"
                                    Content="{lex:Loc ID_BTN_Copy_Content}"
                                    IsEnabled="{Binding EnableStep}" />
                                <Button
                                    Width="100"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                    micro:Message.Attach="PasteStepToLeft()"
                                    Content="{lex:Loc ID_BTN_PasteFront_Content}"
                                    IsEnabled="{Binding EnableStep}" />
                                <Button
                                    Width="100"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                    micro:Message.Attach="PasteStepToRight()"
                                    Content="{lex:Loc ID_BTN_PasteBack_Content}"
                                    IsEnabled="{Binding EnableStep}" />
                                <Button
                                    Width="90"
                                    Height="30"
                                    Margin="10,0,0,0"
                                    micro:Message.Attach="DeleteStep()"
                                    Content="{lex:Loc ID_BTN_Delete_Content}"
                                    IsEnabled="{Binding EnableStep}" />

                                <materialDesign:Badged
                                    x:Name="txtErrorCount"
                                    Margin="30,0,0,0"
                                    VerticalAlignment="Center"
                                    materialDesign:BadgedAssist.IsMiniBadge="True"
                                    BadgeBackground="Red"
                                    BadgeColorZoneMode="Standard"
                                    BadgeForeground="White"
                                    BadgePlacementMode="TopLeft"
                                    CornerRadius="5,5,5,5">
                                    <Button
                                        Width="90"
                                        Height="30"
                                        lex:ResxLocalizationProvider.DefaultDictionary="lang_recipeview"
                                        micro:Message.Attach="ShowValidationDetailWindow()"
                                        Content="{lex:Loc ID_TXT_Validate}"
                                        IsEnabled="{Binding EnableStep}" />
                                </materialDesign:Badged>

                                <materialDesign:Badged
                                    x:Name="txtCellAccessPremCount"
                                    Margin="15,0,0,0"
                                    VerticalAlignment="Center"
                                    materialDesign:BadgedAssist.IsMiniBadge="True"
                                    BadgeBackground="LimeGreen"
                                    BadgeColorZoneMode="Standard"
                                    BadgeForeground="White"
                                    BadgePlacementMode="TopLeft"
                                    CornerRadius="5,5,5,5"
                                    Visibility="{Binding IsShowCellAccessPermEditButton, Converter={StaticResource BoolVisibilityConverter}}">
                                    <Button
                                        Width="100"
                                        Height="30"
                                        Margin="0,0,0,0"
                                        lex:ResxLocalizationProvider.DefaultDictionary="lang_terms"
                                        micro:Message.Attach="SwitchCellAccessPermEditMode()"
                                        Content="{lex:Loc {Binding CurrentRecipe.IsAccessibleWhitelistEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}}"
                                        IsEnabled="{Binding EnableCellPermButton}"
                                        ToolTip="Cell-Access-Perm Edit Mode" />
                                </materialDesign:Badged>

                            </StackPanel>

                            <Border
                                x:Name="dgContainer"
                                Grid.Row="1"
                                Grid.Column="0"
                                Grid.ColumnSpan="2"
                                Background="Transparent"
                                IsHitTestVisible="{Binding IsLoading, Converter={StaticResource BoolReverseConverter}}">
                                <dgExtension:DataGridRecipe
                                    x:Name="dgCustom"
                                    FrozenColumnCount="6"
                                    IsEnabled="{Binding IsPermission}"
                                    Recipe="{Binding CurrentRecipe, Mode=OneWay}" />
                            </Border>
                        </Grid>
                    </TabItem>
                </TabControl>
            </Grid>
        </Grid>

        <uiClientCtrl:PanelLocker
            x:Name="editorLocker"
            LockTarget="{Binding ElementName=rootGrid}"
            Visibility="Collapsed" />
    </Grid>
</UserControl>
