Class ScriptEditControl
Script Engine control. Support writing multi-language script.
Inheritance
Namespace: Syncfusion.Scripting.Design
Assembly: Syncfusion.Scripting.Windows.dll
Syntax
public class ScriptEditControl : UserControl
Constructors
ScriptEditControl()
Provides a user control host for editing multi-language scripts with object browser integration.
Declaration
public ScriptEditControl()
Fields
assemblyDirectives
Holds assembly directive text (e.g., using/imports) for the script.
Declaration
protected string assemblyDirectives
Field Value
| Type |
|---|
| System.String |
bExternalCompile
Indicates whether compilation is delegated to an external manager.
Declaration
protected bool bExternalCompile
Field Value
| Type |
|---|
| System.Boolean |
bExternalRun
Indicates whether execution is delegated to an external manager.
Declaration
protected bool bExternalRun
Field Value
| Type |
|---|
| System.Boolean |
bPendingSave
Tracks whether the editor has unsaved changes.
Declaration
protected bool bPendingSave
Field Value
| Type |
|---|
| System.Boolean |
globalCode
Global code snippet injected into the generated script.
Declaration
protected string globalCode
Field Value
| Type |
|---|
| System.String |
nameSpaceDefine
Defines the namespace for the generated script code.
Declaration
protected string nameSpaceDefine
Field Value
| Type |
|---|
| System.String |
scriptManager
Scripting manager responsible for compiling and running scripts.
Declaration
protected ScriptingManager scriptManager
Field Value
| Type |
|---|
| ScriptingManager |
strScriptStart
Script initialization code inserted into the wrapper’s start section.
Declaration
protected string strScriptStart
Field Value
| Type |
|---|
| System.String |
strScriptStop
Script cleanup code inserted into the wrapper’s stop section.
Declaration
protected string strScriptStop
Field Value
| Type |
|---|
| System.String |
Properties
AssemblyReferences
Gets the collection of assembly reference paths configured for the script.
Declaration
public string[] AssemblyReferences { get; }
Property Value
| Type |
|---|
| System.String[] |
BaseClass
Gets the base class type used when generating wrapper code for the script.
Declaration
public Type BaseClass { get; }
Property Value
| Type |
|---|
| System.Type |
EnableExternalCompile
Indicates if the ScriptingManager is being used for external compilation of the script.
Declaration
public bool EnableExternalCompile { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
EnableExternalRun
Gets or sets a value indicating whether running the script is handled externally. Enabling this option also enables external compilation.
Declaration
public bool EnableExternalRun { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
EntryPoint
Gets or sets the entry point method name to invoke when running the script.
Declaration
public string EntryPoint { get; set; }
Property Value
| Type |
|---|
| System.String |
PendingSave
Gets a value indicating whether the editor contains unsaved changes.
Declaration
public bool PendingSave { get; }
Property Value
| Type |
|---|
| System.Boolean |
RootMoniker
Gets or sets the root moniker that uniquely identifies the script instance.
Declaration
public string RootMoniker { get; set; }
Property Value
| Type |
|---|
| System.String |
RootNamespace
Gets or sets the root namespace to use in generated wrapper code.
Declaration
public string RootNamespace { get; set; }
Property Value
| Type |
|---|
| System.String |
Script
Gets or sets the Script object that contains the source and its metadata.
Declaration
public Script Script { get; set; }
Property Value
| Type |
|---|
| Script |
ScriptingManager
Gets or sets the scripting manager used to compile and execute scripts.
Declaration
public ScriptingManager ScriptingManager { get; set; }
Property Value
| Type |
|---|
| ScriptingManager |
ScriptLanguage
Gets or sets the scripting language used by the editor.
Declaration
public ScriptLanguages ScriptLanguage { get; set; }
Property Value
| Type |
|---|
| ScriptLanguages |
ScriptName
Gets or sets the display name of the script.
Declaration
public string ScriptName { get; set; }
Property Value
| Type |
|---|
| System.String |
ScriptText
Gets or sets script source code.
Declaration
public string ScriptText { get; set; }
Property Value
| Type |
|---|
| System.String |
SelectedItem
Gets or sets the currently selected scriptable object in the object browser.
Declaration
public ScriptObject SelectedItem { get; set; }
Property Value
| Type |
|---|
| ScriptObject |
Methods
AddAssemblyReference(String)
Adds the assembly to the list of referenced assemblies.
Declaration
public void AddAssemblyReference(string assembly)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | assembly | New assembly to reference. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | When assembly is null. |
AddScriptableObject(ScriptObject)
Adds a scriptable object to the object browser and exposes it to the script.
Declaration
public void AddScriptableObject(ScriptObject scriptableitem)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptObject | scriptableitem | The object to expose to the script. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
ClearAssemblyReferences()
Removes all assembly references from the list.
Declaration
public void ClearAssemblyReferences()
CompileScript()
Compiles the current script using the configured scripting manager.
Declaration
public bool CompileScript()
Returns
| Type | Description |
|---|---|
| System.Boolean | True if compilation succeeded; otherwise, false. |
Dispose(Boolean)
Initializes a new instance of the ScriptEditControl class.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing | True to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetFileDialogFilter(ScriptLanguages)
Gets a file dialog filter string that matches the specified scripting language.
Declaration
protected virtual string GetFileDialogFilter(ScriptLanguages language)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The scripting language. |
Returns
| Type | Description |
|---|---|
| System.String | A filter string for selecting files of that language. |
InitializeScriptEditor(Script)
Loads the specified script into the editor.
Declaration
public virtual void InitializeScriptEditor(Script script)
Parameters
| Type | Name | Description |
|---|---|---|
| Script | script | The script to load. |
InitializeScriptEditor(ScriptingManager)
Associates the editor with the specified scripting manager and loads its script.
Declaration
public void InitializeScriptEditor(ScriptingManager scriptmanager)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptingManager | scriptmanager | The scripting manager to use. |
New()
Creates a new blank script document in the editor.
Declaration
public void New()
ObjectBrowser_NodeDoubleClick(Object, NodeDoubleClickEventArgs)
Handles double-clicks in the object browser to insert event handler code.
Declaration
public void ObjectBrowser_NodeDoubleClick(object sender, NodeDoubleClickEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The event source. |
| NodeDoubleClickEventArgs | e | Information about the double-clicked node. |
OnLanguageChange(ScriptLanguages)
Called when the scripting language changes to update the editor configuration and defaults.
Declaration
protected virtual void OnLanguageChange(ScriptLanguages language)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The new scripting language. |
OnScriptChange()
Called when the script text changes to synchronize the editor view.
Declaration
protected virtual void OnScriptChange()
OpenFile()
Opens a script file from disk and loads it into the editor.
Declaration
public void OpenFile()
RemoveScriptableObject(ScriptObject)
Removes a previously added scriptable object from the editor.
Declaration
public void RemoveScriptableObject(ScriptObject scriptableitem)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptObject | scriptableitem | The object to remove. |
RunScript()
Runs the compiled script using the external scripting manager.
Declaration
public void RunScript()
SaveToFile()
Saves the current script to disk as source code or as an Essential Suite Scripting (.ess) file.
Declaration
public void SaveToFile()
scriptingManager_CompileError(Object, VsaErrorEventArgs)
Handles compile errors raised by the scripting manager and populates the error list.
Declaration
protected void scriptingManager_CompileError(object sender, VsaErrorEventArgs eventargs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The event source. |
| VsaErrorEventArgs | eventargs | The error data provided by the scripting manager. |
SetCompileButtonsState()
Updates the enabled state of the compile-related buttons based on the current configuration.
Declaration
protected void SetCompileButtonsState()
StopScript()
Stops the running script and resets the scripting engine.
Declaration
public void StopScript()
UpdateScript(Script)
Updates the provided script instance with the current values from the editor.
Declaration
public void UpdateScript(Script script)
Parameters
| Type | Name | Description |
|---|---|---|
| Script | script | The script to update. |
Events
ScriptChanged
Send when script is changed.
Declaration
public event EventHandler ScriptChanged
Event Type
| Type |
|---|
| System.EventHandler |