Code: Select all
using Neo.ApplicationFramework.Generated;
using System.Reflection;
Code: Select all
// returns null if tag not found
public GlobalDataItem StringToTag(string tagName)
{
string typeName = (new GlobalDataItem()).GetType().Name;
PropertyInfo[] props = Globals.Tags.GetType().GetProperties();
foreach (PropertyInfo prop in props) {
if (prop.PropertyType.Name.Equals(typeName)) {
if (prop.Name.Equals(tagName, StringComparison.CurrentCultureIgnoreCase)) {
return (GlobalDataItem)prop.GetValue(Globals.Tags, null);
}
}
}
return null;
}
Code: Select all
private static IScreenAdapter StringToScreen(string name)
{
Type globalType = typeof(Globals);
Type iAdaptType = typeof(IScreenAdapter);
foreach (var p in globalType.GetProperties())
{
if (p.PropertyType.Name.Equals(iAdaptType.Name) &&
p.Name.Equals(name))
{
return (IScreenAdapter)p.GetValue(globalType, null);
}
}
return null;
}
Code: Select all
//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
using Neo.ApplicationFramework.Generated;
using System.Reflection;
public partial class ScriptModule1
{
public static void ShowScreen(string name)
{
IScreenAdapter scrn = StringToScreen(name);
if (scrn == null) {
return;
}
scrn.Show();
}
private static IScreenAdapter StringToScreen(string name)
{
Type globalType = typeof(Globals);
Type iAdaptType = typeof(IScreenAdapter);
foreach (var p in globalType.GetProperties())
{
if (p.PropertyType.Name.Equals(iAdaptType.Name) &&
p.Name.Equals(name))
{
return (IScreenAdapter)p.GetValue(globalType, null);
}
}
return null;
}
}
}
Code: Select all
ScriptModule1.ShowScreen("Screen2");