|
| 1 | +using ScriptEngine.HostedScript.Library.Binary; |
| 2 | +using ScriptEngine.HostedScript.Library; |
| 3 | +using ScriptEngine.Machine.Contexts; |
| 4 | +using ScriptEngine.Machine; |
| 5 | +using System.Collections.Concurrent; |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Collections; |
| 8 | +using System.IO; |
| 9 | +using System.Linq; |
| 10 | +using System.Reflection; |
| 11 | +using System.Runtime.InteropServices; |
| 12 | +using System; |
| 13 | + |
| 14 | +namespace osdf |
| 15 | +{ |
| 16 | + [ContextClass("ДфДополнительныйБлок", "DfAdditionalDiv")] |
| 17 | + public class DfAdditionalDiv : AutoContext<DfAdditionalDiv> |
| 18 | + { |
| 19 | + |
| 20 | + public DfAdditionalDiv() |
| 21 | + { |
| 22 | + Name = "d" + Path.GetRandomFileName().Replace(".", ""); |
| 23 | + string strFunc = "createElement(\u0022" + "aside" + "\u0022, \u0022" + Name + "\u0022)"; |
| 24 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 25 | + DeclarativeForms.AddToHashtable(Name, this); |
| 26 | + style = new DfStyle(); |
| 27 | + style.Owner = this; |
| 28 | + } |
| 29 | + |
| 30 | + public PropertyInfo this[string p1] |
| 31 | + { |
| 32 | + get { return this.GetType().GetProperty(p1); } |
| 33 | + } |
| 34 | + |
| 35 | + private int scrollTop; |
| 36 | + [ContextProperty("ВертикальноеПрокручивание", "ScrollTop")] |
| 37 | + public int ScrollTop |
| 38 | + { |
| 39 | + get { return scrollTop; } |
| 40 | + set |
| 41 | + { |
| 42 | + scrollTop = value; |
| 43 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 44 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "scrollTop" + "\u0022, \u0022" + scrollTop + "\u0022)"; |
| 45 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + private int scrollLeft; |
| 50 | + [ContextProperty("ГоризонтальноеПрокручивание", "ScrollLeft")] |
| 51 | + public int ScrollLeft |
| 52 | + { |
| 53 | + get { return scrollLeft; } |
| 54 | + set |
| 55 | + { |
| 56 | + scrollLeft = value; |
| 57 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 58 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "scrollLeft" + "\u0022, \u0022" + scrollLeft + "\u0022)"; |
| 59 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + private string id; |
| 64 | + [ContextProperty("Идентификатор", "Id")] |
| 65 | + public string Id |
| 66 | + { |
| 67 | + get { return id; } |
| 68 | + set |
| 69 | + { |
| 70 | + id = value; |
| 71 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 72 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "id" + "\u0022, \u0022" + id + "\u0022)"; |
| 73 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + private string name; |
| 78 | + [ContextProperty("Имя", "Name")] |
| 79 | + public string Name |
| 80 | + { |
| 81 | + get { return name; } |
| 82 | + set { name = value; } |
| 83 | + } |
| 84 | + |
| 85 | + private string className; |
| 86 | + [ContextProperty("ИмяКласса", "ClassName")] |
| 87 | + public string ClassName |
| 88 | + { |
| 89 | + get { return className; } |
| 90 | + set |
| 91 | + { |
| 92 | + className = value; |
| 93 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 94 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "className" + "\u0022, \u0022" + className + "\u0022)"; |
| 95 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + private string accessKey; |
| 100 | + [ContextProperty("КлавишаДоступа", "AccessKey")] |
| 101 | + public string AccessKey |
| 102 | + { |
| 103 | + get { return accessKey; } |
| 104 | + set |
| 105 | + { |
| 106 | + accessKey = value; |
| 107 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 108 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "accessKey" + "\u0022, \u0022" + accessKey + "\u0022)"; |
| 109 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + private string dir; |
| 114 | + [ContextProperty("Направление", "Dir")] |
| 115 | + public string Dir |
| 116 | + { |
| 117 | + get { return dir; } |
| 118 | + set |
| 119 | + { |
| 120 | + dir = value; |
| 121 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 122 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "dir" + "\u0022, \u0022" + dir + "\u0022)"; |
| 123 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + private int tabIndex; |
| 128 | + [ContextProperty("ПорядокОбхода", "TabIndex")] |
| 129 | + public int TabIndex |
| 130 | + { |
| 131 | + get { return tabIndex; } |
| 132 | + set |
| 133 | + { |
| 134 | + tabIndex = value; |
| 135 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 136 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "tabIndex" + "\u0022, \u0022" + tabIndex + "\u0022)"; |
| 137 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + private bool contentEditable; |
| 142 | + [ContextProperty("Редактируемый", "ContentEditable")] |
| 143 | + public bool ContentEditable |
| 144 | + { |
| 145 | + get { return contentEditable; } |
| 146 | + set |
| 147 | + { |
| 148 | + contentEditable = value; |
| 149 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 150 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "contentEditable" + "\u0022, \u0022" + contentEditable.ToString().ToLower() + "\u0022)"; |
| 151 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + private IValue parent; |
| 156 | + [ContextProperty("Родитель", "Parent")] |
| 157 | + public IValue Parent |
| 158 | + { |
| 159 | + get { return parent; } |
| 160 | + set |
| 161 | + { |
| 162 | + parent = value; |
| 163 | + //setParent(nameElement, nameparent) |
| 164 | + string strFunc = "setParent(\u0022" + Name + "\u0022, \u0022" + parent.AsObject().GetPropValue("Name") + "\u0022)"; |
| 165 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 166 | + // Родителю добавим потомка. |
| 167 | + ArrayImpl ArrayImpl1 = ((dynamic)parent).Children; |
| 168 | + ArrayImpl1.Add(this); |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + private DfStyle style; |
| 173 | + [ContextProperty("Стиль", "Style")] |
| 174 | + public DfStyle Style |
| 175 | + { |
| 176 | + get { return style; } |
| 177 | + set { style.Copy(value); } |
| 178 | + } |
| 179 | + |
| 180 | + private IValue innerText; |
| 181 | + [ContextProperty("Текст", "Text")] |
| 182 | + public IValue Text |
| 183 | + { |
| 184 | + get { return innerText; } |
| 185 | + set |
| 186 | + { |
| 187 | + innerText = value; |
| 188 | + //setProperty(nameElement, nameProperty, valueProperty) |
| 189 | + string str = value.AsString(); |
| 190 | + str = str.Replace("\u005C", @"\u005C"); // Обратная косая черта |
| 191 | + str = str.Replace("\u003B", @"\u003B"); // Точка с запятой. |
| 192 | + str = str.Replace("\u000A", @"\u000A"); // Перевод строки |
| 193 | + str = str.Replace("\u007C", @"\u007C"); // Знак | |
| 194 | + str = str.Replace("\u0022", @"\u0022"); // Кавычки. |
| 195 | + string strFunc = "setProperty(\u0022" + Name + "\u0022, \u0022" + "innerText" + "\u0022, \u0022" + str + "\u0022)"; |
| 196 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 197 | + } |
| 198 | + } |
| 199 | + |
| 200 | + private ArrayImpl children = new ArrayImpl(); |
| 201 | + [ContextProperty("Элементы", "Children")] |
| 202 | + public ArrayImpl Children |
| 203 | + { |
| 204 | + get { return children; } |
| 205 | + } |
| 206 | + |
| 207 | + public DfAction dblclick; |
| 208 | + [ContextProperty("ДвойноеНажатие", "DoubleClick")] |
| 209 | + public DfAction DoubleClick |
| 210 | + { |
| 211 | + get { return dblclick; } |
| 212 | + set |
| 213 | + { |
| 214 | + dblclick = value; |
| 215 | + //map.get(nameElement).addEventListener(nameEvent, doEvent); |
| 216 | + string strFunc = "map.get(\u0022" + Name + "\u0022).addEventListener(\u0022dblclick\u0022, doEvent);"; |
| 217 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + public DfAction click; |
| 222 | + [ContextProperty("Нажатие", "Click")] |
| 223 | + public DfAction Click |
| 224 | + { |
| 225 | + get { return click; } |
| 226 | + set |
| 227 | + { |
| 228 | + click = value; |
| 229 | + //map.get(nameElement).addEventListener(nameEvent, doEvent); |
| 230 | + string strFunc = "map.get(\u0022" + Name + "\u0022).addEventListener(\u0022click\u0022, doEvent);"; |
| 231 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + public DfAction mouseup; |
| 236 | + [ContextProperty("ПриОтпусканииМыши", "MouseUp")] |
| 237 | + public DfAction MouseUp |
| 238 | + { |
| 239 | + get { return mouseup; } |
| 240 | + set |
| 241 | + { |
| 242 | + mouseup = value; |
| 243 | + //map.get(nameElement).addEventListener(nameEvent, doEvent); |
| 244 | + string strFunc = "map.get(\u0022" + Name + "\u0022).addEventListener(\u0022mouseup\u0022, doEvent);"; |
| 245 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 246 | + } |
| 247 | + } |
| 248 | + |
| 249 | + [ContextMethod("ДобавитьДочерний", "АppendChild")] |
| 250 | + public IValue АppendChild(IValue p1) |
| 251 | + { |
| 252 | + string strFunc = "map.get(\u0022" + Name + "\u0022).appendChild(map.get(\u0022" + ((dynamic)p1).Name + "\u0022));"; |
| 253 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 254 | + ((dynamic)p1).Parent = this; |
| 255 | + return p1; |
| 256 | + } |
| 257 | + |
| 258 | + [ContextMethod("ПрокрутитьДо", "ScrollIntoView")] |
| 259 | + public void ScrollIntoView(bool p1 = true) |
| 260 | + { |
| 261 | + string strFunc; |
| 262 | + if (!p1) |
| 263 | + { |
| 264 | + strFunc = "map.get(\u0022" + Name + "\u0022).scrollIntoView(false);"; |
| 265 | + } |
| 266 | + else |
| 267 | + { |
| 268 | + strFunc = "map.get(\u0022" + Name + "\u0022).scrollIntoView();"; |
| 269 | + } |
| 270 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 271 | + } |
| 272 | + |
| 273 | + [ContextMethod("СнятьФокус", "Blur")] |
| 274 | + public void Blur() |
| 275 | + { |
| 276 | + //map.get(nameElement).blur(); |
| 277 | + string strFunc = "map.get(\u0022" + Name + "\u0022).blur();"; |
| 278 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 279 | + } |
| 280 | + |
| 281 | + [ContextMethod("Удалить", "Remove")] |
| 282 | + public void Remove() |
| 283 | + { |
| 284 | + //map.get(nameElement).remove(); |
| 285 | + string strFunc = "map.get(\u0022" + Name + "\u0022).remove();"; |
| 286 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 287 | + } |
| 288 | + |
| 289 | + [ContextMethod("УдалитьДочерний", "RemoveChild")] |
| 290 | + public void RemoveChild(IValue p1) |
| 291 | + { |
| 292 | + string strFunc = "map.get(\u0022" + Name + "\u0022).removeChild(map.get(\u0022" + ((dynamic)p1.AsObject()).Name + "\u0022));"; |
| 293 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 294 | + } |
| 295 | + |
| 296 | + [ContextMethod("Фокус", "Focus")] |
| 297 | + public void Focus() |
| 298 | + { |
| 299 | + //map.get(nameElement).focus(); |
| 300 | + string strFunc = "map.get(\u0022" + Name + "\u0022).focus();"; |
| 301 | + DeclarativeForms.strFunctions = DeclarativeForms.strFunctions + strFunc + ";"; |
| 302 | + } |
| 303 | + |
| 304 | + } |
| 305 | +} |
0 commit comments