41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using JD.SceneExplorer.ViewModels;
|
|
using JD.WPF.Commands;
|
|
|
|
namespace SceneExplorer.Commands
|
|
{
|
|
public class GoToFileCommand : BaseCommand
|
|
{
|
|
public override bool CanExecute(object parameter)
|
|
{
|
|
if (parameter != null)
|
|
{
|
|
var selectionList = parameter as ObjectWithRef;
|
|
if (selectionList == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!System.IO.File.Exists(selectionList.FilePath))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void Execute(object parameter)
|
|
{
|
|
var model = parameter as ObjectWithRef;
|
|
if (model != null)
|
|
{
|
|
if (!System.IO.File.Exists(model.FilePath))
|
|
return;
|
|
|
|
System.Diagnostics.ProcessStartInfo pfi = new System.Diagnostics.ProcessStartInfo("Explorer.exe",
|
|
$"/Select, \"{model.FilePath.Replace('/', '\\')}\"");
|
|
System.Diagnostics.Process.Start(pfi);
|
|
}
|
|
}
|
|
}
|
|
}
|