<UserControl x:Class="TradeBlotter.Views.RiskProfileView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
      xmlns:dc="clr-namespace:TradeBlotter.UIUtils"                      
      xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
	>
  <wpfx:BusyIndicator Name="BusyBar" IsBusy="{Binding Path=BusyIndicator}" BusyContent="Generating Risk Profile...">
    <Grid Background="LightGray">
      <DockPanel>
        <Grid DockPanel.Dock="Left" Margin="0,2,4,2">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition Width="11*" />            
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition Height="42" /> 
            <RowDefinition Height="3" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="3" />
            <RowDefinition Height="2*" />
          </Grid.RowDefinitions>
          <GroupBox Header="Selection" MaxWidth="100" Grid.Row="2" Grid.Column="0" >
            <StackPanel MaxWidth="100" Grid.Row="2" Grid.Column="0" Orientation="Vertical">
            <StackPanel Orientation="Vertical">
              <Label Content="Date" HorizontalAlignment="Left" ></Label>
              <Button Content="Select Date" HorizontalAlignment="Left" Command="{Binding Path=ChooseDateCommand}"></Button>
              <Popup IsOpen="{Binding Path=IsCalendarOpen, Mode=TwoWay}" StaysOpen="False">
                <Calendar SelectionMode="SingleDate" dc:CalendarBehavior.RegisterBlackoutDates="{Binding Path=BlackoutDates, Mode=OneTime}" SelectedDate="{Binding Path=SelectedDate, Mode=TwoWay}" DisplayDate="{Binding Path=DisplayDate, Mode=TwoWay}" DisplayDateStart="{Binding Path=DisplayDateStart, Mode=OneTime}" DisplayDateEnd="{Binding Path=DisplayDateEnd, Mode=OneTime}" >
                </Calendar>
              </Popup>
            </StackPanel>
            <Label Content="Account" MinWidth="75" HorizontalAlignment="Left"></Label>
              <ComboBox ItemsSource="{Binding Path=Accounts, Mode=OneTime}" SelectedItem="{Binding Path=SelectedAccount, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" ></ComboBox>
              <Button Margin="0,1" Content="Add Position" HorizontalAlignment="Left" Command="{Binding Path=ProformaAddPositionCommand}"></Button>
              <Button Margin="0,1" Content="Reset" HorizontalAlignment="Left" Command="{Binding Path=ResetCommand}"></Button>
            </StackPanel>
          </GroupBox>

          <StackPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Orientation="Vertical">
            <Label Content="{Binding Path=TitleBetaContribution, Mode=OneWay}" HorizontalAlignment="Center" Target="{Binding ElementName=titleLbl}" FontSize="14" FontWeight="Bold" ></Label>
            <Label Content="{Binding Path=BetaDescription, Mode=OneWay}" HorizontalAlignment="Center" Target="{Binding ElementName=titleBetaDescription}" FontSize="12" FontWeight="Bold"  FontStyle="Italic"></Label>
          </StackPanel>
           <DockPanel x:Name="DockPanel1" Grid.Row="2" Grid.Column="2">
              <telerik:RadCartesianChart DockPanel.Dock="Top" x:Name="CartesianChartBetaContribution" >
              <telerik:RadCartesianChart.SmartLabelsStrategy>
                <telerik:ChartSmartLabelsStrategy />
              </telerik:RadCartesianChart.SmartLabelsStrategy>
              <telerik:RadCartesianChart.HorizontalAxis >
                  <telerik:CategoricalAxis Margin="0 0 0 0"/>
                </telerik:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.VerticalAxis>
                  <telerik:LinearAxis Margin="0 0 0 0"/>
                </telerik:RadCartesianChart.VerticalAxis>
                <telerik:RadCartesianChart.Series>
                  <telerik:BarSeries ClipToPlotArea="False" ItemsSource="{Binding Path=CartesianChartDataBetaContribution}" ShowLabels="True" CategoryBinding="Category" ValueBinding="Value" Margin="0">
                    <telerik:BarSeries.PointTemplate>
                      <DataTemplate>
                        <Rectangle Fill="#E8BC34"/>
                      </DataTemplate>
                    </telerik:BarSeries.PointTemplate>
                    <telerik:BarSeries.LabelDefinitions>
                      <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top">
                        <telerik:ChartSeriesLabelDefinition.Template>
                          <DataTemplate>
                            <TextBlock Foreground="Black" Text="{Binding DataItem.CustomLabel}" FontStyle="Italic" FontSize="9"/>
                          </DataTemplate>
                        </telerik:ChartSeriesLabelDefinition.Template>
                      </telerik:ChartSeriesLabelDefinition>
                    </telerik:BarSeries.LabelDefinitions>
                  </telerik:BarSeries>
                  <telerik:BarSeries ClipToPlotArea="False" ItemsSource="{Binding Path=CartesianChartDataBeta}" ShowLabels="True" CategoryBinding="Category" ValueBinding="Value" Margin="10,0">
                    <telerik:BarSeries.PointTemplate>
                      <DataTemplate>
                        <Rectangle Fill="#DC5B20"/>
                      </DataTemplate>
                    </telerik:BarSeries.PointTemplate>
                    <telerik:BarSeries.LabelDefinitions>
                      <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top"  >
                        <telerik:ChartSeriesLabelDefinition.Template>
                          <DataTemplate>
                            <TextBlock Foreground="Black" Text="{Binding DataItem.CustomLabel}" FontStyle="Italic" FontSize="9">
                            </TextBlock>
                          </DataTemplate>
                        </telerik:ChartSeriesLabelDefinition.Template>
                      </telerik:ChartSeriesLabelDefinition>
                    </telerik:BarSeries.LabelDefinitions>
                  </telerik:BarSeries>
                </telerik:RadCartesianChart.Series>
                <telerik:RadCartesianChart.Grid>
                  <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
                </telerik:RadCartesianChart.Grid>
              </telerik:RadCartesianChart>
            </DockPanel>
        <DockPanel x:Name="DockPanel2" Grid.Row="4" Grid.Column="2" >
              <Label DockPanel.Dock="Top" Content="{Binding Path=TitleSharpeRationContribution, Mode=OneWay}" HorizontalAlignment="Center" Target="{Binding ElementName=SharpeRationContribution}" FontSize="14" FontWeight="Bold" ></Label>
              <telerik:RadCartesianChart DockPanel.Dock="Top" Grid.Row="3" x:Name="CartesianChartSharpeRatioContribution" >
              <telerik:RadCartesianChart.SmartLabelsStrategy>
                <telerik:ChartSmartLabelsStrategy />
              </telerik:RadCartesianChart.SmartLabelsStrategy>
              <telerik:RadCartesianChart.HorizontalAxis >
                  <telerik:CategoricalAxis Margin="0 0 0 0"/>
                </telerik:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.VerticalAxis>
                  <telerik:LinearAxis Margin="0 0 0 0"/>
                </telerik:RadCartesianChart.VerticalAxis>
                <telerik:RadCartesianChart.Series>
                  <telerik:BarSeries ClipToPlotArea="False" ItemsSource="{Binding Path=CartesianChartDataSharpeRatioContribution}" ShowLabels="True" CategoryBinding="Category" ValueBinding="Value" Margin="0">
                    <telerik:BarSeries.PointTemplate>
                      <DataTemplate>
                        <Rectangle Fill="#E8BC34"/>
                      </DataTemplate>
                    </telerik:BarSeries.PointTemplate>
                    <telerik:BarSeries.LabelDefinitions>
                      <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top">
                        <telerik:ChartSeriesLabelDefinition.Template>
                          <DataTemplate>
                            <TextBlock Foreground="Black" Text="{Binding DataItem.CustomLabel}" FontStyle="Italic" FontSize="9"/>
                          </DataTemplate>
                        </telerik:ChartSeriesLabelDefinition.Template>
                      </telerik:ChartSeriesLabelDefinition>
                    </telerik:BarSeries.LabelDefinitions>
                  </telerik:BarSeries>
                  <telerik:BarSeries ClipToPlotArea="False" ItemsSource="{Binding Path=CartesianChartDataSharpeRatioSharpeRatio}" ShowLabels="True" CategoryBinding="Category" ValueBinding="Value" Margin="10,0">
                    <telerik:BarSeries.PointTemplate>
                      <DataTemplate>
                        <Rectangle Fill="#DC5B20"/>
                      </DataTemplate>
                    </telerik:BarSeries.PointTemplate>
                    <telerik:BarSeries.LabelDefinitions>
                      <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top"  >
                        <telerik:ChartSeriesLabelDefinition.Template>
                          <DataTemplate>
                            <TextBlock Foreground="Black" Text="{Binding DataItem.CustomLabel}" FontStyle="Italic" FontSize="9">
                            </TextBlock>
                          </DataTemplate>
                        </telerik:ChartSeriesLabelDefinition.Template>
                      </telerik:ChartSeriesLabelDefinition>
                    </telerik:BarSeries.LabelDefinitions>
                  </telerik:BarSeries>
                </telerik:RadCartesianChart.Series>
                <telerik:RadCartesianChart.Grid>
                  <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
                </telerik:RadCartesianChart.Grid>
              </telerik:RadCartesianChart>
            </DockPanel>
        <GridSplitter Panel.ZIndex="1" Background="Green" ResizeDirection="Rows" Grid.Column="2" Grid.Row="3" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0"/>
        <GridSplitter Grid.Row="1" Grid.Column="1" ResizeDirection="Columns" Grid.RowSpan="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Green" Width="5"/>
        </Grid>
      </DockPanel>
    </Grid>
  </wpfx:BusyIndicator>
</UserControl>


