[101] | 1 | /*
|
---|
| 2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2015 Cores Co., Ltd. Japan
|
---|
| 5 | *
|
---|
| 6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 11 | * スコード中に含まれていること.
|
---|
| 12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 15 | * の無保証規定を掲載すること.
|
---|
| 16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 18 | * と.
|
---|
| 19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 22 | * 報告すること.
|
---|
| 23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 27 | * 免責すること.
|
---|
| 28 | *
|
---|
| 29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 33 | * の責任を負わない.
|
---|
| 34 | *
|
---|
| 35 | * @(#) $Id: Control.cs 101 2015-06-02 15:37:23Z coas-nagasima $
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | using System;
|
---|
| 39 | using System.Collections;
|
---|
| 40 | using System.Collections.Generic;
|
---|
| 41 | using System.Diagnostics;
|
---|
| 42 | using System.Html;
|
---|
| 43 | using System.Linq;
|
---|
| 44 | using System.Net.WebSockets;
|
---|
| 45 | using System.Serialization;
|
---|
| 46 | using System.Text;
|
---|
| 47 | using System.Text.RegularExpressions;
|
---|
| 48 | using System.Web;
|
---|
| 49 | using System.Xml;
|
---|
| 50 | using control;
|
---|
| 51 | using ctrlui;
|
---|
| 52 | using jQueryApi;
|
---|
| 53 | using Kadecot;
|
---|
| 54 |
|
---|
| 55 | namespace control
|
---|
| 56 | {
|
---|
| 57 | public static class UI
|
---|
| 58 | {
|
---|
| 59 | public static DeviceController.DeviceInfo GetDeviceInfo(this JsonClassInfo dc, WebApiObjectInfo dev, WampApiKadecotDevice device)
|
---|
| 60 | {
|
---|
| 61 | DeviceController.DeviceInfo di = new DeviceController.DeviceInfo(dc, dev);
|
---|
| 62 | di.Data = device;
|
---|
| 63 | if (dc != null) {
|
---|
| 64 | foreach (WebApiPropertyInfo prop in dev.properties) {
|
---|
| 65 | JsonPropertyInfo epi = dc.properties.FirstOrDefault(p => p.propertyCode == prop.epc);
|
---|
| 66 | if (epi == null)
|
---|
| 67 | continue;
|
---|
| 68 | di.Properties.Add(new DeviceController.DevicePropertyInfo(epi, prop));
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | return di;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | public static List<WampApiKadecotDevice> GetAllDevices(this object args)
|
---|
| 75 | {
|
---|
| 76 | dynamic[] devs = (dynamic[])(((dynamic[])args)[4]).deviceList;
|
---|
| 77 | List<WampApiKadecotDevice> alldevs = new List<WampApiKadecotDevice>();
|
---|
| 78 | var nodes = new Dictionary<string, List<WampApiKadecotDevice>>();
|
---|
| 79 |
|
---|
| 80 | foreach (dynamic dev in devs) {
|
---|
| 81 | WampApiKadecotDevice device = new WampApiKadecotDevice(dev);
|
---|
| 82 | List<WampApiKadecotDevice> devices;
|
---|
| 83 |
|
---|
| 84 | if (nodes.TryGetValue(device.ip_addr, out devices)) {
|
---|
| 85 | devices.Add(device);
|
---|
| 86 | }
|
---|
| 87 | else {
|
---|
| 88 | devices = new List<WampApiKadecotDevice>();
|
---|
| 89 | devices.Add(device);
|
---|
| 90 | nodes[device.ip_addr] = devices;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | alldevs.Add(device);
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | return alldevs;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /// <summary>
|
---|
| 100 | /// jsonファイルをリストに変換します
|
---|
| 101 | /// </summary>
|
---|
| 102 | /// <param name="data"></param>
|
---|
| 103 | /// <returns></returns>
|
---|
| 104 | public static List<JsonClassGroupInfo> ToJSClassGroupInfoList(this object data)
|
---|
| 105 | {
|
---|
| 106 | dynamic[] _classGroups = (dynamic[])((data.GetType() == typeof(string)) ? jQuery.ParseJson((string)data) : data);
|
---|
| 107 | List<JsonClassGroupInfo> classGroups = new List<JsonClassGroupInfo>();
|
---|
| 108 | foreach (var _item in _classGroups) {
|
---|
| 109 | var item = new JsonClassGroupInfo(_item);
|
---|
| 110 | classGroups.Add(item);
|
---|
| 111 | }
|
---|
| 112 | return classGroups;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | /// <summary>
|
---|
| 116 | /// jsonファイルをリストに変換します
|
---|
| 117 | /// </summary>
|
---|
| 118 | /// <param name="data"></param>
|
---|
| 119 | /// <param name="classGroup">クラス</param>
|
---|
| 120 | /// <returns></returns>
|
---|
| 121 | public static List<JsonClassInfo> ToJSClassInfoList(this object data, JsonClassGroupInfo classGroup)
|
---|
| 122 | {
|
---|
| 123 | dynamic[] _classes = (dynamic[])((data.GetType() == typeof(string)) ? jQuery.ParseJson((string)data) : data);
|
---|
| 124 | List<JsonClassInfo> classes = new List<JsonClassInfo>();
|
---|
| 125 | JsonClassInfo eclass;
|
---|
| 126 | foreach (var _item in _classes) {
|
---|
| 127 | eclass = new JsonClassInfo(_item);
|
---|
| 128 | eclass.classGroup = classGroup;
|
---|
| 129 | classes.Add(eclass);
|
---|
| 130 | }
|
---|
| 131 | return classes;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /// <summary>
|
---|
| 135 | /// jsonファイルをプロパティリストに変換します
|
---|
| 136 | /// </summary>
|
---|
| 137 | /// <param name="data"></param>
|
---|
| 138 | /// <returns></returns>
|
---|
| 139 | public static List<JsonPropertyInfo> ToJSPropertyInfoList(this object data)
|
---|
| 140 | {
|
---|
| 141 | var _properties = (dynamic[])((data.GetType() == typeof(string)) ? jQuery.ParseJson((string)data) : data);
|
---|
| 142 | var properties = new List<JsonPropertyInfo>();
|
---|
| 143 | foreach (var _item in _properties) {
|
---|
| 144 | var item = new JsonPropertyInfo(_item);
|
---|
| 145 | properties.Add(item);
|
---|
| 146 | }
|
---|
| 147 | return properties;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | /// <summary>
|
---|
| 151 | /// disabledをタグに追加します
|
---|
| 152 | /// </summary>
|
---|
| 153 | /// <param name="obj"></param>
|
---|
| 154 | /// <param name="flag">true: disabledをタグに追加 false: disabledをタグから削除</param>
|
---|
| 155 | /// <returns></returns>
|
---|
| 156 | public static jQueryObject Disable(this jQueryObject obj, bool flag)
|
---|
| 157 | {
|
---|
| 158 | if (flag) {
|
---|
| 159 | obj.Attribute("disabled", "disabled");
|
---|
| 160 | }
|
---|
| 161 | else {
|
---|
| 162 | obj.RemoveAttr("disabled");
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | return obj;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | /// <summary>
|
---|
| 169 | /// クラスを入れ替えます
|
---|
| 170 | /// </summary>
|
---|
| 171 | /// <param name="obj"></param>
|
---|
| 172 | /// <param name="deleteClass">削除するクラス</param>
|
---|
| 173 | /// <param name="addClass">追加するクラス</param>
|
---|
| 174 | /// <returns></returns>
|
---|
| 175 | public static jQueryObject ToggleClass(this jQueryObject obj, string deleteClass, string addClass)
|
---|
| 176 | {
|
---|
| 177 | obj.ToggleClass(deleteClass, false);
|
---|
| 178 | obj.ToggleClass(addClass, true);
|
---|
| 179 | return obj;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | public static jQueryObject GetDeviceBtn(this DeviceController.DeviceInfo di)
|
---|
| 183 | {
|
---|
| 184 | return di.GetDeviceLi().Children("a");
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | public static jQueryObject GetDeviceLi(this DeviceController.DeviceInfo di)
|
---|
| 188 | {
|
---|
| 189 | return jQuery.Select("#li_device_" + di.GetObjectID());
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | /// <summary>
|
---|
| 193 | /// 書き込み可であるかどうかしらべます
|
---|
| 194 | /// </summary>
|
---|
| 195 | /// <returns>true:書き込み可,false:書き込み不可</returns>
|
---|
| 196 | public static bool IsRULE_SET(this DeviceController.DevicePropertyInfo dpi)
|
---|
| 197 | {
|
---|
| 198 | return (dpi.PropertyInfo == null) ? false : dpi.PropertyInfo.access.Contains("RULE_SET");
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | public class UIObject
|
---|
| 203 | {
|
---|
| 204 | public jQueryObject Object;
|
---|
| 205 | public Element Element { get { return Object.GetElement(0); } }
|
---|
| 206 |
|
---|
| 207 | public UIObject()
|
---|
| 208 | {
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | public UIObject(UIObject uiobject)
|
---|
| 212 | {
|
---|
| 213 | this.Object = uiobject.Object;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | public UIObject(jQueryObject @object)
|
---|
| 217 | {
|
---|
| 218 | this.Object = @object;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | public UIObject(string html)
|
---|
| 222 | {
|
---|
| 223 | this.Object = jQuery.FromHtml(html);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | public UIObject Change()
|
---|
| 227 | {
|
---|
| 228 | this.Object.Change();
|
---|
| 229 | return this;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | public void Change(jQueryEventHandlerWithContext eventHandler)
|
---|
| 233 | {
|
---|
| 234 | Object.Change(eventHandler);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | public void Keypress(jQueryEventHandlerWithContext eventHandler)
|
---|
| 238 | {
|
---|
| 239 | Object.Keypress(eventHandler);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | public jQueryObject Toggle(bool showOrHide)
|
---|
| 243 | {
|
---|
| 244 | return this.Object.Toggle(showOrHide);
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | public void Attribute(string attributeName, string value)
|
---|
| 248 | {
|
---|
| 249 | this.Object.Attribute(attributeName, value);
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | public void RemoveAttr(string attributeName)
|
---|
| 253 | {
|
---|
| 254 | this.Object.RemoveAttr(attributeName);
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | public string GetAttribute(string attributeName)
|
---|
| 258 | {
|
---|
| 259 | return Object.GetAttribute(attributeName);
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | public jQueryObject Find(string selector)
|
---|
| 263 | {
|
---|
| 264 | return this.Object.Find(selector);
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | public UIObject RemoveClass(string className)
|
---|
| 268 | {
|
---|
| 269 | this.Object.RemoveClass(className);
|
---|
| 270 | return this;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | public UIObject ToggleClass(string className, bool add)
|
---|
| 274 | {
|
---|
| 275 | this.Object.ToggleClass(className, add);
|
---|
| 276 | return this;
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | public UIObject ToggleClass(string deleteClass, string addClass)
|
---|
| 280 | {
|
---|
| 281 | this.Object.ToggleClass(deleteClass, addClass);
|
---|
| 282 | return this;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | public UIObject One(string eventName, jQueryEventHandlerWithContext eventHandler)
|
---|
| 286 | {
|
---|
| 287 | this.Object.One(eventName, eventHandler);
|
---|
| 288 | return this;
|
---|
| 289 | }
|
---|
| 290 |
|
---|
| 291 | public UIObject Attribute(JsDictionary nameValueMap)
|
---|
| 292 | {
|
---|
| 293 | this.Object.Attribute(nameValueMap);
|
---|
| 294 | return this;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | public UIObject Click(jQueryEventHandlerWithContext eventHandler)
|
---|
| 298 | {
|
---|
| 299 | this.Object.Click(eventHandler);
|
---|
| 300 | return this;
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | public UIObject Click(jQueryEventHandler eventHandler)
|
---|
| 304 | {
|
---|
| 305 | this.Object.Click(eventHandler);
|
---|
| 306 | return this;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | public string Text { get { return Object.GetText(); } set { Object.Text(value); } }
|
---|
| 310 | public string Id { get { return Object.GetAttribute("id"); } set { Object.Attribute("id", value); } }
|
---|
| 311 | public string For { get { return Object.GetAttribute("for"); } set { Object.Attribute("for", value); } }
|
---|
| 312 | public string Name { get { return Object.GetAttribute("name"); } set { Object.Attribute("name", value); } }
|
---|
| 313 | public string DataRole { get { return Object.GetAttribute("data-role"); } set { Object.Attribute("data-role", value); } }
|
---|
| 314 | public string DataType { get { return Object.GetAttribute("data-type"); } set { Object.Attribute("data-type", value); } }
|
---|
| 315 | public string Title { get { return Object.GetAttribute("title"); } set { Object.Attribute("title", value); } }
|
---|
| 316 | public string Value
|
---|
| 317 | {
|
---|
| 318 | get
|
---|
| 319 | {
|
---|
| 320 | if (Object.Is("fieldset"))
|
---|
| 321 | return Object.Find("input[type='radio']:checked").GetValue();
|
---|
| 322 | return Object.GetValue();
|
---|
| 323 | }
|
---|
| 324 | set
|
---|
| 325 | {
|
---|
| 326 | if (Object.Is("fieldset")) {
|
---|
| 327 | Object.Find("input[type=\"radio\"]").Each((j, elem) => {
|
---|
| 328 | if (jQuery.Select(elem).GetValue() == value) {
|
---|
| 329 | jQuery.Select(elem).Prop("checked", true);
|
---|
| 330 | }
|
---|
| 331 | else {
|
---|
| 332 | jQuery.Select(elem).Prop("checked", false);
|
---|
| 333 | }
|
---|
| 334 | });
|
---|
| 335 | Object.Find("input[type=\"radio\"]").CheckboxRadio().CheckboxRadio("refresh");
|
---|
| 336 | }
|
---|
| 337 | else {
|
---|
| 338 | Object.Value(value);
|
---|
| 339 | if (DataRole == "flipswitch")
|
---|
| 340 | Object.Value(value).FlipSwitch("refresh");
|
---|
| 341 | }
|
---|
| 342 | }
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | public int Maxlength { get { return int.Parse(GetAttribute("maxlength")); } set { Attribute("maxlength", value.ToString()); } }
|
---|
| 346 | public int Min { get { return int.Parse(Object.GetAttribute("min")); } set { Object.Attribute("min", value.ToString()); } }
|
---|
| 347 | public int Max { get { return int.Parse(Object.GetAttribute("max")); } set { Object.Attribute("max", value.ToString()); } }
|
---|
| 348 | public int TabIndex { get { return int.Parse(Object.GetAttribute("tabindex")); } set { Object.Attribute("tabindex", value.ToString()); } }
|
---|
| 349 | public string Type { get { return Object.GetAttribute("type"); } set { Object.Attribute("type", value); } }
|
---|
| 350 |
|
---|
| 351 | public void Append(UIObject uiobject)
|
---|
| 352 | {
|
---|
| 353 | this.Object.Append(uiobject.Object);
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | public jQueryObject Append(jQueryObject @object)
|
---|
| 357 | {
|
---|
| 358 | return this.Object.Append(@object);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | public UIObject Disable(bool flag)
|
---|
| 362 | {
|
---|
| 363 | if (flag) {
|
---|
| 364 | this.Attribute("disabled", "disabled");
|
---|
| 365 | }
|
---|
| 366 | else {
|
---|
| 367 | this.RemoveAttr("disabled");
|
---|
| 368 | }
|
---|
| 369 | return this;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | public jQueryObject Children()
|
---|
| 373 | {
|
---|
| 374 | return this.Object.Children();
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | public UIObject AddClass(string className)
|
---|
| 378 | {
|
---|
| 379 | this.Object.AddClass(className);
|
---|
| 380 | return this;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | /// <summary>
|
---|
| 384 | ///
|
---|
| 385 | /// </summary>
|
---|
| 386 | /// <param name="flag">false:イベント不可</param>
|
---|
| 387 | /// <returns></returns>
|
---|
| 388 | public UIObject PointerEvents(bool flag)
|
---|
| 389 | {
|
---|
| 390 | if (!flag) {
|
---|
| 391 | this.Object.CSS("pointer-events", "none");
|
---|
| 392 | }
|
---|
| 393 | return this;
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | public UIObject Hide()
|
---|
| 397 | {
|
---|
| 398 | this.Object.Hide();
|
---|
| 399 | return this;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | public UIObject Show()
|
---|
| 403 | {
|
---|
| 404 | this.Object.Show();
|
---|
| 405 | return this;
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | private EcnlClass ecnlclass;
|
---|
| 409 | public EcnlClass Class
|
---|
| 410 | {
|
---|
| 411 | get { return ecnlclass; }
|
---|
| 412 | set
|
---|
| 413 | {
|
---|
| 414 | ecnlclass = value;
|
---|
| 415 | this.AddClass(EcnlClassString(value));
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | public enum EcnlClass
|
---|
| 420 | {
|
---|
| 421 | ecnl_pink,
|
---|
| 422 | ecnl_violet,
|
---|
| 423 | ecnl_light_green,
|
---|
| 424 | ecnl_light_blue,
|
---|
| 425 | }
|
---|
| 426 |
|
---|
| 427 | private string EcnlClassString(EcnlClass @class)
|
---|
| 428 | {
|
---|
| 429 | if (@class == EcnlClass.ecnl_pink) {
|
---|
| 430 | return "ecnl_pink";
|
---|
| 431 | }
|
---|
| 432 | else if (@class == EcnlClass.ecnl_violet) {
|
---|
| 433 | return "ecnl_violet";
|
---|
| 434 | }
|
---|
| 435 | else if (@class == EcnlClass.ecnl_light_green) {
|
---|
| 436 | return "ecnl_light_green";
|
---|
| 437 | }
|
---|
| 438 | else if (@class == EcnlClass.ecnl_light_blue) {
|
---|
| 439 | return "ecnl_light_blue";
|
---|
| 440 | }
|
---|
| 441 | else {
|
---|
| 442 | return "";
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | public class UIGrpBox : UIListviewItem
|
---|
| 448 | {
|
---|
| 449 | UILabel Label;
|
---|
| 450 |
|
---|
| 451 | public UIGrpBox()
|
---|
| 452 | : base()
|
---|
| 453 | {
|
---|
| 454 | LiAside = new UIP("", "ui-li-aside");
|
---|
| 455 | base.Append(LiAside);
|
---|
| 456 | base.Change(GrpBoxChange);
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 | public UIGrpBox(DeviceController.DevicePropertyInfo dpi)
|
---|
| 460 | : this()
|
---|
| 461 | {
|
---|
| 462 | this.dpi = dpi;
|
---|
| 463 | Label = new UILabel(dpi);
|
---|
| 464 | this.dpi.PrepareInputInfo();
|
---|
| 465 |
|
---|
| 466 | if (dpi.PropertyCode == 0x00) {
|
---|
| 467 |
|
---|
| 468 | }
|
---|
| 469 | else if (dpi.PropertyCode == 0x97) {
|
---|
| 470 | SetTimebox();
|
---|
| 471 | }
|
---|
| 472 | else if (dpi.PropertyCode == 0x98) {
|
---|
| 473 | SetCalBox();
|
---|
| 474 | }
|
---|
| 475 | else if (this.dpi.InputTypes.Count == 0) {
|
---|
| 476 | SetTextInput();
|
---|
| 477 | }
|
---|
| 478 | else if (dpi.PropertyCode == 0x80 && dpi.InputTypes.Count == 1 && dpi.InputTypes[0].Mode == PropertyInputMode.Select) {
|
---|
| 479 | SetFlipSwitch();
|
---|
| 480 | }
|
---|
| 481 | else {
|
---|
| 482 | foreach (PropertyInputInfo pii in dpi.InputTypes) {
|
---|
| 483 |
|
---|
| 484 | switch (pii.Mode) {
|
---|
| 485 | case PropertyInputMode.Select: {
|
---|
| 486 | SetFieldSet(pii);
|
---|
| 487 | }
|
---|
| 488 | break;
|
---|
| 489 | case PropertyInputMode.Range: {
|
---|
| 490 | SetRange(pii);
|
---|
| 491 | }
|
---|
| 492 | break;
|
---|
| 493 | default: {
|
---|
| 494 | SetDefault();
|
---|
| 495 | }
|
---|
| 496 | break;
|
---|
| 497 | }
|
---|
| 498 | }
|
---|
| 499 | }
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | public void SetFlipSwitch()
|
---|
| 503 | {
|
---|
| 504 | PropertySelectInput psi = (PropertySelectInput)dpi.InputTypes[0];
|
---|
| 505 |
|
---|
| 506 | // OFF
|
---|
| 507 | var off = psi.Option.First((kvp) => { return kvp.Key == 0x31; });
|
---|
| 508 |
|
---|
| 509 | // ON
|
---|
| 510 | var on = psi.Option.First((kvp) => { return kvp.Key == 0x30; });
|
---|
| 511 |
|
---|
| 512 | UIOption OFF = new UIOption(off.Value, off.Key.ToString("X2"));
|
---|
| 513 | UIOption ON = new UIOption(on.Value, on.Key.ToString("X2"));
|
---|
| 514 |
|
---|
| 515 | UIFlipSwitch Flipswitch = new UIFlipSwitch(OFF, ON);
|
---|
| 516 | Flipswitch.Change(this.flip_Change);
|
---|
| 517 |
|
---|
| 518 | Flipswitch.Disable(!dpi.IsRULE_SET());
|
---|
| 519 |
|
---|
| 520 | FieldContain = new UIFieldContain(Label, Flipswitch);
|
---|
| 521 |
|
---|
| 522 | //FieldContain.Object.Trigger("create");
|
---|
| 523 | Append(FieldContain);
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 | public void SetDefault()
|
---|
| 527 | {
|
---|
| 528 | UITextInput Textbox = new UITextInput();
|
---|
| 529 | Textbox.Change(text_Change);
|
---|
| 530 | var value = ""/*.ToString("X")*/;
|
---|
| 531 | Textbox.Value = value;
|
---|
| 532 | FieldContain = new UIFieldContain(Label, Textbox);
|
---|
| 533 | Append(FieldContain);
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | public void SetRange(PropertyInputInfo pii)
|
---|
| 537 | {
|
---|
| 538 | UIRangeInput range = new UIRangeInput();
|
---|
| 539 | range.Change(range_Change);
|
---|
| 540 | FieldContain = new UIFieldContain(Label, range);
|
---|
| 541 | var value = ((PropertyRangeInput)pii).Minimum;
|
---|
| 542 |
|
---|
| 543 | range.Value = value;
|
---|
| 544 | range.Min = ((PropertyRangeInput)pii).Minimum;
|
---|
| 545 | range.Max = ((PropertyRangeInput)pii).Maximum;
|
---|
| 546 |
|
---|
| 547 | Append(FieldContain.Object).Trigger("create");
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | private void range_Change(Element elem, jQueryEvent ev)
|
---|
| 551 | {
|
---|
| 552 | if (!CheckValiable()) { return; };
|
---|
| 553 | if (!CheckHex()) { return; };
|
---|
| 554 | byte[] data = ByteValue;
|
---|
| 555 | dpi.InputData = data;
|
---|
| 556 | KadecotSet(dpi, data);
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | private void SetCalBox()
|
---|
| 560 | {
|
---|
| 561 | UICalBox Textbox = new UICalBox();
|
---|
| 562 | Textbox.Change(calbox_Change);
|
---|
| 563 |
|
---|
| 564 | JsonPropertyInfo epi = dpi.PropertyInfo;
|
---|
| 565 |
|
---|
| 566 | FieldContain = new UIFieldContain(Label, Textbox);
|
---|
| 567 |
|
---|
| 568 | int len = dpi.GetMaxLength();
|
---|
| 569 |
|
---|
| 570 | string valueDescription = "";
|
---|
| 571 | foreach (JsonFieldInfo jfi in epi.fields) {
|
---|
| 572 | valueDescription += "【" + jfi.description + ":" + jfi.valueDescription + "】";
|
---|
| 573 | }
|
---|
| 574 | Textbox.Placeholder = dpi.GetText();
|
---|
| 575 | Textbox.Value = "";
|
---|
| 576 | //Textbox.Disable(!dpi.IsRULE_SET());
|
---|
| 577 | Textbox.ReadOnly = !dpi.IsRULE_SET();
|
---|
| 578 | Textbox.Title = valueDescription;
|
---|
| 579 | One("dateboxcreate", calbox_Create);
|
---|
| 580 | Append(FieldContain.Object);
|
---|
| 581 | }
|
---|
| 582 |
|
---|
| 583 | private void calbox_Create(Element ele, jQueryEvent ev)
|
---|
| 584 | {
|
---|
| 585 | var textinput = jQuery.Select(ev.Target).Parent(".ui-input-datebox");
|
---|
| 586 | textinput.Append(BackButton.Object);
|
---|
| 587 | BackButton.Click(BackButtonClick);
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | private void calbox_Change(Element elem, jQueryEvent ev)
|
---|
| 591 | {
|
---|
| 592 | UICalBox Calbox = (UICalBox)FieldContain.Input;
|
---|
| 593 | byte[] data = new byte[4];
|
---|
| 594 | RemoveClass();
|
---|
| 595 |
|
---|
| 596 | if (!((Calbox.dY >= 1 && Calbox.dY < 9999) && ((Calbox.dM >= 1 && Calbox.dM <= 12) && (Calbox.dD >= 1 && Calbox.dD <= 31)))) {
|
---|
| 597 | ToggleClass(true ? "ecnl_pink" : "ecnl_violet", true);
|
---|
| 598 | }
|
---|
| 599 | else {
|
---|
| 600 | data[0] = Byte.Parse(Calbox.xY.Substring(0, 2), 16);
|
---|
| 601 | data[1] = Byte.Parse(Calbox.xY.Substring(2, 2), 16);
|
---|
| 602 | data[2] = Byte.Parse(Calbox.xM, 16);
|
---|
| 603 | data[3] = Byte.Parse(Calbox.xD, 16);
|
---|
| 604 |
|
---|
| 605 | dpi.InputData = data;
|
---|
| 606 | dpi.IsWaitRes = true;
|
---|
| 607 |
|
---|
| 608 | this.Class = EcnlClass.ecnl_light_green;
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | private void flip_Change(Element elem, jQueryEvent ev)
|
---|
| 613 | {
|
---|
| 614 | byte[] data = ByteValue;
|
---|
| 615 | dpi.InputData = data;
|
---|
| 616 | KadecotSet(dpi, data);
|
---|
| 617 | }
|
---|
| 618 |
|
---|
| 619 | private void SetTextInput()
|
---|
| 620 | {
|
---|
| 621 | UITextInput Textbox = new UITextInput();
|
---|
| 622 | Textbox.Change(text_Change);
|
---|
| 623 | Textbox.Keypress(text_KeyPress);
|
---|
| 624 | Textbox.Keyup(text_Keyup);
|
---|
| 625 | Textbox.On("textinputcreate", this.text_Create);
|
---|
| 626 | JsonPropertyInfo epi = dpi.PropertyInfo;
|
---|
| 627 |
|
---|
| 628 | string valueDescription = "";
|
---|
| 629 | foreach (JsonFieldInfo jfi in epi.fields) {
|
---|
| 630 | valueDescription += "【" + jfi.description + ":" + jfi.valueDescription + "】";
|
---|
| 631 | }
|
---|
| 632 | Textbox.Value = "";
|
---|
| 633 | //Textbox.Disable(!dpi.IsRULE_SET());
|
---|
| 634 | Textbox.ReadOnly = !dpi.IsRULE_SET();
|
---|
| 635 | Textbox.Maxlength = dpi.GetMaxLength();
|
---|
| 636 | Textbox.Title = valueDescription;
|
---|
| 637 | FieldContain = new UIFieldContain(Label, Textbox);
|
---|
| 638 | base.Append(FieldContain.Object);
|
---|
| 639 | }
|
---|
| 640 |
|
---|
| 641 | private void SetTimebox()
|
---|
| 642 | {
|
---|
| 643 | UITimeBox Textbox = new UITimeBox();
|
---|
| 644 | Textbox.Change(timebox_Change);
|
---|
| 645 | JsonPropertyInfo epi = dpi.PropertyInfo;
|
---|
| 646 | FieldContain = new UIFieldContain(Label, Textbox);
|
---|
| 647 | int len = dpi.GetMaxLength();
|
---|
| 648 | string valueDescription = "";
|
---|
| 649 |
|
---|
| 650 | foreach (JsonFieldInfo jfi in epi.fields) {
|
---|
| 651 | valueDescription += "【" + jfi.description + ":" + jfi.valueDescription + "】";
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | Textbox.Placeholder = dpi.GetText();
|
---|
| 655 | Textbox.Value = "";
|
---|
| 656 | Textbox.Title = valueDescription;
|
---|
| 657 | //Textbox.Disable(!dpi.IsRULE_SET());
|
---|
| 658 | Textbox.ReadOnly = !dpi.IsRULE_SET();
|
---|
| 659 | this.Append(FieldContain);
|
---|
| 660 | this.One("dateboxcreate", timebox_Create);
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | private void SetFieldSet(PropertyInputInfo pii)
|
---|
| 664 | {
|
---|
| 665 | UIFieldSet FieldSet = new UIFieldSet();
|
---|
| 666 | UILabel Label = new UILabel();
|
---|
| 667 | Label.Text = dpi.GetText();
|
---|
| 668 | FieldSet.Horizontal = true;
|
---|
| 669 | FieldSet.Change(select_Change);
|
---|
| 670 | FieldContain = new UIFieldContain(Label, FieldSet);
|
---|
| 671 |
|
---|
| 672 | foreach (KeyValuePair<long, string> opt in ((PropertySelectInput)pii).Option) {
|
---|
| 673 | UIRadioInput Radio = new UIRadioInput(opt.Key.ToString("X"));
|
---|
| 674 | FieldSet.Append(new UIFieldSet.RadioInput(new UILabel(opt.Value), Radio));
|
---|
| 675 | }
|
---|
| 676 |
|
---|
| 677 | Append(FieldContain.Object);
|
---|
| 678 | }
|
---|
| 679 |
|
---|
| 680 | private void select_Change(Element elem, jQueryEvent ev)
|
---|
| 681 | {
|
---|
| 682 | byte[] data = ByteValue;
|
---|
| 683 | dpi.InputData = data;
|
---|
| 684 | KadecotSet(dpi, data);
|
---|
| 685 | }
|
---|
| 686 |
|
---|
| 687 | /// <summary>
|
---|
| 688 | /// 時刻入力フォームの入力値が変更された場合
|
---|
| 689 | /// </summary>
|
---|
| 690 | /// <param name="ele"></param>
|
---|
| 691 | /// <param name="ev"></param>
|
---|
| 692 | private void timebox_Change(Element ele, jQueryEvent ev)
|
---|
| 693 | {
|
---|
| 694 | RemoveClass();
|
---|
| 695 | if (Changed) {
|
---|
| 696 | timebox_Change();
|
---|
| 697 | }
|
---|
| 698 | }
|
---|
| 699 |
|
---|
| 700 | private void timebox_Change()
|
---|
| 701 | {
|
---|
| 702 | string value = FieldContain.Input.Value;
|
---|
| 703 | string[] val = value.Split(":");
|
---|
| 704 |
|
---|
| 705 | Byte[] data = new Byte[2];
|
---|
| 706 | data[0] = byte.Parse(val[0], 10);
|
---|
| 707 | data[1] = byte.Parse(val[1], 10);
|
---|
| 708 |
|
---|
| 709 | string hex = data[0].ToString("X2") + data[1].ToString("X2");
|
---|
| 710 |
|
---|
| 711 | RemoveClass();
|
---|
| 712 |
|
---|
| 713 | dpi.InputData = data;
|
---|
| 714 | dpi.IsWaitRes = true;
|
---|
| 715 | ToggleClass(true ? "ecnl_light_green" : "ecnl_light_blue", true);
|
---|
| 716 | }
|
---|
| 717 |
|
---|
| 718 | private void timebox_Create(Element ele, jQueryEvent ev)
|
---|
| 719 | {
|
---|
| 720 | var textinput = jQuery.Select(ev.Target).Parent(".ui-input-datebox");
|
---|
| 721 | textinput.Append(BackButton.Object);
|
---|
| 722 | BackButton.Click(BackButtonClick);
|
---|
| 723 | }
|
---|
| 724 |
|
---|
| 725 | private void text_Keyup(Element elem, jQueryEvent ev)
|
---|
| 726 | {
|
---|
| 727 | jQuery.Select(elem).Change();
|
---|
| 728 | }
|
---|
| 729 |
|
---|
| 730 | private void text_Create(Element elem, jQueryEvent ev)
|
---|
| 731 | {
|
---|
| 732 | var textinput = jQuery.Select(ev.Target).Parent(".ui-input-text");
|
---|
| 733 | textinput.Append(BackButton.Object);
|
---|
| 734 | BackButton.Click(BackButtonClick);
|
---|
| 735 | }
|
---|
| 736 |
|
---|
| 737 | private void text_KeyPress(Element elem, jQueryEvent ev)
|
---|
| 738 | {
|
---|
| 739 | bool number = (ev.Which >= (int)KeyPress._0 && ev.Which <= (int)KeyPress._9);
|
---|
| 740 | bool lower = (ev.Which >= (int)KeyPress.a && ev.Which <= (int)KeyPress.f);
|
---|
| 741 | bool upper = (ev.Which >= (int)KeyPress.A && ev.Which <= (int)KeyPress.F);
|
---|
| 742 | bool BackSpace = (ev.Which == (int)KeyPress.BackSpace);
|
---|
| 743 | bool Delete = (ev.Which == (int)KeyPress.Delete);
|
---|
| 744 |
|
---|
| 745 | bool flag = (!number && !lower) && (!BackSpace && !Delete) && !upper;
|
---|
| 746 | if (flag) ev.PreventDefault();
|
---|
| 747 | }
|
---|
| 748 |
|
---|
| 749 | private void BackButtonClick(Element elem, jQueryEvent ev)
|
---|
| 750 | {
|
---|
| 751 | FieldContain.Input.Value = ToText(GetValue);
|
---|
| 752 | FieldContain.Input.Object.Change();
|
---|
| 753 | }
|
---|
| 754 |
|
---|
| 755 | private void text_Change(Element elem, jQueryEvent ev)
|
---|
| 756 | {
|
---|
| 757 | if (Changed) {
|
---|
| 758 | RemoveClass();
|
---|
| 759 | if (!CheckValiable()) { return; };
|
---|
| 760 | if (!CheckHex()) { return; };
|
---|
| 761 | SetDpi();
|
---|
| 762 | }
|
---|
| 763 | }
|
---|
| 764 |
|
---|
| 765 | private Type InputType { get { return FieldContain.Input.GetType(); } }
|
---|
| 766 | private byte[] ToByteValue()
|
---|
| 767 | {
|
---|
| 768 | string Value = FieldContain.Input.Value;
|
---|
| 769 | byte[] data = new byte[Value.Length / 2];
|
---|
| 770 | for (int i = 0, j = 0; j < Value.Length; j += 2) {
|
---|
| 771 | data[i++] = Byte.Parse(Value.Substring(j, 2), 16);
|
---|
| 772 | }
|
---|
| 773 | return data;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | private void SetDpi()
|
---|
| 777 | {
|
---|
| 778 | dpi.InputData = ByteValue;
|
---|
| 779 | dpi.IsWaitRes = true;
|
---|
| 780 | ErrorText = "";
|
---|
| 781 | ToggleClass(user ? "ecnl_light_green" : "ecnl_light_blue", true);
|
---|
| 782 | }
|
---|
| 783 |
|
---|
| 784 | bool user = true;
|
---|
| 785 | private byte[] ByteValue { get { return ToByteValue(); } }
|
---|
| 786 | private DeviceController.DevicePropertyInfo dpi;
|
---|
| 787 | private UIP LiAside;
|
---|
| 788 | public string ErrorText { get { return LiAside.Text; } set { LiAside.Text = value; } }
|
---|
| 789 | public byte[] GetValue;
|
---|
| 790 | public UIFieldContain FieldContain;
|
---|
| 791 |
|
---|
| 792 | public void RemoveClass()
|
---|
| 793 | {
|
---|
| 794 | ErrorText = "";
|
---|
| 795 | BackButton.Hide();
|
---|
| 796 | RemoveClass("ecnl_pink");
|
---|
| 797 | RemoveClass("ecnl_violet");
|
---|
| 798 | RemoveClass("ecnl_light_green");
|
---|
| 799 | RemoveClass("ecnl_light_blue");
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 | public void SetName(string nameid)
|
---|
| 803 | {
|
---|
| 804 | string name = nameid;
|
---|
| 805 | if (InputType == typeof(UICalBox)) {
|
---|
| 806 | name = "cal_" + nameid;
|
---|
| 807 | }
|
---|
| 808 | else if (InputType == typeof(UITimeBox)) {
|
---|
| 809 | name = "tmb_" + nameid;
|
---|
| 810 | }
|
---|
| 811 | else if (InputType == typeof(UITextInput)) {
|
---|
| 812 | name = "txt_" + nameid;
|
---|
| 813 | }
|
---|
| 814 | else if (InputType == typeof(UIRadioInput)) {
|
---|
| 815 | name = "rng_" + nameid;
|
---|
| 816 | }
|
---|
| 817 | else if (InputType == typeof(UIFlipSwitch)) {
|
---|
| 818 | name = "flp_" + nameid;
|
---|
| 819 | UIFlipSwitch Flipswitch = (UIFlipSwitch)FieldContain.Input;
|
---|
| 820 |
|
---|
| 821 | string val0 = Flipswitch.OFF.Value;
|
---|
| 822 | string val1 = Flipswitch.ON.Value;
|
---|
| 823 | Flipswitch.OFF.Id = name + val0;
|
---|
| 824 | Flipswitch.ON.Id = name + val1;
|
---|
| 825 | }
|
---|
| 826 | else if (InputType == typeof(UIFieldSet)) {
|
---|
| 827 | name = "sel_" + nameid;
|
---|
| 828 | UIFieldSet FieldSet = (UIFieldSet)FieldContain.Input;
|
---|
| 829 | FieldSet.Id = name;
|
---|
| 830 |
|
---|
| 831 | for (int i = 0; i < FieldSet.RadioList.Count; i++) {
|
---|
| 832 | var id = name + FieldSet.RadioList[i].Radio.Value;
|
---|
| 833 | FieldSet.RadioList[i].Radio.Name = name;
|
---|
| 834 | FieldSet.RadioList[i].Radio.Id = id;
|
---|
| 835 | FieldSet.RadioList[i].Label.For = id;
|
---|
| 836 | }
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 | FieldContain.Label.For = name;
|
---|
| 840 | FieldContain.Input.Id = name;
|
---|
| 841 | FieldContain.Input.Name = name;
|
---|
| 842 | }
|
---|
| 843 |
|
---|
| 844 | public bool CheckHex()
|
---|
| 845 | {
|
---|
| 846 | string Value = FieldContain.Input.Value;
|
---|
| 847 | if (!new Regex("^([0-9A-Fa-f][0-9A-Fa-f])+$").Test(Value)) {
|
---|
| 848 | ErrorText = "16進数で入力してください";
|
---|
| 849 | ToggleClass(true ? "ecnl_pink" : "ecnl_violet", true);
|
---|
| 850 | return false;
|
---|
| 851 | }
|
---|
| 852 | return true;
|
---|
| 853 | }
|
---|
| 854 |
|
---|
| 855 | public bool CheckValiable()
|
---|
| 856 | {
|
---|
| 857 | JsonPropertyInfo epi = dpi.PropertyInfo;
|
---|
| 858 | //可変長データの場合
|
---|
| 859 | bool valiable = dpi.IsValiable();
|
---|
| 860 | int len = dpi.GetMaxLength();
|
---|
| 861 | string Value = FieldContain.Input.Value;
|
---|
| 862 | bool length = (Value.Length != len) && (!valiable || (Value.Length > len));
|
---|
| 863 |
|
---|
| 864 | if ((Value.Length != len) && (!valiable || (Value.Length > len))) {
|
---|
| 865 | ErrorText = len.ToString() + "文字で入力してください";
|
---|
| 866 | ToggleClass(user ? "ecnl_pink" : "ecnl_violet", true);
|
---|
| 867 |
|
---|
| 868 | return false;
|
---|
| 869 | }
|
---|
| 870 | return true;
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | public string ToTextDefault(byte[] data)
|
---|
| 874 | {
|
---|
| 875 | string value = "";
|
---|
| 876 | if (data == null) {
|
---|
| 877 | return "";
|
---|
| 878 | }
|
---|
| 879 | for (int i = 0; i < data.Length; i++) {
|
---|
| 880 | value += data[i].ToString("X2");
|
---|
| 881 | }
|
---|
| 882 | return value;
|
---|
| 883 | }
|
---|
| 884 |
|
---|
| 885 | public string ToTextTimeBox(byte[] data)
|
---|
| 886 | {
|
---|
| 887 |
|
---|
| 888 | string str = ToTextDefault(data);
|
---|
| 889 | if (str.Length == 4) {
|
---|
| 890 | int h = int.Parse("0x" + str.Substr(0, 2));
|
---|
| 891 | int m = int.Parse("0x" + str.Substr(2, 2));
|
---|
| 892 | return h.ToString("D2") + ":" + m.ToString("D2");
|
---|
| 893 | }
|
---|
| 894 | else {
|
---|
| 895 | return "";
|
---|
| 896 | }
|
---|
| 897 | }
|
---|
| 898 |
|
---|
| 899 | public string ToTextCal(byte[] data)
|
---|
| 900 | {
|
---|
| 901 | string str = ToText(data);
|
---|
| 902 | if (str.Length == 8) {
|
---|
| 903 | int y = int.Parse("0x" + str.Substr(0, 4));
|
---|
| 904 | int m = int.Parse("0x" + str.Substr(4, 2));
|
---|
| 905 | int d = int.Parse("0x" + str.Substr(6, 2));
|
---|
| 906 | if ((y < 1 || m < 1) || d < 1) {
|
---|
| 907 | return y.ToString("D4") + "/" + m.ToString("D2") + "/" + m.ToString("D2");
|
---|
| 908 | }
|
---|
| 909 | DateTime date = new DateTime(y, m, d);
|
---|
| 910 | return date.ToString("yyyy/MM/dd");
|
---|
| 911 | }
|
---|
| 912 | else {
|
---|
| 913 | return "";
|
---|
| 914 | }
|
---|
| 915 | }
|
---|
| 916 |
|
---|
| 917 | public string ToText(byte[] data)
|
---|
| 918 | {
|
---|
| 919 | if (data == null) {
|
---|
| 920 | return "";
|
---|
| 921 | }
|
---|
| 922 | if (FieldContain.Input.GetType().Equals(typeof(UITimeBox))) {
|
---|
| 923 | return ToTextTimeBox(data);
|
---|
| 924 | }
|
---|
| 925 | else if (FieldContain.Input.GetType().Equals(typeof(UICalBox))) {
|
---|
| 926 | return ToTextCal(data);
|
---|
| 927 | }
|
---|
| 928 | else {
|
---|
| 929 | return ToTextDefault(data);
|
---|
| 930 | }
|
---|
| 931 | }
|
---|
| 932 |
|
---|
| 933 | /// <summary>
|
---|
| 934 | /// 値が変わった時true
|
---|
| 935 | /// </summary>
|
---|
| 936 | public bool Changed { get { return !FieldContain.Input.Value.Equals(ToText(GetValue)); } }
|
---|
| 937 | public void GrpBoxChange(Element ele, jQueryEvent ev)
|
---|
| 938 | {
|
---|
| 939 | BackButton.Toggle(Changed);
|
---|
| 940 | if (!Changed) {
|
---|
| 941 | dpi.IsWaitRes = false;
|
---|
| 942 | dpi.InputData = null;
|
---|
| 943 | RemoveClass();
|
---|
| 944 | }
|
---|
| 945 | }
|
---|
| 946 |
|
---|
| 947 | public EventHandlerDevicePropertyInfo KadecotSet;
|
---|
| 948 | public void SetGetValue(byte[] data)
|
---|
| 949 | {
|
---|
| 950 | RemoveClass();
|
---|
| 951 | GetValue = data;
|
---|
| 952 | FieldContain.Input.Value = ToText(data);
|
---|
| 953 | FieldContain.Input.Change();
|
---|
| 954 | }
|
---|
| 955 |
|
---|
| 956 | public UIBackButton BackButton = new UIBackButton();
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | public class UIBackButton : UIButton
|
---|
| 960 | {
|
---|
| 961 | public UIBackButton()
|
---|
| 962 | : base()
|
---|
| 963 | {
|
---|
| 964 | base.ButtonIcon = Icon.back;
|
---|
| 965 | base.Title = "元に戻す";
|
---|
| 966 | base.TabIndex = -1;
|
---|
| 967 | base.AddClass("text_backButton");
|
---|
| 968 | base.Object.Hide();
|
---|
| 969 | }
|
---|
| 970 | }
|
---|
| 971 |
|
---|
| 972 | public class UIDiv : UIObject
|
---|
| 973 | {
|
---|
| 974 | public UIDiv()
|
---|
| 975 | : base("<div>")
|
---|
| 976 | {
|
---|
| 977 |
|
---|
| 978 | }
|
---|
| 979 | }
|
---|
| 980 |
|
---|
| 981 | public class UILabel : UIObject
|
---|
| 982 | {
|
---|
| 983 | public UILabel()
|
---|
| 984 | : base("<label>")
|
---|
| 985 | {
|
---|
| 986 | }
|
---|
| 987 |
|
---|
| 988 | public UILabel(string text)
|
---|
| 989 | : this()
|
---|
| 990 | {
|
---|
| 991 | base.Text = text;
|
---|
| 992 | }
|
---|
| 993 |
|
---|
| 994 | public UILabel(string text, string @for)
|
---|
| 995 | : this(text)
|
---|
| 996 | {
|
---|
| 997 | base.For = @for;
|
---|
| 998 | }
|
---|
| 999 |
|
---|
| 1000 | public UILabel(string text, string @for, string name)
|
---|
| 1001 | : this(text, @for)
|
---|
| 1002 | {
|
---|
| 1003 | base.Name = name;
|
---|
| 1004 | }
|
---|
| 1005 |
|
---|
| 1006 | public UILabel(DeviceController.DevicePropertyInfo dpi)
|
---|
| 1007 | : this(dpi.GetText())
|
---|
| 1008 | {
|
---|
| 1009 | base.Title = dpi.PropertyInfo.valueDescription;
|
---|
| 1010 | }
|
---|
| 1011 | }
|
---|
| 1012 |
|
---|
| 1013 | public class UIFieldContain : UIObject
|
---|
| 1014 | {
|
---|
| 1015 | public UIFieldContain()
|
---|
| 1016 | : base("<div>")
|
---|
| 1017 | {
|
---|
| 1018 | base.DataRole = "fieldcontain";
|
---|
| 1019 | }
|
---|
| 1020 |
|
---|
| 1021 | public UIFieldContain(UIObject uiobject)
|
---|
| 1022 | : this()
|
---|
| 1023 | {
|
---|
| 1024 | base.Append(uiobject);
|
---|
| 1025 | }
|
---|
| 1026 |
|
---|
| 1027 | public UIFieldContain(UILabel label, UIObject uiobject)
|
---|
| 1028 | : this()
|
---|
| 1029 | {
|
---|
| 1030 | this.Label = label;
|
---|
| 1031 | this.Input = uiobject;
|
---|
| 1032 | base.Append(this.Label);
|
---|
| 1033 | base.Append(this.Input);
|
---|
| 1034 | }
|
---|
| 1035 |
|
---|
| 1036 | public UILabel Label;
|
---|
| 1037 | public UIObject Input;
|
---|
| 1038 | }
|
---|
| 1039 |
|
---|
| 1040 | public class UIGridA : UIObject
|
---|
| 1041 | {
|
---|
| 1042 | public UIGridA()
|
---|
| 1043 | : base("<div>")
|
---|
| 1044 | {
|
---|
| 1045 | this.Object.AddClass("ui-grid-a");
|
---|
| 1046 | this.Append(BlockA);
|
---|
| 1047 | this.Append(BlockB);
|
---|
| 1048 | }
|
---|
| 1049 |
|
---|
| 1050 | public UIBlockA BlockA = new UIBlockA();
|
---|
| 1051 | public UIBlockB BlockB = new UIBlockB();
|
---|
| 1052 |
|
---|
| 1053 | public class UIBlockA : UIObject
|
---|
| 1054 | {
|
---|
| 1055 | public UIBlockA()
|
---|
| 1056 | : base("<div>")
|
---|
| 1057 | {
|
---|
| 1058 | this.Object.AddClass("ui-block-a");
|
---|
| 1059 | }
|
---|
| 1060 | }
|
---|
| 1061 |
|
---|
| 1062 | public class UIBlockB : UIObject
|
---|
| 1063 | {
|
---|
| 1064 | public UIBlockB()
|
---|
| 1065 | : base("<div>")
|
---|
| 1066 | {
|
---|
| 1067 | this.Object.AddClass("ui-block-b");
|
---|
| 1068 | }
|
---|
| 1069 | }
|
---|
| 1070 | }
|
---|
| 1071 |
|
---|
| 1072 | public class UIFlipSwitch : UIObject
|
---|
| 1073 | {
|
---|
| 1074 | public UIFlipSwitch()
|
---|
| 1075 | : base("<select>")
|
---|
| 1076 | {
|
---|
| 1077 | base.DataRole = "flipswitch";
|
---|
| 1078 | //base.Append(new UIOption());
|
---|
| 1079 | //base.Append(new UIOption());
|
---|
| 1080 | }
|
---|
| 1081 |
|
---|
| 1082 | public UIFlipSwitch(UIOption off, UIOption on)
|
---|
| 1083 | : this()
|
---|
| 1084 | {
|
---|
| 1085 | this.OFF = off;
|
---|
| 1086 | this.ON = on;
|
---|
| 1087 | base.Append(this.OFF);
|
---|
| 1088 | base.Append(this.ON);
|
---|
| 1089 | }
|
---|
| 1090 |
|
---|
| 1091 | public UIOption ON;//{ get { return new UIOption(base.Object.Find("option").Eq(1)); } set { base.Object.Find("option").Eq(1).ReplaceWith(value.Object); } }
|
---|
| 1092 | public UIOption OFF;// { get { return new UIOption(base.Object.Find("option").Eq(0)); } set { base.Object.Find("option").Eq(0).ReplaceWith(value.Object); } }
|
---|
| 1093 | }
|
---|
| 1094 |
|
---|
| 1095 | public class UIButton : UIObject
|
---|
| 1096 | {
|
---|
| 1097 | public UIButton()
|
---|
| 1098 | : base("<a>")
|
---|
| 1099 | {
|
---|
| 1100 | this.Button = true;
|
---|
| 1101 | this.NoText = true;
|
---|
| 1102 |
|
---|
| 1103 | this.Href = "#";
|
---|
| 1104 | this.CornerAll = true;
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
| 1107 | public bool Button { get { return base.Object.HasClass("ui-btn"); } set { base.Object.ToggleClass("ui-btn", value); } }
|
---|
| 1108 | public bool NoText { get { return base.Object.HasClass("ui-btn-icon-notext"); } set { base.Object.ToggleClass("ui-btn-icon-notext", value); } }
|
---|
| 1109 | public bool CornerAll { get { return base.Object.HasClass("ui-corner-all"); } set { base.Object.ToggleClass("ui-corner-all", value); } }
|
---|
| 1110 | public Icon ButtonIcon { get { return getIcon(); } set { base.Object.ToggleClass(getClass(value), true); } }
|
---|
| 1111 | public string Href { get { return base.Object.GetAttribute("href"); } set { base.Object.Attribute("href", value); } }
|
---|
| 1112 | public enum Icon
|
---|
| 1113 | {
|
---|
| 1114 | delete,
|
---|
| 1115 | refresh,
|
---|
| 1116 | back,
|
---|
| 1117 | }
|
---|
| 1118 |
|
---|
| 1119 | private string getClass(Icon icon)
|
---|
| 1120 | {
|
---|
| 1121 | string text = "";
|
---|
| 1122 | if (icon == Icon.delete) {
|
---|
| 1123 | text = "delete";
|
---|
| 1124 | }
|
---|
| 1125 | else if (icon == Icon.refresh) {
|
---|
| 1126 | text = "refresh";
|
---|
| 1127 | }
|
---|
| 1128 | else if (icon == Icon.back) {
|
---|
| 1129 | text = "back";
|
---|
| 1130 | }
|
---|
| 1131 | return "ui-icon-" + text;
|
---|
| 1132 | }
|
---|
| 1133 |
|
---|
| 1134 | private Icon getIcon()
|
---|
| 1135 | {
|
---|
| 1136 | if (base.Object.HasClass("ui-icon-delete")) {
|
---|
| 1137 | return Icon.delete;
|
---|
| 1138 | }
|
---|
| 1139 | else if (base.Object.HasClass("ui-icon-refresh")) {
|
---|
| 1140 | return Icon.refresh;
|
---|
| 1141 | }
|
---|
| 1142 | else if (base.Object.HasClass("ui-icon-back")) {
|
---|
| 1143 | return Icon.back;
|
---|
| 1144 | }
|
---|
| 1145 | return Icon.delete;
|
---|
| 1146 | }
|
---|
| 1147 | }
|
---|
| 1148 |
|
---|
| 1149 | public class UIOption : UIObject
|
---|
| 1150 | {
|
---|
| 1151 | public UIOption()
|
---|
| 1152 | : base("<option>")
|
---|
| 1153 | {
|
---|
| 1154 |
|
---|
| 1155 | }
|
---|
| 1156 |
|
---|
| 1157 | public UIOption(string text, string value)
|
---|
| 1158 | : this()
|
---|
| 1159 | {
|
---|
| 1160 | base.Text = text;
|
---|
| 1161 | base.Value = value;
|
---|
| 1162 | }
|
---|
| 1163 |
|
---|
| 1164 | public UIOption(jQueryObject @object)
|
---|
| 1165 | : base(@object)
|
---|
| 1166 | {
|
---|
| 1167 |
|
---|
| 1168 | }
|
---|
| 1169 | }
|
---|
| 1170 |
|
---|
| 1171 | public class UIRadioInput : UIObject
|
---|
| 1172 | {
|
---|
| 1173 | public UIRadioInput()
|
---|
| 1174 | : base("<input>")
|
---|
| 1175 | {
|
---|
| 1176 | base.Object.Attribute("type", "radio");
|
---|
| 1177 | }
|
---|
| 1178 |
|
---|
| 1179 | public UIRadioInput(string id, string name)
|
---|
| 1180 | : this()
|
---|
| 1181 | {
|
---|
| 1182 | base.Id = id;
|
---|
| 1183 | base.Name = name;
|
---|
| 1184 | }
|
---|
| 1185 |
|
---|
| 1186 | public UIRadioInput(string id, string name, string value)
|
---|
| 1187 | : this(id, name)
|
---|
| 1188 | {
|
---|
| 1189 | base.Value = value;
|
---|
| 1190 | }
|
---|
| 1191 |
|
---|
| 1192 | public UIRadioInput(string value)
|
---|
| 1193 | : this()
|
---|
| 1194 | {
|
---|
| 1195 | base.Value = value;
|
---|
| 1196 | }
|
---|
| 1197 | }
|
---|
| 1198 |
|
---|
| 1199 | public class UILi : UIObject
|
---|
| 1200 | {
|
---|
| 1201 | public UILi()
|
---|
| 1202 | : base("<li>")
|
---|
| 1203 | {
|
---|
| 1204 | }
|
---|
| 1205 | }
|
---|
| 1206 |
|
---|
| 1207 | public class UIFieldSet : UIObject
|
---|
| 1208 | {
|
---|
| 1209 | public UIFieldSet()
|
---|
| 1210 | : base("<fieldset>")
|
---|
| 1211 | {
|
---|
| 1212 | this.ControlGroup = true;
|
---|
| 1213 | }
|
---|
| 1214 |
|
---|
| 1215 | public UIFieldSet(bool horizontal)
|
---|
| 1216 | : this()
|
---|
| 1217 | {
|
---|
| 1218 | this.Horizontal = horizontal;
|
---|
| 1219 | }
|
---|
| 1220 |
|
---|
| 1221 | public string CheckdValue()
|
---|
| 1222 | {
|
---|
| 1223 | return jQuery.Select("input[type='radio']:checked", base.Object).GetValue();
|
---|
| 1224 | }
|
---|
| 1225 |
|
---|
| 1226 | public void Append(RadioInput radio)
|
---|
| 1227 | {
|
---|
| 1228 | if (RadioList == null) {
|
---|
| 1229 | RadioList = new List<RadioInput>();
|
---|
| 1230 | }
|
---|
| 1231 | RadioList.Add(new RadioInput(radio.Label, radio.Radio));
|
---|
| 1232 | RadioInput last = RadioList.Last<RadioInput>();
|
---|
| 1233 | base.Append(last.Label);
|
---|
| 1234 | base.Append(last.Radio);
|
---|
| 1235 | }
|
---|
| 1236 |
|
---|
| 1237 | public List<RadioInput> RadioList;
|
---|
| 1238 | private bool _ControlGroup;
|
---|
| 1239 | public bool ControlGroup
|
---|
| 1240 | {
|
---|
| 1241 | get
|
---|
| 1242 | {
|
---|
| 1243 | return _ControlGroup;
|
---|
| 1244 | }
|
---|
| 1245 | set
|
---|
| 1246 | {
|
---|
| 1247 | if (value) {
|
---|
| 1248 | base.DataRole = "controlgroup";
|
---|
| 1249 | }
|
---|
| 1250 | else {
|
---|
| 1251 | base.DataRole = "";
|
---|
| 1252 | }
|
---|
| 1253 | _ControlGroup = value;
|
---|
| 1254 | }
|
---|
| 1255 | }
|
---|
| 1256 |
|
---|
| 1257 | private bool _Horizontal;
|
---|
| 1258 | public bool Horizontal
|
---|
| 1259 | {
|
---|
| 1260 | get { return _Horizontal; }
|
---|
| 1261 | set
|
---|
| 1262 | {
|
---|
| 1263 | if (value) {
|
---|
| 1264 | base.DataType = "horizontal";
|
---|
| 1265 | }
|
---|
| 1266 | else {
|
---|
| 1267 | base.DataType = "";
|
---|
| 1268 | }
|
---|
| 1269 | _Horizontal = value;
|
---|
| 1270 | }
|
---|
| 1271 | }
|
---|
| 1272 |
|
---|
| 1273 | public class RadioInput
|
---|
| 1274 | {
|
---|
| 1275 | public UIRadioInput Radio;
|
---|
| 1276 | public UILabel Label;
|
---|
| 1277 | public RadioInput(UILabel Label, UIRadioInput Radio)
|
---|
| 1278 | {
|
---|
| 1279 | this.Radio = Radio;
|
---|
| 1280 | this.Label = Label;
|
---|
| 1281 | }
|
---|
| 1282 | }
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
| 1285 | public class UIRangeInput : UIObject
|
---|
| 1286 | {
|
---|
| 1287 | public UIRangeInput()
|
---|
| 1288 | : base("<input>")
|
---|
| 1289 | {
|
---|
| 1290 | base.Type = "number";
|
---|
| 1291 | base.DataType = "range";
|
---|
| 1292 | this.DataHighlight = true;
|
---|
| 1293 | base.Keypress(SliderKeypress);
|
---|
| 1294 | this.Handle = true;
|
---|
| 1295 | base.One("slidecreate", SliderCreate);
|
---|
| 1296 | }
|
---|
| 1297 |
|
---|
| 1298 | public UIRangeInput(int min, int max)
|
---|
| 1299 | : this()
|
---|
| 1300 | {
|
---|
| 1301 | base.Min = min;
|
---|
| 1302 | base.Max = max;
|
---|
| 1303 | base.Maxlength = GetMaxLength();
|
---|
| 1304 | }
|
---|
| 1305 |
|
---|
| 1306 | private int GetMaxLength()
|
---|
| 1307 | {
|
---|
| 1308 | int min = 0;
|
---|
| 1309 | int j;
|
---|
| 1310 | if (Min < 0) {
|
---|
| 1311 | min = 1;
|
---|
| 1312 | j = -10;
|
---|
| 1313 | while (Max / j > 1) {
|
---|
| 1314 | min++;
|
---|
| 1315 | j *= 10;
|
---|
| 1316 | }
|
---|
| 1317 | min++;
|
---|
| 1318 |
|
---|
| 1319 | }
|
---|
| 1320 | int i = 1;
|
---|
| 1321 | j = 10;
|
---|
| 1322 | while (Max / j >= 1) {
|
---|
| 1323 | i++;
|
---|
| 1324 | j *= 10;
|
---|
| 1325 | }
|
---|
| 1326 |
|
---|
| 1327 | return (i > min) ? i : min;
|
---|
| 1328 | }
|
---|
| 1329 |
|
---|
| 1330 | bool DataHighlight
|
---|
| 1331 | {
|
---|
| 1332 | get { return bool.Parse(base.GetAttribute("data-highlight")); }
|
---|
| 1333 | set { base.Attribute("data-highlight", value.ToString()); }
|
---|
| 1334 | }
|
---|
| 1335 |
|
---|
| 1336 | public new int Value
|
---|
| 1337 | {
|
---|
| 1338 | get
|
---|
| 1339 | {
|
---|
| 1340 | if (base.Value == "") {
|
---|
| 1341 | this.Value = base.Min;
|
---|
| 1342 | }
|
---|
| 1343 | return int.Parse(base.Value);
|
---|
| 1344 | }
|
---|
| 1345 | set { base.Value = value.ToString(); }
|
---|
| 1346 | }
|
---|
| 1347 |
|
---|
| 1348 | private void SliderKeypress(Element ele, jQueryEvent ev)
|
---|
| 1349 | {
|
---|
| 1350 | bool number = (ev.Which >= (int)KeyPress._0 && ev.Which <= (int)KeyPress._9);
|
---|
| 1351 |
|
---|
| 1352 | bool BackSpace = (ev.Which == (int)KeyPress.BackSpace);
|
---|
| 1353 | bool Delete = (ev.Which == (int)KeyPress.Delete);
|
---|
| 1354 | bool minus = (ev.Which == (int)KeyPress.minus);
|
---|
| 1355 | bool flag = (!number && !minus) && (!BackSpace && !Delete);
|
---|
| 1356 | if (flag) ev.PreventDefault();
|
---|
| 1357 | }
|
---|
| 1358 |
|
---|
| 1359 | public bool Handle;
|
---|
| 1360 | public UIHandle SliderHandle;
|
---|
| 1361 |
|
---|
| 1362 | private void SliderCreate(Element ele, jQueryEvent ev)
|
---|
| 1363 | {
|
---|
| 1364 | SliderHandle = new UIHandle(ev);
|
---|
| 1365 | SliderHandle.Toggle(this.Handle);
|
---|
| 1366 |
|
---|
| 1367 | UISliderTrack SliderTrack = new UISliderTrack(ev);
|
---|
| 1368 | SliderTrack.PointerEvents(this.Handle);
|
---|
| 1369 | base.PointerEvents(this.Handle);
|
---|
| 1370 | }
|
---|
| 1371 |
|
---|
| 1372 | public class UIHandle : UIObject
|
---|
| 1373 | {
|
---|
| 1374 | public UIHandle(jQueryEvent ev)
|
---|
| 1375 | {
|
---|
| 1376 | base.Object = jQuery.Select(ev.Target).Parent().Find(".ui-slider-handle");
|
---|
| 1377 | }
|
---|
| 1378 | }
|
---|
| 1379 |
|
---|
| 1380 | public class UISliderTrack : UIObject
|
---|
| 1381 | {
|
---|
| 1382 | public UISliderTrack(jQueryEvent ev)
|
---|
| 1383 | {
|
---|
| 1384 | base.Object = jQuery.Select(ev.Target).Parent().Find(".ui-slider-track");
|
---|
| 1385 | }
|
---|
| 1386 | }
|
---|
| 1387 | }
|
---|
| 1388 |
|
---|
| 1389 | public class UITextInput : UIObject
|
---|
| 1390 | {
|
---|
| 1391 | public UITextInput()
|
---|
| 1392 | : base("<input>")
|
---|
| 1393 | {
|
---|
| 1394 | base.Type = "text";
|
---|
| 1395 | this.DataClearBtn = true;
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | public UITextInput(JsDictionary dic)
|
---|
| 1399 | : this()
|
---|
| 1400 | {
|
---|
| 1401 | base.Attribute(dic);
|
---|
| 1402 | }
|
---|
| 1403 |
|
---|
| 1404 | public bool DataClearBtn
|
---|
| 1405 | {
|
---|
| 1406 | get { return bool.Parse(base.GetAttribute("data-clear-btn")); }
|
---|
| 1407 | set
|
---|
| 1408 | {
|
---|
| 1409 | if (value) { base.Attribute("data-clear-btn", value.ToString()); }
|
---|
| 1410 | else { base.RemoveAttr("data-clear-btn"); };
|
---|
| 1411 | }
|
---|
| 1412 | }
|
---|
| 1413 |
|
---|
| 1414 | public string Placeholder { get { return base.GetAttribute("placeholder"); } set { base.Attribute("placeholder", value); } }
|
---|
| 1415 | public JsDictionary DataOptions
|
---|
| 1416 | {
|
---|
| 1417 | get
|
---|
| 1418 | {
|
---|
| 1419 | return Json.Parse<JsDictionary>(base.GetAttribute("data-options"));
|
---|
| 1420 | }
|
---|
| 1421 | set
|
---|
| 1422 | {
|
---|
| 1423 | base.Attribute("data-options", Json.Stringify(value));
|
---|
| 1424 | }
|
---|
| 1425 | }
|
---|
| 1426 |
|
---|
| 1427 | public jQueryObject Keyup(jQueryEventHandlerWithContext eventHandler)
|
---|
| 1428 | {
|
---|
| 1429 | base.Object.Keyup(eventHandler);
|
---|
| 1430 | return base.Object;
|
---|
| 1431 | }
|
---|
| 1432 |
|
---|
| 1433 | public jQueryObject On(string eventName, jQueryEventHandlerWithContext eventHandler)
|
---|
| 1434 | {
|
---|
| 1435 | base.Object.On(eventName, eventHandler);
|
---|
| 1436 | return base.Object;
|
---|
| 1437 | }
|
---|
| 1438 |
|
---|
| 1439 | public bool ReadOnly
|
---|
| 1440 | {
|
---|
| 1441 | get { return base.GetAttribute("readonly") == "readonly"; }
|
---|
| 1442 | set
|
---|
| 1443 | {
|
---|
| 1444 | if (value) {
|
---|
| 1445 | this.Attribute("readonly", "readonly");
|
---|
| 1446 | }
|
---|
| 1447 | else {
|
---|
| 1448 | this.RemoveAttr("readonly");
|
---|
| 1449 | }
|
---|
| 1450 | }
|
---|
| 1451 | }
|
---|
| 1452 | }
|
---|
| 1453 |
|
---|
| 1454 | public class UITimeBox : UITextInput
|
---|
| 1455 | {
|
---|
| 1456 | public UITimeBox()
|
---|
| 1457 | : base()
|
---|
| 1458 | {
|
---|
| 1459 | base.DataRole = "datebox";
|
---|
| 1460 | base.DataOptions = new JsDictionary("mode", "timebox");
|
---|
| 1461 | base.DataClearBtn = false;
|
---|
| 1462 | base.On("dateboxcreate", DateBoxCreate);
|
---|
| 1463 | }
|
---|
| 1464 |
|
---|
| 1465 | private void DateBoxCreate(Element ele, jQueryEvent ev)
|
---|
| 1466 | {
|
---|
| 1467 | jQuery.Select(ele).Parents().Find(".ui-icon-grid").ToggleClass("ui-icon-grid", "ui-icon-clock");
|
---|
| 1468 | }
|
---|
| 1469 | }
|
---|
| 1470 |
|
---|
| 1471 | public class UICalBox : UITextInput
|
---|
| 1472 | {
|
---|
| 1473 | /// <summary>年</summary>
|
---|
| 1474 | public int dY { get { return GetCal(0); } }
|
---|
| 1475 |
|
---|
| 1476 | /// <summary>月</summary>
|
---|
| 1477 | public int dM { get { return GetCal(1); } }
|
---|
| 1478 |
|
---|
| 1479 | /// <summary>日</summary>
|
---|
| 1480 | public int dD { get { return GetCal(2); } }
|
---|
| 1481 |
|
---|
| 1482 | /// <summary>年(16進4桁)</summary>
|
---|
| 1483 | public string xY { get { return dY.ToString("X4"); } }
|
---|
| 1484 |
|
---|
| 1485 | /// <summary>月(16進2桁)</summary>
|
---|
| 1486 | public string xM { get { return dM.ToString("X2"); } }
|
---|
| 1487 |
|
---|
| 1488 | /// <summary>日(16進2桁)</summary>
|
---|
| 1489 | public string xD { get { return dD.ToString("X2"); } }
|
---|
| 1490 |
|
---|
| 1491 | /// <summary>年月日(16進8桁)</summary>
|
---|
| 1492 | public string YYYYMMDD { get { return xY + xM + xD; } }
|
---|
| 1493 |
|
---|
| 1494 | /// <summary>年(10進4桁)/月(10進4桁)/日(10進4桁)</summary>
|
---|
| 1495 | public string yyyymmdd { get { return dY.ToString("D4") + "/" + dM.ToString("D2") + "/" + dD.ToString("D2"); } }
|
---|
| 1496 |
|
---|
| 1497 | public UICalBox()
|
---|
| 1498 | : base()
|
---|
| 1499 | {
|
---|
| 1500 | base.DataRole = "datebox";
|
---|
| 1501 | base.DataOptions = new JsDictionary("mode", "calbox");
|
---|
| 1502 | base.DataClearBtn = false;
|
---|
| 1503 | base.On("dateboxcreate", DateBoxCreate);
|
---|
| 1504 | }
|
---|
| 1505 |
|
---|
| 1506 | private void DateBoxCreate(Element ele, jQueryEvent ev)
|
---|
| 1507 | {
|
---|
| 1508 | jQuery.Select(ele).Parents().Find(".ui-icon-grid").ToggleClass("ui-icon-grid", "ui-icon-calendar");
|
---|
| 1509 | }
|
---|
| 1510 |
|
---|
| 1511 | private int GetCal(int i)
|
---|
| 1512 | {
|
---|
| 1513 | int x = 0;
|
---|
| 1514 | if (Value.Contains("/")) {
|
---|
| 1515 | string[] value = Value.Split("/");
|
---|
| 1516 | x = int.Parse(value[i]);
|
---|
| 1517 | }
|
---|
| 1518 | return x;
|
---|
| 1519 | }
|
---|
| 1520 |
|
---|
| 1521 | public class UIInputDate : UIObject
|
---|
| 1522 | {
|
---|
| 1523 | public UIInputDate(jQueryEvent ev)
|
---|
| 1524 | {
|
---|
| 1525 | base.Object = jQuery.Select(ev.Target).Parent(".ui-input-datebox");
|
---|
| 1526 | }
|
---|
| 1527 | }
|
---|
| 1528 | }
|
---|
| 1529 |
|
---|
| 1530 | public class UICollapsibleset : UIObject
|
---|
| 1531 | {
|
---|
| 1532 | public UICollapsibleset()
|
---|
| 1533 | : base("<div>")
|
---|
| 1534 | {
|
---|
| 1535 | base.DataRole = "collapsible";
|
---|
| 1536 | }
|
---|
| 1537 |
|
---|
| 1538 | public UICollapsibleset(JsDictionary attr, string h2)
|
---|
| 1539 | : this()
|
---|
| 1540 | {
|
---|
| 1541 | base.Attribute(attr);
|
---|
| 1542 | base.Append(new UIH(2, h2));
|
---|
| 1543 | }
|
---|
| 1544 |
|
---|
| 1545 | public UICollapsibleset(string h2)
|
---|
| 1546 | : this()
|
---|
| 1547 | {
|
---|
| 1548 | base.Append(new UIH(2, h2));
|
---|
| 1549 | }
|
---|
| 1550 |
|
---|
| 1551 | public bool DataInset { get { return bool.Parse(base.Object.GetAttribute("data-inset")); } set { base.Object.Attribute("data-inset", value.ToString()); } }
|
---|
| 1552 | }
|
---|
| 1553 |
|
---|
| 1554 | public class UIListview : UIObject
|
---|
| 1555 | {
|
---|
| 1556 | public UIListview()
|
---|
| 1557 | : base("<ul>")
|
---|
| 1558 | {
|
---|
| 1559 | base.DataRole = "listview";
|
---|
| 1560 | }
|
---|
| 1561 |
|
---|
| 1562 | public UIListview(params object[] nameValuePairs)
|
---|
| 1563 | : this()
|
---|
| 1564 | {
|
---|
| 1565 | base.Attribute(new JsDictionary(nameValuePairs));
|
---|
| 1566 | }
|
---|
| 1567 | }
|
---|
| 1568 |
|
---|
| 1569 | public class UIListviewItem : UIObject
|
---|
| 1570 | {
|
---|
| 1571 | public UIListviewItem()
|
---|
| 1572 | : base("<li>")
|
---|
| 1573 | {
|
---|
| 1574 |
|
---|
| 1575 | }
|
---|
| 1576 |
|
---|
| 1577 | public UIListviewItem(UIObject uiobject)
|
---|
| 1578 | : this()
|
---|
| 1579 | {
|
---|
| 1580 | base.Append(uiobject);
|
---|
| 1581 | }
|
---|
| 1582 | }
|
---|
| 1583 |
|
---|
| 1584 | public class UIListDivider : UIListviewItem
|
---|
| 1585 | {
|
---|
| 1586 | public UIListDivider()
|
---|
| 1587 | : base()
|
---|
| 1588 | {
|
---|
| 1589 | base.DataRole = "list-divider";
|
---|
| 1590 | }
|
---|
| 1591 |
|
---|
| 1592 | public UIListDivider(string text)
|
---|
| 1593 | : this()
|
---|
| 1594 | {
|
---|
| 1595 | base.Text = text;
|
---|
| 1596 | }
|
---|
| 1597 |
|
---|
| 1598 | public UIListDivider(UIObject uiobject)
|
---|
| 1599 | : this()
|
---|
| 1600 | {
|
---|
| 1601 | base.Append(uiobject);
|
---|
| 1602 | }
|
---|
| 1603 |
|
---|
| 1604 | public UIListDivider(jQueryObject @object)
|
---|
| 1605 | : this()
|
---|
| 1606 | {
|
---|
| 1607 | base.Append(@object);
|
---|
| 1608 | }
|
---|
| 1609 | }
|
---|
| 1610 |
|
---|
| 1611 | public class UIP : UIObject
|
---|
| 1612 | {
|
---|
| 1613 | public UIP()
|
---|
| 1614 | : base("<p>")
|
---|
| 1615 | {
|
---|
| 1616 | }
|
---|
| 1617 |
|
---|
| 1618 | public UIP(string text)
|
---|
| 1619 | : this()
|
---|
| 1620 | {
|
---|
| 1621 | base.Text = text;
|
---|
| 1622 | }
|
---|
| 1623 |
|
---|
| 1624 | public UIP(string text, string @class)
|
---|
| 1625 | : this(text)
|
---|
| 1626 | {
|
---|
| 1627 | base.AddClass(@class);
|
---|
| 1628 | }
|
---|
| 1629 | }
|
---|
| 1630 |
|
---|
| 1631 | public class UIAnchor : UIObject
|
---|
| 1632 | {
|
---|
| 1633 | public UIAnchor()
|
---|
| 1634 | : base("<a>")
|
---|
| 1635 | {
|
---|
| 1636 |
|
---|
| 1637 | }
|
---|
| 1638 |
|
---|
| 1639 | public UIAnchor(string text)
|
---|
| 1640 | : this()
|
---|
| 1641 | {
|
---|
| 1642 | base.Text = text;
|
---|
| 1643 | }
|
---|
| 1644 |
|
---|
| 1645 | public UIAnchor(UIObject uiobject)
|
---|
| 1646 | : this()
|
---|
| 1647 | {
|
---|
| 1648 | base.Append(uiobject);
|
---|
| 1649 | }
|
---|
| 1650 |
|
---|
| 1651 | public string Href { get { return base.GetAttribute("href"); } set { base.Attribute("href", value); } }
|
---|
| 1652 | public string Target { get { return base.GetAttribute("target"); } set { base.Attribute("target", value); } }
|
---|
| 1653 | }
|
---|
| 1654 |
|
---|
| 1655 | public class UIH : UIObject
|
---|
| 1656 | {
|
---|
| 1657 | public UIH()
|
---|
| 1658 | : base("<h1>")
|
---|
| 1659 | {
|
---|
| 1660 | }
|
---|
| 1661 |
|
---|
| 1662 | public UIH(int i)
|
---|
| 1663 | : base("<h" + i.ToString() + ">")
|
---|
| 1664 | {
|
---|
| 1665 |
|
---|
| 1666 | }
|
---|
| 1667 |
|
---|
| 1668 | public UIH(int i, string text)
|
---|
| 1669 | : this(i)
|
---|
| 1670 | {
|
---|
| 1671 | base.Text = text;
|
---|
| 1672 | }
|
---|
| 1673 | }
|
---|
| 1674 |
|
---|
| 1675 | public class UIImg : UIObject
|
---|
| 1676 | {
|
---|
| 1677 | public UIImg()
|
---|
| 1678 | : base("<img>")
|
---|
| 1679 | {
|
---|
| 1680 |
|
---|
| 1681 | }
|
---|
| 1682 |
|
---|
| 1683 | public UIImg(JsDictionary attr)
|
---|
| 1684 | : this()
|
---|
| 1685 | {
|
---|
| 1686 | base.Attribute(attr);
|
---|
| 1687 | }
|
---|
| 1688 |
|
---|
| 1689 | public UIImg(params object[] nameValuePairs)
|
---|
| 1690 | : this()
|
---|
| 1691 | {
|
---|
| 1692 | base.Attribute(new JsDictionary(nameValuePairs));
|
---|
| 1693 | }
|
---|
| 1694 | }
|
---|
| 1695 |
|
---|
| 1696 | public class UIPin : UILi
|
---|
| 1697 | {
|
---|
| 1698 | public UIButton ReadButton;
|
---|
| 1699 | public UIFieldSet UIPinMode;
|
---|
| 1700 | public UIRangeInput Range;
|
---|
| 1701 | public UIRangeInput AnalogRead;
|
---|
| 1702 | public UIFlipSwitch FlipSwitch;
|
---|
| 1703 | public int Pin;
|
---|
| 1704 | public UIListDivider ListDivider;
|
---|
| 1705 | private UIFieldSet SetUIPinMode(int i)
|
---|
| 1706 | {
|
---|
| 1707 | UIPinMode.Append(new UILabel("INPUT", "input" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1708 | UIPinMode.Append(new UIRadioInput("input" + i.ToString(), "pin" + i.ToString(), "INPUT"));
|
---|
| 1709 | UIPinMode.Append(new UILabel("OUTPUT", "output" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1710 | UIPinMode.Append(new UIRadioInput("output" + i.ToString(), "pin" + i.ToString(), "OUTPUT"));
|
---|
| 1711 | UIPinMode.Append(new UILabel("INPUT_PULLUP", "input_pullup" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1712 | UIPinMode.Append(new UIRadioInput("input_pullup" + i.ToString(), "pin" + i.ToString(), "INPUT_PULLUP"));
|
---|
| 1713 | return UIPinMode;
|
---|
| 1714 | }
|
---|
| 1715 |
|
---|
| 1716 | private void SetUIDigital(int i)
|
---|
| 1717 | {
|
---|
| 1718 | }
|
---|
| 1719 |
|
---|
| 1720 | private void SetUIRange(int i)
|
---|
| 1721 | {
|
---|
| 1722 | Range = new UIRangeInput(-1, 255);
|
---|
| 1723 | Range.Value = 123;
|
---|
| 1724 | }
|
---|
| 1725 |
|
---|
| 1726 | private void SetAnalogRead(int i)
|
---|
| 1727 | {
|
---|
| 1728 | AnalogRead = new UIRangeInput(0, 1023);
|
---|
| 1729 | AnalogRead.Handle = false;
|
---|
| 1730 | }
|
---|
| 1731 |
|
---|
| 1732 | public UIPin()
|
---|
| 1733 | : base()
|
---|
| 1734 | {
|
---|
| 1735 | base.AddClass("pin");
|
---|
| 1736 | ListDivider = new UIListDivider();
|
---|
| 1737 | UIPinMode = new UIFieldSet(true);
|
---|
| 1738 |
|
---|
| 1739 | Range = new UIRangeInput();
|
---|
| 1740 |
|
---|
| 1741 | ReadButton = new UIButton();
|
---|
| 1742 | ReadButton.Title = "取得";
|
---|
| 1743 | ReadButton.ButtonIcon = UIButton.Icon.refresh;
|
---|
| 1744 | }
|
---|
| 1745 |
|
---|
| 1746 | public UIPin(int pin)
|
---|
| 1747 | : this()
|
---|
| 1748 | {
|
---|
| 1749 | this.Pin = pin;
|
---|
| 1750 | UIDiv Div = new UIDiv();
|
---|
| 1751 |
|
---|
| 1752 | Div.Append(new UIH(1, "pin" + pin.ToString()));
|
---|
| 1753 | Div.Append(ReadButton);
|
---|
| 1754 | ListDivider.Append(Div);
|
---|
| 1755 | SetUIPinMode(pin);
|
---|
| 1756 | SetUIDigital(pin);
|
---|
| 1757 | SetUIRange(pin);
|
---|
| 1758 |
|
---|
| 1759 | if (pin >= 0 && pin <= 7) {
|
---|
| 1760 | FlipSwitch = new UIFlipSwitch(new UIOption("LOW", "LOW"), new UIOption("HIGH", "HIGH"));
|
---|
| 1761 | base.Append(new UIFieldContain(UIPinMode));
|
---|
| 1762 | base.Append(new UIFieldContain(FlipSwitch));
|
---|
| 1763 | base.Append(new UIFieldContain(Range));
|
---|
| 1764 | }
|
---|
| 1765 | else if (pin >= 8 && pin <= 13) {
|
---|
| 1766 | FlipSwitch = new UIFlipSwitch(new UIOption("LOW", "LOW"), new UIOption("HIGH", "HIGH"));
|
---|
| 1767 | base.Append(new UIFieldContain(UIPinMode));
|
---|
| 1768 | base.Append(new UIFieldContain(FlipSwitch));
|
---|
| 1769 | }
|
---|
| 1770 | else if (pin >= 14 && pin <= 19) {
|
---|
| 1771 | SetAnalogRead(pin);
|
---|
| 1772 | base.Append(new UIFieldContain(AnalogRead));
|
---|
| 1773 | }
|
---|
| 1774 | }
|
---|
| 1775 |
|
---|
| 1776 | public Element[] GetElements()
|
---|
| 1777 | {
|
---|
| 1778 | Element[] elements = new Element[2];
|
---|
| 1779 | elements[0] = ListDivider.Element;
|
---|
| 1780 | elements[1] = base.Element;
|
---|
| 1781 | return elements;
|
---|
| 1782 | }
|
---|
| 1783 |
|
---|
| 1784 | public void SetPinModeChange(EventHandlerFieldSet eventhandler)
|
---|
| 1785 | {
|
---|
| 1786 | if (UIPinMode != null) {
|
---|
| 1787 | UIPinMode.Change((elem, ev) => { eventhandler(UIPinMode, Pin); });
|
---|
| 1788 | }
|
---|
| 1789 | }
|
---|
| 1790 |
|
---|
| 1791 | public void SetDigitalChange(EventHandlerFlipSwitch eventhandler)
|
---|
| 1792 | {
|
---|
| 1793 | if (FlipSwitch != null) {
|
---|
| 1794 | FlipSwitch.Change((elem, ev) => { eventhandler(ReadButton, FlipSwitch, Pin); });
|
---|
| 1795 | }
|
---|
| 1796 | }
|
---|
| 1797 |
|
---|
| 1798 | public void SetReadButtonClick(EventHandlerFlipSwitch eventhandler)
|
---|
| 1799 | {
|
---|
| 1800 | if (FlipSwitch != null) {
|
---|
| 1801 | ReadButton.Click((elem, ev) => { eventhandler(ReadButton, FlipSwitch, Pin); });
|
---|
| 1802 | }
|
---|
| 1803 | }
|
---|
| 1804 |
|
---|
| 1805 | public void SetAnalogWriteChange(EventHandlerRange eventhandler)
|
---|
| 1806 | {
|
---|
| 1807 | if (Range != null) {
|
---|
| 1808 | Range.Change((elem, ev) => { eventhandler(Range, Pin); });
|
---|
| 1809 | }
|
---|
| 1810 | }
|
---|
| 1811 |
|
---|
| 1812 | public void SetAnalogReadChange(EventHandlerRange eventhandler)
|
---|
| 1813 | {
|
---|
| 1814 | if (AnalogRead != null) {
|
---|
| 1815 | ReadButton.Click((elem, ev) => { eventhandler(AnalogRead, Pin); });
|
---|
| 1816 | }
|
---|
| 1817 | }
|
---|
| 1818 | }
|
---|
| 1819 |
|
---|
| 1820 | public delegate void EventHandlerFieldSet(UIFieldSet fieldcontain, int pin);
|
---|
| 1821 | public delegate void EventHandlerFlipSwitch(UIButton button, UIFlipSwitch fieldcontain, int pin);
|
---|
| 1822 | public delegate void EventHandlerDevicePropertyInfo(DeviceController.DevicePropertyInfo dpi, byte[] data);
|
---|
| 1823 | public delegate void EventHandlerRange(UIRangeInput fieldcontain, int pin);
|
---|
| 1824 |
|
---|
| 1825 | public class UIDeviceController
|
---|
| 1826 | {
|
---|
| 1827 | public DeviceController DeviceController;
|
---|
| 1828 | public class UIDeviceInfo
|
---|
| 1829 | {
|
---|
| 1830 | protected CtrlUI Page;
|
---|
| 1831 | public DeviceController.DeviceInfo di = null;
|
---|
| 1832 | Element[] Elements;
|
---|
| 1833 |
|
---|
| 1834 | protected void UIDeviceSet(DeviceController.DeviceInfo di, CtrlUI Page)
|
---|
| 1835 | {
|
---|
| 1836 | this.di = di;
|
---|
| 1837 | this.Page = Page;
|
---|
| 1838 | if (((WampApiKadecotDevice)di.Data).protocol == "arduino") {
|
---|
| 1839 | Elements = di.SetPin(Page);
|
---|
| 1840 | }
|
---|
| 1841 | else {
|
---|
| 1842 | Elements = di.SetEchonetlite(Page);
|
---|
| 1843 | }
|
---|
| 1844 | }
|
---|
| 1845 |
|
---|
| 1846 | public jQueryObject GetPropertys()
|
---|
| 1847 | {
|
---|
| 1848 | return jQuery.FromElements(Elements);
|
---|
| 1849 | }
|
---|
| 1850 |
|
---|
| 1851 | public void GetData()
|
---|
| 1852 | {
|
---|
| 1853 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1854 | if (dpi.Data != null) {
|
---|
| 1855 | dpi.GetValue(dpi.Data);
|
---|
| 1856 | }
|
---|
| 1857 | }
|
---|
| 1858 | }
|
---|
| 1859 |
|
---|
| 1860 | public bool IsWait()
|
---|
| 1861 | {
|
---|
| 1862 | bool flag = false;
|
---|
| 1863 |
|
---|
| 1864 | if (di != null && di.Properties != null) {
|
---|
| 1865 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1866 | if (dpi != null && dpi.IsWaitRes) {
|
---|
| 1867 | flag = true;
|
---|
| 1868 | }
|
---|
| 1869 | }
|
---|
| 1870 | }
|
---|
| 1871 |
|
---|
| 1872 | return flag;
|
---|
| 1873 | }
|
---|
| 1874 |
|
---|
| 1875 | public Element[] SetEchonetlite(CtrlUI ctrlui)
|
---|
| 1876 | {
|
---|
| 1877 | Element[] ele = new Element[di.Properties.Count];
|
---|
| 1878 | int i = 0;
|
---|
| 1879 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1880 | dpi.SetProperty(dpi);
|
---|
| 1881 | dpi.SetName(di);
|
---|
| 1882 | dpi.SetKadecotGet(Page.KadecotGet);
|
---|
| 1883 | dpi.SetKadecotSet(Page.KadecotSet);
|
---|
| 1884 | ele[i++] = dpi.GetElement();
|
---|
| 1885 | }
|
---|
| 1886 | return ele;
|
---|
| 1887 | }
|
---|
| 1888 |
|
---|
| 1889 | public Element[] SetPin(CtrlUI ctrlui)
|
---|
| 1890 | {
|
---|
| 1891 | Page = ctrlui;
|
---|
| 1892 | Element[] ele = new Element[20];
|
---|
| 1893 | Element[] element;
|
---|
| 1894 | int j = 0;
|
---|
| 1895 | for (int i = 0; i <= 19; i++) {
|
---|
| 1896 | element = SetPin(i, Page);
|
---|
| 1897 | ele[j++] = element[0];
|
---|
| 1898 | ele[j++] = element[1];
|
---|
| 1899 | }
|
---|
| 1900 | return ele;
|
---|
| 1901 | }
|
---|
| 1902 |
|
---|
| 1903 | public Element[] SetPin(int i, CtrlUI Page)
|
---|
| 1904 | {
|
---|
| 1905 | UIPin uiPin = new UIPin(i);
|
---|
| 1906 | uiPin.SetPinModeChange(Page.pinMode_Change);
|
---|
| 1907 | uiPin.SetDigitalChange(Page.digital_Change);
|
---|
| 1908 | uiPin.SetReadButtonClick(Page.DigitalRead);
|
---|
| 1909 | uiPin.SetAnalogWriteChange(Page.analogWrite_Change);
|
---|
| 1910 | uiPin.SetAnalogReadChange(Page.analogRead);
|
---|
| 1911 | return uiPin.GetElements();
|
---|
| 1912 | }
|
---|
| 1913 | }
|
---|
| 1914 |
|
---|
| 1915 | public jQueryObject GetUINodeList(jQueryEventHandlerWithContextDi listitem_click)
|
---|
| 1916 | {
|
---|
| 1917 | UINodeList nodelist = new UINodeList(DeviceController.NodeList, listitem_click);
|
---|
| 1918 |
|
---|
| 1919 | return nodelist.GetNodeList();
|
---|
| 1920 | }
|
---|
| 1921 |
|
---|
| 1922 | public delegate void jQueryEventHandlerWithContextDi(Element elem, jQueryEvent e, DeviceController.DeviceInfo node);
|
---|
| 1923 |
|
---|
| 1924 | public class UIDevicePropertyInfo
|
---|
| 1925 | {
|
---|
| 1926 | private UIGrpBox Grpbox;
|
---|
| 1927 |
|
---|
| 1928 | public Element GetElement()
|
---|
| 1929 | {
|
---|
| 1930 | return Grpbox.Object.GetElement(0);
|
---|
| 1931 | }
|
---|
| 1932 |
|
---|
| 1933 | public void SetName(DeviceController.DeviceInfo di)
|
---|
| 1934 | {
|
---|
| 1935 | string nameid = di.GetObjectID() + dpi.GetPropertyCode("X2");
|
---|
| 1936 | Grpbox.SetName(nameid);
|
---|
| 1937 | }
|
---|
| 1938 |
|
---|
| 1939 | public string ErrorText { get { return Grpbox.ErrorText; } set { Grpbox.ErrorText = value; } }
|
---|
| 1940 |
|
---|
| 1941 | public int GetMaxLength()
|
---|
| 1942 | {
|
---|
| 1943 | int len = 2 * ((dpi.PropertyInfo == null) ? dpi.Size : (((dpi.PropertyInfo.arrayCount == 0) ? 1 : dpi.PropertyInfo.arrayCount) * dpi.PropertyInfo.size));
|
---|
| 1944 | return len;
|
---|
| 1945 | }
|
---|
| 1946 |
|
---|
| 1947 | public void SetProperty(DeviceController.DevicePropertyInfo dpi)
|
---|
| 1948 | {
|
---|
| 1949 | this.dpi = dpi;
|
---|
| 1950 | Grpbox = new UIGrpBox(dpi);
|
---|
| 1951 | }
|
---|
| 1952 |
|
---|
| 1953 | public void SetKadecotGet(EventHandlerPropertyInfo KadecotGet)
|
---|
| 1954 | {
|
---|
| 1955 | DeviceController.DevicePropertyInfo opeSt = null;
|
---|
| 1956 |
|
---|
| 1957 | //現在時刻設定
|
---|
| 1958 | if (dpi.PropertyCode == 0x97) {
|
---|
| 1959 | }
|
---|
| 1960 | else if (dpi.PropertyCode == 0x98) {
|
---|
| 1961 |
|
---|
| 1962 | }
|
---|
| 1963 | else if (this.dpi.InputTypes.Count == 0) {
|
---|
| 1964 |
|
---|
| 1965 | }
|
---|
| 1966 | else if (dpi.PropertyCode == 0x80 && dpi.InputTypes.Count == 1 && dpi.InputTypes[0].Mode == PropertyInputMode.Select) {
|
---|
| 1967 |
|
---|
| 1968 | }
|
---|
| 1969 |
|
---|
| 1970 | else {
|
---|
| 1971 | foreach (PropertyInputInfo pii in dpi.InputTypes) {
|
---|
| 1972 | if (dpi.PropertyCode == 0x80)
|
---|
| 1973 | opeSt = dpi;
|
---|
| 1974 | }
|
---|
| 1975 | if (opeSt != null)
|
---|
| 1976 | KadecotGet(opeSt);
|
---|
| 1977 | }
|
---|
| 1978 | }
|
---|
| 1979 |
|
---|
| 1980 | public void SetKadecotSet(EventHandlerDevicePropertyInfo KadecotSet)
|
---|
| 1981 | {
|
---|
| 1982 | Grpbox.KadecotSet = KadecotSet;
|
---|
| 1983 | }
|
---|
| 1984 |
|
---|
| 1985 | private DeviceController.DevicePropertyInfo dpi;
|
---|
| 1986 |
|
---|
| 1987 | public delegate void EventHandlerPropertyInfo(DeviceController.DevicePropertyInfo dpi);
|
---|
| 1988 |
|
---|
| 1989 | public void GetValue(byte[] data)
|
---|
| 1990 | {
|
---|
| 1991 | Grpbox.SetGetValue(data);
|
---|
| 1992 | }
|
---|
| 1993 | }
|
---|
| 1994 | }
|
---|
| 1995 |
|
---|
| 1996 | public class UINodeList
|
---|
| 1997 | {
|
---|
| 1998 | public UINodeList(IEnumerable<DeviceController.NodeInfo> NodeList, UIDeviceController.jQueryEventHandlerWithContextDi listitem_click)
|
---|
| 1999 | {
|
---|
| 2000 | info = new UIDiv();
|
---|
| 2001 | string identifer = "";
|
---|
| 2002 | foreach (var node in NodeList) {
|
---|
| 2003 |
|
---|
| 2004 | var profile = node.Profile;
|
---|
| 2005 |
|
---|
| 2006 | if (jQuery.Select("#" + "cl_node_" + identifer).Length > 0)
|
---|
| 2007 | continue;
|
---|
| 2008 | UICollapsibleset col = new UICollapsibleset(node.Data.ToString());
|
---|
| 2009 | col.Id = "cl_node_" + identifer;
|
---|
| 2010 | col.DataInset = true;
|
---|
| 2011 | info.Append(col);
|
---|
| 2012 | UIListview listview = new UIListview("id", "lv_node_" + identifer);
|
---|
| 2013 |
|
---|
| 2014 | col.Append(listview);
|
---|
| 2015 | foreach (var item in node.Devices) {
|
---|
| 2016 |
|
---|
| 2017 | if (item.Profile)
|
---|
| 2018 | continue;
|
---|
| 2019 |
|
---|
| 2020 | identifer = item.GetObjectID();
|
---|
| 2021 | if (jQuery.Select("#" + "li_device_" + identifer).Length > 0)
|
---|
| 2022 | continue;
|
---|
| 2023 | UIListviewItem listitem = new UIListviewItem();
|
---|
| 2024 | listitem.Id = "li_device_" + identifer;
|
---|
| 2025 | listitem.Click((ele, ev) => { listitem_click(ele, ev, item); });
|
---|
| 2026 | listview.Append(listitem);
|
---|
| 2027 |
|
---|
| 2028 |
|
---|
| 2029 | UIAnchor anchor = new UIAnchor();
|
---|
| 2030 | anchor.Href = "#";
|
---|
| 2031 | anchor.Title = ((WampApiKadecotDevice)item.Data).description;
|
---|
| 2032 | anchor.Text = ((WampApiKadecotDevice)item.Data).nickname;
|
---|
| 2033 | anchor.Click((ele, ev) => { listitem_Click(listitem, item); });
|
---|
| 2034 |
|
---|
| 2035 | listitem.Append(anchor);
|
---|
| 2036 | }
|
---|
| 2037 | }
|
---|
| 2038 | }
|
---|
| 2039 |
|
---|
| 2040 | private UIDiv info;
|
---|
| 2041 |
|
---|
| 2042 | public jQueryObject GetNodeList()
|
---|
| 2043 | {
|
---|
| 2044 | return info.Children();
|
---|
| 2045 | }
|
---|
| 2046 |
|
---|
| 2047 | /// <summary>
|
---|
| 2048 | /// "#li_device_XXXXXX"をクリック
|
---|
| 2049 | /// </summary>
|
---|
| 2050 | /// <param name="elem"></param>
|
---|
| 2051 | /// <param name="ev"></param>
|
---|
| 2052 | private void listitem_Click(UIListviewItem listitem, DeviceController.DeviceInfo item)
|
---|
| 2053 | {
|
---|
| 2054 | //選択中クラスの追加
|
---|
| 2055 | jQuery.Select(".li-select").RemoveClass("li-select");
|
---|
| 2056 | listitem.AddClass("li-select");
|
---|
| 2057 | }
|
---|
| 2058 | }
|
---|
| 2059 |
|
---|
| 2060 | public static class UIEventNames
|
---|
| 2061 | {
|
---|
| 2062 | public static string CurrentNodeChange = "currentnode.change";
|
---|
| 2063 | public static string LoadingShow = "loading.show";
|
---|
| 2064 | public static string LoadingHide = "loading.hide";
|
---|
| 2065 | /// <summary>
|
---|
| 2066 | /// 機器検索開始
|
---|
| 2067 | /// </summary>
|
---|
| 2068 | public static string SearchStart = "search.start";
|
---|
| 2069 | /// <summary>
|
---|
| 2070 | /// 機器検索終了
|
---|
| 2071 | /// </summary>
|
---|
| 2072 | public static string SearchEnd = "search.end";
|
---|
| 2073 | /// <summary>
|
---|
| 2074 | /// 機器検索エラー
|
---|
| 2075 | /// </summary>
|
---|
| 2076 | public static string SearchError = "search.error";
|
---|
| 2077 | /// <summary>
|
---|
| 2078 | /// 入力画面作成開始
|
---|
| 2079 | /// </summary>
|
---|
| 2080 | public static string PropertyWriteStart = "propertywrite.start";
|
---|
| 2081 | /// <summary>
|
---|
| 2082 | /// 入力画面作成終了
|
---|
| 2083 | /// </summary>
|
---|
| 2084 | public static string PropertyWriteEnd = "propertywrite.end";
|
---|
| 2085 | }
|
---|
| 2086 |
|
---|
| 2087 | public static class UIEventHandler
|
---|
| 2088 | {
|
---|
| 2089 | public static void LoadingShow(jQueryEvent ev)
|
---|
| 2090 | {
|
---|
| 2091 | jQueryMobile.Loading("show");
|
---|
| 2092 | }
|
---|
| 2093 |
|
---|
| 2094 | public static void LoadingHide(jQueryEvent ev)
|
---|
| 2095 | {
|
---|
| 2096 | jQueryMobile.Loading("hide");
|
---|
| 2097 | }
|
---|
| 2098 | }
|
---|
| 2099 |
|
---|
| 2100 | public enum KeyPress
|
---|
| 2101 | {
|
---|
| 2102 | Delete = 0,
|
---|
| 2103 | BackSpace = 8,
|
---|
| 2104 | minus = 45,
|
---|
| 2105 | dot = 46,
|
---|
| 2106 | slash = 47,
|
---|
| 2107 | _0 = 48,
|
---|
| 2108 | _1 = 49,
|
---|
| 2109 | _2 = 50,
|
---|
| 2110 | _3 = 51,
|
---|
| 2111 | _4 = 52,
|
---|
| 2112 | _5 = 53,
|
---|
| 2113 | _6 = 54,
|
---|
| 2114 | _7 = 55,
|
---|
| 2115 | _8 = 56,
|
---|
| 2116 | _9 = 57,
|
---|
| 2117 | A = 65,
|
---|
| 2118 | B = 66,
|
---|
| 2119 | C = 67,
|
---|
| 2120 | D = 68,
|
---|
| 2121 | E = 69,
|
---|
| 2122 | F = 70,
|
---|
| 2123 | a = 97,
|
---|
| 2124 | b = 98,
|
---|
| 2125 | c = 99,
|
---|
| 2126 | d = 100,
|
---|
| 2127 | e = 101,
|
---|
| 2128 | f = 102,
|
---|
| 2129 | }
|
---|
| 2130 | }
|
---|