code_review: PR #1314

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-16 09:44:36 +08:00
parent 85b223a3d0
commit e4490d87dc
No known key found for this signature in database

View file

@ -107,18 +107,24 @@ namespace SourceGit
#region Utility Functions #region Utility Functions
public static void ShowWindow(object data, bool showAsDialog) public static void ShowWindow(object data, bool showAsDialog)
{ {
if (data is Views.ChromelessWindow window) var impl = (Views.ChromelessWindow target, bool isDialog) =>
{ {
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner }) if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
{ {
if (showAsDialog) if (isDialog)
window.ShowDialog(owner); target.ShowDialog(owner);
else else
window.Show(owner); target.Show(owner);
} }
else else
window.Show(); {
target.Show();
}
};
if (data is Views.ChromelessWindow window)
{
impl(window, showAsDialog);
return; return;
} }
@ -135,10 +141,7 @@ namespace SourceGit
if (window != null) if (window != null)
{ {
window.DataContext = data; window.DataContext = data;
if (showAsDialog && Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner }) impl(window, showAsDialog);
window.ShowDialog(owner);
else
window.Show();
} }
} }