<UserControl x:Class="Serein.Workbench.Views.FlowEditView"
             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:local="clr-namespace:Serein.Workbench.Views"
             xmlns:converter="clr-namespace:Serein.Workbench.Converters"
             xmlns:vm="clr-namespace:Serein.Workbench.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             d:DataContext="{d:DesignInstance vm:FlowEditViewModel}"
             Background="#E7F0F6">
    <UserControl.Resources>
        <converter:InvertableBooleanToVisibilityConverter x:Key="InvertableBooleanToVisibilityConverter"/>

    </UserControl.Resources>
    <Grid>
        
        <TabControl SelectedItem="{Binding SelectedTab}" 
                    ItemsSource="{Binding CanvasTabs}"
                    SelectionChanged="TabControl_SelectionChanged"
                    x:Name="CanvasTab">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel >
                        <!-- 双击选项卡名称来进入编辑模式 -->
                        <TextBlock Text="{Binding Model.Name}"
                                   FontSize="18"
                                   Visibility="{Binding IsEditing, Converter={StaticResource  InvertableBooleanToVisibilityConverter},ConverterParameter=Inverted}"
                                   PreviewMouseLeftButtonDown="TextBlock_PreviewMouseLeftButtonDown"
                                   MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
                        <!-- 编辑模式下显示TextBox -->
                        <TextBox Text="{Binding Model.Name, Mode=TwoWay}" 
                                 FontSize="18"
                                 Visibility="{Binding IsEditing, Converter={StaticResource   InvertableBooleanToVisibilityConverter},ConverterParameter=Normal}"
                                 KeyDown="TextBox_KeyDown" />
                    </StackPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>

          

            <!-- Content of the Tab (e.g., FlowCanvasView) -->
            <TabControl.ContentTemplate>
                <DataTemplate>
                    <Grid Background="#FFD3D3D3">
                        <ContentControl Content="{Binding Content}" />
                    </Grid>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>

        <!-- Tab control buttons -->
        <!--<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">
            <Button Content="添加" Command="{Binding AddTabCommand}"  Margin="5" Width="80"/>
            <Button Content="移除" Command="{Binding RemoveTabCommand}"  Margin="5" Width="80"/>
            --><!--<Button Content="Rename Tab" Command="{Binding RenameTabCommand}" />--><!--
        </StackPanel>-->
    </Grid>
</UserControl>

