<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DynamicChart"
             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:FasdDesktopUi.Basics.UserControls"
             xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
             xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
             Name="DynChartUc"
             mc:Ignorable="d" 
             SizeChanged="UserControl_SizeChanged"
             d:DesignHeight="450" d:DesignWidth="800">

    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
        <vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
    </UserControl.Resources>

    <Border CornerRadius="10"
            Margin="0 0 0 10"
            Height="270"
            Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
            Visibility="{Binding ElementName=DynChartUc, Path=ChartData, Converter={StaticResource NullToVisibility}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="42" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!--#region Kopfzeile -->
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="45" />
                    <ColumnDefinition Width="10" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="10" />
                    <ColumnDefinition Width="45" />
                </Grid.ColumnDefinitions>

                <ico:AdaptableIcon  x:Name="BarChartButton"
                                    Grid.Column="0"
                                    SelectedMaterialIcon="ic_sort"
                                    MouseLeftButtonUp="ChangeChartType_MouseLeftButtonUp"
                                    TouchDown="ChangeChartType_TouchDown"
                                    Style="{DynamicResource Menu.MenuBar.PinnedIcon.Color}"
                                    Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
                    <ico:AdaptableIcon.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="-90"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </ico:AdaptableIcon.RenderTransform>
                </ico:AdaptableIcon>

                <ico:AdaptableIcon  x:Name="LineGraphButton"
                                    Grid.Column="0"
                                    SelectedMaterialIcon="ic_clear_all"
                                    MouseLeftButtonUp="ChangeChartType_MouseLeftButtonUp"
                                    TouchDown="ChangeChartType_TouchDown"
                                    Style="{DynamicResource Menu.MenuBar.PinnedIcon.Color}"
                                    Visibility="Visible"/>
                
                <Border Grid.Column="2"
                        Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
                        CornerRadius="10,0,0,0">

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock  Grid.Row="0"
                                    x:Name="TitleBlock"
                                    HorizontalAlignment="Center"
                                    Margin="0,5,0,0"
                                    FontFamily="Calibri"
                                    FontSize="14"
                                    FontWeight="Bold"
                                    Foreground="{DynamicResource Color.Menu.Icon}">

                        </TextBlock>
                        <TextBlock  Grid.Row="1"
                                    x:Name="DateBlock"
                                    HorizontalAlignment="Center"
                                    FontFamily="Calibri"
                                    FontSize="13"
                                    FontWeight="Regular"
                                    Foreground="{DynamicResource Color.Menu.Icon}">

                        </TextBlock>
                    </Grid>

                </Border>

                <ico:AdaptableIcon x:Name="CloseButton"
                                   Grid.Column="4"
                                   SelectedInternIcon="window_close"
                                   MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
                                   TouchDown="CloseButton_TouchDown"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   Visibility="{Binding ElementName=DynChartUc, Path=IsCloseButtonVisible, Converter={StaticResource BoolToVisibility}}"/>

            </Grid>
            <!--#endregion-->

            <!--#region Inhalt -->
            <Grid Grid.Row="1"
                  Margin="10">

                <Border x:Name="GraphicBorder"
                        Panel.ZIndex="1">
                    <Border x:Name="CanvasBorder">
                        <Canvas x:Name="GraphicCanvas"
                                Panel.ZIndex="1"/>
                    </Border>
                </Border>

            </Grid>
            <!--#endregion-->
        </Grid>
        
    </Border>
    
</UserControl>
