mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-25 03:12:21 +08:00
330 lines
20 KiB
XML
330 lines
20 KiB
XML
<Window x:Class="SourceGit.UI.Launcher"
|
|
x:Name="me"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
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:source="clr-namespace:SourceGit"
|
|
xmlns:local="clr-namespace:SourceGit.UI"
|
|
xmlns:converters="clr-namespace:SourceGit.Converters"
|
|
mc:Ignorable="d"
|
|
MinWidth="800" MinHeight="600"
|
|
Title="Source Git"
|
|
Width="{Binding Source={x:Static source:App.Setting}, Path=UI.WindowWidth, Mode=TwoWay}"
|
|
Height="{Binding Source={x:Static source:App.Setting}, Path=UI.WindowHeight, Mode=TwoWay}"
|
|
WindowStartupLocation="CenterScreen"
|
|
UseLayoutRounding="True">
|
|
|
|
<!-- Enable WindowChrome Feature -->
|
|
<WindowChrome.WindowChrome>
|
|
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
|
</WindowChrome.WindowChrome>
|
|
|
|
<!-- Window Layout -->
|
|
<Border BorderBrush="{StaticResource Brush.Border0}" Background="{StaticResource Brush.Border0}">
|
|
|
|
<!-- Fix Maximize BUG -->
|
|
<Border.Style>
|
|
<Style TargetType="{x:Type Border}">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding WindowState, ElementName=me}" Value="Maximized">
|
|
<Setter Property="Margin" Value="{x:Static local:Launcher.MAXIMIZE_MARGIN}"/>
|
|
<Setter Property="BorderThickness" Value="0"/>
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding WindowState, ElementName=me}" Value="Normal">
|
|
<Setter Property="Margin" Value="0"/>
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Border.Style>
|
|
|
|
<!-- Window Content -->
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="28"/>
|
|
<RowDefinition Height="*"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid Grid.Row="0" Background="{StaticResource Brush.TitleBar}">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition x:Name="openedTabsColumn" Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="200"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Rectangle Grid.Column="0" Grid.ColumnSpan="4"
|
|
Height="1"
|
|
VerticalAlignment="Bottom"
|
|
Fill="{StaticResource Brush.Border0}"/>
|
|
|
|
<!-- Tab scroller left -->
|
|
<Border Grid.Column="0" x:Name="tabScrollerLeft" Width="18" Height="28" BorderThickness="0,0,1,0" BorderBrush="{StaticResource Brush.Border0}" WindowChrome.IsHitTestVisibleInChrome="True">
|
|
<Button Click="ScrollToLeft" Margin="0" Padding="0">
|
|
<Path Width="10" Height="12" Data="{StaticResource Icon.ScrollLeft}"/>
|
|
</Button>
|
|
</Border>
|
|
|
|
<!-- Tabs -->
|
|
<ScrollViewer x:Name="openedTabsScroller" Grid.Column="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" CanContentScroll="True">
|
|
<TabControl x:Name="openedTabs" Padding="0" SnapsToDevicePixels="True" ItemsSource="{Binding ElementName=me, Path=Tabs}" SizeChanged="OpenedTabsSizeChanged">
|
|
<TabControl.Style>
|
|
<Style TargetType="{x:Type TabControl}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type TabControl}">
|
|
<StackPanel Orientation="Horizontal" Margin="0">
|
|
<StackPanel Orientation="Horizontal" IsItemsHost="True" SnapsToDevicePixels="True" KeyboardNavigation.TabIndex="1"/>
|
|
<Button Margin="4,0,0,0" Click="NewTab" ToolTip="{StaticResource Text.Launcher.NewPageButton}" WindowChrome.IsHitTestVisibleInChrome="True">
|
|
<Button.Style>
|
|
<Style TargetType="{x:Type Button}" BasedOn="{x:Null}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<Border x:Name="newTabBG" Width="20" Height="20" BorderThickness="0" Background="Transparent">
|
|
<Path Width="14" Height="14" Data="{StaticResource Icon.NewTab}" Fill="{StaticResource Brush.FG1}"/>
|
|
</Border>
|
|
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter TargetName="newTabBG" Property="Background" Value="{StaticResource Brush.NewPageHover}"/>
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</Button.Style>
|
|
</Button>
|
|
</StackPanel>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</TabControl.Style>
|
|
|
|
<TabControl.Resources>
|
|
<converters:IntToRepoColor x:Key="IntToRepoColor"/>
|
|
</TabControl.Resources>
|
|
|
|
<TabControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<Grid x:Name="BG" Margin="8,0" Background="Transparent">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="4"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Path
|
|
x:Name="Icon"
|
|
Grid.Column="0"
|
|
Width="14" Height="14"
|
|
Fill="{Binding Color, Converter={StaticResource IntToRepoColor}}"
|
|
|
|
Data="{StaticResource Icon.Bookmark}"
|
|
VerticalAlignment="Center"/>
|
|
|
|
<Label
|
|
x:Name="Title"
|
|
Grid.Column="1"
|
|
Content="{Binding Title}"
|
|
Foreground="{StaticResource Brush.FG1}" FontFamily="Consolas" FontWeight="Bold"/>
|
|
|
|
<Button Grid.Column="3" Click="CloseTab" Width="16" Height="16" VerticalAlignment="Center" ToolTip="{StaticResource Text.Close}" Style="{StaticResource Style.Button.HighlightHover}">
|
|
<Path
|
|
Width="8" Height="8"
|
|
Fill="{StaticResource Brush.FG1}"
|
|
|
|
Data="{StaticResource Icon.Close}"/>
|
|
</Button>
|
|
</Grid>
|
|
|
|
<DataTemplate.Triggers>
|
|
<DataTrigger Binding="{Binding IsRepo}" Value="False">
|
|
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.NewPage}"/>
|
|
<Setter TargetName="Icon" Property="Fill" Value="{StaticResource Brush.FG1}"/>
|
|
</DataTrigger>
|
|
<MultiDataTrigger>
|
|
<MultiDataTrigger.Conditions>
|
|
<Condition Binding="{Binding IsRepo}" Value="True"/>
|
|
<Condition Binding="{Binding Color}" Value="0"/>
|
|
</MultiDataTrigger.Conditions>
|
|
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Git}"/>
|
|
<Setter TargetName="Icon" Property="Fill" Value="{StaticResource Brush.FG1}"/>
|
|
</MultiDataTrigger>
|
|
</DataTemplate.Triggers>
|
|
</DataTemplate>
|
|
</TabControl.ItemTemplate>
|
|
|
|
<TabControl.ItemContainerStyle>
|
|
<Style TargetType="{x:Type TabItem}">
|
|
<Setter Property="AllowDrop" Value="True"/>
|
|
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
|
|
<Setter Property="Margin" Value="0"/>
|
|
<Setter Property="Padding" Value="0"/>
|
|
<Setter Property="ClipToBounds" Value="False"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type TabItem}">
|
|
<Grid x:Name="Container" SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="{Binding Tooltip}">
|
|
<Border
|
|
x:Name="BG"
|
|
BorderThickness="0,0,1,0"
|
|
BorderBrush="{StaticResource Brush.Border0}"
|
|
Background="Transparent"/>
|
|
|
|
<ContentPresenter
|
|
x:Name="ContentSite"
|
|
VerticalAlignment="Center"
|
|
ContentSource="Header"
|
|
RecognizesAccessKey="True"
|
|
Opacity=".5"/>
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter TargetName="BG" Property="Background" Value="{StaticResource Brush.Window}"/>
|
|
<Setter TargetName="ContentSite" Property="Opacity" Value="1"/>
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsMouseOver" Value="True"/>
|
|
<Condition Property="IsSelected" Value="False"/>
|
|
</MultiTrigger.Conditions>
|
|
<Setter TargetName="ContentSite" Property="Opacity" Value=".9"/>
|
|
</MultiTrigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
|
|
<EventSetter Event="MouseMove" Handler="TabsMouseMove"/>
|
|
<EventSetter Event="Drop" Handler="TabsDrop"/>
|
|
<EventSetter Event="ContextMenuOpening" Handler="TabsContextMenuOpening"/>
|
|
</Style>
|
|
</TabControl.ItemContainerStyle>
|
|
</TabControl>
|
|
</ScrollViewer>
|
|
|
|
<!-- Tab scroller right -->
|
|
<Border Grid.Column="2" x:Name="tabScrollerRight" Width="18" Height="28" BorderThickness="1,0,1,0" BorderBrush="{StaticResource Brush.Border0}" WindowChrome.IsHitTestVisibleInChrome="True">
|
|
<Button Click="ScrollToRight" Margin="0" Padding="0">
|
|
<Path Width="10" Height="12" Data="{StaticResource Icon.ScrollRight}"/>
|
|
</Button>
|
|
</Border>
|
|
|
|
<!-- Window Command -->
|
|
<StackPanel
|
|
Grid.Column="3"
|
|
Margin="32,0,0,0"
|
|
Orientation="Horizontal"
|
|
HorizontalAlignment="Right"
|
|
VerticalAlignment="Top"
|
|
Height="27"
|
|
WindowChrome.IsHitTestVisibleInChrome="True">
|
|
<Button Click="ShowPreference" Width="28" ToolTip="{StaticResource Text.Launcher.Preference}">
|
|
<Path Width="14" Height="14" Data="{StaticResource Icon.Preference}"/>
|
|
</Button>
|
|
<Button Click="ShowAbout" Width="28" ToolTip="{StaticResource Text.Launcher.About}">
|
|
<Path Width="14" Height="14" Data="{StaticResource Icon.Info}"/>
|
|
</Button>
|
|
<Button Click="Minimize" Width="28" Style="{StaticResource Style.Button.HighlightHover}">
|
|
<Path Width="10" Height="10" Data="{StaticResource Icon.Minimize}"/>
|
|
</Button>
|
|
<Button Click="MaximizeOrRestore" Width="28" Style="{StaticResource Style.Button.HighlightHover}">
|
|
<Path Width="10" Height="10" Data="{StaticResource Icon.Maximize}"/>
|
|
</Button>
|
|
<Button Click="Quit" Width="28">
|
|
<Button.Style>
|
|
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource Style.Button.HighlightHover}">
|
|
<Style.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter Property="Background" Value="Red"/>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Button.Style>
|
|
|
|
<Path Width="10" Data="{StaticResource Icon.Close}"/>
|
|
</Button>
|
|
</StackPanel>
|
|
</Grid>
|
|
|
|
<!-- Pages -->
|
|
<ItemsControl Grid.Row="1" ItemsSource="{Binding ElementName=me, Path=Tabs}" Background="{StaticResource Brush.Window}">
|
|
<ItemsControl.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<Grid/>
|
|
</ItemsPanelTemplate>
|
|
</ItemsControl.ItemsPanel>
|
|
<ItemsControl.Resources>
|
|
<BooleanToVisibilityConverter x:Key="Bool2Visible"/>
|
|
</ItemsControl.Resources>
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<ContentControl Content="{Binding Page}" Visibility="{Binding IsActive, Converter={StaticResource Bool2Visible}}"/>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
|
|
<!-- Alerts -->
|
|
<ItemsControl
|
|
Grid.Row="1"
|
|
HorizontalAlignment="Right"
|
|
VerticalAlignment="Top"
|
|
Margin="0,32,0,0" Width="Auto" Height="Auto"
|
|
ItemsSource="{Binding Errors, ElementName=me}">
|
|
|
|
<ItemsControl.Style>
|
|
<Style TargetType="{x:Type ItemsControl}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
|
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
|
</ScrollViewer>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</ItemsControl.Style>
|
|
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<Grid x:Name="item" Height="Auto" Width="300" Margin="8,8,16,8">
|
|
<Border Background="{StaticResource Brush.Window}">
|
|
<Border.Effect>
|
|
<DropShadowEffect ShadowDepth="0"/>
|
|
</Border.Effect>
|
|
</Border>
|
|
|
|
<Grid Margin="8">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="26"/>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<Label Grid.Row="0" Content="{StaticResource Text.Launcher.Error}" FontWeight="DemiBold"/>
|
|
<TextBlock Grid.Row="1" Margin="6,8" Text="{Binding}" Foreground="{StaticResource Brush.FG1}" TextWrapping="Wrap"/>
|
|
<Button
|
|
Grid.Row="2"
|
|
Margin="4,0"
|
|
Click="RemoveError"
|
|
Height="25"
|
|
Content="{StaticResource Text.Close}"
|
|
Style="{StaticResource Style.Button.AccentBordered}"
|
|
BorderBrush="{StaticResource Brush.FG1}"
|
|
VerticalAlignment="Center"
|
|
HorizontalAlignment="Right"/>
|
|
</Grid>
|
|
</Grid>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
</Grid>
|
|
</Border>
|
|
</Window>
|