<UserControl x:Class="Tango.Console.ConsoleControl"
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:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
xmlns:local="clr-namespace:Tango.Console"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" FontFamily="Consolas" FontSize="14" FocusVisualStyle="{x:Null}" Focusable="False" d:DataContext="{d:DesignInstance Type=local:ConsoleControlVM, IsDesignTimeCreatable=False}" Background="Black" Foreground="Silver" x:Name="control">
<UserControl.Style>
<Style TargetType="UserControl">
<Setter Property="local:ConsoleControl.CaretBrush" Value="White"></Setter>
<Setter Property="local:ConsoleControl.SelectionBrush" Value="#828282"></Setter>
<Setter Property="local:ConsoleControl.BusyTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Margin="0 0 5 0" Foreground="Yellow" >...</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="local:ConsoleControl.SuggestionsBorderBrush" Value="DimGray"></Setter>
<Setter Property="local:ConsoleControl.SuggestionsForeground" Value="Silver"></Setter>
<Setter Property="local:ConsoleControl.SuggestionsBackground" Value="#383838"></Setter>
</Style>
</UserControl.Style>
<UserControl.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<local:ConsoleTextBoxMaxWidthConverter x:Key="ConsoleTextBoxMaxWidthConverter" />
</UserControl.Resources>
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Focusable="False" PreviewMouseDown="ScrollViewer_PreviewMouseDown">
<StackPanel>
<ItemsControl ItemsSource="{Binding Commands}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0 0 0 10">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center">
<Run Text="{Binding WorkingFolder}"></Run><Run Text=">"></Run>
</TextBlock>
<StackPanel VerticalAlignment="Center" Margin="5 0 0 0" Orientation="Horizontal">
<TextBox Style="{x:Null}" VerticalAlignment="Center" IsReadOnly="True" Cursor="Arrow" AcceptsReturn="True" Background="Transparent" BorderThickness="0" Foreground="{Binding ElementName=control,Path=Foreground}" CaretBrush="{Binding ElementName=control,Path=CaretBrush}" SelectionBrush="{Binding ElementName=control,Path=SelectionBrush}" Text="{Binding CommandText}"></TextBox>
</StackPanel>
</StackPanel>
<TextBox Style="{x:Null}" IsReadOnly="True" Cursor="Arrow" TextWrapping="Wrap" AcceptsReturn="True" Background="Transparent" BorderThickness="0" Foreground="Silver" CaretBrush="White" SelectionBrush="#777777" Text="{Binding Output,Mode=OneWay}"></TextBox>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="lbWorkingFolder">
<Run Text="{Binding CurrentCommand.WorkingFolder}"></Run><Run Text=">"></Run>
</TextBlock>
<StackPanel Margin="0 0 0 0" Orientation="Horizontal">
<ContentControl Margin="0 0 5 0" Content="{Binding}" ContentTemplate="{Binding ElementName=control,Path=BusyTemplate}" Visibility="{Binding CurrentCommand.IsExecuting,Converter={StaticResource BooleanToVisibilityConverter}}"/>
<local:ConsoleTextBox x:Name="txtCurrentCommand" Suggestions="{Binding Suggestions}" Height="Auto" AcceptsReturn="False" TextWrapping="Wrap" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Disabled" Cursor="Arrow" MinWidth="10" Background="Transparent" BorderThickness="0" SuggestionsBackground="{Binding ElementName=control,Path=SuggestionsBackground}" SuggestionsForeground="{Binding ElementName=control,Path=SuggestionsForeground}" SuggestionsBorderBrush="{Binding ElementName=control,Path=SuggestionsBorderBrush}" Foreground="{Binding ElementName=control,Path=Foreground}" CaretBrush="Transparent" CaretBottomBrush="{Binding ElementName=control,Path=CaretBrush}" SelectionBrush="{Binding ElementName=control,Path=SelectionBrush}" Text="{Binding CurrentCommand.CommandText,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding CurrentCommand.IsExecuting}">
<local:ConsoleTextBox.MaxWidth>
<MultiBinding Converter="{StaticResource ConsoleTextBoxMaxWidthConverter}">
<Binding ElementName="lbWorkingFolder" Path="ActualWidth" />
<Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="ActualWidth"></Binding>
</MultiBinding>
</local:ConsoleTextBox.MaxWidth>
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ExecuteCommand}" />
<KeyBinding Key="Up" Command="{Binding HistoryUpCommand}" />
<KeyBinding Key="Down" Command="{Binding HistoryDownCommand}" />
</TextBox.InputBindings>
</local:ConsoleTextBox>
</StackPanel>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>