mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
ux: subject length tooltip font size and color
This commit is contained in:
parent
ee6c360dc9
commit
907e009275
3 changed files with 19 additions and 21 deletions
|
@ -19,7 +19,10 @@ namespace SourceGit.Converters
|
|||
public static readonly FuncValueConverter<int, bool> IsNotOne =
|
||||
new FuncValueConverter<int, bool>(v => v != 1);
|
||||
|
||||
public static readonly FuncValueConverter<int, bool> IsBadSubjectLength =
|
||||
public static readonly FuncValueConverter<int, bool> IsSubjectLengthBad =
|
||||
new FuncValueConverter<int, bool>(v => v > ViewModels.Preference.Instance.SubjectGuideLength);
|
||||
|
||||
public static readonly FuncValueConverter<int, bool> IsSubjectLengthGood =
|
||||
new FuncValueConverter<int, bool>(v => v <= ViewModels.Preference.Instance.SubjectGuideLength);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,15 +42,19 @@
|
|||
|
||||
<Border Grid.Row="1" CornerRadius="0,0,4,4" BorderThickness="0,1,0,0" BorderBrush="{DynamicResource Brush.Border2}" Background="{DynamicResource Brush.Window}" ClipToBounds="True">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<Path Grid.Column="0" Height="12" Width="12" Margin="4,0,0,0" Data="{DynamicResource Icons.Info}" ToolTip.Tip="{DynamicResource Text.CommitMessageTextBox.Tip}"/>
|
||||
<Border Grid.Column="0" Background="Transparent" Width="16" Height="16" ToolTip.Tip="{DynamicResource Text.CommitMessageTextBox.Tip}">
|
||||
<Path Height="12" Width="12" Margin="4,0,0,0" Data="{DynamicResource Icons.Info}"/>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="4,2">
|
||||
<TextBlock Text="Subject:" FontSize="10" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="10" Text="{Binding #ThisControl.SubjectLength}"/>
|
||||
<TextBlock Classes="monospace" FontSize="10" Text="/"/>
|
||||
<TextBlock Classes="monospace" FontSize="10" 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.SubjectLength, Converter={x:Static c:IntConverters.IsBadSubjectLength}}"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Total:" FontSize="10" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="10" Text="{Binding #ThisControl.Text.Length}"/>
|
||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Text="{Binding #ThisControl.SubjectLength}" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthGood}}"/>
|
||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Foreground="DarkGoldenrod" Text="{Binding #ThisControl.SubjectLength}" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
|
||||
<TextBlock Classes="monospace" FontSize="11" Text="/"/>
|
||||
<TextBlock Classes="monospace" 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.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Total:" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Text="{Binding #ThisControl.Text.Length}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace SourceGit.Views
|
|||
public TextDocument Document
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public CommitMessageTextBox()
|
||||
|
@ -44,12 +43,9 @@ namespace SourceGit.Views
|
|||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
||||
if (change.Property == TextProperty)
|
||||
{
|
||||
if (!_isDocumentTextChanging)
|
||||
if (change.Property == TextProperty && !_isDocumentTextChanging)
|
||||
Document.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextEditorLayoutUpdated(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -85,24 +81,19 @@ namespace SourceGit.Views
|
|||
SetCurrentValue(TextProperty, Document.Text);
|
||||
_isDocumentTextChanging = false;
|
||||
|
||||
var setSubject = false;
|
||||
for (int i = 0; i < Document.LineCount; i++)
|
||||
for (var i = 0; i < Document.LineCount; i++)
|
||||
{
|
||||
var line = Document.Lines[i];
|
||||
if (line.LineNumber > 1 && line.Length == 0)
|
||||
{
|
||||
var subject = Text.Substring(0, line.Offset).ReplaceLineEndings(" ").Trim();
|
||||
var subject = Text[..line.Offset].ReplaceLineEndings(" ").Trim();
|
||||
SetCurrentValue(SubjectLengthProperty, subject.Length);
|
||||
setSubject = true;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
_subjectEndLineNumber = line.LineNumber;
|
||||
}
|
||||
|
||||
if (setSubject)
|
||||
return;
|
||||
|
||||
SetCurrentValue(SubjectLengthProperty, Text.ReplaceLineEndings(" ").Trim().Length);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue