optimize<WorkingCopy>: use animated icon instead of waiting panel for committing status

This commit is contained in:
leo 2021-04-02 19:29:05 +08:00
parent 30dea811a3
commit 762e51de74
4 changed files with 21 additions and 9 deletions

View file

@ -413,7 +413,6 @@
<sys:String x:Key="Text.Waiting.UpdateSubmodule">WAITING SUBMOUDLE UPDATE COMPLETE...</sys:String> <sys:String x:Key="Text.Waiting.UpdateSubmodule">WAITING SUBMOUDLE UPDATE COMPLETE...</sys:String>
<sys:String x:Key="Text.Waiting.Staging">WAITING STAGE COMPLETE...</sys:String> <sys:String x:Key="Text.Waiting.Staging">WAITING STAGE COMPLETE...</sys:String>
<sys:String x:Key="Text.Waiting.Commit">WAITING COMMIT COMPLETE ...</sys:String>
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured.\nPlease to go [Preference] and configure it first.</sys:String> <sys:String x:Key="Text.NotConfigured">Git has NOT been configured.\nPlease to go [Preference] and configure it first.</sys:String>
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String> <sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>

View file

@ -413,7 +413,6 @@
<sys:String x:Key="Text.Waiting.UpdateSubmodule">等待子模块更新完成...</sys:String> <sys:String x:Key="Text.Waiting.UpdateSubmodule">等待子模块更新完成...</sys:String>
<sys:String x:Key="Text.Waiting.Staging">等待暂存完成 ...</sys:String> <sys:String x:Key="Text.Waiting.Staging">等待暂存完成 ...</sys:String>
<sys:String x:Key="Text.Waiting.Commit">等待提交完成 ...</sys:String>
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String> <sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String> <sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>

View file

@ -418,6 +418,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Grid.Column="0" Width="16" Height="16" Margin="0,0,8,0" Click="OpenCommitMessageSelector" ToolTip="{StaticResource Text.WorkingCopy.MessageHistories}"> <Button Grid.Column="0" Width="16" Height="16" Margin="0,0,8,0" Click="OpenCommitMessageSelector" ToolTip="{StaticResource Text.WorkingCopy.MessageHistories}">
@ -426,8 +427,15 @@
<CheckBox Grid.Column="1" x:Name="chkAmend" HorizontalAlignment="Left" Content="{StaticResource Text.WorkingCopy.Amend}" Checked="StartAmend" Unchecked="EndAmend"/> <CheckBox Grid.Column="1" x:Name="chkAmend" HorizontalAlignment="Left" Content="{StaticResource Text.WorkingCopy.Amend}" Checked="StartAmend" Unchecked="EndAmend"/>
<Button Grid.Column="3" Height="26" Click="Commit" Style="{StaticResource Style.Button.AccentBordered}" Content="{StaticResource Text.WorkingCopy.Commit}"/> <!-- Loading tip -->
<Button Grid.Column="4" x:Name="btnCommitAndPush" Height="26" Click="CommitAndPush" Style="{StaticResource Style.Button.Bordered}" Content="{StaticResource Text.WorkingCopy.CommitAndPush}" Margin="8,0,0,0"/> <Path x:Name="iconCommiting" Grid.Column="3" Visibility="Collapsed" Margin="8,0" Data="{StaticResource Icon.Loading}" RenderTransformOrigin=".5,.5">
<Path.RenderTransform>
<RotateTransform Angle="0"/>
</Path.RenderTransform>
</Path>
<Button Grid.Column="4" Height="26" Click="Commit" Style="{StaticResource Style.Button.AccentBordered}" Content="{StaticResource Text.WorkingCopy.Commit}"/>
<Button Grid.Column="5" x:Name="btnCommitAndPush" Height="26" Click="CommitAndPush" Style="{StaticResource Style.Button.Bordered}" Content="{StaticResource Text.WorkingCopy.CommitAndPush}" Margin="8,0,0,0"/>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>

View file

@ -11,6 +11,7 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation;
namespace SourceGit.UI { namespace SourceGit.UI {
@ -914,7 +915,7 @@ namespace SourceGit.UI {
} }
} }
private void Commit(object sender, RoutedEventArgs e) { private async void Commit(object sender, RoutedEventArgs e) {
foreach (var c in UnstagedListData) { foreach (var c in UnstagedListData) {
if (c.IsConflit) { if (c.IsConflit) {
App.RaiseError("You have unsolved conflicts in your working copy!"); App.RaiseError("You have unsolved conflicts in your working copy!");
@ -933,10 +934,15 @@ namespace SourceGit.UI {
txtCommitMsg.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtCommitMsg.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtCommitMsg)) return; if (Validation.GetHasError(txtCommitMsg)) return;
Waiting.Show(Repo, "Text.Waiting.Commit", () => { DoubleAnimation anim = new DoubleAnimation(0, 360, TimeSpan.FromSeconds(1));
bool succ = Repo.DoCommit(CommitMessage, amend); anim.RepeatBehavior = RepeatBehavior.Forever;
if (succ) Dispatcher.Invoke(ClearMessage); iconCommiting.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, anim);
}); iconCommiting.Visibility = Visibility.Visible;
bool succ = await Task.Run(() => Repo.DoCommit(CommitMessage, amend));
if (succ) Dispatcher.Invoke(ClearMessage);
iconCommiting.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
iconCommiting.Visibility = Visibility.Collapsed;
} }
private async void CommitAndPush(object sender, RoutedEventArgs e) { private async void CommitAndPush(object sender, RoutedEventArgs e) {