55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using CaeGlobals;
|
|
using System;
|
|
#pragma warning disable IDE0130
|
|
|
|
namespace CPSO.Commands
|
|
{
|
|
[Serializable]
|
|
class CImportFile : PreprocessCommand, IImportFileCommand, ICommandWithDialog
|
|
{
|
|
// Variables
|
|
private string _fileName;
|
|
private bool _onlyMaterials;
|
|
|
|
// Properties
|
|
public string FileName
|
|
{
|
|
get => _fileName;
|
|
set => _fileName = value;
|
|
}
|
|
public bool OnlyMaterials => _onlyMaterials;
|
|
|
|
// Constructor
|
|
public CImportFile(string fileName, bool onlyMaterials)
|
|
: base("Import file")
|
|
{
|
|
_fileName = Tools.GetLocalPath(fileName);
|
|
_onlyMaterials = onlyMaterials;
|
|
}
|
|
|
|
// Methods
|
|
public override bool Execute(Controller receiver)
|
|
{
|
|
receiver.ImportFile(Tools.GetGlobalPath(_fileName), _onlyMaterials);
|
|
return true;
|
|
}
|
|
|
|
// ICommandWithDialog
|
|
public bool ExecuteWithDialog(Controller receiver)
|
|
{
|
|
string fileName = receiver.GetFileNameToImport(_onlyMaterials);
|
|
if (fileName != null)
|
|
{
|
|
_fileName = Tools.GetLocalPath(fileName);
|
|
}
|
|
|
|
return Execute(receiver);
|
|
}
|
|
|
|
public override string GetCommandString()
|
|
{
|
|
return base.GetCommandString() + _fileName;
|
|
}
|
|
}
|
|
}
|