<Window x:Class="StructureHelper.Windows.MainWindow.CrossSectionView"
        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:infrastructure="clr-namespace:StructureHelper.Infrastructure"
        xmlns:dataTemplates="clr-namespace:StructureHelper.Infrastructure.UI.DataTemplates"
        xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
        xmlns:vm="clr-namespace:StructureHelper.Windows.MainWindow"
        xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
        xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
        xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance local:CrossSectionViewModel}"
        Title="Cross-Section NDM Analysis" Height="700" Width="1000" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Infrastructure/UI/Resources/MaterialButtonStyles.xaml"/>
                <ResourceDictionary Source="/Infrastructure/UI/Resources/CalculatorButtonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}">
            <dataTemplates:RectangleTemplate/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type dataContexts:CircleViewPrimitive}">
            <dataTemplates:EllipseTemplate/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type dataContexts:PointViewPrimitive}">
            <dataTemplates:EllipseTemplate/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type dataContexts:ShapeViewPrimitive}">
            <dataTemplates:PolygonTemplate/>
        </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar DataContext="{Binding CombinationsLogic}" ToolTip="Actions">
                <Button Style="{StaticResource ToolButton}" 
                        Command="{Binding Add}"
                         CommandParameter="{x:Static enums:ActionType.ForceCombination}"
                        Content="Full" ToolTip="Add Full Combination"/>
                <Button Style="{StaticResource ToolButton}" 
                        Command="{Binding Add}"
                         CommandParameter="{x:Static enums:ActionType.ForceCombinationByFactor}"
                        Content="Fact" ToolTip="Add Factored Combination"/>
                <Button Style="{StaticResource ToolButton}" 
                        Command="{Binding Add}"
                         CommandParameter="{x:Static enums:ActionType.ForceCombinationFromFile}"
                        Content="File" ToolTip="Add Combination From File"/>
            </ToolBar>
            <ToolBar DataContext="{Binding MaterialsLogic}" ToolTip="Materials">
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:MaterialType.Concrete}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add concrete material"
                                                IconContent="{StaticResource ConcreteMaterial}"
                                                DescriptionText="Adds new material of concrete according to SP63.13330.2018"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ConcreteMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:MaterialType.Reinforcement}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Reinforcement material"
                                                IconContent="{StaticResource ReinforcementMaterial}"
                                                DescriptionText="Adds new material of reinforcement according to SP63.13330.2018"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ReinforcementMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:MaterialType.Steel}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Steel material"
                                                IconContent="{StaticResource SteelMaterial}"
                                                DescriptionText="Adds new material of steel according to SP16.13330.2017"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource SteelMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:MaterialType.Elastic}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Carbon Fiber material"
                                                IconContent="{StaticResource ElasticMaterial}"
                                                DescriptionText="Adds new elastic material with linear stress-strain curve"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ElasticMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:MaterialType.CarbonFiber}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Carbon Fiber material"
                                                IconContent="{StaticResource CarbonFiberMaterial}"
                                                DescriptionText="Adds new carbon fiber material according to SP164.1325800.2014"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource CarbonFiberMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.GlassFiber}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Glass Fiber material"
                                                IconContent="{StaticResource GlassFiberMaterial}"
                                                DescriptionText="Adds new glass fiber material according to SP164.1325800.2014"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource GlassFiberMaterial}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}"  Command="{Binding EditMaterialsCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Show materials"
                                                IconContent="{StaticResource Materials}"
                                                DescriptionText="Shows material properties like diagrams, etc."/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource Materials}"/>
                    </Viewbox>
                </Button>
            </ToolBar>

            <ToolBar ToolTip="RC Templates">
                <Button Style="{StaticResource ToolButton}" Command="{Binding AddColumnCase}" ToolTip="Add Rectangle RC Column">
                    <Image Source="/Windows/MainWindow/RectangleColumn32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding AddRCCircleCase}" ToolTip="Add Circle RC Column">
                    <Image Source="/Windows/MainWindow/CircleColumn32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding AddBeamCase}" ToolTip="Add RC Beam">
                    <Image Source="/Windows/MainWindow/Beam32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding AddSlabCase}" ToolTip="Add RC Slab">
                    <Image Source="/Windows/MainWindow/Slab32.png"/>
                </Button>
            </ToolBar>
            <ToolBar ToolTip="Analises" DataContext="{Binding CalculatorsLogic}">
                <Button Style="{StaticResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}" ToolTip="Add Force Calculator">
                    <Image Source="/Windows/MainWindow/Calculator32.png"/>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}" ToolTip="Add Interaction Diagram Calculator">
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource DiagramCalculator}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Crack Calculator"
                                                IconContent="{StaticResource Polygon}"
                                                DescriptionText="Adds calculator for design reinforced concrete cross-section for crack width"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:CalculatorTypes.ValueDiagramCalculator}" >
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Value Diagram Calculator"
                                                IconContent="{StaticResource ValueDiagramCalculator}"
                                                DescriptionText="Adds new calculator for creating diagram of results on line of cross-section"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ValueDiagramCalculator}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}"  CommandParameter="{x:Static enums:CalculatorTypes.CurvatureCalcualtor}" >
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add Curvature Calculator"
                                                IconContent="{StaticResource CurvatureCalculator}"
                                                DescriptionText="Adds new calculator for calculating of curvature of cross-section"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource CurvatureCalculator}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Run}" ToolTip="Run Calculations">
                    <Viewbox>
                        <ContentControl ContentTemplate="{DynamicResource CalculatorRun}"/>
                    </Viewbox>
                </Button>
            </ToolBar>
            <ToolBar ToolTip="Tools">
                <Button Style="{StaticResource ToolButton}" Command="{Binding MovePrimitiveToGravityCenterCommand}" ToolTip="Move All Primitives to Gravity Center">
                    <Image Source="/Windows/MainWindow/MovePrimitivesToCenter.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding ShowVisualProperty}" ToolTip="Visual Settings">
                    <Image Source="/Windows/MainWindow/Tools_Settings.png"/>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar ToolTip="Base Primitives" DataContext="{Binding PrimitiveLogic}">
                <Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Polygon}" >
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Add polygon primitive"
                                                IconContent="{StaticResource Polygon}"
                                                DescriptionText="Add polygon primitive with default properties into cross-section"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource Polygon}"/>
                    </Viewbox>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}" ToolTip="Add Rectangle Primitive">
                    <Image Source="/Windows/MainWindow/Rectangle32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}" ToolTip="Add Circle Primitive">
                    <Image Source="/Windows/MainWindow/Circle32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}" ToolTip="Add Rebar Primitive">
                    <Image Source="/Windows/MainWindow/Rebar32.png"/>
                </Button>
                <Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}" ToolTip="Add Point Primitive">
                    <Image Source="/Windows/MainWindow/Point32.png"/>
                </Button>
            </ToolBar>
            <ToolBar Name="DxfOperation">
                <Button Style="{DynamicResource ToolButton}" Command="{Binding ExportToDxfCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Export to *.dxf file"
                                        IconContent="{StaticResource ExportToDxf}"
                                        DescriptionText="Exports primitives to new *.dxf file"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ExportToDxf}"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource ToolButton}" Command="{Binding ImportFromDxfCommand}">
                    <Button.ToolTip>
                        <uc:ButtonToolTipEh HeaderText="Import from *.dxf file"
                                        IconContent="{StaticResource ImportFromDxf}"
                                        DescriptionText="Imports primitives from *.dxf file"/>
                    </Button.ToolTip>
                    <Viewbox>
                        <ContentControl ContentTemplate="{StaticResource ImportFromDxf}"/>
                    </Viewbox>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="25"/>
            </Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <StackPanel>
                        <Expander Header="Actions" MinWidth="20" DataContext="{Binding CombinationsLogic}">
                            <Expander.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Add">
                                        <MenuItem Header="Combination" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombination}"/>
                                        <MenuItem Header="Combination By Factors" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombinationByFactor}"/>
                                        <MenuItem Header="Combination From File" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombinationFromFile}"/>
                                    </MenuItem>
                                </ContextMenu>
                            </Expander.ContextMenu>
                            <ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ContextMenu="{StaticResource EditCopyDelete}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <TextBlock Text="{Binding Name}"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Expander>
                        <Expander MinWidth="20" DataContext="{Binding MaterialsLogic}">
                            <Expander.Header>
                                <StackPanel Orientation="Horizontal">
                                    <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Materials32.png"/>
                                    <TextBlock Text="Materials" Margin="5,0,0,0"/>
                                </StackPanel>
                            </Expander.Header>
                            <Expander.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Materials" Command="{Binding EditMaterialsCommand}">
                                        <MenuItem.Icon>
                                            <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Materials32.png" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Add">
                                        <MenuItem Header="Concrete" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Concrete}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource ConcreteMaterial}" />
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Reinforcement" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Reinforcement}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource ReinforcementMaterial}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Steel" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Steel}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource SteelMaterial}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Elastic" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Elastic}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource ElasticMaterial}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="CarbonFiber" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.CarbonFiber}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource CarbonFiberMaterial}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="GlassFiber" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.GlassFiber}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource GlassFiberMaterial}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                </ContextMenu>
                            </Expander.ContextMenu>
                            <ListBox ItemsSource="{Binding Items}"
                                     SelectedItem="{Binding SelectedItem}"
                                     ItemTemplate="{StaticResource ColoredItemTemplate}">
                                <ListBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem Header="Edit" Command="{Binding Edit}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Copy" Command="{Binding Copy}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Delete" Command="{Binding Delete}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <Separator/>
                                        <MenuItem Header="Set material" Command="{Binding SetMaterialToPrimititveCommand}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="/Windows/MainWindow/Materials32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </ContextMenu>
                                </ListBox.ContextMenu>
                            </ListBox>
                        </Expander>
                        <Expander Header="Geometry" MinWidth="20">
                            <Expander.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Add" DataContext="{Binding PrimitiveLogic}">
                                        <MenuItem Header="Rectangle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Rectangle32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Circle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Circle}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Circle32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Rebar" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Reinforcement}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Rebar32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Point" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Point32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                    <MenuItem Header="Templates">
                                        <MenuItem Header="Add Rectangle RC Column" Command="{Binding AddColumnCase}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/RectangleColumn32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add Circle RC Column" Command="{Binding AddRCCircleCase}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/CircleColumn32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add RC Beam" Command="{Binding AddBeamCase}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Beam32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add RC slab" Command="{Binding AddSlabCase}">
                                            <MenuItem.Icon>
                                                <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Slab32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                    <MenuItem Header="Delete" DataContext="{Binding PrimitiveLogic}">
                                        <MenuItem Header="All" Command="{Binding DeleteAllCommand}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{StaticResource DeleteEntity}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Select" Command="{Binding DeleteSelectedCommand}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{StaticResource DeleteEntity}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                </ContextMenu>
                            </Expander.ContextMenu>
                            <ListBox DataContext="{Binding PrimitiveLogic}"
                                     ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}"
                                     ItemTemplate="{StaticResource ColoredItemTemplate}" ContextMenu="{StaticResource PrimitiveCRUD}">
                            </ListBox>
                        </Expander>
                        <Expander MinWidth="20" DataContext="{Binding CalculatorsLogic}">
                            <Expander.Header>
                                <StackPanel Orientation="Horizontal">
                                    <Image Style="{StaticResource ButtonImage16}" Source="/Windows/MainWindow/Analysis32.png" />
                                    <TextBlock Text="Analysis" Margin="5,0,0,0"/>
                                </StackPanel>
                            </Expander.Header>
                            <Expander.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Add">
                                        <MenuItem Header="Add Force Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ForceCalculator}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="/Windows/MainWindow/Calculator32.png" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add Interaction Diagram Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.LimitCurveCalculator}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource DiagramCalculator}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add Crack Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add Value Diagram Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.ValueDiagramCalculator}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource ValueDiagramCalculator}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Add Curvature Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CurvatureCalcualtor}">
                                            <MenuItem.Icon>
                                                <Viewbox Width="16" Height="16">
                                                    <ContentControl ContentTemplate="{DynamicResource CurvatureCalculator}"/>
                                                </Viewbox>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                </ContextMenu>
                            </Expander.ContextMenu>
                            <ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ContextMenu="{StaticResource AnalisesCRUD}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <TextBlock Text="{Binding Name}"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Expander>
                    </StackPanel>
                </ScrollViewer>
                <Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.Column="1">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="PreviewMouseDown">
                            <i:InvokeCommandAction Command="{Binding ClearSelection}" CommandParameter="{Binding}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <uc:WorkPlane ViewModel="{Binding}"/>
                </Border>
            </Grid>
            <StatusBar Grid.Row="1">
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Zoom: "/>
                        <TextBlock Text="{Binding VisualProperty.ScaleValue}"/>
                    </StackPanel>
                </StatusBarItem>
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Number of primitives: "/>
                        <TextBlock Text="{Binding PrimitiveLogic.PrimitivesCount}"/>
                    </StackPanel>
                </StatusBarItem>
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Grid size: "/>
                        <TextBlock Text="{Binding VisualProperty.GridSize, Converter={StaticResource LengthConverter}}"/>
                    </StackPanel>
                </StatusBarItem>
            </StatusBar>
        </Grid>
    </DockPanel>
</Window>
