i am trying to built a user interface using C# ,so i tried to convert a VB Script code to C# and the code was this :
- Code: Select all
public class GeneratedGui : DotNetScriptGui
{
public GeneratedGui(ZeusContext context) : base(context) {}
//-----------------------------------------
// The User Interface Entry Point
//-----------------------------------------
GuiListBox lstTables;
public override void Setup()
{
// ** UNCOMMENT CODE BELOW TO SEE UI **
if(context.Objects.ContainsKey(\"DnpUtils\"))
{
DnpUtils.ReadInputFromCache(context);
}
ui.Title = \"Generate C# dOOdads\";
ui.Width = 330;
ui.Height = 480;
string sOutputPath;
sOutputPath = \"\";
if(input.Contains(\"defaultOutputPath\"))
sOutputPath =input[\"defaultOutputPath\"].ToString();
ui.AddLabel(\"lblPath\", \"Output file path: \",\"Select the output path.\");
ui.AddTextBox(\"txtPath\", sOutputPath,\"Select the Output Path.\");
ui.AddFilePicker(\"btnPath\", \"Select Path\", \"Select the Output Path.\", \"txtPath\", true);
ui.AddLabel(\"lblNamespace\", \"Namespace: \", \"Provide your objects namespace.\");
ui.AddTextBox(\"txtNamespace\", \"Your.Namespace\", \"Provide your objects namespace.\");
// List Databases in a ComboBox
ui.AddLabel(\"lblDatabases\", \"Select a database:\", \"Select a database in the dropdown below.\");
GuiComboBox cmbDatabases = ui.AddComboBox(\"cmbDatabase\", \"Select a database.\");
// List Tables in a listbox
ui.AddLabel(\"lblTables\", \"Select tables:\", \"Select tables from the listbox below.\");
lstTables = ui.AddListBox (\"lstTables\", \"Select tables:\");
//lstTables.IsMultiSelect = false
lstTables.Height = 120;
GuiCheckBox prefix = ui.AddCheckBox(\"prefix\", \"Prefix the 'File' with an underscore?\", false, \"If checked, the file on disk will begin with an underscore\");
GuiCheckBox trimName = ui.AddCheckBox(\"trimName\", \"Trim spaces from output filename?\", false, \"If checked, the file on disk will have spaces trimmed from the name.\");
if(MyMeta.DriverString == \"FIREBIRD\")
{
ui.Height = ui.Height + 20;
GuiCheckBox chk = ui.AddCheckBox(\"ckDialect3\", \"DIALECT 3\", false, \"If checked, the stored procedure will use dialect 3 syntax\");
chk.ForeColor = \"red\";
}
//setupDatabaseDropdown(cmbDatabases);
//cmbDatabases.AttachEvent(\"onchange\", \"cmbDatabases_onchange\");
ui.ShowGui = true;
}
private void setupDatabaseDropdown(GuiComboBox cmbDatabases)
{
cmbDatabases.BindData(MyMeta.Databases);
if(MyMeta.DefaultDatabase!=null)
{
cmbDatabases.SelectedValue=MyMeta.DefaultDatabase.Name;
bindTables(cmbDatabases.SelectedValue);
}
}
private void bindTables(string sDatabase)
{
lstTables.BindData(MyMeta.Databases[\"sDatabase\"].Tables);
}
//Event Handler
//Sub cmbDatabases_onchange(control)
//Set cmbDatabases = ui.item(\"cmbDatabase\")
//bindTables cmbDatabases.SelectedText
//End Sub
but when i try to execute this code i got this error:
ExceptionType:
NullReferenceException
=======
soruce:
DotNetScriptingEngine
=======
Method:
Void EngineExecuteGuiCode(Zeus.IZeusCodeSegment, Zeus.IZeusContext)
=======
Merssage :
Object reference not set to an instance of an object.
=======
Track:
at Zeus.DotNetScript.DotNetScriptExecutioner.EngineExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
at Zeus.ZeusExecutioner.ExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
at Zeus.ZeusExecutioner.ExecuteCodeSegment(IZeusCodeSegment segment, IZeusContext context)
at Zeus.ZeusCodeSegment.Execute(IZeusContext context)
at MyGeneration.TemplateForms.TemplateEditor._Execute()
any1 have any ideas ,please reply me
coz all template smaples has wrietten in JScript and VBScrip
thnx in Advance
