<UserControl x:Class="TradeBlotter.Views.DCFValuationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             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:dc="clr-namespace:TradeBlotter.UIUtils"
             xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="600">
    <wpfx:BusyIndicator Name="BusyBar" IsBusy="{Binding Path=BusyIndicator}" BusyContent="Calculating discounted cashflows...">
        <Grid  Background="LightGray">
            <!--<AdornerDecorator>-->
                <Grid>
                    <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>
                                </StackPanel>
                            </GroupBox>
                        </Grid>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height=".12*" />
                                <RowDefinition Height=".8*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width=".01*"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <GridSplitter Background="LightBlue" ResizeDirection="Columns" Grid.Column="1" Grid.RowSpan="3" Grid.Row="0" Width="5" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0"/>
                            <Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" FontFamily="Arial" Content="{Binding Path=Title}" HorizontalAlignment="Center" FontSize="20"></Label>
                            <DockPanel Grid.Row="1" Grid.Column="0" >
                                <telerik:RadGridView CanUserSelect="True" FontSize="10" SelectionMode="Single" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" AlternationCount="2" AlternateRowBackground="Bisque" ShowGroupPanel="false" ShowGroupFooters="False" ItemsSource="{Binding Path=AllDCF, ValidatesOnDataErrors=True}" AutoGenerateColumns="False" >
                                    <telerik:RadGridView.Columns>
                                        <telerik:GridViewDataColumn Header="Dates" IsReadOnly="true" DataMemberBinding="{Binding Path=Date,StringFormat={}{0:MM/dd/yyyy}}" />
                                        <telerik:GridViewDataColumn Header="Free Cashflow"  IsReadOnly="true" DataMemberBinding="{Binding Path=Value,StringFormat={}{0:C}}" />
                                        <telerik:GridViewDataColumn Header="Return"  IsReadOnly="true" DataMemberBinding="{Binding Path=Return,StringFormat={}{0:P}}" />
                                    </telerik:RadGridView.Columns>
                                </telerik:RadGridView>
                            </DockPanel>
                            <GroupBox BorderBrush="Black"  Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="2" Header="Assumptions" FontSize="11" >
                                <StackPanel Grid.Row="0" Grid.Column="1">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="23*" />
                                            <RowDefinition Height="19*" />
                                            <RowDefinition Height="23*" />
                                            <RowDefinition Height="19*" />
                                            <RowDefinition Height="24*" />
                                            <RowDefinition Height="18*" />
                                            <RowDefinition Height="23*" />
                                            <RowDefinition Height="19*" />
                                            <RowDefinition Height="23*" />
                                            <RowDefinition Height="19*" />
                                            <RowDefinition Height="23*" />
                                            <RowDefinition Height="19*" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="62*"></ColumnDefinition>
                                            <ColumnDefinition Width="3*"></ColumnDefinition>
                                            <ColumnDefinition Width="56*"></ColumnDefinition>
                                            <ColumnDefinition Width="3*"></ColumnDefinition>
                                            <ColumnDefinition Width="52*"></ColumnDefinition>
                                            <ColumnDefinition Width="3*"></ColumnDefinition>
                                            <ColumnDefinition Width="52*"></ColumnDefinition>
                                            <ColumnDefinition Width="3*"></ColumnDefinition>
                                            <ColumnDefinition Width="52*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>

                                        <Label Grid.Row="0" Grid.Column="0" FontSize="10" Content="Beta" HorizontalAlignment="Left"></Label>
                                        <TextBox Grid.Row="1" Grid.Column="0" FontSize="10" HorizontalAlignment="Left" Width="55" IsReadOnly="true" Text="{Binding Path=Beta, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}">
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=BetaDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="0" Grid.Column="2" FontSize="10" Content="Market Return (Rm)" HorizontalAlignment="Left"></Label>
																				<TextBox Grid.Row="1" Grid.Column="2" FontSize="10" HorizontalAlignment="Left" Width="55" IsReadOnly="true" Text="{Binding Path=HistoricalMarketReturn, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}">
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=HistoricalMarketReturnDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

																				<TextBox Grid.Row="1" Grid.Column="4" FontSize="10" IsReadOnly="true" Text="{Binding Path=RiskFreeRate, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=RiskFreeRateDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="0" Grid.Column="4" FontSize="10" Content="Risk Free Rate (RFR)" HorizontalAlignment="Left"></Label>
                                        <TextBox Grid.Row="1" Grid.Column="4" FontSize="10" IsReadOnly="true" Text="{Binding Path=RiskFreeRate, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=RiskFreeRateDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="0" Grid.Column="6" FontSize="10" Content="Total Equity MV(E)" HorizontalAlignment="Left"></Label>
                                        <TextBox Grid.Row="1" Grid.Column="6" FontSize="10" IsReadOnly="true" Text="{Binding Path=TotalEquity, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=TotalEquityDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="0" Grid.Column="8" FontSize="10" Content="Total Debt MV(D)" HorizontalAlignment="Left"></Label>
                                        <TextBox Grid.Row="1" Grid.Column="8" FontSize="10" IsReadOnly="true" Text="{Binding Path=TotalDebt, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=TotalLongAndShortTermDebtDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="2" Grid.Column="0" FontSize="10" Content="Total Capital Invested (V)" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="3" Grid.Column="0"  FontSize="10" IsReadOnly="true" Text="{Binding Path=TotalCapitalInvested, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=TotalCapitalInvestedDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="4" Grid.Column="0" FontSize="10" Content="WACC" HorizontalAlignment="Left"></Label>
                                        <TextBox Background="{Binding Path=CapitalBackground}" Grid.Row="5" Grid.Column="0" FontSize="10" HorizontalAlignment="Left" Width="55" IsReadOnly="true" Text="{Binding Path=WACC, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}">
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=WACCDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>
                                        
                                        <Label Grid.Row="4" Grid.Column="2" FontSize="10" Content="ROIC" HorizontalAlignment="Left"></Label>
                                        <TextBox Background="{Binding Path=CapitalBackground}" Grid.Row="5" Grid.Column="2" FontSize="10" HorizontalAlignment="Left" Width="55" IsReadOnly="true" Text="{Binding Path=ROIC, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}">
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=ROICDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>


                                        <Label Grid.Row="2" Grid.Column="2" FontSize="10" Content="Cost of Debt (rD)" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="3" Grid.Column="2"  FontSize="10" IsReadOnly="true" Text="{Binding Path=CostOfDebt, Mode=OneWay}" >
																				<ToolTipService.ToolTip>
																					<ToolTip IsEnabled="true" HasDropShadow="True">
																						<TextBlock Background="LemonChiffon" Text="{Binding Path=CostOfDebtDescription}"/>
																					</ToolTip>
																				</ToolTipService.ToolTip>
																			</TextBox>

                                        <Label Grid.Row="2" Grid.Column="4" FontSize="10" Content="Cost of Equity (rE)" HorizontalAlignment="Left" ></Label>
                                        <TextBox  Grid.Row="3" Grid.Column="4"  FontSize="10" IsReadOnly="true" Text="{Binding Path=CostOfEquity, Mode=OneWay}" >
																				<ToolTipService.ToolTip>
																					<ToolTip IsEnabled="true" HasDropShadow="True">
																						<TextBlock Background="LemonChiffon" Text="{Binding Path=CostOfEquityDescription}"/>
																					</ToolTip>
																				</ToolTipService.ToolTip>
																			</TextBox>

                                        <Label Grid.Row="2" Grid.Column="6" FontSize="10" Content="Tax Rate (Tc)" HorizontalAlignment="Left" ></Label>
                                        <TextBox ToolTipService.ToolTip="Tc=Tax Rate." Grid.Row="3" Grid.Column="6"  FontSize="10" IsReadOnly="true" Text="{Binding Path=TaxRate, Mode=OneWay}" ></TextBox>

                                        <Label Grid.Row="2" Grid.Column="8" FontSize="10" Content="Interest Expense (Ei)" HorizontalAlignment="Left" ></Label>
                                        <TextBox  Grid.Row="3" Grid.Column="8"  FontSize="10" IsReadOnly="true" Text="{Binding Path=InterestExpense, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=InterestExpenseDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="4" Grid.Column="4" FontSize="10" Content="Oustanding Shares" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="5" Grid.Column="4" FontSize="10" IsReadOnly="true" Text="{Binding Path=OutstandingShares, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=OutstandingSharesDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="4" Grid.Column="6" FontSize="10" Content="MOS" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="5" Grid.Column="6"  Background="{Binding Path=MOSBackground}" FontSize="10" IsReadOnly="true" Text="{Binding Path=MOS, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=MOSDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>
                                        
                                        <Label Grid.Row="4" Grid.Column="8" FontSize="10" Content="MOS80" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="5" Grid.Column="8"  Background="{Binding Path=MOS80Background}" FontSize="10" IsReadOnly="true" Text="{Binding Path=MOS80, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=MOS80Description}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="6" Grid.Column="0" FontSize="10" Content="Present Value" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="7" Grid.Column="0"  FontSize="10" IsReadOnly="true" Text="{Binding Path=PresentValue, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=SumOfDiscountedCashflowsDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="6" Grid.Column="2" FontSize="10" Content="Est. Stock Price" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="7" Grid.Column="2"  FontSize="10" IsReadOnly="true" Text="{Binding Path=EstimatedStockPrice, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=EstimatedStockPriceDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="6" Grid.Column="4" FontSize="10" Content="Latest Price" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="7" Grid.Column="4"  FontSize="10" IsReadOnly="true" Text="{Binding Path=CurrentPrice, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=LatestPriceDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>
                                        
                                        <Label Grid.Row="6" Grid.Column="6" FontSize="10" Content="Price Date" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="7" Grid.Column="6"  FontSize="10" IsReadOnly="true" Text="{Binding Path=PriceDate, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=PriceDateDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="8" Grid.Column="0" FontSize="10" Content="Intrinsic Value" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="9" Grid.Column="0"  FontSize="10" IsReadOnly="true" Text="{Binding Path=IntrinsicValue, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=IntrinsicValueDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="8" Grid.Column="2" FontSize="10" Content="RGV(Intrinsic)" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="9" Grid.Column="2"  FontSize="10" IsReadOnly="true" Text="{Binding Path=RGVIntrinsic, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=IntrinsicValueDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="8" Grid.Column="4" FontSize="10" Content="Intrinsic Value(Rev.)" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="9" Grid.Column="4"  FontSize="10" IsReadOnly="true" Text="{Binding Path=IntrinsicValueRevised, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=IntrinsicValueRevisedDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="8" Grid.Column="6" FontSize="10" Content="RGV(Instrinsic Rev.)" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="9" Grid.Column="6"  FontSize="10" IsReadOnly="true" Text="{Binding Path=RGVIntrinsicValueRevised, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=RGVIntrinsicRevDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="8" Grid.Column="8" FontSize="10" Content="FreeCashflow Growth" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="9" Grid.Column="8"  FontSize="10" IsReadOnly="true" Text="{Binding Path=FreeCashflowGrowth, Mode=OneWay}" >
																					<ToolTipService.ToolTip>
																						<ToolTip IsEnabled="true" HasDropShadow="True">
																							<TextBlock Background="LemonChiffon" Text="{Binding Path=FreeCashflowGrowthDescription}"/>
																						</ToolTip>
																					</ToolTipService.ToolTip>
																				</TextBox>

                                        <Label Grid.Row="10" Grid.Column="0" FontSize="10" Content="Message" HorizontalAlignment="Left" ></Label>
                                        <TextBox Grid.Row="11" Grid.Column="0"  Grid.ColumnSpan="4" IsReadOnly="true" Text="{Binding Path=Message, Mode=OneWay}" ></TextBox>

                                    </Grid>

                                </StackPanel>
                            </GroupBox>
                        </Grid>
                    </DockPanel>
                </Grid>
            <!--</AdornerDecorator>-->
        </Grid>
    </wpfx:BusyIndicator>
</UserControl>
