public override Form CreateForm(object value)
        {
            string scriptName = (string) value;

            script = null;
            wasGenerated = false;

            // Open the script this property is referencing.
            if (scriptName.Length > 0)
                script = EditorControl.World.GetScript(scriptName);

            // If it is null, create a new hidden script.
            if (script == null) {
                script = EditorControl.GenerateInternalScript();
                wasGenerated = true;

                if (PropertyGrid.PropertyObject is IEventObject) {
                    ObjectEvent e = ((IEventObject) PropertyGrid.PropertyObject).Events.GetEvent(property.Name);
                    if (e != null)
                        script.Parameters = e.Parameters;
                }
            }

            // Open the scrpit editor form.
            ScriptEditor form = new ScriptEditor(script, EditorControl);
            return form;
        }
Exemplo n.º 2
0
 public override void Open(EditorControl editorControl)
 {
     using (ScriptEditor form = new ScriptEditor(script, editorControl)) {
         if (form.ShowDialog(editorControl.EditorForm) == DialogResult.OK) {
             editorControl.RefreshWorldTreeView();
         }
     }
 }
Exemplo n.º 3
0
        // Create Script...
        private void buttonAddScript_Click(object sender, EventArgs e)
        {
            Script script = new Script();
            script.Name = "untitled";
            script.Code = "";
            worldTreeView.RefreshScripts();
            editorControl.AddScript(script);

            using (ScriptEditor form = new ScriptEditor(script, editorControl)) {
                if (form.ShowDialog(this) == DialogResult.OK) {
                }
                else {
                    editorControl.World.RemoveScript(script);
                }

                worldTreeView.RefreshScripts();
            }
        }
        // Button: Edit Script.
        private void buttonEditScript_Click(object sender, EventArgs e)
        {
            Script script = objectEvent.ReferencedScript;

            if (script != null) {
                using (ScriptEditor form = new ScriptEditor(script, EditorControl)) {
                    if (form.ShowDialog(EditorControl.EditorForm) == DialogResult.OK) {

                    }
                    else {

                    }
                }
            }
            else {
                MessageBox.Show("The script '" + comboBoxScript.Text +
                    "' doesn't exist.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        // Button: Edit Code.
        private void buttonEditCode_Click(object sender, EventArgs e)
        {
            // Create a custom script if it is null.
            if (objectEvent.CustomScript == null) {
                objectEvent.CustomScript = new Script();
                if (objectEvent.Event != null) {
                    objectEvent.CustomScript.Parameters = objectEvent.Event.Parameters;
                    objectEvent.CustomScript.Code = "// Parameters = (";
                    for (int i = 0; i < objectEvent.CustomScript.Parameters.Count; i++) {
                        if (i > 0)
                            objectEvent.CustomScript.Code += ", ";
                        objectEvent.CustomScript.Code +=
                                objectEvent.CustomScript.Parameters[i].Type + " " +
                                objectEvent.CustomScript.Parameters[i].Name;
                    }
                    objectEvent.CustomScript.Code += ")\n";
                }
            }

            // Open the script editor.
            using (ScriptEditor form = new ScriptEditor(objectEvent.CustomScript, EditorControl)) {
                if (form.ShowDialog(EditorControl.EditorForm) == DialogResult.OK) {

                }
            }
        }