[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 148 2016-01-08 05:35:52Z 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(); } }
|
---|
[148] | 766 |
|
---|
[101] | 767 | private byte[] ToByteValue()
|
---|
| 768 | {
|
---|
| 769 | string Value = FieldContain.Input.Value;
|
---|
| 770 | byte[] data = new byte[Value.Length / 2];
|
---|
| 771 | for (int i = 0, j = 0; j < Value.Length; j += 2) {
|
---|
| 772 | data[i++] = Byte.Parse(Value.Substring(j, 2), 16);
|
---|
| 773 | }
|
---|
| 774 | return data;
|
---|
| 775 | }
|
---|
| 776 |
|
---|
| 777 | private void SetDpi()
|
---|
| 778 | {
|
---|
| 779 | dpi.InputData = ByteValue;
|
---|
| 780 | dpi.IsWaitRes = true;
|
---|
| 781 | ErrorText = "";
|
---|
| 782 | ToggleClass(user ? "ecnl_light_green" : "ecnl_light_blue", true);
|
---|
| 783 | }
|
---|
| 784 |
|
---|
| 785 | bool user = true;
|
---|
| 786 | private byte[] ByteValue { get { return ToByteValue(); } }
|
---|
| 787 | private DeviceController.DevicePropertyInfo dpi;
|
---|
| 788 | private UIP LiAside;
|
---|
| 789 | public string ErrorText { get { return LiAside.Text; } set { LiAside.Text = value; } }
|
---|
| 790 | public byte[] GetValue;
|
---|
| 791 | public UIFieldContain FieldContain;
|
---|
| 792 |
|
---|
| 793 | public void RemoveClass()
|
---|
| 794 | {
|
---|
| 795 | ErrorText = "";
|
---|
| 796 | BackButton.Hide();
|
---|
| 797 | RemoveClass("ecnl_pink");
|
---|
| 798 | RemoveClass("ecnl_violet");
|
---|
| 799 | RemoveClass("ecnl_light_green");
|
---|
| 800 | RemoveClass("ecnl_light_blue");
|
---|
| 801 | }
|
---|
| 802 |
|
---|
| 803 | public void SetName(string nameid)
|
---|
| 804 | {
|
---|
| 805 | string name = nameid;
|
---|
| 806 | if (InputType == typeof(UICalBox)) {
|
---|
| 807 | name = "cal_" + nameid;
|
---|
| 808 | }
|
---|
| 809 | else if (InputType == typeof(UITimeBox)) {
|
---|
| 810 | name = "tmb_" + nameid;
|
---|
| 811 | }
|
---|
| 812 | else if (InputType == typeof(UITextInput)) {
|
---|
| 813 | name = "txt_" + nameid;
|
---|
| 814 | }
|
---|
| 815 | else if (InputType == typeof(UIRadioInput)) {
|
---|
| 816 | name = "rng_" + nameid;
|
---|
| 817 | }
|
---|
| 818 | else if (InputType == typeof(UIFlipSwitch)) {
|
---|
| 819 | name = "flp_" + nameid;
|
---|
| 820 | UIFlipSwitch Flipswitch = (UIFlipSwitch)FieldContain.Input;
|
---|
| 821 |
|
---|
| 822 | string val0 = Flipswitch.OFF.Value;
|
---|
| 823 | string val1 = Flipswitch.ON.Value;
|
---|
| 824 | Flipswitch.OFF.Id = name + val0;
|
---|
| 825 | Flipswitch.ON.Id = name + val1;
|
---|
| 826 | }
|
---|
| 827 | else if (InputType == typeof(UIFieldSet)) {
|
---|
| 828 | name = "sel_" + nameid;
|
---|
| 829 | UIFieldSet FieldSet = (UIFieldSet)FieldContain.Input;
|
---|
| 830 | FieldSet.Id = name;
|
---|
| 831 |
|
---|
| 832 | for (int i = 0; i < FieldSet.RadioList.Count; i++) {
|
---|
| 833 | var id = name + FieldSet.RadioList[i].Radio.Value;
|
---|
| 834 | FieldSet.RadioList[i].Radio.Name = name;
|
---|
| 835 | FieldSet.RadioList[i].Radio.Id = id;
|
---|
| 836 | FieldSet.RadioList[i].Label.For = id;
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
| 839 |
|
---|
| 840 | FieldContain.Label.For = name;
|
---|
| 841 | FieldContain.Input.Id = name;
|
---|
| 842 | FieldContain.Input.Name = name;
|
---|
| 843 | }
|
---|
| 844 |
|
---|
| 845 | public bool CheckHex()
|
---|
| 846 | {
|
---|
| 847 | string Value = FieldContain.Input.Value;
|
---|
| 848 | if (!new Regex("^([0-9A-Fa-f][0-9A-Fa-f])+$").Test(Value)) {
|
---|
| 849 | ErrorText = "16進数で入力してください";
|
---|
| 850 | ToggleClass(true ? "ecnl_pink" : "ecnl_violet", true);
|
---|
| 851 | return false;
|
---|
| 852 | }
|
---|
| 853 | return true;
|
---|
| 854 | }
|
---|
| 855 |
|
---|
| 856 | public bool CheckValiable()
|
---|
| 857 | {
|
---|
| 858 | JsonPropertyInfo epi = dpi.PropertyInfo;
|
---|
| 859 | //可変長データの場合
|
---|
| 860 | bool valiable = dpi.IsValiable();
|
---|
| 861 | int len = dpi.GetMaxLength();
|
---|
| 862 | string Value = FieldContain.Input.Value;
|
---|
| 863 | bool length = (Value.Length != len) && (!valiable || (Value.Length > len));
|
---|
| 864 |
|
---|
| 865 | if ((Value.Length != len) && (!valiable || (Value.Length > len))) {
|
---|
| 866 | ErrorText = len.ToString() + "文字で入力してください";
|
---|
| 867 | ToggleClass(user ? "ecnl_pink" : "ecnl_violet", true);
|
---|
| 868 |
|
---|
| 869 | return false;
|
---|
| 870 | }
|
---|
| 871 | return true;
|
---|
| 872 | }
|
---|
| 873 |
|
---|
| 874 | public string ToTextDefault(byte[] data)
|
---|
| 875 | {
|
---|
| 876 | string value = "";
|
---|
| 877 | if (data == null) {
|
---|
| 878 | return "";
|
---|
| 879 | }
|
---|
| 880 | for (int i = 0; i < data.Length; i++) {
|
---|
| 881 | value += data[i].ToString("X2");
|
---|
| 882 | }
|
---|
| 883 | return value;
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 | public string ToTextTimeBox(byte[] data)
|
---|
| 887 | {
|
---|
| 888 |
|
---|
| 889 | string str = ToTextDefault(data);
|
---|
| 890 | if (str.Length == 4) {
|
---|
| 891 | int h = int.Parse("0x" + str.Substr(0, 2));
|
---|
| 892 | int m = int.Parse("0x" + str.Substr(2, 2));
|
---|
| 893 | return h.ToString("D2") + ":" + m.ToString("D2");
|
---|
| 894 | }
|
---|
| 895 | else {
|
---|
| 896 | return "";
|
---|
| 897 | }
|
---|
| 898 | }
|
---|
| 899 |
|
---|
| 900 | public string ToTextCal(byte[] data)
|
---|
| 901 | {
|
---|
| 902 | string str = ToText(data);
|
---|
| 903 | if (str.Length == 8) {
|
---|
| 904 | int y = int.Parse("0x" + str.Substr(0, 4));
|
---|
| 905 | int m = int.Parse("0x" + str.Substr(4, 2));
|
---|
| 906 | int d = int.Parse("0x" + str.Substr(6, 2));
|
---|
| 907 | if ((y < 1 || m < 1) || d < 1) {
|
---|
| 908 | return y.ToString("D4") + "/" + m.ToString("D2") + "/" + m.ToString("D2");
|
---|
| 909 | }
|
---|
| 910 | DateTime date = new DateTime(y, m, d);
|
---|
| 911 | return date.ToString("yyyy/MM/dd");
|
---|
| 912 | }
|
---|
| 913 | else {
|
---|
| 914 | return "";
|
---|
| 915 | }
|
---|
| 916 | }
|
---|
| 917 |
|
---|
| 918 | public string ToText(byte[] data)
|
---|
| 919 | {
|
---|
| 920 | if (data == null) {
|
---|
| 921 | return "";
|
---|
| 922 | }
|
---|
| 923 | if (FieldContain.Input.GetType().Equals(typeof(UITimeBox))) {
|
---|
| 924 | return ToTextTimeBox(data);
|
---|
| 925 | }
|
---|
| 926 | else if (FieldContain.Input.GetType().Equals(typeof(UICalBox))) {
|
---|
| 927 | return ToTextCal(data);
|
---|
| 928 | }
|
---|
| 929 | else {
|
---|
| 930 | return ToTextDefault(data);
|
---|
| 931 | }
|
---|
| 932 | }
|
---|
| 933 |
|
---|
| 934 | /// <summary>
|
---|
| 935 | /// 値が変わった時true
|
---|
| 936 | /// </summary>
|
---|
| 937 | public bool Changed { get { return !FieldContain.Input.Value.Equals(ToText(GetValue)); } }
|
---|
[148] | 938 |
|
---|
[101] | 939 | public void GrpBoxChange(Element ele, jQueryEvent ev)
|
---|
| 940 | {
|
---|
| 941 | BackButton.Toggle(Changed);
|
---|
| 942 | if (!Changed) {
|
---|
| 943 | dpi.IsWaitRes = false;
|
---|
| 944 | dpi.InputData = null;
|
---|
| 945 | RemoveClass();
|
---|
| 946 | }
|
---|
| 947 | }
|
---|
| 948 |
|
---|
| 949 | public EventHandlerDevicePropertyInfo KadecotSet;
|
---|
[148] | 950 |
|
---|
[101] | 951 | public void SetGetValue(byte[] data)
|
---|
| 952 | {
|
---|
| 953 | RemoveClass();
|
---|
| 954 | GetValue = data;
|
---|
| 955 | FieldContain.Input.Value = ToText(data);
|
---|
| 956 | FieldContain.Input.Change();
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | public UIBackButton BackButton = new UIBackButton();
|
---|
| 960 | }
|
---|
| 961 |
|
---|
| 962 | public class UIBackButton : UIButton
|
---|
| 963 | {
|
---|
| 964 | public UIBackButton()
|
---|
| 965 | : base()
|
---|
| 966 | {
|
---|
| 967 | base.ButtonIcon = Icon.back;
|
---|
| 968 | base.Title = "元に戻す";
|
---|
| 969 | base.TabIndex = -1;
|
---|
| 970 | base.AddClass("text_backButton");
|
---|
| 971 | base.Object.Hide();
|
---|
| 972 | }
|
---|
| 973 | }
|
---|
| 974 |
|
---|
| 975 | public class UIDiv : UIObject
|
---|
| 976 | {
|
---|
| 977 | public UIDiv()
|
---|
| 978 | : base("<div>")
|
---|
| 979 | {
|
---|
| 980 |
|
---|
| 981 | }
|
---|
| 982 | }
|
---|
| 983 |
|
---|
| 984 | public class UILabel : UIObject
|
---|
| 985 | {
|
---|
| 986 | public UILabel()
|
---|
| 987 | : base("<label>")
|
---|
| 988 | {
|
---|
| 989 | }
|
---|
| 990 |
|
---|
| 991 | public UILabel(string text)
|
---|
| 992 | : this()
|
---|
| 993 | {
|
---|
| 994 | base.Text = text;
|
---|
| 995 | }
|
---|
| 996 |
|
---|
| 997 | public UILabel(string text, string @for)
|
---|
| 998 | : this(text)
|
---|
| 999 | {
|
---|
| 1000 | base.For = @for;
|
---|
| 1001 | }
|
---|
| 1002 |
|
---|
| 1003 | public UILabel(string text, string @for, string name)
|
---|
| 1004 | : this(text, @for)
|
---|
| 1005 | {
|
---|
| 1006 | base.Name = name;
|
---|
| 1007 | }
|
---|
| 1008 |
|
---|
| 1009 | public UILabel(DeviceController.DevicePropertyInfo dpi)
|
---|
| 1010 | : this(dpi.GetText())
|
---|
| 1011 | {
|
---|
| 1012 | base.Title = dpi.PropertyInfo.valueDescription;
|
---|
| 1013 | }
|
---|
| 1014 | }
|
---|
| 1015 |
|
---|
| 1016 | public class UIFieldContain : UIObject
|
---|
| 1017 | {
|
---|
| 1018 | public UIFieldContain()
|
---|
| 1019 | : base("<div>")
|
---|
| 1020 | {
|
---|
| 1021 | base.DataRole = "fieldcontain";
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
| 1024 | public UIFieldContain(UIObject uiobject)
|
---|
| 1025 | : this()
|
---|
| 1026 | {
|
---|
| 1027 | base.Append(uiobject);
|
---|
| 1028 | }
|
---|
| 1029 |
|
---|
| 1030 | public UIFieldContain(UILabel label, UIObject uiobject)
|
---|
| 1031 | : this()
|
---|
| 1032 | {
|
---|
| 1033 | this.Label = label;
|
---|
| 1034 | this.Input = uiobject;
|
---|
| 1035 | base.Append(this.Label);
|
---|
| 1036 | base.Append(this.Input);
|
---|
| 1037 | }
|
---|
| 1038 |
|
---|
| 1039 | public UILabel Label;
|
---|
| 1040 | public UIObject Input;
|
---|
| 1041 | }
|
---|
| 1042 |
|
---|
| 1043 | public class UIGridA : UIObject
|
---|
| 1044 | {
|
---|
| 1045 | public UIGridA()
|
---|
| 1046 | : base("<div>")
|
---|
| 1047 | {
|
---|
| 1048 | this.Object.AddClass("ui-grid-a");
|
---|
| 1049 | this.Append(BlockA);
|
---|
| 1050 | this.Append(BlockB);
|
---|
| 1051 | }
|
---|
| 1052 |
|
---|
| 1053 | public UIBlockA BlockA = new UIBlockA();
|
---|
| 1054 | public UIBlockB BlockB = new UIBlockB();
|
---|
| 1055 |
|
---|
| 1056 | public class UIBlockA : UIObject
|
---|
| 1057 | {
|
---|
| 1058 | public UIBlockA()
|
---|
| 1059 | : base("<div>")
|
---|
| 1060 | {
|
---|
| 1061 | this.Object.AddClass("ui-block-a");
|
---|
| 1062 | }
|
---|
| 1063 | }
|
---|
| 1064 |
|
---|
| 1065 | public class UIBlockB : UIObject
|
---|
| 1066 | {
|
---|
| 1067 | public UIBlockB()
|
---|
| 1068 | : base("<div>")
|
---|
| 1069 | {
|
---|
| 1070 | this.Object.AddClass("ui-block-b");
|
---|
| 1071 | }
|
---|
| 1072 | }
|
---|
| 1073 | }
|
---|
| 1074 |
|
---|
| 1075 | public class UIFlipSwitch : UIObject
|
---|
| 1076 | {
|
---|
| 1077 | public UIFlipSwitch()
|
---|
| 1078 | : base("<select>")
|
---|
| 1079 | {
|
---|
| 1080 | base.DataRole = "flipswitch";
|
---|
| 1081 | //base.Append(new UIOption());
|
---|
| 1082 | //base.Append(new UIOption());
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
| 1085 | public UIFlipSwitch(UIOption off, UIOption on)
|
---|
| 1086 | : this()
|
---|
| 1087 | {
|
---|
| 1088 | this.OFF = off;
|
---|
| 1089 | this.ON = on;
|
---|
| 1090 | base.Append(this.OFF);
|
---|
| 1091 | base.Append(this.ON);
|
---|
| 1092 | }
|
---|
| 1093 |
|
---|
| 1094 | public UIOption ON;//{ get { return new UIOption(base.Object.Find("option").Eq(1)); } set { base.Object.Find("option").Eq(1).ReplaceWith(value.Object); } }
|
---|
| 1095 | public UIOption OFF;// { get { return new UIOption(base.Object.Find("option").Eq(0)); } set { base.Object.Find("option").Eq(0).ReplaceWith(value.Object); } }
|
---|
| 1096 | }
|
---|
| 1097 |
|
---|
| 1098 | public class UIButton : UIObject
|
---|
| 1099 | {
|
---|
| 1100 | public UIButton()
|
---|
| 1101 | : base("<a>")
|
---|
| 1102 | {
|
---|
| 1103 | this.Button = true;
|
---|
| 1104 | this.NoText = true;
|
---|
| 1105 |
|
---|
| 1106 | this.Href = "#";
|
---|
| 1107 | this.CornerAll = true;
|
---|
| 1108 | }
|
---|
| 1109 |
|
---|
| 1110 | public bool Button { get { return base.Object.HasClass("ui-btn"); } set { base.Object.ToggleClass("ui-btn", value); } }
|
---|
| 1111 | public bool NoText { get { return base.Object.HasClass("ui-btn-icon-notext"); } set { base.Object.ToggleClass("ui-btn-icon-notext", value); } }
|
---|
| 1112 | public bool CornerAll { get { return base.Object.HasClass("ui-corner-all"); } set { base.Object.ToggleClass("ui-corner-all", value); } }
|
---|
| 1113 | public Icon ButtonIcon { get { return getIcon(); } set { base.Object.ToggleClass(getClass(value), true); } }
|
---|
| 1114 | public string Href { get { return base.Object.GetAttribute("href"); } set { base.Object.Attribute("href", value); } }
|
---|
[148] | 1115 |
|
---|
[101] | 1116 | public enum Icon
|
---|
| 1117 | {
|
---|
| 1118 | delete,
|
---|
| 1119 | refresh,
|
---|
| 1120 | back,
|
---|
| 1121 | }
|
---|
| 1122 |
|
---|
| 1123 | private string getClass(Icon icon)
|
---|
| 1124 | {
|
---|
| 1125 | string text = "";
|
---|
| 1126 | if (icon == Icon.delete) {
|
---|
| 1127 | text = "delete";
|
---|
| 1128 | }
|
---|
| 1129 | else if (icon == Icon.refresh) {
|
---|
| 1130 | text = "refresh";
|
---|
| 1131 | }
|
---|
| 1132 | else if (icon == Icon.back) {
|
---|
| 1133 | text = "back";
|
---|
| 1134 | }
|
---|
| 1135 | return "ui-icon-" + text;
|
---|
| 1136 | }
|
---|
| 1137 |
|
---|
| 1138 | private Icon getIcon()
|
---|
| 1139 | {
|
---|
| 1140 | if (base.Object.HasClass("ui-icon-delete")) {
|
---|
| 1141 | return Icon.delete;
|
---|
| 1142 | }
|
---|
| 1143 | else if (base.Object.HasClass("ui-icon-refresh")) {
|
---|
| 1144 | return Icon.refresh;
|
---|
| 1145 | }
|
---|
| 1146 | else if (base.Object.HasClass("ui-icon-back")) {
|
---|
| 1147 | return Icon.back;
|
---|
| 1148 | }
|
---|
| 1149 | return Icon.delete;
|
---|
| 1150 | }
|
---|
| 1151 | }
|
---|
| 1152 |
|
---|
| 1153 | public class UIOption : UIObject
|
---|
| 1154 | {
|
---|
| 1155 | public UIOption()
|
---|
| 1156 | : base("<option>")
|
---|
| 1157 | {
|
---|
| 1158 |
|
---|
| 1159 | }
|
---|
| 1160 |
|
---|
| 1161 | public UIOption(string text, string value)
|
---|
| 1162 | : this()
|
---|
| 1163 | {
|
---|
| 1164 | base.Text = text;
|
---|
| 1165 | base.Value = value;
|
---|
| 1166 | }
|
---|
| 1167 |
|
---|
| 1168 | public UIOption(jQueryObject @object)
|
---|
| 1169 | : base(@object)
|
---|
| 1170 | {
|
---|
| 1171 |
|
---|
| 1172 | }
|
---|
| 1173 | }
|
---|
| 1174 |
|
---|
| 1175 | public class UIRadioInput : UIObject
|
---|
| 1176 | {
|
---|
| 1177 | public UIRadioInput()
|
---|
| 1178 | : base("<input>")
|
---|
| 1179 | {
|
---|
| 1180 | base.Object.Attribute("type", "radio");
|
---|
| 1181 | }
|
---|
| 1182 |
|
---|
| 1183 | public UIRadioInput(string id, string name)
|
---|
| 1184 | : this()
|
---|
| 1185 | {
|
---|
| 1186 | base.Id = id;
|
---|
| 1187 | base.Name = name;
|
---|
| 1188 | }
|
---|
| 1189 |
|
---|
| 1190 | public UIRadioInput(string id, string name, string value)
|
---|
| 1191 | : this(id, name)
|
---|
| 1192 | {
|
---|
| 1193 | base.Value = value;
|
---|
| 1194 | }
|
---|
| 1195 |
|
---|
| 1196 | public UIRadioInput(string value)
|
---|
| 1197 | : this()
|
---|
| 1198 | {
|
---|
| 1199 | base.Value = value;
|
---|
| 1200 | }
|
---|
| 1201 | }
|
---|
| 1202 |
|
---|
| 1203 | public class UILi : UIObject
|
---|
| 1204 | {
|
---|
| 1205 | public UILi()
|
---|
| 1206 | : base("<li>")
|
---|
| 1207 | {
|
---|
| 1208 | }
|
---|
| 1209 | }
|
---|
| 1210 |
|
---|
| 1211 | public class UIFieldSet : UIObject
|
---|
| 1212 | {
|
---|
| 1213 | public UIFieldSet()
|
---|
| 1214 | : base("<fieldset>")
|
---|
| 1215 | {
|
---|
| 1216 | this.ControlGroup = true;
|
---|
| 1217 | }
|
---|
| 1218 |
|
---|
| 1219 | public UIFieldSet(bool horizontal)
|
---|
| 1220 | : this()
|
---|
| 1221 | {
|
---|
| 1222 | this.Horizontal = horizontal;
|
---|
| 1223 | }
|
---|
| 1224 |
|
---|
| 1225 | public string CheckdValue()
|
---|
| 1226 | {
|
---|
| 1227 | return jQuery.Select("input[type='radio']:checked", base.Object).GetValue();
|
---|
| 1228 | }
|
---|
| 1229 |
|
---|
| 1230 | public void Append(RadioInput radio)
|
---|
| 1231 | {
|
---|
| 1232 | if (RadioList == null) {
|
---|
| 1233 | RadioList = new List<RadioInput>();
|
---|
| 1234 | }
|
---|
| 1235 | RadioList.Add(new RadioInput(radio.Label, radio.Radio));
|
---|
| 1236 | RadioInput last = RadioList.Last<RadioInput>();
|
---|
| 1237 | base.Append(last.Label);
|
---|
| 1238 | base.Append(last.Radio);
|
---|
| 1239 | }
|
---|
| 1240 |
|
---|
| 1241 | public List<RadioInput> RadioList;
|
---|
| 1242 | private bool _ControlGroup;
|
---|
[148] | 1243 |
|
---|
[101] | 1244 | public bool ControlGroup
|
---|
| 1245 | {
|
---|
| 1246 | get
|
---|
| 1247 | {
|
---|
| 1248 | return _ControlGroup;
|
---|
| 1249 | }
|
---|
| 1250 | set
|
---|
| 1251 | {
|
---|
| 1252 | if (value) {
|
---|
| 1253 | base.DataRole = "controlgroup";
|
---|
| 1254 | }
|
---|
| 1255 | else {
|
---|
| 1256 | base.DataRole = "";
|
---|
| 1257 | }
|
---|
| 1258 | _ControlGroup = value;
|
---|
| 1259 | }
|
---|
| 1260 | }
|
---|
| 1261 |
|
---|
| 1262 | private bool _Horizontal;
|
---|
[148] | 1263 |
|
---|
[101] | 1264 | public bool Horizontal
|
---|
| 1265 | {
|
---|
| 1266 | get { return _Horizontal; }
|
---|
| 1267 | set
|
---|
| 1268 | {
|
---|
| 1269 | if (value) {
|
---|
| 1270 | base.DataType = "horizontal";
|
---|
| 1271 | }
|
---|
| 1272 | else {
|
---|
| 1273 | base.DataType = "";
|
---|
| 1274 | }
|
---|
| 1275 | _Horizontal = value;
|
---|
| 1276 | }
|
---|
| 1277 | }
|
---|
| 1278 |
|
---|
| 1279 | public class RadioInput
|
---|
| 1280 | {
|
---|
| 1281 | public UIRadioInput Radio;
|
---|
| 1282 | public UILabel Label;
|
---|
[148] | 1283 |
|
---|
[101] | 1284 | public RadioInput(UILabel Label, UIRadioInput Radio)
|
---|
| 1285 | {
|
---|
| 1286 | this.Radio = Radio;
|
---|
| 1287 | this.Label = Label;
|
---|
| 1288 | }
|
---|
| 1289 | }
|
---|
| 1290 | }
|
---|
| 1291 |
|
---|
| 1292 | public class UIRangeInput : UIObject
|
---|
| 1293 | {
|
---|
| 1294 | public UIRangeInput()
|
---|
| 1295 | : base("<input>")
|
---|
| 1296 | {
|
---|
| 1297 | base.Type = "number";
|
---|
| 1298 | base.DataType = "range";
|
---|
| 1299 | this.DataHighlight = true;
|
---|
| 1300 | base.Keypress(SliderKeypress);
|
---|
| 1301 | this.Handle = true;
|
---|
| 1302 | base.One("slidecreate", SliderCreate);
|
---|
| 1303 | }
|
---|
| 1304 |
|
---|
| 1305 | public UIRangeInput(int min, int max)
|
---|
| 1306 | : this()
|
---|
| 1307 | {
|
---|
| 1308 | base.Min = min;
|
---|
| 1309 | base.Max = max;
|
---|
| 1310 | base.Maxlength = GetMaxLength();
|
---|
| 1311 | }
|
---|
| 1312 |
|
---|
| 1313 | private int GetMaxLength()
|
---|
| 1314 | {
|
---|
| 1315 | int min = 0;
|
---|
| 1316 | int j;
|
---|
| 1317 | if (Min < 0) {
|
---|
| 1318 | min = 1;
|
---|
| 1319 | j = -10;
|
---|
| 1320 | while (Max / j > 1) {
|
---|
| 1321 | min++;
|
---|
| 1322 | j *= 10;
|
---|
| 1323 | }
|
---|
| 1324 | min++;
|
---|
| 1325 |
|
---|
| 1326 | }
|
---|
| 1327 | int i = 1;
|
---|
| 1328 | j = 10;
|
---|
| 1329 | while (Max / j >= 1) {
|
---|
| 1330 | i++;
|
---|
| 1331 | j *= 10;
|
---|
| 1332 | }
|
---|
| 1333 |
|
---|
| 1334 | return (i > min) ? i : min;
|
---|
| 1335 | }
|
---|
| 1336 |
|
---|
| 1337 | bool DataHighlight
|
---|
| 1338 | {
|
---|
| 1339 | get { return bool.Parse(base.GetAttribute("data-highlight")); }
|
---|
| 1340 | set { base.Attribute("data-highlight", value.ToString()); }
|
---|
| 1341 | }
|
---|
| 1342 |
|
---|
| 1343 | public new int Value
|
---|
| 1344 | {
|
---|
| 1345 | get
|
---|
| 1346 | {
|
---|
| 1347 | if (base.Value == "") {
|
---|
| 1348 | this.Value = base.Min;
|
---|
| 1349 | }
|
---|
| 1350 | return int.Parse(base.Value);
|
---|
| 1351 | }
|
---|
| 1352 | set { base.Value = value.ToString(); }
|
---|
| 1353 | }
|
---|
| 1354 |
|
---|
| 1355 | private void SliderKeypress(Element ele, jQueryEvent ev)
|
---|
| 1356 | {
|
---|
| 1357 | bool number = (ev.Which >= (int)KeyPress._0 && ev.Which <= (int)KeyPress._9);
|
---|
| 1358 |
|
---|
| 1359 | bool BackSpace = (ev.Which == (int)KeyPress.BackSpace);
|
---|
| 1360 | bool Delete = (ev.Which == (int)KeyPress.Delete);
|
---|
| 1361 | bool minus = (ev.Which == (int)KeyPress.minus);
|
---|
| 1362 | bool flag = (!number && !minus) && (!BackSpace && !Delete);
|
---|
| 1363 | if (flag) ev.PreventDefault();
|
---|
| 1364 | }
|
---|
| 1365 |
|
---|
| 1366 | public bool Handle;
|
---|
| 1367 | public UIHandle SliderHandle;
|
---|
| 1368 |
|
---|
| 1369 | private void SliderCreate(Element ele, jQueryEvent ev)
|
---|
| 1370 | {
|
---|
| 1371 | SliderHandle = new UIHandle(ev);
|
---|
| 1372 | SliderHandle.Toggle(this.Handle);
|
---|
| 1373 |
|
---|
| 1374 | UISliderTrack SliderTrack = new UISliderTrack(ev);
|
---|
| 1375 | SliderTrack.PointerEvents(this.Handle);
|
---|
| 1376 | base.PointerEvents(this.Handle);
|
---|
| 1377 | }
|
---|
| 1378 |
|
---|
| 1379 | public class UIHandle : UIObject
|
---|
| 1380 | {
|
---|
| 1381 | public UIHandle(jQueryEvent ev)
|
---|
| 1382 | {
|
---|
| 1383 | base.Object = jQuery.Select(ev.Target).Parent().Find(".ui-slider-handle");
|
---|
| 1384 | }
|
---|
| 1385 | }
|
---|
| 1386 |
|
---|
| 1387 | public class UISliderTrack : UIObject
|
---|
| 1388 | {
|
---|
| 1389 | public UISliderTrack(jQueryEvent ev)
|
---|
| 1390 | {
|
---|
| 1391 | base.Object = jQuery.Select(ev.Target).Parent().Find(".ui-slider-track");
|
---|
| 1392 | }
|
---|
| 1393 | }
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | public class UITextInput : UIObject
|
---|
| 1397 | {
|
---|
| 1398 | public UITextInput()
|
---|
| 1399 | : base("<input>")
|
---|
| 1400 | {
|
---|
| 1401 | base.Type = "text";
|
---|
| 1402 | this.DataClearBtn = true;
|
---|
| 1403 | }
|
---|
| 1404 |
|
---|
| 1405 | public UITextInput(JsDictionary dic)
|
---|
| 1406 | : this()
|
---|
| 1407 | {
|
---|
| 1408 | base.Attribute(dic);
|
---|
| 1409 | }
|
---|
| 1410 |
|
---|
| 1411 | public bool DataClearBtn
|
---|
| 1412 | {
|
---|
| 1413 | get { return bool.Parse(base.GetAttribute("data-clear-btn")); }
|
---|
| 1414 | set
|
---|
| 1415 | {
|
---|
| 1416 | if (value) { base.Attribute("data-clear-btn", value.ToString()); }
|
---|
| 1417 | else { base.RemoveAttr("data-clear-btn"); };
|
---|
| 1418 | }
|
---|
| 1419 | }
|
---|
| 1420 |
|
---|
| 1421 | public string Placeholder { get { return base.GetAttribute("placeholder"); } set { base.Attribute("placeholder", value); } }
|
---|
[148] | 1422 |
|
---|
[101] | 1423 | public JsDictionary DataOptions
|
---|
| 1424 | {
|
---|
| 1425 | get
|
---|
| 1426 | {
|
---|
| 1427 | return Json.Parse<JsDictionary>(base.GetAttribute("data-options"));
|
---|
| 1428 | }
|
---|
| 1429 | set
|
---|
| 1430 | {
|
---|
| 1431 | base.Attribute("data-options", Json.Stringify(value));
|
---|
| 1432 | }
|
---|
| 1433 | }
|
---|
| 1434 |
|
---|
| 1435 | public jQueryObject Keyup(jQueryEventHandlerWithContext eventHandler)
|
---|
| 1436 | {
|
---|
| 1437 | base.Object.Keyup(eventHandler);
|
---|
| 1438 | return base.Object;
|
---|
| 1439 | }
|
---|
| 1440 |
|
---|
| 1441 | public jQueryObject On(string eventName, jQueryEventHandlerWithContext eventHandler)
|
---|
| 1442 | {
|
---|
| 1443 | base.Object.On(eventName, eventHandler);
|
---|
| 1444 | return base.Object;
|
---|
| 1445 | }
|
---|
| 1446 |
|
---|
| 1447 | public bool ReadOnly
|
---|
| 1448 | {
|
---|
| 1449 | get { return base.GetAttribute("readonly") == "readonly"; }
|
---|
| 1450 | set
|
---|
| 1451 | {
|
---|
| 1452 | if (value) {
|
---|
| 1453 | this.Attribute("readonly", "readonly");
|
---|
| 1454 | }
|
---|
| 1455 | else {
|
---|
| 1456 | this.RemoveAttr("readonly");
|
---|
| 1457 | }
|
---|
| 1458 | }
|
---|
| 1459 | }
|
---|
| 1460 | }
|
---|
| 1461 |
|
---|
| 1462 | public class UITimeBox : UITextInput
|
---|
| 1463 | {
|
---|
| 1464 | public UITimeBox()
|
---|
| 1465 | : base()
|
---|
| 1466 | {
|
---|
| 1467 | base.DataRole = "datebox";
|
---|
| 1468 | base.DataOptions = new JsDictionary("mode", "timebox");
|
---|
| 1469 | base.DataClearBtn = false;
|
---|
| 1470 | base.On("dateboxcreate", DateBoxCreate);
|
---|
| 1471 | }
|
---|
| 1472 |
|
---|
| 1473 | private void DateBoxCreate(Element ele, jQueryEvent ev)
|
---|
| 1474 | {
|
---|
| 1475 | jQuery.Select(ele).Parents().Find(".ui-icon-grid").ToggleClass("ui-icon-grid", "ui-icon-clock");
|
---|
| 1476 | }
|
---|
| 1477 | }
|
---|
| 1478 |
|
---|
| 1479 | public class UICalBox : UITextInput
|
---|
| 1480 | {
|
---|
| 1481 | /// <summary>年</summary>
|
---|
| 1482 | public int dY { get { return GetCal(0); } }
|
---|
| 1483 |
|
---|
| 1484 | /// <summary>月</summary>
|
---|
| 1485 | public int dM { get { return GetCal(1); } }
|
---|
| 1486 |
|
---|
| 1487 | /// <summary>日</summary>
|
---|
| 1488 | public int dD { get { return GetCal(2); } }
|
---|
| 1489 |
|
---|
| 1490 | /// <summary>年(16進4桁)</summary>
|
---|
| 1491 | public string xY { get { return dY.ToString("X4"); } }
|
---|
| 1492 |
|
---|
| 1493 | /// <summary>月(16進2桁)</summary>
|
---|
| 1494 | public string xM { get { return dM.ToString("X2"); } }
|
---|
| 1495 |
|
---|
| 1496 | /// <summary>日(16進2桁)</summary>
|
---|
| 1497 | public string xD { get { return dD.ToString("X2"); } }
|
---|
| 1498 |
|
---|
| 1499 | /// <summary>年月日(16進8桁)</summary>
|
---|
| 1500 | public string YYYYMMDD { get { return xY + xM + xD; } }
|
---|
| 1501 |
|
---|
| 1502 | /// <summary>年(10進4桁)/月(10進4桁)/日(10進4桁)</summary>
|
---|
| 1503 | public string yyyymmdd { get { return dY.ToString("D4") + "/" + dM.ToString("D2") + "/" + dD.ToString("D2"); } }
|
---|
| 1504 |
|
---|
| 1505 | public UICalBox()
|
---|
| 1506 | : base()
|
---|
| 1507 | {
|
---|
| 1508 | base.DataRole = "datebox";
|
---|
| 1509 | base.DataOptions = new JsDictionary("mode", "calbox");
|
---|
| 1510 | base.DataClearBtn = false;
|
---|
| 1511 | base.On("dateboxcreate", DateBoxCreate);
|
---|
| 1512 | }
|
---|
| 1513 |
|
---|
| 1514 | private void DateBoxCreate(Element ele, jQueryEvent ev)
|
---|
| 1515 | {
|
---|
| 1516 | jQuery.Select(ele).Parents().Find(".ui-icon-grid").ToggleClass("ui-icon-grid", "ui-icon-calendar");
|
---|
| 1517 | }
|
---|
| 1518 |
|
---|
| 1519 | private int GetCal(int i)
|
---|
| 1520 | {
|
---|
| 1521 | int x = 0;
|
---|
| 1522 | if (Value.Contains("/")) {
|
---|
| 1523 | string[] value = Value.Split("/");
|
---|
| 1524 | x = int.Parse(value[i]);
|
---|
| 1525 | }
|
---|
| 1526 | return x;
|
---|
| 1527 | }
|
---|
| 1528 |
|
---|
| 1529 | public class UIInputDate : UIObject
|
---|
| 1530 | {
|
---|
| 1531 | public UIInputDate(jQueryEvent ev)
|
---|
| 1532 | {
|
---|
| 1533 | base.Object = jQuery.Select(ev.Target).Parent(".ui-input-datebox");
|
---|
| 1534 | }
|
---|
| 1535 | }
|
---|
| 1536 | }
|
---|
| 1537 |
|
---|
| 1538 | public class UICollapsibleset : UIObject
|
---|
| 1539 | {
|
---|
| 1540 | public UICollapsibleset()
|
---|
| 1541 | : base("<div>")
|
---|
| 1542 | {
|
---|
| 1543 | base.DataRole = "collapsible";
|
---|
| 1544 | }
|
---|
| 1545 |
|
---|
| 1546 | public UICollapsibleset(JsDictionary attr, string h2)
|
---|
| 1547 | : this()
|
---|
| 1548 | {
|
---|
| 1549 | base.Attribute(attr);
|
---|
| 1550 | base.Append(new UIH(2, h2));
|
---|
| 1551 | }
|
---|
| 1552 |
|
---|
| 1553 | public UICollapsibleset(string h2)
|
---|
| 1554 | : this()
|
---|
| 1555 | {
|
---|
| 1556 | base.Append(new UIH(2, h2));
|
---|
| 1557 | }
|
---|
| 1558 |
|
---|
| 1559 | public bool DataInset { get { return bool.Parse(base.Object.GetAttribute("data-inset")); } set { base.Object.Attribute("data-inset", value.ToString()); } }
|
---|
| 1560 | }
|
---|
| 1561 |
|
---|
| 1562 | public class UIListview : UIObject
|
---|
| 1563 | {
|
---|
| 1564 | public UIListview()
|
---|
| 1565 | : base("<ul>")
|
---|
| 1566 | {
|
---|
| 1567 | base.DataRole = "listview";
|
---|
| 1568 | }
|
---|
| 1569 |
|
---|
| 1570 | public UIListview(params object[] nameValuePairs)
|
---|
| 1571 | : this()
|
---|
| 1572 | {
|
---|
| 1573 | base.Attribute(new JsDictionary(nameValuePairs));
|
---|
| 1574 | }
|
---|
| 1575 | }
|
---|
| 1576 |
|
---|
| 1577 | public class UIListviewItem : UIObject
|
---|
| 1578 | {
|
---|
| 1579 | public UIListviewItem()
|
---|
| 1580 | : base("<li>")
|
---|
| 1581 | {
|
---|
| 1582 | }
|
---|
| 1583 |
|
---|
| 1584 | public UIListviewItem(UIObject uiobject)
|
---|
| 1585 | : this()
|
---|
| 1586 | {
|
---|
| 1587 | base.Append(uiobject);
|
---|
| 1588 | }
|
---|
| 1589 | }
|
---|
| 1590 |
|
---|
| 1591 | public class UIListDivider : UIListviewItem
|
---|
| 1592 | {
|
---|
| 1593 | public UIListDivider()
|
---|
| 1594 | : base()
|
---|
| 1595 | {
|
---|
| 1596 | base.DataRole = "list-divider";
|
---|
| 1597 | }
|
---|
| 1598 |
|
---|
| 1599 | public UIListDivider(string text)
|
---|
| 1600 | : this()
|
---|
| 1601 | {
|
---|
| 1602 | base.Text = text;
|
---|
| 1603 | }
|
---|
| 1604 |
|
---|
| 1605 | public UIListDivider(UIObject uiobject)
|
---|
| 1606 | : this()
|
---|
| 1607 | {
|
---|
| 1608 | base.Append(uiobject);
|
---|
| 1609 | }
|
---|
| 1610 |
|
---|
| 1611 | public UIListDivider(jQueryObject @object)
|
---|
| 1612 | : this()
|
---|
| 1613 | {
|
---|
| 1614 | base.Append(@object);
|
---|
| 1615 | }
|
---|
| 1616 | }
|
---|
| 1617 |
|
---|
| 1618 | public class UIP : UIObject
|
---|
| 1619 | {
|
---|
| 1620 | public UIP()
|
---|
| 1621 | : base("<p>")
|
---|
| 1622 | {
|
---|
| 1623 | }
|
---|
| 1624 |
|
---|
| 1625 | public UIP(string text)
|
---|
| 1626 | : this()
|
---|
| 1627 | {
|
---|
| 1628 | base.Text = text;
|
---|
| 1629 | }
|
---|
| 1630 |
|
---|
| 1631 | public UIP(string text, string @class)
|
---|
| 1632 | : this(text)
|
---|
| 1633 | {
|
---|
| 1634 | base.AddClass(@class);
|
---|
| 1635 | }
|
---|
| 1636 | }
|
---|
| 1637 |
|
---|
| 1638 | public class UIAnchor : UIObject
|
---|
| 1639 | {
|
---|
| 1640 | public UIAnchor()
|
---|
| 1641 | : base("<a>")
|
---|
| 1642 | {
|
---|
| 1643 | }
|
---|
| 1644 |
|
---|
| 1645 | public UIAnchor(string text)
|
---|
| 1646 | : this()
|
---|
| 1647 | {
|
---|
| 1648 | base.Text = text;
|
---|
| 1649 | }
|
---|
| 1650 |
|
---|
| 1651 | public UIAnchor(UIObject uiobject)
|
---|
| 1652 | : this()
|
---|
| 1653 | {
|
---|
| 1654 | base.Append(uiobject);
|
---|
| 1655 | }
|
---|
| 1656 |
|
---|
| 1657 | public string Href { get { return base.GetAttribute("href"); } set { base.Attribute("href", value); } }
|
---|
| 1658 | public string Target { get { return base.GetAttribute("target"); } set { base.Attribute("target", value); } }
|
---|
| 1659 | }
|
---|
| 1660 |
|
---|
| 1661 | public class UIH : UIObject
|
---|
| 1662 | {
|
---|
| 1663 | public UIH()
|
---|
| 1664 | : base("<h1>")
|
---|
| 1665 | {
|
---|
| 1666 | }
|
---|
| 1667 |
|
---|
| 1668 | public UIH(int i)
|
---|
| 1669 | : base("<h" + i.ToString() + ">")
|
---|
| 1670 | {
|
---|
| 1671 | }
|
---|
| 1672 |
|
---|
| 1673 | public UIH(int i, string text)
|
---|
| 1674 | : this(i)
|
---|
| 1675 | {
|
---|
| 1676 | base.Text = text;
|
---|
| 1677 | }
|
---|
| 1678 | }
|
---|
| 1679 |
|
---|
| 1680 | public class UIImg : UIObject
|
---|
| 1681 | {
|
---|
| 1682 | public UIImg()
|
---|
| 1683 | : base("<img>")
|
---|
| 1684 | {
|
---|
| 1685 | }
|
---|
| 1686 |
|
---|
| 1687 | public UIImg(JsDictionary attr)
|
---|
| 1688 | : this()
|
---|
| 1689 | {
|
---|
| 1690 | base.Attribute(attr);
|
---|
| 1691 | }
|
---|
| 1692 |
|
---|
| 1693 | public UIImg(params object[] nameValuePairs)
|
---|
| 1694 | : this()
|
---|
| 1695 | {
|
---|
| 1696 | base.Attribute(new JsDictionary(nameValuePairs));
|
---|
| 1697 | }
|
---|
| 1698 | }
|
---|
| 1699 |
|
---|
| 1700 | public class UIPin : UILi
|
---|
| 1701 | {
|
---|
| 1702 | public UIButton ReadButton;
|
---|
| 1703 | public UIFieldSet UIPinMode;
|
---|
| 1704 | public UIRangeInput Range;
|
---|
| 1705 | public UIRangeInput AnalogRead;
|
---|
| 1706 | public UIFlipSwitch FlipSwitch;
|
---|
| 1707 | public int Pin;
|
---|
| 1708 | public UIListDivider ListDivider;
|
---|
| 1709 | private UIFieldSet SetUIPinMode(int i)
|
---|
| 1710 | {
|
---|
| 1711 | UIPinMode.Append(new UILabel("INPUT", "input" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1712 | UIPinMode.Append(new UIRadioInput("input" + i.ToString(), "pin" + i.ToString(), "INPUT"));
|
---|
| 1713 | UIPinMode.Append(new UILabel("OUTPUT", "output" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1714 | UIPinMode.Append(new UIRadioInput("output" + i.ToString(), "pin" + i.ToString(), "OUTPUT"));
|
---|
| 1715 | UIPinMode.Append(new UILabel("INPUT_PULLUP", "input_pullup" + i.ToString(), "pin" + i.ToString()));
|
---|
| 1716 | UIPinMode.Append(new UIRadioInput("input_pullup" + i.ToString(), "pin" + i.ToString(), "INPUT_PULLUP"));
|
---|
| 1717 | return UIPinMode;
|
---|
| 1718 | }
|
---|
| 1719 |
|
---|
| 1720 | private void SetUIDigital(int i)
|
---|
| 1721 | {
|
---|
| 1722 | }
|
---|
| 1723 |
|
---|
| 1724 | private void SetUIRange(int i)
|
---|
| 1725 | {
|
---|
| 1726 | Range = new UIRangeInput(-1, 255);
|
---|
| 1727 | Range.Value = 123;
|
---|
| 1728 | }
|
---|
| 1729 |
|
---|
| 1730 | private void SetAnalogRead(int i)
|
---|
| 1731 | {
|
---|
| 1732 | AnalogRead = new UIRangeInput(0, 1023);
|
---|
| 1733 | AnalogRead.Handle = false;
|
---|
| 1734 | }
|
---|
| 1735 |
|
---|
| 1736 | public UIPin()
|
---|
| 1737 | : base()
|
---|
| 1738 | {
|
---|
| 1739 | base.AddClass("pin");
|
---|
| 1740 | ListDivider = new UIListDivider();
|
---|
| 1741 | UIPinMode = new UIFieldSet(true);
|
---|
| 1742 |
|
---|
| 1743 | Range = new UIRangeInput();
|
---|
| 1744 |
|
---|
| 1745 | ReadButton = new UIButton();
|
---|
| 1746 | ReadButton.Title = "取得";
|
---|
| 1747 | ReadButton.ButtonIcon = UIButton.Icon.refresh;
|
---|
| 1748 | }
|
---|
| 1749 |
|
---|
| 1750 | public UIPin(int pin)
|
---|
| 1751 | : this()
|
---|
| 1752 | {
|
---|
| 1753 | this.Pin = pin;
|
---|
| 1754 | UIDiv Div = new UIDiv();
|
---|
| 1755 |
|
---|
| 1756 | Div.Append(new UIH(1, "pin" + pin.ToString()));
|
---|
| 1757 | Div.Append(ReadButton);
|
---|
| 1758 | ListDivider.Append(Div);
|
---|
| 1759 | SetUIPinMode(pin);
|
---|
| 1760 | SetUIDigital(pin);
|
---|
| 1761 | SetUIRange(pin);
|
---|
| 1762 |
|
---|
| 1763 | if (pin >= 0 && pin <= 7) {
|
---|
| 1764 | FlipSwitch = new UIFlipSwitch(new UIOption("LOW", "LOW"), new UIOption("HIGH", "HIGH"));
|
---|
| 1765 | base.Append(new UIFieldContain(UIPinMode));
|
---|
| 1766 | base.Append(new UIFieldContain(FlipSwitch));
|
---|
| 1767 | base.Append(new UIFieldContain(Range));
|
---|
| 1768 | }
|
---|
| 1769 | else if (pin >= 8 && pin <= 13) {
|
---|
| 1770 | FlipSwitch = new UIFlipSwitch(new UIOption("LOW", "LOW"), new UIOption("HIGH", "HIGH"));
|
---|
| 1771 | base.Append(new UIFieldContain(UIPinMode));
|
---|
| 1772 | base.Append(new UIFieldContain(FlipSwitch));
|
---|
| 1773 | }
|
---|
| 1774 | else if (pin >= 14 && pin <= 19) {
|
---|
| 1775 | SetAnalogRead(pin);
|
---|
| 1776 | base.Append(new UIFieldContain(AnalogRead));
|
---|
| 1777 | }
|
---|
| 1778 | }
|
---|
| 1779 |
|
---|
| 1780 | public Element[] GetElements()
|
---|
| 1781 | {
|
---|
| 1782 | Element[] elements = new Element[2];
|
---|
| 1783 | elements[0] = ListDivider.Element;
|
---|
| 1784 | elements[1] = base.Element;
|
---|
| 1785 | return elements;
|
---|
| 1786 | }
|
---|
| 1787 |
|
---|
| 1788 | public void SetPinModeChange(EventHandlerFieldSet eventhandler)
|
---|
| 1789 | {
|
---|
| 1790 | if (UIPinMode != null) {
|
---|
| 1791 | UIPinMode.Change((elem, ev) => { eventhandler(UIPinMode, Pin); });
|
---|
| 1792 | }
|
---|
| 1793 | }
|
---|
| 1794 |
|
---|
| 1795 | public void SetDigitalChange(EventHandlerFlipSwitch eventhandler)
|
---|
| 1796 | {
|
---|
| 1797 | if (FlipSwitch != null) {
|
---|
| 1798 | FlipSwitch.Change((elem, ev) => { eventhandler(ReadButton, FlipSwitch, Pin); });
|
---|
| 1799 | }
|
---|
| 1800 | }
|
---|
| 1801 |
|
---|
| 1802 | public void SetReadButtonClick(EventHandlerFlipSwitch eventhandler)
|
---|
| 1803 | {
|
---|
| 1804 | if (FlipSwitch != null) {
|
---|
| 1805 | ReadButton.Click((elem, ev) => { eventhandler(ReadButton, FlipSwitch, Pin); });
|
---|
| 1806 | }
|
---|
| 1807 | }
|
---|
| 1808 |
|
---|
| 1809 | public void SetAnalogWriteChange(EventHandlerRange eventhandler)
|
---|
| 1810 | {
|
---|
| 1811 | if (Range != null) {
|
---|
| 1812 | Range.Change((elem, ev) => { eventhandler(Range, Pin); });
|
---|
| 1813 | }
|
---|
| 1814 | }
|
---|
| 1815 |
|
---|
| 1816 | public void SetAnalogReadChange(EventHandlerRange eventhandler)
|
---|
| 1817 | {
|
---|
| 1818 | if (AnalogRead != null) {
|
---|
| 1819 | ReadButton.Click((elem, ev) => { eventhandler(AnalogRead, Pin); });
|
---|
| 1820 | }
|
---|
| 1821 | }
|
---|
| 1822 | }
|
---|
| 1823 |
|
---|
| 1824 | public delegate void EventHandlerFieldSet(UIFieldSet fieldcontain, int pin);
|
---|
| 1825 | public delegate void EventHandlerFlipSwitch(UIButton button, UIFlipSwitch fieldcontain, int pin);
|
---|
| 1826 | public delegate void EventHandlerDevicePropertyInfo(DeviceController.DevicePropertyInfo dpi, byte[] data);
|
---|
| 1827 | public delegate void EventHandlerRange(UIRangeInput fieldcontain, int pin);
|
---|
| 1828 |
|
---|
| 1829 | public class UIDeviceController
|
---|
| 1830 | {
|
---|
| 1831 | public DeviceController DeviceController;
|
---|
[148] | 1832 |
|
---|
[101] | 1833 | public class UIDeviceInfo
|
---|
| 1834 | {
|
---|
| 1835 | protected CtrlUI Page;
|
---|
| 1836 | public DeviceController.DeviceInfo di = null;
|
---|
| 1837 | Element[] Elements;
|
---|
| 1838 |
|
---|
| 1839 | protected void UIDeviceSet(DeviceController.DeviceInfo di, CtrlUI Page)
|
---|
| 1840 | {
|
---|
| 1841 | this.di = di;
|
---|
| 1842 | this.Page = Page;
|
---|
| 1843 | if (((WampApiKadecotDevice)di.Data).protocol == "arduino") {
|
---|
| 1844 | Elements = di.SetPin(Page);
|
---|
| 1845 | }
|
---|
| 1846 | else {
|
---|
| 1847 | Elements = di.SetEchonetlite(Page);
|
---|
| 1848 | }
|
---|
| 1849 | }
|
---|
| 1850 |
|
---|
| 1851 | public jQueryObject GetPropertys()
|
---|
| 1852 | {
|
---|
| 1853 | return jQuery.FromElements(Elements);
|
---|
| 1854 | }
|
---|
| 1855 |
|
---|
| 1856 | public void GetData()
|
---|
| 1857 | {
|
---|
| 1858 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1859 | if (dpi.Data != null) {
|
---|
| 1860 | dpi.GetValue(dpi.Data);
|
---|
| 1861 | }
|
---|
| 1862 | }
|
---|
| 1863 | }
|
---|
| 1864 |
|
---|
| 1865 | public bool IsWait()
|
---|
| 1866 | {
|
---|
| 1867 | bool flag = false;
|
---|
| 1868 |
|
---|
| 1869 | if (di != null && di.Properties != null) {
|
---|
| 1870 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1871 | if (dpi != null && dpi.IsWaitRes) {
|
---|
| 1872 | flag = true;
|
---|
| 1873 | }
|
---|
| 1874 | }
|
---|
| 1875 | }
|
---|
| 1876 |
|
---|
| 1877 | return flag;
|
---|
| 1878 | }
|
---|
| 1879 |
|
---|
| 1880 | public Element[] SetEchonetlite(CtrlUI ctrlui)
|
---|
| 1881 | {
|
---|
| 1882 | Element[] ele = new Element[di.Properties.Count];
|
---|
| 1883 | int i = 0;
|
---|
| 1884 | foreach (DeviceController.DevicePropertyInfo dpi in di.Properties) {
|
---|
| 1885 | dpi.SetProperty(dpi);
|
---|
| 1886 | dpi.SetName(di);
|
---|
| 1887 | dpi.SetKadecotGet(Page.KadecotGet);
|
---|
| 1888 | dpi.SetKadecotSet(Page.KadecotSet);
|
---|
| 1889 | ele[i++] = dpi.GetElement();
|
---|
| 1890 | }
|
---|
| 1891 | return ele;
|
---|
| 1892 | }
|
---|
| 1893 |
|
---|
| 1894 | public Element[] SetPin(CtrlUI ctrlui)
|
---|
| 1895 | {
|
---|
| 1896 | Page = ctrlui;
|
---|
| 1897 | Element[] ele = new Element[20];
|
---|
| 1898 | Element[] element;
|
---|
| 1899 | int j = 0;
|
---|
| 1900 | for (int i = 0; i <= 19; i++) {
|
---|
| 1901 | element = SetPin(i, Page);
|
---|
| 1902 | ele[j++] = element[0];
|
---|
| 1903 | ele[j++] = element[1];
|
---|
| 1904 | }
|
---|
| 1905 | return ele;
|
---|
| 1906 | }
|
---|
| 1907 |
|
---|
| 1908 | public Element[] SetPin(int i, CtrlUI Page)
|
---|
| 1909 | {
|
---|
| 1910 | UIPin uiPin = new UIPin(i);
|
---|
| 1911 | uiPin.SetPinModeChange(Page.pinMode_Change);
|
---|
| 1912 | uiPin.SetDigitalChange(Page.digital_Change);
|
---|
| 1913 | uiPin.SetReadButtonClick(Page.DigitalRead);
|
---|
| 1914 | uiPin.SetAnalogWriteChange(Page.analogWrite_Change);
|
---|
| 1915 | uiPin.SetAnalogReadChange(Page.analogRead);
|
---|
| 1916 | return uiPin.GetElements();
|
---|
| 1917 | }
|
---|
| 1918 | }
|
---|
| 1919 |
|
---|
| 1920 | public jQueryObject GetUINodeList(jQueryEventHandlerWithContextDi listitem_click)
|
---|
| 1921 | {
|
---|
| 1922 | UINodeList nodelist = new UINodeList(DeviceController.NodeList, listitem_click);
|
---|
| 1923 |
|
---|
| 1924 | return nodelist.GetNodeList();
|
---|
| 1925 | }
|
---|
| 1926 |
|
---|
| 1927 | public delegate void jQueryEventHandlerWithContextDi(Element elem, jQueryEvent e, DeviceController.DeviceInfo node);
|
---|
| 1928 |
|
---|
| 1929 | public class UIDevicePropertyInfo
|
---|
| 1930 | {
|
---|
| 1931 | private UIGrpBox Grpbox;
|
---|
| 1932 |
|
---|
| 1933 | public Element GetElement()
|
---|
| 1934 | {
|
---|
| 1935 | return Grpbox.Object.GetElement(0);
|
---|
| 1936 | }
|
---|
| 1937 |
|
---|
| 1938 | public void SetName(DeviceController.DeviceInfo di)
|
---|
| 1939 | {
|
---|
| 1940 | string nameid = di.GetObjectID() + dpi.GetPropertyCode("X2");
|
---|
| 1941 | Grpbox.SetName(nameid);
|
---|
| 1942 | }
|
---|
| 1943 |
|
---|
| 1944 | public string ErrorText { get { return Grpbox.ErrorText; } set { Grpbox.ErrorText = value; } }
|
---|
| 1945 |
|
---|
| 1946 | public int GetMaxLength()
|
---|
| 1947 | {
|
---|
| 1948 | int len = 2 * ((dpi.PropertyInfo == null) ? dpi.Size : (((dpi.PropertyInfo.arrayCount == 0) ? 1 : dpi.PropertyInfo.arrayCount) * dpi.PropertyInfo.size));
|
---|
| 1949 | return len;
|
---|
| 1950 | }
|
---|
| 1951 |
|
---|
| 1952 | public void SetProperty(DeviceController.DevicePropertyInfo dpi)
|
---|
| 1953 | {
|
---|
| 1954 | this.dpi = dpi;
|
---|
| 1955 | Grpbox = new UIGrpBox(dpi);
|
---|
| 1956 | }
|
---|
| 1957 |
|
---|
| 1958 | public void SetKadecotGet(EventHandlerPropertyInfo KadecotGet)
|
---|
| 1959 | {
|
---|
| 1960 | DeviceController.DevicePropertyInfo opeSt = null;
|
---|
| 1961 |
|
---|
| 1962 | //現在時刻設定
|
---|
| 1963 | if (dpi.PropertyCode == 0x97) {
|
---|
| 1964 | }
|
---|
| 1965 | else if (dpi.PropertyCode == 0x98) {
|
---|
| 1966 |
|
---|
| 1967 | }
|
---|
| 1968 | else if (this.dpi.InputTypes.Count == 0) {
|
---|
| 1969 |
|
---|
| 1970 | }
|
---|
| 1971 | else if (dpi.PropertyCode == 0x80 && dpi.InputTypes.Count == 1 && dpi.InputTypes[0].Mode == PropertyInputMode.Select) {
|
---|
| 1972 |
|
---|
| 1973 | }
|
---|
| 1974 |
|
---|
| 1975 | else {
|
---|
| 1976 | foreach (PropertyInputInfo pii in dpi.InputTypes) {
|
---|
| 1977 | if (dpi.PropertyCode == 0x80)
|
---|
| 1978 | opeSt = dpi;
|
---|
| 1979 | }
|
---|
| 1980 | if (opeSt != null)
|
---|
| 1981 | KadecotGet(opeSt);
|
---|
| 1982 | }
|
---|
| 1983 | }
|
---|
| 1984 |
|
---|
| 1985 | public void SetKadecotSet(EventHandlerDevicePropertyInfo KadecotSet)
|
---|
| 1986 | {
|
---|
| 1987 | Grpbox.KadecotSet = KadecotSet;
|
---|
| 1988 | }
|
---|
| 1989 |
|
---|
| 1990 | private DeviceController.DevicePropertyInfo dpi;
|
---|
| 1991 |
|
---|
| 1992 | public delegate void EventHandlerPropertyInfo(DeviceController.DevicePropertyInfo dpi);
|
---|
| 1993 |
|
---|
| 1994 | public void GetValue(byte[] data)
|
---|
| 1995 | {
|
---|
| 1996 | Grpbox.SetGetValue(data);
|
---|
| 1997 | }
|
---|
| 1998 | }
|
---|
| 1999 | }
|
---|
| 2000 |
|
---|
| 2001 | public class UINodeList
|
---|
| 2002 | {
|
---|
| 2003 | public UINodeList(IEnumerable<DeviceController.NodeInfo> NodeList, UIDeviceController.jQueryEventHandlerWithContextDi listitem_click)
|
---|
| 2004 | {
|
---|
| 2005 | info = new UIDiv();
|
---|
| 2006 | string identifer = "";
|
---|
[148] | 2007 |
|
---|
[101] | 2008 | foreach (var node in NodeList) {
|
---|
| 2009 | var profile = node.Profile;
|
---|
| 2010 |
|
---|
| 2011 | if (jQuery.Select("#" + "cl_node_" + identifer).Length > 0)
|
---|
| 2012 | continue;
|
---|
[148] | 2013 |
|
---|
[101] | 2014 | UICollapsibleset col = new UICollapsibleset(node.Data.ToString());
|
---|
| 2015 | col.Id = "cl_node_" + identifer;
|
---|
| 2016 | col.DataInset = true;
|
---|
| 2017 | info.Append(col);
|
---|
| 2018 | UIListview listview = new UIListview("id", "lv_node_" + identifer);
|
---|
| 2019 |
|
---|
| 2020 | col.Append(listview);
|
---|
[148] | 2021 |
|
---|
[101] | 2022 | foreach (var item in node.Devices) {
|
---|
| 2023 | if (item.Profile)
|
---|
| 2024 | continue;
|
---|
| 2025 |
|
---|
| 2026 | identifer = item.GetObjectID();
|
---|
| 2027 | if (jQuery.Select("#" + "li_device_" + identifer).Length > 0)
|
---|
| 2028 | continue;
|
---|
| 2029 | UIListviewItem listitem = new UIListviewItem();
|
---|
| 2030 | listitem.Id = "li_device_" + identifer;
|
---|
| 2031 | listitem.Click((ele, ev) => { listitem_click(ele, ev, item); });
|
---|
| 2032 | listview.Append(listitem);
|
---|
| 2033 |
|
---|
| 2034 |
|
---|
| 2035 | UIAnchor anchor = new UIAnchor();
|
---|
| 2036 | anchor.Href = "#";
|
---|
| 2037 | anchor.Title = ((WampApiKadecotDevice)item.Data).description;
|
---|
| 2038 | anchor.Text = ((WampApiKadecotDevice)item.Data).nickname;
|
---|
| 2039 | anchor.Click((ele, ev) => { listitem_Click(listitem, item); });
|
---|
| 2040 |
|
---|
| 2041 | listitem.Append(anchor);
|
---|
| 2042 | }
|
---|
| 2043 | }
|
---|
| 2044 | }
|
---|
| 2045 |
|
---|
| 2046 | private UIDiv info;
|
---|
| 2047 |
|
---|
| 2048 | public jQueryObject GetNodeList()
|
---|
| 2049 | {
|
---|
| 2050 | return info.Children();
|
---|
| 2051 | }
|
---|
| 2052 |
|
---|
| 2053 | /// <summary>
|
---|
| 2054 | /// "#li_device_XXXXXX"をクリック
|
---|
| 2055 | /// </summary>
|
---|
| 2056 | /// <param name="elem"></param>
|
---|
| 2057 | /// <param name="ev"></param>
|
---|
| 2058 | private void listitem_Click(UIListviewItem listitem, DeviceController.DeviceInfo item)
|
---|
| 2059 | {
|
---|
| 2060 | //選択中クラスの追加
|
---|
| 2061 | jQuery.Select(".li-select").RemoveClass("li-select");
|
---|
| 2062 | listitem.AddClass("li-select");
|
---|
| 2063 | }
|
---|
| 2064 | }
|
---|
| 2065 |
|
---|
| 2066 | public static class UIEventNames
|
---|
| 2067 | {
|
---|
| 2068 | public static string CurrentNodeChange = "currentnode.change";
|
---|
| 2069 | public static string LoadingShow = "loading.show";
|
---|
| 2070 | public static string LoadingHide = "loading.hide";
|
---|
[148] | 2071 | /// <summary>機器検索開始</summary>
|
---|
[101] | 2072 | public static string SearchStart = "search.start";
|
---|
[148] | 2073 | /// <summary>機器検索終了</summary>
|
---|
[101] | 2074 | public static string SearchEnd = "search.end";
|
---|
[148] | 2075 | /// <summary>機器検索エラー</summary>
|
---|
[101] | 2076 | public static string SearchError = "search.error";
|
---|
[148] | 2077 | /// <summary>入力画面作成開始</summary>
|
---|
[101] | 2078 | public static string PropertyWriteStart = "propertywrite.start";
|
---|
[148] | 2079 | /// <summary>入力画面作成終了</summary>
|
---|
[101] | 2080 | public static string PropertyWriteEnd = "propertywrite.end";
|
---|
| 2081 | }
|
---|
| 2082 |
|
---|
| 2083 | public static class UIEventHandler
|
---|
| 2084 | {
|
---|
| 2085 | public static void LoadingShow(jQueryEvent ev)
|
---|
| 2086 | {
|
---|
| 2087 | jQueryMobile.Loading("show");
|
---|
| 2088 | }
|
---|
| 2089 |
|
---|
| 2090 | public static void LoadingHide(jQueryEvent ev)
|
---|
| 2091 | {
|
---|
| 2092 | jQueryMobile.Loading("hide");
|
---|
| 2093 | }
|
---|
| 2094 | }
|
---|
| 2095 |
|
---|
| 2096 | public enum KeyPress
|
---|
| 2097 | {
|
---|
| 2098 | Delete = 0,
|
---|
| 2099 | BackSpace = 8,
|
---|
| 2100 | minus = 45,
|
---|
| 2101 | dot = 46,
|
---|
| 2102 | slash = 47,
|
---|
| 2103 | _0 = 48,
|
---|
| 2104 | _1 = 49,
|
---|
| 2105 | _2 = 50,
|
---|
| 2106 | _3 = 51,
|
---|
| 2107 | _4 = 52,
|
---|
| 2108 | _5 = 53,
|
---|
| 2109 | _6 = 54,
|
---|
| 2110 | _7 = 55,
|
---|
| 2111 | _8 = 56,
|
---|
| 2112 | _9 = 57,
|
---|
| 2113 | A = 65,
|
---|
| 2114 | B = 66,
|
---|
| 2115 | C = 67,
|
---|
| 2116 | D = 68,
|
---|
| 2117 | E = 69,
|
---|
| 2118 | F = 70,
|
---|
| 2119 | a = 97,
|
---|
| 2120 | b = 98,
|
---|
| 2121 | c = 99,
|
---|
| 2122 | d = 100,
|
---|
| 2123 | e = 101,
|
---|
| 2124 | f = 102,
|
---|
| 2125 | }
|
---|
| 2126 | }
|
---|