sourcegit/src/Views/CommitMessageTextBox.axaml

79 lines
4.2 KiB
XML

<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:c="using:SourceGit.Converters"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.CommitMessageTextBox"
x:Name="ThisControl">
<Border Background="{DynamicResource Brush.Contents}"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
CornerRadius="4">
<Grid RowDefinitions="Auto,1,*">
<Grid Grid.Row="0" ColumnDefinitions="*,1,Auto">
<v:EnhancedTextBox Grid.Column="0"
x:Name="SubjectEditor"
Classes="no_border"
Margin="0"
Padding="4"
CornerRadius="4,4,0,0"
BorderThickness="0"
Background="Transparent"
AcceptsReturn="False"
TextWrapping="Wrap"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Text="{Binding #ThisControl.Subject, Mode=TwoWay}"
Watermark="{DynamicResource Text.CommitMessageTextBox.SubjectPlaceholder}"
PreviewKeyDown="OnSubjectTextBoxPreviewKeyDown"/>
<Rectangle Grid.Column="1"
Width="1"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
IsHitTestVisible="False"
Fill="{DynamicResource Brush.Border2}"/>
<StackPanel Grid.Column="2"
Margin="8,0"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Classes="primary" Margin="2,0,0,0" FontSize="11" Text="{Binding #ThisControl.Subject.Length}" IsVisible="{Binding #ThisControl.Subject.Length, Converter={x:Static c:IntConverters.IsSubjectLengthGood}}"/>
<TextBlock Classes="primary" Margin="2,0,0,0" FontSize="11" Foreground="DarkGoldenrod" Text="{Binding #ThisControl.Subject.Length}" IsVisible="{Binding #ThisControl.Subject.Length, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
<TextBlock Classes="primary" FontSize="11" Text="/"/>
<TextBlock Classes="primary" FontSize="11" Text="{Binding Source={x:Static vm:Preference.Instance}, Path=SubjectGuideLength}"/>
<Path Width="10" Height="10" Margin="4,0,0,0" Data="{StaticResource Icons.Error}" Fill="DarkGoldenrod" IsVisible="{Binding #ThisControl.Subject.Length, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
</StackPanel>
</Grid>
<Rectangle Grid.Row="1"
Height="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsHitTestVisible="False"
Fill="{DynamicResource Brush.Border2}"/>
<v:EnhancedTextBox Grid.Row="2"
x:Name="DescriptionEditor"
Classes="no_border"
Margin="0"
Padding="4"
CornerRadius="0,0,4,4"
BorderThickness="0"
Background="Transparent"
VerticalContentAlignment="Top"
AcceptsReturn="True"
AcceptsTab="True"
TextWrapping="Wrap"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Text="{Binding #ThisControl.Description, Mode=TwoWay}"
Watermark="{DynamicResource Text.CommitMessageTextBox.MessagePlaceholder}"
PreviewKeyDown="OnDescriptionTextBoxPreviewKeyDown"/>
</Grid>
</Border>
</UserControl>