<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.DataLogs.DataHistory.SelectUserDefineView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="clr-namespace:Caliburn.Micro"
    xmlns:ctrl="http://OpenSEMI.Ctrlib.com/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.DataLogs.DataHistory"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
    xmlns:wf="[wf ]clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:wfi="[wfi ]clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
    d:DesignHeight="600"
    d:DesignWidth="1200"
    mc:Ignorable="d">
    <UserControl.Resources>
        <Style TargetType="{x:Type ListBox}">
            <Setter Property="Foreground" Value="{DynamicResource FG_Black}" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
            <Setter Property="VerticalContentAlignment" Value="top" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBox}">
                        <Border x:Name="Bd" SnapsToDevicePixels="true">
                            <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false">
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </ScrollViewer>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false" />
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Margin" Value="10,5,0,0" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Rectangle.StrokeThickness" Value="1" />
            <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
            <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Bd" SnapsToDevicePixels="true">
                            <Grid>
                                <ContentPresenter
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Cursor="Hand"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                <Rectangle
                                    x:Name="Highlight"
                                    Opacity="0"
                                    StrokeThickness="{TemplateBinding Rectangle.StrokeThickness}" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Highlight" Property="Stroke" Value="Blue" />
                                <Setter TargetName="Highlight" Property="Opacity" Value="1" />
                                <Setter Property="Foreground" Value="{DynamicResource FG_Black}" />
                                <Setter Property="Background" Value="Blue" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid Width="1200" Height="600">
        <Border
            Padding="10"
            Background="White"
            BorderBrush="Gray"
            BorderThickness="1">
            <Border.Effect>
                <DropShadowEffect
                    BlurRadius="5"
                    ShadowDepth="5"
                    Color="#3F000000" />
            </Border.Effect>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.5*" />
                    <ColumnDefinition Width="0.5*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Border
                    Grid.Row="0"
                    Grid.RowSpan="2"
                    Grid.Column="1"
                    Margin="10,5,0,0"
                    Padding="5"
                    BorderBrush="Gray"
                    BorderThickness="1">
                    <TreeView x:Name="ParameterTreeView" ItemsSource="{Binding ParameterNodes}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="TreeView.SelectedItemChanged">
                                <cal:ActionMessage MethodName="OnTreeSelectedChanged">
                                    <cal:Parameter Value="{Binding ElementName=ParameterTreeView, Path=SelectedItem}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">
                                <StackPanel Orientation="Horizontal">
                                    <CheckBox IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="Click">
                                                <cal:ActionMessage MethodName="ParameterCheck">
                                                    <cal:Parameter Value="{Binding}" />
                                                </cal:ActionMessage>
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </CheckBox>
                                    <TextBlock Text="{Binding Name}" />
                                </StackPanel>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
                </Border>
                <TextBlock
                    Grid.Row="0"
                    Grid.Column="0"
                    Margin="10,5,0,5"
                    FontFamily="Arial"
                    FontSize="14"
                    Text="Selected Parameter" />
                <Border
                    Grid.Row="1"
                    Grid.Column="0"
                    Margin="10,0,0,0"
                    Padding="5"
                    BorderBrush="Gray"
                    BorderThickness="1">
                    <ListBox
                        x:Name="_selectListBox"
                        FontFamily="Arial"
                        FontSize="14"
                        ItemsSource="{Binding SelectedParameters}"
                        SelectedItem="{Binding SelectedItem}"
                        SelectionMode="Multiple" />
                </Border>

                <StackPanel
                    Grid.Row="2"
                    Grid.ColumnSpan="2"
                    Margin="0,10,0,0"
                    HorizontalAlignment="Center"
                    Orientation="Horizontal">
                    <Button
                        Width="100"
                        Height="30"
                        Content="Delete">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="Delete" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="100"
                        Height="30"
                        Margin="20,0,20,0"
                        Content="Delete All">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="DeleteAll" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="100"
                        Height="30"
                        Content="OK">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="OK" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="100"
                        Height="30"
                        Margin="20,0,0,0"
                        Content="Cancel">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="Cancel" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>

