JD2022-TU1/main/tools/apps/ConfigurePlus/Commands/StartTechnoCommand.cs

61 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using UAF.Application;
using UAF.WPF.Commands;
using ConfigurePlus.Models;
namespace ConfigurePlus.Commands
{
public class StartTechnoCommand : BaseCommand
{
public override bool CanExecute(object parameter)
{
MainViewModel mainModel = Workspace.This.FirstDocument as MainViewModel;
if (mainModel != null)
{
if (mainModel.SelectedProject != null)
{
if (mainModel.SelectedProject.DataPath != null && mainModel.SelectedProject.EnginePath != null)
{
return true;
}
}
}
return false;
}
public override void Execute(object parameter)
{
MainViewModel mainModel = Workspace.This.FirstDocument as MainViewModel;
if (mainModel != null)
{
if (mainModel.SelectedProject != null)
{
if (mainModel.SelectedProject.DataPath != null && mainModel.SelectedProject.EnginePath != null)
{
string processFileName = mainModel.SelectedProject.EnginePath;
if(mainModel.SelectedProject.EngineStartMode == EngineStartMode.UA_Engine)
processFileName += "\\UA_Bin\\UA_Engine.exe";
else if(mainModel.SelectedProject.EngineStartMode == EngineStartMode.UA_Framework)
processFileName += "\\UA_Bin\\UA_Framework.exe";
else
throw new InvalidOperationException("Unrecognized start mode. ");
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.FileName = processFileName;
processStartInfo.Arguments = "root=" + mainModel.SelectedProject.DataPath;
Process.Start(processStartInfo);
}
}
}
}
}
}