Translate

Adroit Newsletter

Sign up now for the latest news and updates in Adroit

Scripts Print E-mail
1. How do I open a graphic form from a Script Engine spider?

Answer:
This contains the necessary code that opens a graphic form from a Script Engine spider.
Please note that the input variable (“var 1”) needs to contain a fully qualified graphic form name.

____________________________________________________________________________ Cut Start

//.NET Namespaces:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;

//VIZNET Namespaces:
using VIZNET.Shared.Interfaces;
using VIZNET.Shared.DataElements;
using VIZNET.Shared.DataElements.Engine;
using VIZNET.Shared.DataElements.Collections;
using VIZNET.Shared.Helpers;
using VIZNET.Shared.Interfaces.UI;
using VIZNET.Shared.Interfaces.Script;

namespace VIZNET.Scripting
{
public class Script : ICodeProviderScript, INeedConnection, INeedApplication, INeedGraphicObject, INeedSpiderInfo
{
private IConnection MyConnection = null;
private IObjectManager MyApplication = null;
private INeedController MyController = null;
private Control MyGraphicObject = null;

private Hashtable MyInputs = null;
private Hashtable MyOutputs = null;

//entry point for script engine
public void Main()
{

//var 1 is the fully qualified GF Name (as an example)
DataElement __deGFName = MyInputs["var 1"] as DataElement;
if (__deGFName.Value!=null)
{
string __gfName = __deGFName.Value.ToString();

//do the read from the server
MethodReturnInfo __mri = MyConnection.ReadDataElements( new string[] { __gfName } );
if (__mri.Success == true )
{
DataElementCollection __dec = __mri.ReturnObject as DataElementCollection;
if(__dec != null)
{
IGraphicObject igo = __dec.GetElementByKeyValue(__gfName).Value as IGraphicObject;
MyApplication.OpenGraphicObject(igo, GraphicObjectDialogType.Replace);
}
}
}

}


#region VIZNET Generated Code

#region IHost Members
//INeedApplication Members
public IObjectManager Application
{
get {return MyApplication;}
set {MyApplication=value;}
}

//INeedConnection Members
public IConnection Connection
{
get {return MyConnection;}
set {MyConnection=value;}
}

//INeedGraphicObject Members
public System.Windows.Forms.Control Control
{
get {return MyGraphicObject;}
set {MyGraphicObject=value;}
}

public VIZNET.Shared.Interfaces.INeedController Controller
{
get { return MyController; }
set { MyController = value; }
}

//INeedSpiderInfo Members
public Hashtable Inputs
{
get { return MyInputs; }
set { MyInputs = value; }
}
public Hashtable Outputs
{
get { return MyOutputs; }
set { MyOutputs = value; }
}
#endregion


#endregion
}
}

____________________________________________________________________________ Cut End