fix(*): show special characters, like '-', '_', etc, in local branches; App.RaiseError crashes when called in other threads except UI.

This commit is contained in:
leo 2020-08-07 23:40:23 +08:00
parent cf203c66aa
commit 8bc23a7d71
3 changed files with 29 additions and 27 deletions

View file

@ -33,8 +33,9 @@ namespace SourceGit {
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
public static void RaiseError(string msg) { public static void RaiseError(string msg) {
var main = Current.MainWindow as UI.Launcher; Current.Dispatcher.Invoke(() => {
main.Dispatcher.Invoke(() => main.Errors.Add(msg)); (Current.MainWindow as UI.Launcher).Errors.Add(msg);
});
} }
/// <summary> /// <summary>

View file

@ -32,7 +32,7 @@
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" Panel.ZIndex="100"> <Grid Grid.Row="0" Panel.ZIndex="100">
<Border Background="{StaticResource Brush.BG1}" Margin="0,2,0,0"> <Border Background="{StaticResource Brush.BG1}" Margin="0,16,0,0">
<Border.Effect> <Border.Effect>
<DropShadowEffect ShadowDepth="2" Direction="270" Opacity=".5" Color="Black"/> <DropShadowEffect ShadowDepth="2" Direction="270" Opacity=".5" Color="Black"/>
</Border.Effect> </Border.Effect>
@ -210,6 +210,8 @@
Padding="0" Padding="0"
Background="{StaticResource Brush.BG3}" Background="{StaticResource Brush.BG3}"
FontFamily="Consolas" FontFamily="Consolas"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
LostFocus="TreeLostFocus" LostFocus="TreeLostFocus"
SelectedItemChanged="LocalBranchSelected" SelectedItemChanged="LocalBranchSelected"
PreviewMouseWheel="TreeMouseWheel"> PreviewMouseWheel="TreeMouseWheel">
@ -230,7 +232,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Path Grid.Column="0" Width="10" x:Name="icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Branch}"/> <Path Grid.Column="0" Width="10" x:Name="icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Branch}"/>
<Label Grid.Column="1" x:Name="name" Content="{Binding Name}" Padding="4,0,0,0"/> <TextBlock Grid.Column="1" x:Name="name" Text="{Binding Name}" Padding="4,0,0,0" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG}" ClipToBounds="True"/>
<StackPanel Grid.Column="2" Orientation="Horizontal"> <StackPanel Grid.Column="2" Orientation="Horizontal">
<Border Style="{StaticResource Style.Border.Badge}" Visibility="{Binding TrackVisibility}"> <Border Style="{StaticResource Style.Border.Badge}" Visibility="{Binding TrackVisibility}">
<Label Margin="4,-2,4,-2" Content="{Binding Branch.UpstreamTrack}" FontSize="10"/> <Label Margin="4,-2,4,-2" Content="{Binding Branch.UpstreamTrack}" FontSize="10"/>

View file

@ -35,7 +35,7 @@
</Border.Style> </Border.Style>
<!-- Window Content --> <!-- Window Content -->
<Grid> <Grid Background="{StaticResource Brush.BG1}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="32"/> <RowDefinition Height="32"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
@ -50,21 +50,18 @@
<!-- Tabs --> <!-- Tabs -->
<ScrollViewer x:Name="openedTabsScroller" Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled"> <ScrollViewer x:Name="openedTabsScroller" Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled">
<TabControl x:Name="openedTabs" Padding="0" ItemsSource="{Binding ElementName=me, Path=Tabs}" SizeChanged="OpenedTabsSizeChanged"> <TabControl x:Name="openedTabs" Padding="0" SnapsToDevicePixels="True" ItemsSource="{Binding ElementName=me, Path=Tabs}" SizeChanged="OpenedTabsSizeChanged">
<TabControl.Style> <TabControl.Style>
<Style TargetType="{x:Type TabControl}"> <Style TargetType="{x:Type TabControl}">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}"> <ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local" Height="32">
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
x:Name="HeaderPanel" x:Name="HeaderPanel"
Grid.Row="0"
Margin="6,4,0,0" Margin="6,4,0,0"
IsItemsHost="True" IsItemsHost="True"
KeyboardNavigation.TabIndex="1" SnapsToDevicePixels="True"
Background="Transparent" /> KeyboardNavigation.TabIndex="1"/>
</Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
@ -75,11 +72,13 @@
<Style TargetType="{x:Type TabItem}"> <Style TargetType="{x:Type TabItem}">
<Setter Property="AllowDrop" Value="True"/> <Setter Property="AllowDrop" Value="True"/>
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/> <Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}"> <ControlTemplate TargetType="{x:Type TabItem}">
<Grid x:Name="Container" Opacity=".7" Height="28" WindowChrome.IsHitTestVisibleInChrome="True"> <Grid x:Name="Container" Opacity=".7" SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True">
<Border x:Name="BG" Background="Transparent" BorderThickness="0" BorderBrush="{StaticResource Brush.BG3}" CornerRadius="4,4,0,0"> <Border x:Name="BG" SnapsToDevicePixels="True" Background="Transparent" BorderThickness="0" BorderBrush="{StaticResource Brush.BG3}" CornerRadius="4,4,0,0">
<Border.Effect> <Border.Effect>
<DropShadowEffect ShadowDepth="2" Direction="30" Color="Black" Opacity=".3"/> <DropShadowEffect ShadowDepth="2" Direction="30" Color="Black" Opacity=".3"/>
</Border.Effect> </Border.Effect>
@ -87,22 +86,22 @@
<Path <Path
x:Name="CornerLeft" x:Name="CornerLeft"
Width="4" Width="6"
Height="4" Height="6"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Margin="-4,0,0,0" Margin="-5,0,0,0"
Data="M 0,4 L 4,4 4,0 C 4,0 4,4 0,4 Z" Data="M 0,6 L 6,6 6,0 C 6,0 6,6 0,6 Z"
Fill="Transparent"/> Fill="Transparent"/>
<Path <Path
x:Name="CornerRight" x:Name="CornerRight"
Width="4" Width="6"
Height="4" Height="6"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Margin="0,0,-4,0" Margin="0,0,-5,0"
Data="M 0,0 L 0,4 4,4 C 4,4 0,4 0,0 Z" Data="M 0,0 L 0,6 6,6 C 6,6 0,6 0,0 Z"
Fill="Transparent"/> Fill="Transparent"/>
<ContentPresenter <ContentPresenter
@ -141,7 +140,7 @@
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal" Margin="6,0"> <StackPanel Orientation="Horizontal" Margin="6,0" VerticalAlignment="Center">
<Path Grid.Column="0" Width="14" Height="14" x:Name="Icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/> <Path Grid.Column="0" Width="14" Height="14" x:Name="Icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
<TextBlock Grid.Column="1" Text="{Binding Title}" Foreground="{StaticResource Brush.FG}" Margin="8,0,0,0" FontWeight="Bold"> <TextBlock Grid.Column="1" Text="{Binding Title}" Foreground="{StaticResource Brush.FG}" Margin="8,0,0,0" FontWeight="Bold">
<TextBlock.ToolTip> <TextBlock.ToolTip>