Skip to content

Commit fc22406

Browse files
committed
Restart function fixes
1 parent 873a945 commit fc22406

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/PicView.Avalonia/UI/FunctionsHelper.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public static Task<Func<Task>> GetFunctionByName(string functionName)
140140
"GalleryClick" => GalleryClick,
141141
"Slideshow" => Slideshow,
142142
"ColorPicker" => ColorPicker,
143+
"Restart" => Restart,
143144

144145
_ => null
145146
});
@@ -1046,7 +1047,32 @@ public static async Task ResetSettings()
10461047

10471048
public static async Task Restart()
10481049
{
1049-
ProcessHelper.RestartApp(Environment.GetCommandLineArgs()?.ToString());
1050+
var openFile = string.Empty;
1051+
var getFromArgs = false;
1052+
if (Vm?.FileInfo is not null)
1053+
{
1054+
if (Vm.FileInfo.Exists)
1055+
{
1056+
openFile = Vm.FileInfo.FullName;
1057+
}
1058+
else
1059+
{
1060+
getFromArgs = true;
1061+
}
1062+
}
1063+
else
1064+
{
1065+
getFromArgs = true;
1066+
}
1067+
if (getFromArgs)
1068+
{
1069+
var args = Environment.GetCommandLineArgs();
1070+
if (args is not null && args.Length > 0)
1071+
{
1072+
openFile = args[1];
1073+
}
1074+
}
1075+
ProcessHelper.RestartApp(openFile);
10501076

10511077
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
10521078
{

0 commit comments

Comments
 (0)