sourcegit/src/Views/Widgets/WorkingCopy.xaml
2021-04-29 20:05:55 +08:00

249 lines
11 KiB
XML

<UserControl x:Class="SourceGit.Views.Widgets.WorkingCopy"
x:Name="me"
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:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:converter="clr-namespace:SourceGit.Views.Converters"
xmlns:models="clr-namespace:SourceGit.Models"
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<converter:BoolToCollapsed x:Key="BoolToCollapsed"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" MinWidth="300"/>
<ColumnDefinition Width="1"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Left -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Unstaged Toolbar -->
<Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:ChangeDisplaySwitcher
Grid.Column="0"
x:Name="unstagedMode"
Width="14" Height="14"
Margin="4,0,0,0"
Mode="{Binding Source={x:Static models:Preference.Instance}, Path=Window.ChangeInUnstaged, Mode=TwoWay}"/>
<TextBlock
Grid.Column="1"
Margin="6,0"
Text="{StaticResource Text.WorkingCopy.Unstaged}"
Foreground="{StaticResource Brush.FG2}"
FontWeight="Bold"/>
<controls:Loading
Grid.Column="2"
Width="12" Height="12"
x:Name="iconStaging"
IsAnimating="{Binding ElementName=unstagedContainer, Path=IsStaging}"
Visibility="{Binding ElementName=unstagedContainer, Path=IsStaging, Converter={StaticResource BoolToCollapsed}}"/>
<controls:IconButton
Grid.Column="4"
Click="StageSelected"
Width="14" Height="14"
Margin="4,0"
Icon="{StaticResource Icon.Down}"
ToolTip="{StaticResource Text.WorkingCopy.Unstaged.Stage}"/>
<controls:IconButton
Grid.Column="5"
Click="StageAll"
Width="14" Height="14"
Margin="4,0"
Icon="{StaticResource Icon.DoubleDown}"
ToolTip="{StaticResource Text.WorkingCopy.Unstaged.StageAll}"/>
</Grid>
</Border>
<!-- Unstaged Changes -->
<Border Grid.Row="1" Background="{StaticResource Brush.Contents}">
<widgets:WorkingCopyChanges
x:Name="unstagedContainer"
IsUnstaged="True"
Mode="{Binding ElementName=unstagedMode, Path=Mode}"
DiffTargetChanged="OnDiffTargetChanged"/>
</Border>
<!-- Staged Toolbar -->
<Border Grid.Row="2" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:ChangeDisplaySwitcher
Grid.Column="0"
x:Name="stagedMode"
Width="14" Height="14"
Margin="4,0,0,0"
Mode="{Binding Source={x:Static models:Preference.Instance}, Path=Window.ChangeInStaged, Mode=TwoWay}"/>
<TextBlock
Grid.Column="1"
Margin="6,0"
Text="{StaticResource Text.WorkingCopy.Staged}"
Foreground="{StaticResource Brush.FG2}"
FontWeight="Bold"/>
<controls:IconButton
Grid.Column="2"
Click="UnstageSelected"
Width="14" Height="14"
Margin="4,0"
Icon="{StaticResource Icon.Up}"
ToolTip="{StaticResource Text.WorkingCopy.Staged.Unstage}"/>
<controls:IconButton
Grid.Column="3"
Click="UnstageAll"
Width="14" Height="14"
Margin="4,0"
Icon="{StaticResource Icon.DoubleUp}"
ToolTip="{StaticResource Text.WorkingCopy.Staged.UnstageAll}"/>
</Grid>
</Border>
<!-- Staged Changes -->
<Border Grid.Row="3" Background="{StaticResource Brush.Contents}">
<widgets:WorkingCopyChanges
x:Name="stagedContainer"
IsUnstaged="False"
Mode="{Binding ElementName=stagedMode, Path=Mode}"
DiffTargetChanged="OnDiffTargetChanged"/>
</Border>
</Grid>
<GridSplitter Grid.Column="1" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch" Background="{StaticResource Brush.Border0}"/>
<!-- Right -->
<Grid Grid.Column="2" Margin="4">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Diff viewer -->
<widgets:DiffViewer Grid.Row="0" x:Name="diffViewer"/>
<!-- Merge Option Panel -->
<Grid Grid.Row="0" x:Name="mergePanel" Background="{StaticResource Brush.Window}" Visibility="Collapsed">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path
Width="64" Height="64"
Data="{StaticResource Icon.Conflict}"
Fill="{StaticResource Brush.FG2}"/>
<TextBlock
Margin="0,16,0,28"
FontSize="20" FontWeight="DemiBold"
Text="{StaticResource Text.WorkingCopy.Conflicts}"
Foreground="{StaticResource Brush.FG2}"
HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Click="UseTheirs" Content="{StaticResource Text.WorkingCopy.UseTheirs}" Height="24" Padding="8,0"/>
<Button Click="UseMine" Content="{StaticResource Text.WorkingCopy.UseMine}" Height="24" Margin="8,0" Padding="8,0"/>
<Button Click="UseMergeTool" Content="{StaticResource Text.WorkingCopy.OpenMerger}" Height="24" Padding="8,0"/>
</StackPanel>
</StackPanel>
</Grid>
<!-- Commit Message -->
<controls:TextEdit
Grid.Row="1"
x:Name="txtCommitMessage"
Height="64"
Margin="0,4" Padding="1"
AcceptsReturn="True"
AcceptsTab="True"
TextWrapping="Wrap"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Placeholder="{StaticResource Text.WorkingCopy.CommitMessageTip}"
PlaceholderBaseline="Top">
<TextBox.Text>
<Binding ElementName="me" Path="CommitMessage" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<validations:CommitMessage/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</controls:TextEdit>
<!-- Commit Options -->
<Grid Grid.Row="2" Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:IconButton
Grid.Column="0"
Width="14" Height="14"
Click="OpenCommitMessageRecorder"
ToolTip="{StaticResource Text.WorkingCopy.MessageHistories}"
Icon="{StaticResource Icon.List}"
Opacity=".5"/>
<CheckBox
Grid.Column="1"
x:Name="chkAmend"
Margin="8,0,0,0"
HorizontalAlignment="Left"
Content="{StaticResource Text.WorkingCopy.Amend}"
Checked="StartAmend" Unchecked="EndAmend"/>
<controls:Loading
Grid.Column="3"
x:Name="iconCommitting"
Width="18" Height="18"
Margin="0,0,8,0"
Visibility="Collapsed"/>
<Button
Grid.Column="4"
Height="26"
Padding="8,0"
Click="Commit"
Background="{StaticResource Brush.Accent1}"
BorderBrush="{StaticResource Brush.FG1}"
Content="{StaticResource Text.WorkingCopy.Commit}"/>
<Button
Grid.Column="5"
x:Name="btnCommitAndPush"
Height="26"
Padding="8,0"
Click="CommitAndPush"
Content="{StaticResource Text.WorkingCopy.CommitAndPush}"
Margin="8,0,0,0"/>
</Grid>
</Grid>
</Grid>
</UserControl>