<UserControl xmlns="https://github.com/avaloniaui"
             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:vm="using:PortfolioManager.ViewModels"
             xmlns:vw="using:PortfolioManager.Views"
             xmlns:md="using:PortfolioManager.Models"
             xmlns:local="using:PortfolioManager.UIUtils"		
             xmlns:li="using:LoadingIndicators.Avalonia"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             xmlns:mxc="https://schemas.eremexcontrols.net/avalonia/charts"                      
             x:DataType="vm:BollingerBandViewModel"
             x:Class="PortfolioManager.Views.BollingerBandView"
             >
  <UserControl.Resources>
      <local:CurrencyValueConverter x:Key="CurrencyFormat"/>
      <local:DoubleValueConverter x:Key="DoubleFormat"/>
      <local:IntValueConverter x:Key="IntFormat"/>
      <local:DateValueConverter x:Key="DateFormat"/>
      <local:RMultipleValueConverter x:Key="RMultipleFormat"/>
      <local:BoolValueConverter x:Key="BoolFormat"/>
  </UserControl.Resources>

		<Grid Background="LightGray">
    <li:LoadingIndicator ZIndex="1" IsActive="{Binding IsBusy}" Mode="Arcs" SpeedRatio="1.2" Width="200" Height="200"/>
    <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" />
          <RowDefinition Height="30" />
          <RowDefinition Height="30" />          
          <RowDefinition Height="30" />
          <RowDefinition Height="30" />
          <RowDefinition Height="89*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Vertical">
          <Label Content="Watch List" HorizontalAlignment="Left" ></Label>
          <ComboBox ItemsSource="{Binding Path=WatchListNames, Mode=OneWay}" SelectedItem="{Binding Path=SelectedWatchList}">
            <ComboBox.ItemsPanel>
              <ItemsPanelTemplate>
                <VirtualizingStackPanel/>
              </ItemsPanelTemplate>
            </ComboBox.ItemsPanel>
          </ComboBox>

          <Label Content="Symbols" HorizontalAlignment="Left" ></Label>
          <ComboBox ItemsSource="{Binding Path=Symbols, Mode=OneWay}" SelectedItem="{Binding Path=SelectedSymbol}">
            <ComboBox.ItemsPanel>
              <ItemsPanelTemplate>
                <VirtualizingStackPanel/>
              </ItemsPanelTemplate>
            </ComboBox.ItemsPanel>
          </ComboBox>
          <Label Content="Day Count" HorizontalAlignment="Left" ></Label>
          <ComboBox ItemsSource="{Binding Path=DayCounts, Mode=OneWay}" SelectedItem="{Binding Path=SelectedDayCount}"/>
          <Button Content="Refresh" HorizontalAlignment="Stretch" Command="{Binding Path=Refresh}"></Button>     
          <CheckBox Content="Sync Trade To Band" IsChecked="{Binding Mode=TwoWay,Path=SyncTradeToBand}" HorizontalAlignment="Stretch" />
          <CheckBox Content="Show Trade Labels" IsChecked="{Binding Mode=TwoWay,Path=ShowTradeLabels}" HorizontalAlignment="Stretch" />
          <CheckBox Content="Show Insider Transactions" IsChecked="{Binding Mode=TwoWay,Path=CheckBoxShowInsiderTransactions}" HorizontalAlignment="Stretch" />
        </StackPanel>
				</Grid>

        <Grid> 
        <Grid.RowDefinitions>
          <RowDefinition Height="3*" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>

            <Grid >
              <Grid.RowDefinitions>
                <RowDefinition Height="24" />
                <RowDefinition Height="*" />
              </Grid.RowDefinitions>
              <TextBlock Grid.Row="0" FontSize="16" Text="{Binding Path=GraphTitle}"  HorizontalAlignment="Center"></TextBlock>  

            <mxc:CartesianChart Grid.Row="1">

              <mxc:CartesianChart.AxesY>
                  <mxc:AxisY Title="Price" >
                      <mxc:AxisYRange AlwaysShowZeroLevel="False" />
                  </mxc:AxisY>
              </mxc:CartesianChart.AxesY>

              <mxc:CartesianChart.AxesX>
                  <mxc:AxisX /> 
              </mxc:CartesianChart.AxesX>              

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="KSeries" DataAdapter="{Binding K.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="3"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>
 
                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="KL1Series" DataAdapter="{Binding KL1.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="LSeries" DataAdapter="{Binding L.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="3"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>    

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="LP1Series" DataAdapter="{Binding LP1.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series> 

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="HighSeries" DataAdapter="{Binding High.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Blue" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series> 

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="LowSeries" DataAdapter="{Binding Low.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Red" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>                 

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="CloseSeries" DataAdapter="{Binding Close.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Black" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>        

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="LeastSquares" DataAdapter="{Binding LeastSquares.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Orange" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>                              

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="SMANSeries" DataAdapter="{Binding SMAN.DataAdapter}" >
                    <mxc:CartesianLineSeriesView ShowInCrosshair="False" Color="Purple" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>                        
                    </mxc:CartesianSeries>
                </mxc:CartesianChart.Series>

                <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphDisposedSmall" DataAdapter="{Binding InsiderTransactionPointDisposedSmall.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="red" MarkerSize="10"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>     

               <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphDisposedMedium" DataAdapter="{Binding InsiderTransactionPointDisposedMedium.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="red" MarkerSize="20"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>                

               <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphDisposedLarge" DataAdapter="{Binding InsiderTransactionPointDisposedLarge.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="red" MarkerSize="30"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>                

               <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphAcquiredSmall" DataAdapter="{Binding InsiderTransactionPointAcquiredSmall.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="green" MarkerSize="10"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>                

               <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphAcquiredMedium" DataAdapter="{Binding InsiderTransactionPointAcquiredMedium.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="green" MarkerSize="20"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>                

               <mxc:CartesianChart.Series>
                    <mxc:CartesianSeries Name="InsiderTransactionsPointMarkersPointsGraphAcquiredLarge" DataAdapter="{Binding InsiderTransactionPointAcquiredLarge.DataAdapter}" >
                      <mxc:CartesianPointSeriesView ShowInCrosshair="False" Color="green" MarkerSize="30"/>
                     </mxc:CartesianSeries>    
                </mxc:CartesianChart.Series>                

            </mxc:CartesianChart>    
          </Grid>

      </Grid>
    </DockPanel>
  </Grid>
</UserControl>
