public Colors(ScriptEngine engine) : base(engine) { engine.SetGlobalValue("Color", new ColorConstructor(engine)); foreach (string key in _colorSet.Keys) { ColorInstance instance = new ColorInstance(engine, key, _colorSet[key]); this.DefineProperty(key, new PropertyDescriptor(instance, PropertyAttributes.Enumerable | PropertyAttributes.Sealed), false); } }
internal void addChat(ArrayInstance chatNodes) { List <ChatNode> result = new List <ChatNode>(); for (int i = 0; i < chatNodes.Length; i++) { ObjectInstance obj = chatNodes[i] as ObjectInstance; if (obj == null) { continue; } string str = obj.GetPropertyValue("text") as string; object oTxt = obj.GetPropertyValue("text"); if (oTxt == null) { continue; } str = oTxt.ToString(); ColorInstance color = obj.GetPropertyValue("color") as ColorInstance; string cssClass = obj.GetPropertyValue("cssClass") as string; if (str == null) { continue; } else if (color == null && cssClass == null) { continue; } ChatNode node; if (color == null) { node = new ChatNode(str, cssClass); } else { node = new ChatNode(str, Color.FromArgb(255, color.R, color.G, color.B)); } result.Add(node); } try { _client.MainWindow.AddChat(result); } catch (Exception ex) { throw new JavaScriptException(_engine, ex.GetType().Name, ex.Message); } }