<UserControl x:Class="TradeBlotter.Views.OptionsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0" 
             xmlns:dc="clr-namespace:TradeBlotter.UIUtils"
						 xmlns:vw="clr-namespace:TradeBlotter.Views"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="600">
    <wpfx:BusyIndicator Name="BusyBar" IsBusy="{Binding Path=BusyIndicator}" BusyContent="Loading...">
    <Grid>
    <AdornerDecorator>
    <Grid Background="LightGray">
    <DockPanel>
      <Grid Margin="4">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="6" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="3" />
          <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <GroupBox BorderBrush="Black" Grid.Row="0" Grid.Column="0" Header="Parameters">
        <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Vertical">
        <Label Content="Watch List" HorizontalAlignment="Left"  ></Label>
        <ComboBox ItemsSource="{Binding Path=WatchListNames, Mode=OneTime}" SelectedItem="{Binding Path=SelectedWatchList, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" ></ComboBox>
        <!--<Label Content="Symbol" HorizontalAlignment="Left" Target="{Binding ElementName=tradeDateLbl}" ></Label>-->
        <Label Content="Symbol" HorizontalAlignment="Left"></Label>					
        <ComboBox ItemsSource="{Binding Path=Symbols, Mode=OneWay}" SelectedItem="{Binding Path=SelectedSymbol, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" >
				<ComboBox.ItemsPanel>
					<ItemsPanelTemplate>
						<VirtualizingStackPanel/>
					</ItemsPanelTemplate>
				</ComboBox.ItemsPanel>
			</ComboBox>
        <Label Content="Option Type" HorizontalAlignment="Left" Target="{Binding ElementName=optionTypeLbl}" ></Label>
        <ComboBox ItemsSource="{Binding Path=OptionTypes, Mode=OneWay}" SelectedItem="{Binding Path=SelectedOptionType, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" ></ComboBox>
        <Label Content="Expiration" HorizontalAlignment="Left" Target="{Binding ElementName=expirationLbl}" ></Label>
        <ComboBox  ItemsSource="{Binding Path=ExpirationDates, Mode=OneWay}" DisplayMemberPath="Value" SelectedItem="{Binding Path=SelectedExpirationDate}" >
				 <ComboBox.ItemsPanel>
					<ItemsPanelTemplate>
							<VirtualizingStackPanel />
					</ItemsPanelTemplate>
					</ComboBox.ItemsPanel>								
				</ComboBox>
        <Button Margin="0,4" Content="Update" HorizontalAlignment="Left" Command="{Binding Path=UpdateCommand}" Height="21" Width="76"></Button>
        <CheckBox Margin="0,4" Content="Full History" HorizontalAlignment="Left" IsEnabled="{Binding Path=CheckBoxFullHistoryEnabled, Mode=OneWay}" IsChecked="{Binding Path=CheckBoxFullHistory, Mode=TwoWay}" Height="21" Width="76"></CheckBox>
        <CheckBox Margin="0,4" Content="Call/Put Ratio" HorizontalAlignment="Left" IsEnabled="{Binding Path=CheckBoxCallPutRatioEnabled, Mode=OneWay}" IsChecked="{Binding Path=CheckBoxCallPutRatio, Mode=TwoWay}" Height="21"></CheckBox>
        </StackPanel>
        </GroupBox>

        <GroupBox BorderBrush="Black"  Grid.Row="1" Header="Assumptions">
        <StackPanel Grid.Row="1" Grid.Column="0">
        <Label Content="Risk Free Rate" HorizontalAlignment="Left" Target="{Binding ElementName=riskFreeRateLbl}" ></Label>
        <TextBox IsReadOnly="true" Text="{Binding Path=SelectedRiskFreeRate, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}"/>
        <Label Content="Rate Type" HorizontalAlignment="Left" Target="{Binding ElementName=riskFreeRateTypeLbl}" ></Label>
        <ComboBox ItemsSource="{Binding Path=RiskFreeRateTypes, Mode=OneWay}" SelectedItem="{Binding Path=SelectedRiskFreeRateType,Mode=TwoWay}" ></ComboBox>

        <Label Content="Rate Date" HorizontalAlignment="Left" Target="{Binding ElementName=riskFreeRateDateLbl}" ></Label>
        <TextBox IsReadOnly="true" Text="{Binding Path=SelectedRiskFreeRateDate, Mode=OneWay, StringFormat={}{0:MM/dd/yyyy}}" ></TextBox>

        <Label Content="Underlying Price" HorizontalAlignment="Left" Target="{Binding ElementName=underlyingPriceLbl}" ></Label>
        <TextBox IsReadOnly="true" Text="{Binding Path=UnderlyingPrice, Mode=OneWay}" ></TextBox>
        <Label Content="Pricing Date" HorizontalAlignment="Left" Target="{Binding ElementName=pricingDateLbl}" ></Label>
        <TextBox IsReadOnly="true" Text="{Binding Path=PricingDate, Mode=OneWay}" ></TextBox>

        <Label Content="Volatility" HorizontalAlignment="Left" ></Label>
        <TextBox IsReadOnly="true" Text="{Binding Path=Volatility, Mode=OneWay}" ></TextBox>
        <Label Content="Volatility Days" HorizontalAlignment="Left" ></Label>
        <ComboBox ItemsSource="{Binding Path=VolatilityDays, Mode=OneWay}" SelectedItem="{Binding Path=SelectedVolatilityDays,Mode=TwoWay}" ></ComboBox>
        <CheckBox Content="Least Squares Fit" IsChecked="{Binding Mode=TwoWay,Path=LeastSquaresFit}" Grid.ColumnSpan="3" Grid.Row="7" Height="16" HorizontalAlignment="Left" Margin="5,6,0,0" VerticalAlignment="Top" />
					

        </StackPanel>
        </GroupBox>
      </Grid>
      <Grid> 
        <Grid.RowDefinitions>
          <RowDefinition Height=".12*" />
          <RowDefinition Height=".80*" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>
    <Label Grid.Row="0" Grid.Column="2" FontFamily="Arial" Content="{Binding Path=Title}" HorizontalAlignment="Center" FontSize="20"></Label>
    <DockPanel Grid.Row="1" Grid.Column="2" >
    <telerik:RadGridView CanUserSelect="True"  SelectionMode="Single" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" AlternationCount="2" AlternateRowBackground="Bisque" ShowGroupFooters="False" ItemsSource="{Binding Path=AllOptions, ValidatesOnDataErrors=True}" AutoGenerateColumns="False" >
    <telerik:RadContextMenu.ContextMenu>
      <telerik:RadContextMenu x:Name="GridContextMenu" StaysOpen="False" ItemsSource="{Binding MenuItems}">
          <telerik:RadContextMenu.ItemContainerStyle>
              <Style TargetType="telerik:RadMenuItem">
                  <Setter Property="Header" Value="{Binding Text}" />
                  <Setter Property="Command" Value="{Binding MenuItemClickedCommand}" />
                  <Setter Property="StaysOpenOnClick" Value="False" />
              </Style>
          </telerik:RadContextMenu.ItemContainerStyle>
      </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
    <telerik:RadGridView.Columns>
      <telerik:GridViewDataColumn Header="Symbol" IsReadOnly="true" DataMemberBinding="{Binding Path=Symbol}" />
      <telerik:GridViewDataColumn Header="Expiration Date"  IsReadOnly="true" DataMemberBinding="{Binding Path=Expiration,StringFormat={}{0:MM/dd/yyyy}}" />
      <telerik:GridViewDataColumn Header="Days"  IsReadOnly="true" DataMemberBinding="{Binding Path=DaysToExpiration}" />
      <telerik:GridViewDataColumn Header="Option Type"  IsReadOnly="true" DataMemberBinding="{Binding Path=Type}" />
      <telerik:GridViewDataColumn Header="Strike Price" IsReadOnly="true" DataMemberBinding="{Binding Path=Strike,StringFormat={}{0:C}}" />
      <telerik:GridViewDataColumn Header="Ratio" IsReadOnly="true" DataMemberBinding="{Binding Path=Ratio,StringFormat={}{0:0.00}}" >
				<telerik:GridViewColumn.ToolTipTemplate>
					<DataTemplate >
						<StackPanel Orientation="Horizontal" >
							<TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:OptionsView}},Path=DataContext.RatioDescription}"/>
						</StackPanel>
					</DataTemplate>
				</telerik:GridViewColumn.ToolTipTemplate>
			</telerik:GridViewDataColumn>	
      <telerik:GridViewDataColumn Header="Volume" IsReadOnly="true" DataMemberBinding="{Binding Path=Volume}" />
      <telerik:GridViewDataColumn Header="Open Interest" IsReadOnly="true" DataMemberBinding="{Binding Path=OpenInterest}" />
      <telerik:GridViewDataColumn Header="Bid" IsReadOnly="true" DataMemberBinding="{Binding Path=Bid,StringFormat={}{0:C}}" />
      <telerik:GridViewDataColumn Header="Ask" IsReadOnly="true" DataMemberBinding="{Binding Path=Ask,StringFormat={}{0:C}}" />
      <telerik:GridViewDataColumn Header="Option Value" IsReadOnly="true" DataMemberBinding="{Binding Path=OptionValue,StringFormat={}{0:C}}" />
      <telerik:GridViewDataColumn Header="Money" IsReadOnly="true" DataMemberBinding="{Binding ElementName=Money, Path=MoneyTypeAsString}" />
      <telerik:GridViewDataColumn Header="Modified" IsReadOnly="true" DataMemberBinding="{Binding Path=Modified,StringFormat={}{0:MM/dd/yyyy}}" />
    </telerik:RadGridView.Columns>
    </telerik:RadGridView>
    </DockPanel>
    <DockPanel Grid.Row="2" Grid.Column="2">
      <d3:ChartPlotter Background="WhiteSmoke" Grid.Row="0" Margin="10,16,20,4" Name="bollinger" LegendVisibility="Hidden" NewLegendVisible="False" d3:Viewport2D.UsesApproximateContentBoundsComparison="False" BorderThickness="0">
        <d3:ChartPlotter.MainHorizontalAxis>
          <d3:HorizontalDateTimeAxis Name="dateAxis"/>
        </d3:ChartPlotter.MainHorizontalAxis>
        <d3:ChartPlotter.MainVerticalAxis>
          <d3:VerticalAxis Name="countAxis" MinWidth="40" MaxWidth="40"/>
        </d3:ChartPlotter.MainVerticalAxis>
        <d3:LineGraph  d3:Viewport2D.UsesApproximateContentBoundsComparison="True" x:Name="K" DataSource="{Binding Path=K}" Stroke="Green" StrokeThickness="3" />
        <d3:LineGraph x:Name="L" DataSource="{Binding Path=L}" Stroke="Green" StrokeThickness="3"/>
        <d3:LineGraph x:Name="KL1"  DataSource="{Binding Path=KL1}" Stroke="Green"/>
        <d3:LineGraph x:Name="LP1" DataSource="{Binding Path=LP1}" Stroke="Green"/>
        <d3:LineGraph x:Name="High" DataSource="{Binding Path=High}" Stroke="Blue" StrokeThickness="2"/>
        <d3:LineGraph x:Name="Low" DataSource="{Binding Path=Low}" Stroke="Red" StrokeThickness="2"/>
        <d3:LineGraph x:Name="Close" DataSource="{Binding Path=Close}" Stroke="Black" StrokeThickness="2"/>
        <d3:LineGraph x:Name="SMAN" DataSource="{Binding Path=SMAN}" Stroke="Purple" StrokeThickness="2"/>
        <d3:LineGraph x:Name="LeastSquares" d3:NewLegend.Description="LeastSquares" DataSource="{Binding LeastSquares}" Stroke="Orange" StrokeThickness="2"/>				
        <d3:CursorCoordinateGraph Name="cursorGraph" dc:CoordinateGraphBehavior.XTextMappingProperty="MM/dd/yyyy" LineStrokeThickness="1"/>  
        <!--<d3:AxisCursorGraph></d3:AxisCursorGraph>-->
        <d3:MarkerPointsGraph x:Name="StrikeMarkerPointsGraph" DataSource="{Binding Path=OptionStrikePoints}"  >
          <d3:MarkerPointsGraph.Marker>
          <d3:TrianglePointMarker Size="9">
          <d3:TrianglePointMarker.Pen>
          <Pen Thickness="1"> 
          <Pen.Brush >
          <SolidColorBrush Color="Black">
          </SolidColorBrush>
          </Pen.Brush>
          </Pen>
          </d3:TrianglePointMarker.Pen>
          <d3:TrianglePointMarker.Fill>
          <SolidColorBrush Color="Yellow">
          </SolidColorBrush>
          </d3:TrianglePointMarker.Fill>
          </d3:TrianglePointMarker>
          </d3:MarkerPointsGraph.Marker>
        </d3:MarkerPointsGraph>
        <d3:MarkerPointsGraph x:Name="SelectedStrikeMarkerPointsGraph" DataSource="{Binding Path=SelectedOptionStrikePoints}"  >
          <d3:MarkerPointsGraph.Marker>
          <d3:TrianglePointMarker Size="9">
          <d3:TrianglePointMarker.Pen>
          <Pen Thickness="1"> 
          <Pen.Brush >
          <SolidColorBrush Color="Black">
          </SolidColorBrush>
          </Pen.Brush>
          </Pen>
          </d3:TrianglePointMarker.Pen>
          <d3:TrianglePointMarker.Fill>
          <SolidColorBrush Color="Red">
          </SolidColorBrush>
          </d3:TrianglePointMarker.Fill>
          </d3:TrianglePointMarker>
          </d3:MarkerPointsGraph.Marker>
        </d3:MarkerPointsGraph>
        <d3:VerticalAxisTitle FontFamily="Arial" Content="Price"/>
        <d3:HorizontalAxisTitle FontFamily="Arial" Content="" />
      </d3:ChartPlotter>
      </DockPanel>
      </Grid>
    </DockPanel>
  </Grid>
</AdornerDecorator>
</Grid>
</wpfx:BusyIndicator>
</UserControl>
