<Window x:Class="StructureHelper.Windows.MainWindow.Materials.MaterialDiagramView"
        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:MaterialDiagramViewModel}"
        mc:Ignorable="d"
        Title="Material Diagram" Height="550" Width="800" MinHeight="550" MinWidth="800" 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>
            </ToolBar>
            <ToolBar>
                <Button Style="{StaticResource ToolButton}" 
                        Command="{Binding GetAreaCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Show diagram's areas"
                                                IconContent="{StaticResource GetArea}"
                                                DescriptionText="Show areas of regions under diagrams (represents energy of deformation of material)"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource GetArea}"/>
                    </Viewbox>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="170"/>
                </Grid.RowDefinitions>
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <StackPanel>
                        <Expander Header="Materials" IsExpanded="True">
                            <ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding MaterialsModel}"/>
                        </Expander>
                        <Expander Header="Limit States">
                            <ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding LimitStatesModel}"/>
                        </Expander>
                        <Expander Header="Calculation terms">
                            <ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding CalcTermsModel}"/>
                        </Expander>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="100"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="22"/>
                                <RowDefinition Height="22"/>
                                <RowDefinition Height="22"/>
                                <RowDefinition Height="22"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Minimum strain"/>
                            <TextBox Grid.Column="1" Text="{Binding MinValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
                            <TextBlock Grid.Row="1" Text="Maximum strain"/>
                            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding MaxValue, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
                            <TextBlock Grid.Row="2" Text="Step count"/>
                            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding StepCount, ValidatesOnDataErrors=True}"/>
                            <TextBlock Grid.Row="3" Text="Positive in tension"/>
                            <CheckBox Grid.Column="1" Grid.Row="3" Margin="4" IsChecked="{Binding PositiveInTension}"/>
                        </Grid>
                    </StackPanel>
                </ScrollViewer>
                <ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/>
            </Grid>
            <Grid Grid.Column="1">
                <lvc:CartesianChart Name="MainChart" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy" Background="White">
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis Title="Stress"></lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Title="Strain"  Labels="{Binding Labels}"></lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                </lvc:CartesianChart>
            </Grid>
        </Grid>
    </DockPanel>
</Window>
