54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using CaeGlobals;
|
|
using System;
|
|
using System.IO;
|
|
#pragma warning disable IDE0130
|
|
|
|
|
|
namespace CPSO.Commands
|
|
{
|
|
[Serializable]
|
|
class COpenFile : PreprocessCommand, IFileCommand, ICommandWithDialog
|
|
{
|
|
// Variables
|
|
private string _fileName;
|
|
private string _parameters;
|
|
|
|
// Properties
|
|
public string FileName
|
|
{
|
|
get => _fileName;
|
|
set => _fileName = value;
|
|
}
|
|
public string FileExtension => Path.GetExtension(_fileName).ToLower();
|
|
|
|
|
|
// Constructor
|
|
public COpenFile(string fileName, string parameters)
|
|
: base("Open file")
|
|
{
|
|
_fileName = Tools.GetLocalPath(fileName);
|
|
_parameters = parameters;
|
|
}
|
|
|
|
// Methods
|
|
public override bool Execute(Controller receiver)
|
|
{
|
|
receiver.Open(Tools.GetGlobalPath(_fileName), _parameters);
|
|
return true;
|
|
}
|
|
|
|
// ICommandWithDialog
|
|
public bool ExecuteWithDialog(Controller receiver)
|
|
{
|
|
string fileName = receiver.GetFileNameToOpen();
|
|
if (fileName != null) _fileName = Tools.GetLocalPath(fileName);
|
|
return Execute(receiver);
|
|
}
|
|
|
|
public override string GetCommandString()
|
|
{
|
|
return base.GetCommandString() + _fileName;
|
|
}
|
|
}
|
|
}
|