I have initial a Statement by inheriting ‘CustomStatementBase’, however I can’t find any way to set its icon, sentence content and replaceable parameter.
code:
public class VisibleControllerStatement : CustomStatementBase{
////throw exception
//public string Name
//{
// get { return Name; }
// set { Name = value; }
//}
public VisibleControllerStatement()
{
////can't work and throw exception
//Name = "VisibleChanged";
//Statement.Name += "ForVisibleChanged";
//Statement.CreateProperty(typeof(string), PropertyConstraintType.AllValuesAllowed, "ComponentList");//, statement.GetProperty("TargetProperty")
//Statement.CreateProperty(typeof(bool), PropertyConstraintType.AllValuesAllowed, "Visible");
}
public override void Execute(IExecutor executor)
{
var componentArray = Statement.GetProperty("ComponentList").Value.ToString().Split(',');
foreach (var componentName in componentArray)
{
var componentModel = IoC.Get<IApplication>().World.Components.FirstOrDefault(x => x.Name == componentName);
if (componentModel != null)
{
componentModel.IsVisible = Convert.ToBoolean(Statement.GetProperty("Visible").Value);
}
}
executor.Continue();
}
public override void ExecuteImmediate(IExecutor executor)
{
}
}
Execute(){
var statement = IoC.Get<ITeachContext>().ActiveScope.AddStatement<VisibleControllerStatement>(IoC.Get<ITeachContext>().ActiveStatementIndex + 1);//ISetPropertyStatement
}