<Window x:Class="StructureHelper.Windows.Graphs.GraphView"
        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"
        xmlns:local="clr-namespace:StructureHelper.Windows.Graphs"
        xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
        xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
        d:DataContext="{d:DesignInstance local:GraphViewModel}"
        mc:Ignorable="d"
        Title="Graph" Height="750" Width="1200" MinHeight="500" MinWidth="600" MaxHeight="1100" MaxWidth="1800" WindowStartupLocation="CenterScreen">
    <DockPanel>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar>
                <Button Style="{StaticResource ToolButton}" 
                        Command="{Binding RedrawLinesCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Redraw lines"
                                                IconContent="{StaticResource Renew}"
                                                DescriptionText="Redraw all lines of chart which have been selected"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource Renew}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding CopyToClipboardCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Copy to clipboard"
                                                IconContent="{StaticResource CopyToClipboard}"
                                                DescriptionText="Copy chart to clipboard as image"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource CopyToClipboard}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding SaveAsImage}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Export to *.png"
                                                IconContent="{StaticResource PngImage}"
                                                DescriptionText="Export chart to *.png file"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource PngImage}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding ExportToCSVCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Export to *.csv"
                                                IconContent="{StaticResource ExportToXLS}"
                                                DescriptionText="Export all valid results to *.csv file"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource ExportToXLS}"/>
                    </Viewbox>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <Grid x:Name="MainGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="300"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="5*"/>
            </Grid.ColumnDefinitions>
            <TabControl>
                <TabItem Header="Series">
                    <ScrollViewer>
                        <ListBox ItemsSource="{Binding Series}" ScrollViewer.VerticalScrollBarVisibility="Hidden">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Expander Header="{Binding Name}" IsExpanded="True" Background="{Binding Color}">
                                        <Grid HorizontalAlignment="Stretch">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="70"/>
                                                <RowDefinition/>
                                            </Grid.RowDefinitions>
                                            <GroupBox Grid.Row="0" Margin="10,0,10,0" Header="X-axis values">
                                                <StackPanel>
                                                    <ComboBox ItemsSource="{Binding XItems.Collection}" SelectedItem="{Binding XItems.SelectedItem}">
                                                        <ComboBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <Grid>
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="20"/>
                                                                        <ColumnDefinition/>
                                                                    </Grid.ColumnDefinitions>
                                                                    <Rectangle Grid.Column="0" Margin="3">
                                                                        <Rectangle.Fill>
                                                                            <SolidColorBrush Color="{Binding Color}"/>
                                                                        </Rectangle.Fill>
                                                                    </Rectangle>
                                                                    <TextBlock Grid.Column="1" Text="{Binding Name}"/>
                                                                </Grid>
                                                            </DataTemplate>
                                                        </ComboBox.ItemTemplate>
                                                    </ComboBox>
                                                    <CheckBox Margin="5" Content="Invert Values" IsChecked="{Binding InvertXValues}"/>
                                                </StackPanel>

                                            </GroupBox>
                                            <GroupBox Grid.Row="1" Margin="10,0,10,0" Header="Y-axis values">
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition/>
                                                        <RowDefinition Height="30"/>
                                                    </Grid.RowDefinitions>
                                                    <ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
                                                    <CheckBox Grid.Row="1" Margin="5" Content="Invert Values" IsChecked="{Binding InvertYValues}"/>
                                                </Grid>
                                            </GroupBox>
                                        </Grid>
                                    </Expander>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </ScrollViewer>
                </TabItem>
                <TabItem Header="Settings">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="170"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <ContentControl ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/>
                    </Grid>
                </TabItem>
            </TabControl>
            <GridSplitter Grid.Column="1" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="False"/>
            <Grid Grid.Column="2">
                <lvc:CartesianChart Name="MainChart" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy" Background="White">
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis Title="y-value"></lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Title="x-value"></lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                </lvc:CartesianChart>
            </Grid>
        </Grid>
    </DockPanel>
    
</Window>
