<UserControl x:Class="TradeBlotter.Views.FeedStatisticsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:dc="clr-namespace:TradeBlotter.UIUtils"
             xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:Effects="clr-namespace:Telerik.Windows.Controls.ColorEditor.Effects;assembly=Telerik.Windows.Controls.Input"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
  <UserControl.Resources>
    <GroupStyle x:Key="PricingGroupStyle">
      <GroupStyle.HeaderTemplate>
        <DataTemplate>
          <TextBlock 
            x:Name="txt" 
            Background="{StaticResource Brush_HeaderBackground}"
            FontWeight="Bold"
            Foreground="White"
            Margin="1"
            Padding="4,2,0,2"
            Text="People" 
            />
          <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Name}" Value="True">
              <Setter TargetName="txt" Property="Text" Value="Companies" />
            </DataTrigger>
          </DataTemplate.Triggers>
        </DataTemplate>
      </GroupStyle.HeaderTemplate>
    </GroupStyle>

    <Style x:Key="ValuationItemStyle" TargetType="{x:Type ListViewItem}">
      <!-- 
      Stretch the content of each cell so that we can 
      right-align text in the Total Sales column. 
      -->
      <Setter Property="HorizontalContentAlignment" Value="Stretch" />
      <!-- 
      Bind the IsSelected property of a ListViewItem to the 
      IsSelected property of a PricingViewModel object.
      -->
      <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
      <Style.Triggers>
        <MultiTrigger>
          <MultiTrigger.Conditions>
            <Condition Property="ItemsControl.AlternationIndex" Value="1" />
            <Condition Property="IsSelected" Value="False" />
            <Condition Property="IsMouseOver" Value="False" />
          </MultiTrigger.Conditions>
          <Setter Property="Background" Value="#EEEEEEEE" />
        </MultiTrigger>
      </Style.Triggers>
    </Style>
  </UserControl.Resources>

  <wpfx:BusyIndicator x:Name="BusyBar" BusyContent="Loading Statistics..." IsBusy="{Binding BusyIndicator}">
    <Grid  Background="LightGray">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="6" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="35" />
        <RowDefinition Height="4" />
        <RowDefinition Height="2*" />
        <RowDefinition Height="3" />
        <RowDefinition Height="*" />
      </Grid.RowDefinitions>
      <Label Grid.Row="0" Grid.Column="2" FontFamily="Arial" Content="{Binding Title}" HorizontalAlignment="Center" FontSize="20"/>

      <StackPanel Grid.Row="2" Grid.Column="0" Orientation="Vertical">
        <Label Margin="2,0" Content="Feed" MinWidth="100" HorizontalAlignment="Left" />
        <ComboBox Margin="2,1" ItemsSource="{Binding FeedTypes, Mode=OneTime}" SelectedItem="{Binding SelectedFeedType}" />
        <Button Margin="0,2" Content="Refresh" HorizontalAlignment="Left" Command="{Binding Path=RefreshCommand}"></Button>
				<Button Margin="0,2" Content="Clear Price Cache" HorizontalAlignment="Left" Command="{Binding Path=ClearCacheCommand}"></Button>
      </StackPanel>
      <DockPanel Grid.Row="4" Grid.Column="2" >
        <telerik:RadGridView IsReadOnly="True" AlternationCount="2" AutoGenerateColumns="False" AlternateRowBackground="Bisque" ItemsSource="{Binding AllItems, ValidatesOnDataErrors=False}" ShowGroupFooters="False" >
          <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Feed}" Header="Feed"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Date, StringFormat=\{0:MM/dd/yyyy\}}" Header="Date"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Records}" Header="Records"/>
          </telerik:RadGridView.Columns>
        </telerik:RadGridView>
      </DockPanel>
      <DockPanel Grid.Row="2" Grid.Column="2" >
        <d3:ChartPlotter Background="WhiteSmoke" Margin="10,10,20,10" x:Name="statistics" LegendVisibility="Hidden" NewLegendVisible="False" d3:Viewport2D.UsesApproximateContentBoundsComparison="False" BorderThickness="0">
          <d3:ChartPlotter.MainHorizontalAxis>
            <d3:HorizontalDateTimeAxis x:Name="dateAxis"/>
          </d3:ChartPlotter.MainHorizontalAxis>
          <d3:ChartPlotter.MainVerticalAxis>
            <d3:VerticalAxis x:Name="countAxis" MinWidth="40" MaxWidth="40"/>
          </d3:ChartPlotter.MainVerticalAxis>
          <d3:LineGraph x:Name="Statistics" DataSource="{Binding Statistics}" Stroke="Black" StrokeThickness="1"/>
          <d3:CursorCoordinateGraph x:Name="cursorGraph" dc:CoordinateGraphBehavior.XTextMappingProperty="MM/dd/yyyy" LineStrokeThickness="1"/>
          <d3:VerticalAxisTitle FontFamily="Arial" Content="Records"/>
          <d3:HorizontalAxisTitle FontFamily="Arial" Content="" />
        </d3:ChartPlotter>
      </DockPanel>
      <GridSplitter Background="LightBlue" ResizeDirection="Rows" Grid.Column="2" Grid.ColumnSpan="1" Grid.Row="3" Width="Auto" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0"/>
    </Grid>
  </wpfx:BusyIndicator>
</UserControl>

