feature<SaveAsPatch>: show notification after saving patch successfully

This commit is contained in:
leo 2023-08-24 16:20:38 +08:00
parent a1bfbfe02e
commit 0a7a0bff42
8 changed files with 28 additions and 10 deletions

View file

@ -15,6 +15,7 @@
<sys:String x:Key="Text.Filter">FILTER</sys:String>
<sys:String x:Key="Text.Optional">Optional.</sys:String>
<sys:String x:Key="Text.OpenFolder">SELECT FOLDER</sys:String>
<sys:String x:Key="Text.Notice">NOTICE</sys:String>
<sys:String x:Key="Text.URL">URL :</sys:String>
<sys:String x:Key="Text.RepositoryURL">Git Repository URL</sys:String>
@ -536,4 +537,5 @@
<sys:String x:Key="Text.Required">This field is required</sys:String>
<sys:String x:Key="Text.ConfirmRemoveRepo">You are removing repository '{0}'. Are you sure to continue?</sys:String>
<sys:String x:Key="Text.ConfirmClearStashes">You are trying to clear all stashes. Are you sure to continue?</sys:String>
<sys:String x:Key="Text.SaveAsPatchSuccess">Patch has been saved successfully!</sys:String>
</ResourceDictionary>

View file

@ -14,6 +14,7 @@
<sys:String x:Key="Text.Filter">过滤</sys:String>
<sys:String x:Key="Text.Optional">选填</sys:String>
<sys:String x:Key="Text.OpenFolder">选择文件夹</sys:String>
<sys:String x:Key="Text.Notice">系统提示</sys:String>
<sys:String x:Key="Text.URL">仓库地址 </sys:String>
<sys:String x:Key="Text.RepositoryURL">远程仓库地址</sys:String>
@ -535,4 +536,5 @@
<sys:String x:Key="Text.Required">内容未填写!</sys:String>
<sys:String x:Key="Text.ConfirmRemoveRepo">正在将 '{0}' 从列表中移除,是否要继续?</sys:String>
<sys:String x:Key="Text.ConfirmClearStashes">您正在丢弃所有的贮藏,一经操作,无法回退,是否继续?</sys:String>
<sys:String x:Key="Text.SaveAsPatchSuccess">补丁已成功保存!</sys:String>
</ResourceDictionary>

View file

@ -6,11 +6,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
mc:Ignorable="d"
WindowStartupLocation="CenterOwner"
Width="500" SizeToContent="Height"
ResizeMode="NoResize">
ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
@ -61,7 +60,6 @@
<TextBlock
Grid.Row="0" Grid.Column="0"
x:Name="txtMessage"
Text="{DynamicResource Text.Clone.RemoteURL}"
Margin="8, 16"
HorizontalAlignment="Center"
TextWrapping="Wrap"/>
@ -72,7 +70,7 @@
Orientation="Horizontal"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Click="OnSure" Width="80" Content="{DynamicResource Text.Sure}" FontWeight="Bold"/>
<Button Click="OnQuit" Width="80" Margin="8,0,0,0" Content="{DynamicResource Text.Cancel}" FontWeight="Bold"/>
<Button x:Name="btnCancel" Click="OnQuit" Width="80" Margin="8,0,0,0" Content="{DynamicResource Text.Cancel}" FontWeight="Bold"/>
</StackPanel>
</Grid>
</Grid>

View file

@ -10,14 +10,30 @@ namespace SourceGit.Views {
private Action cbOK;
private Action cbCancel;
public ConfirmDialog(string title, string message) {
Owner = App.Current.MainWindow;
cbOK = null;
cbCancel = null;
InitializeComponent();
txtTitle.Text = title;
txtMessage.Text = message;
btnCancel.Visibility = Visibility.Collapsed;
}
public ConfirmDialog(string title, string message, Action onOk, Action onCancel = null) {
Owner = App.Current.MainWindow;
cbOK = onOk;
cbCancel = onCancel;
InitializeComponent();
txtTitle.Text = title;
txtMessage.Text = message;
cbOK = onOk;
cbCancel = onCancel;
btnCancel.Visibility = Visibility.Visible;
}
private void OnSure(object sender, RoutedEventArgs e) {

View file

@ -373,6 +373,7 @@ namespace SourceGit.Views.Widgets {
dialog.ShowNewFolderButton = true;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
new Commands.FormatPatch(repo.Path, commit.SHA, dialog.SelectedPath).Exec();
new ConfirmDialog(App.Text("Notice"), App.Text("SaveAsPatchSuccess")).ShowDialog();
}
};
menu.Items.Add(saveToPatch);

View file

@ -43,8 +43,6 @@ namespace SourceGit.Views.Widgets {
waiting.Visibility = Visibility.Collapsed;
waiting.IsAnimating = false;
});
confirmDialog.Owner = App.Current.MainWindow;
confirmDialog.ShowDialog();
e.Handled = true;
}

View file

@ -107,7 +107,6 @@ namespace SourceGit.Views.Widgets {
Models.Preference.Instance.RemoveRepository(repo.Path);
UpdateVisibles();
});
confirmDialog.Owner = App.Current.MainWindow;
confirmDialog.ShowDialog();
e.Handled = true;
}

View file

@ -396,6 +396,8 @@ namespace SourceGit.Views.Widgets {
stream.Flush();
writer.Close();
stream.Close();
new ConfirmDialog(App.Text("Notice"), App.Text("SaveAsPatchSuccess")).ShowDialog();
}
private void OpenUnstagedContextMenuByNodes(ContextMenu menu, List<ChangeNode> nodes, List<Models.Change> changes) {