private static void InitJS(Form f, FlowLayoutPanel layout) { engine.AddGlobal(); engine.Add("alert", new Func <string, DialogResult>(MessageBox.Show)); engine.Add("prompt", new Func <string, string>(s => Interaction.InputBox(s))); engine.Add("createObj", new Func <string, object>(Functions.CreateObj)); engine.Add("require", new Action <string>(s => Functions.Require(engine, s))); engine.Add("import", new Func <string, string, object[], object>(Functions.Import)); engine.Add("window", new Window(f)); engine.Add("document", new Base.JS.ScriptingTypes.Document(doc, layout)); engine.Add("host", new ExtendedHostFunctions()); engine.Add("clr", new HostTypeCollection("System", "System.Core", "System.Drawing", "System.Windows.Forms")); engine.Add("XMLHttpRequest", typeof(XmlHttpRequest)); engine.Add("Extensions", typeof(Extensions)); engine.Add("Object", typeof(Object)); engine.Add("JSON", new JSON()); engine.Add("Math", new Math()); engine.Add("screen", new Screen()); engine.Add("console", new FirebugConsole()); engine.Add("escape", new Func <string, string>(GlobalObject.escape)); engine.Add("unescape", new Func <string, string>(GlobalObject.unescape)); engine.Add("parseFloat", new Func <string, float>(float.Parse)); engine.Add("parseInt", new Func <string, int>(int.Parse)); engine.Add("String", new Func <string, string>(s => s.toString())); engine.Add("setCursor", new Action <Cursor>(c => f.Cursor = c)); engine.Add("cursors", typeof(Cursors)); engine.Add("$", new DollarSignFunc((arg1, arg2) => { var name = arg1 as string; if (name == null) { new Window(f).AddEventHandler("Load", arg1); } else if (arg2 != null) { new Window(f).AddEventHandler(name, arg2); } else { return (new Base.JS.ScriptingTypes.Document(doc, layout) .GetElementById(name)); } return(new PlaceholderTextBox()); })); engine.Add("ui", new Func <object, Control>(o => (Control)o)); engine.Add("color", new Func <string, Color>(s => new Base.CSS.Converters.ColorConverter().Convert(s))); engine.Add("eval", new Func <string, object>( o => engine.Evaluate(o))); engine.Add("Transition", typeof(Transition)); engine.Add(new[] { new KeyValuePair <string, Type>("bounce", typeof(TransitionType_Bounce)), new KeyValuePair <string, Type>("linear", typeof(TransitionType_Linear)), new KeyValuePair <string, Type>("ease_inout", typeof(TransitionType_EaseInEaseOut)) }); //engine.Add("Iterator", new Func<object[], Iterator>(objects => )); }