Skip to content

Commit

Permalink
Restart function fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 27, 2024
1 parent 873a945 commit fc22406
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/PicView.Avalonia/UI/FunctionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public static Task<Func<Task>> GetFunctionByName(string functionName)
"GalleryClick" => GalleryClick,
"Slideshow" => Slideshow,
"ColorPicker" => ColorPicker,
"Restart" => Restart,

_ => null
});
Expand Down Expand Up @@ -1046,7 +1047,32 @@ public static async Task ResetSettings()

public static async Task Restart()
{
ProcessHelper.RestartApp(Environment.GetCommandLineArgs()?.ToString());
var openFile = string.Empty;
var getFromArgs = false;
if (Vm?.FileInfo is not null)
{
if (Vm.FileInfo.Exists)
{
openFile = Vm.FileInfo.FullName;
}
else
{
getFromArgs = true;
}
}
else
{
getFromArgs = true;
}
if (getFromArgs)
{
var args = Environment.GetCommandLineArgs();
if (args is not null && args.Length > 0)
{
openFile = args[1];
}
}
ProcessHelper.RestartApp(openFile);

if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
{
Expand Down

0 comments on commit fc22406

Please sign in to comment.