public void ValueChanged(JSC.JSValue value) { if (value != null && value.ValueType == JSC.JSValueType.String) { textEditor.Text = value.Value as string; } }
public void ValueChanged(JSC.JSValue value) { string rez = null; if (value == null) { rez = ""; } else { if (value.ValueType == JSC.JSValueType.Object) { if (value.Value == null) { rez = ""; } else { var sc = value["$type"]; if ((rez = sc.Value as string) == null) { rez = "Object"; } } } else { rez = value.ToString(); } } this.Text = rez; }
public veMsStatus(InBase owner, JSC.JSValue manifest) { _owner = owner; InitializeComponent(); ValueChanged(_owner.value); TypeChanged(manifest); }
public TopicField(DTopic t, string fPath, JSC.JSValue value) { _topic = t; _fPath = fPath; _value = value; _tcs = new TaskCompletionSource <JSC.JSValue>(); }
public Task <bool> SetValue(JSC.JSValue val) { var ds = new TopicPublish(this, val); App.PostMsg(ds); return(ds.Task); }
private static JSC.JSValue SJ_CustomTypesRepl(JSC.JSValue thisBind, JSC.Arguments args) { if (args.Length == 2 && args[1].ValueType == JSC.JSValueType.String) { var s = args[1].Value as string; if (s != null) { if (s.StartsWith("¤BA")) { try { return(new ByteArray(Convert.FromBase64String(s.Substring(3)))); } catch (Exception ex) { Log.Warning("ParseJson(" + args[0].ToString() + ", " + s + ") - " + ex.Message); return(new ByteArray()); } } // 2015-09-16T14:15:18.994Z if (s.Length == 24 && s[4] == '-' && s[7] == '-' && s[10] == 'T' && s[13] == ':' && s[16] == ':' && s[19] == '.') { DateTimeOffset dto; if (!DateTimeOffset.TryParseExact(s, "yyyy-MM-ddTH:mm:ss.fffK", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out dto) || Math.Abs(dto.Year - 1001) < 1) { return(JSC.JSObject.Marshal(DateTime.Now)); } return(JSC.JSValue.Marshal(dto.LocalDateTime)); } } } return(args[1]); }
public void send(JSC.JSValue value) { byte[] data; if (value == null) { data = null; } else if (value.ValueType == JSC.JSValueType.String) { string s = value.Value as string; data = s != null?Encoding.UTF8.GetBytes(s) : null; } else { data = null; } if (_req.Method == "POST" && data != null) { _req.ContentType = _contentType ?? "application/x-www-form-urlencoded"; _req.ContentLength = data.Length; using (var stream = _req.GetRequestStream()) { stream.Write(data, 0, data.Length); } } _resp_w = _req.BeginGetResponse(RespCallback, null); }
public Task <DTopic> CreateAsync(string name, JSC.JSValue st, JSC.JSValue manifest) { var req = new TopicReq(this, this == Connection.root ? ("/" + name) : (this.path + "/" + name), st, manifest); App.PostMsg(req); return(req.Task); }
public static void ClearTimeout(JSC.JSValue oi) { if (oi == null || !oi.IsNumber) { return; } var idx = (int)oi; TimerContainer t = _timer, tp = null; while (t != null) { if ((long)t.idx == (long)idx) { if (tp == null) { _timer = t.next; } else { tp.next = t.next; } } else { tp = t; } t = t.next; } }
public void Tick() { EsMessage msg; while (_msgs.TryTake(out msg)) { if (msg.Count == 0) { continue; } try { if (msg[0].ValueType == JSC.JSValueType.String) { var key = msg[0].Value as string; var a = new JSC.JSValue[msg.Count - 1]; for (int i = 1; i < msg.Count; i++) { a[i - 1] = msg[i]; } RPC.Call(key, a); } } catch (Exception ex) { if (verbose) { Log.Warning("{0} - {1}", msg, ex); } } } }
public Task <JSC.JSValue> SetField(string fPath, JSC.JSValue val) { var ds = new TopicField(this, fPath, val); App.PostMsg(ds); return(ds.Task); }
private void _data_PropertyChanged(DTopic.Art art, DTopic child) { if (art == DTopic.Art.type) { _value = _data.Manifest; UpdateType(_tManifest != null ? _tManifest.State : null, _data.Manifest); } }
public void SetField02() { JSC.JSValue o = null, r, v = new JSL.Boolean(true); r = JsLib.SetField(o, "a", v); Assert.AreNotEqual(o, r); Assert.AreEqual(JSC.JSValueType.Object, r.ValueType); Assert.AreEqual(v, r["a"]); }
protected virtual void UpdateType(JSC.JSValue manifest) { this._manifest = manifest; string nv = null; int attr = 0; BitmapSource ni = null; if (_manifest != null && _manifest.ValueType == JSC.JSValueType.Object && _manifest.Value != null) { var vv = _manifest["editor"]; string tmp_s; if (vv.ValueType == JSC.JSValueType.String && !string.IsNullOrEmpty(tmp_s = vv.Value as string)) { nv = tmp_s; } var iv = _manifest["icon"]; if (iv.ValueType == JSC.JSValueType.String && !string.IsNullOrEmpty(tmp_s = iv.Value as string)) { ni = App.GetIcon(tmp_s); } JSC.JSValue js_attr; if ((js_attr = _manifest["attr"]).IsNumber) { attr = (int)js_attr; } } IsReadonly = (attr & 2) != 0; IsRequired = (attr & 1) != 0; if (nv == null) { nv = DTopic.JSV2Type(value); } if (ni == null) { if (value.ValueType == JSC.JSValueType.Object && value.Value == null) { ni = App.GetIcon((this is InTopic) ? string.Empty : "Null"); // Folder or Null } } if (ni == null) { ni = App.GetIcon(nv); } if (ni != icon) { icon = ni; PropertyChangedReise("icon"); } if (nv != _editorName) { _editorName = nv; editor = InspectorForm.GetEditor(_editorName, this, _manifest); PropertyChangedReise("editor"); } this.editor.TypeChanged(_manifest); }
public LoVariable(LogramPl pl, Topic owner) { this._pl = pl; this._owner = owner; _links = new List <ILoItem>(); _value = null; _value_new = _owner.GetState(); _pl.EnqueuePr(this); }
public void SetValue(JSC.JSValue value, Topic prim) { if (!JsLib.Equal(_value, value)) { _value_new = value; _prim = prim; _pl.EnqueuePr(this); } }
public TopicReq(DTopic cur, string path, JSC.JSValue st, JSC.JSValue manifest) { this._cur = cur; this._path = path; this._create = true; this._state = st; this._manifest = manifest; this._tcs = new TaskCompletionSource <DTopic>(); }
public void ValueChanged(JSC.JSValue value) { if(value != null && value.ValueType == JSC.JSValueType.String && value.Value != null) { string ov = base.SelectedValue as string; string nv = value.Value as string; if(ov != nv) { base.SelectedValue = nv; } } }
public veSliderBool(InBase owner, JSC.JSValue type) //-V3117 { _owner = owner; InitializeComponent(); ValueChanged(_owner.value); tbBoolean.Checked += cbBool_Checked; tbBoolean.Unchecked += cbBool_Unchecked; }
public new void ValueChanged(JSC.JSValue value) { try { _oldValue = (double)value; base.Value = _oldValue; } catch (Exception) { base.Value = null; } }
private veEsStatus(InBase owner, JSC.JSValue manifest) { _owner = owner; _client = (_owner as InTopic).Owner.Connection; base.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; base.Padding = new System.Windows.Thickness(10, 0, 10, 0); base.GotFocus += ve_GotFocus; _client.PropertyChanged += _client_PropertyChanged; ShowStatus(); }
public void SetField03() { JSC.JSValue o = JSC.JSObject.CreateObject(), o1 = new JSL.Boolean(false), r, v = new JSL.Boolean(true); o["b"] = o1; r = JsLib.SetField(o, "a", v); Assert.AreNotEqual(o, r); Assert.AreEqual(JSC.JSValueType.Object, r.ValueType); Assert.AreEqual(v, r["a"]); Assert.AreEqual(o1, r["b"]); }
private InTopic(JSC.JSValue tag, InTopic parent) { _parent = parent; base._compactView = true; _collFunc = parent._collFunc; name = string.Empty; IsEdited = true; levelPadding = _parent == null ? 1 : _parent.levelPadding + 8; _createTag = tag; }
public void TypeChanged(NiL.JS.Core.JSValue manifest) { tbSaved.Visibility = _owner.levelPadding > 9 ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible; tbConfig.Visibility = _owner.levelPadding > 9 ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible; tbInternal.Visibility = _owner.levelPadding > 9 ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible; tbSaved.IsEnabled = !_owner.IsReadonly; tbConfig.IsEnabled = !_owner.IsReadonly; tbReadonly.IsEnabled = !_owner.IsReadonly; tbRequired.IsEnabled = !_owner.IsReadonly; tbInternal.IsEnabled = !_owner.IsReadonly; }
public void TypeChanged(JSC.JSValue type) { if(_owner.IsReadonly) { base.IsReadOnly = true; base.Background = Brushes.White; base.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); } else { base.IsReadOnly = false; base.Background = Brushes.Azure; base.BorderThickness = new System.Windows.Thickness(1, 0, 1, 0); } }
public void ValueChanged(JSC.JSValue value) { if (value.ValueType == JSC.JSValueType.String) { _oldValue = value.Value as string; } else { _oldValue = value.ToString(); } base.Text = _oldValue; }
private veEditor(InBase owner, JSC.JSValue manifest) { this._owner = owner; base.ItemsSource = InspectorForm.GetEditors(); base.IsEditable = false; base.BorderBrush = Brushes.Black; base.Padding = new System.Windows.Thickness(10, 0, 10, 0); base.MinWidth = 90; base.GotFocus += ve_GotFocus; ValueChanged(_owner.value); TypeChanged(manifest); base.SelectionChanged += ve_SelectionChanged; }
private InTopic(JSC.JSValue cStruct, InTopic parent, Action<InBase, bool> collFunc) { _parent = parent; _cStruct = cStruct; name = string.Empty; IsEdited = true; levelPadding = _parent == null ? 5 : _parent.levelPadding + 7; JSC.JSValue sn; if(_cStruct != null && (sn = _cStruct["schema"]).ValueType == JSC.JSValueType.String) { parent._owner.GetAsync("/etc/schema/" + (sn.Value as string)).ContinueWith(SchemaLoaded, TaskScheduler.FromCurrentSynchronizationContext()); } }
private InValue(JSC.JSValue manifest, InValue parent) { this._parent = parent; base._compactView = false; base._manifest = manifest; base._collFunc = parent._collFunc; base.name = string.Empty; this._path = _parent._path + "."; base.levelPadding = _parent.levelPadding + 8; base._items = new List <InBase>(); base.IsEdited = true; }
private veByteArray(InBase owner, JSC.JSValue manifest) { _owner = owner; base.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; base.Padding = new System.Windows.Thickness(10, 0, 10, 0); base.BorderBrush = Brushes.Black; base.GotFocus += ve_GotFocus; base.LostFocus += ve_LostFocus; base.KeyUp += ve_KeyUp; ValueChanged(_owner.value); TypeChanged(manifest); }
private void _data_PropertyChanged(DTopic.Art art, DTopic child) { if (art == DTopic.Art.type) { UpdateType(_data.Manifest); } else if (art == DTopic.Art.value) { _value = _data.State; UpdateData(_data.State); } }
private InValue(DTopic data, InValue parent, string name, JSC.JSValue value, JSC.JSValue schema, Action<InBase, bool> collFunc) { _data = data; _parent = parent; _collFunc = collFunc; _path = _parent._path + "." + name; base.name = name; _items = new List<InBase>(); _isVisible = true; _isExpanded = true; // fill _valueVC levelPadding = _parent.levelPadding + 7; _value = value; UpdateSchema(schema); UpdateData(value); _isExpanded = this.HasChildren; }
public InValue(DTopic data, Action<InBase, bool> collFunc) { _data = data; _parent = null; _collFunc = collFunc; name = "value"; _path = string.Empty; _isVisible = true; _isExpanded = true; // fill _valueVC levelPadding = 5; _items = new List<InBase>(); _value = _data.value; UpdateSchema(_data.schema); UpdateData(_data.value); _isExpanded = this.HasChildren; _data.changed += _data_PropertyChanged; }
public void Response(DWorkspace ws, bool success, JSC.JSValue value) { _resp = value; _success = success; }
private void UpdateData(JSC.JSValue val) { _value = val; if(_value.ValueType == JSC.JSValueType.Object) { InValue vc; int i; foreach(var kv in _value.OrderBy(z => z.Key)) { vc = _items.OfType<InValue>().FirstOrDefault(z => z.name == kv.Key); if(vc != null) { vc.UpdateData(kv.Value); } else { for(i = _items.Count - 1; i >= 0; i--) { if(string.Compare(_items[i].name, kv.Key) < 0) { break; } } JSC.JSValue cs; { JSC.JSValue pr; if(_schema == null || (pr = _schema["Properties"] as JSC.JSValue).ValueType != JSC.JSValueType.Object || (cs = pr[kv.Key]).ValueType != JSC.JSValueType.Object) { cs = null; } } var ni= new InValue(_data, this, kv.Key, kv.Value, cs, _collFunc); _items.Insert(i + 1, ni); if(_isVisible && _isExpanded) { _collFunc(ni, true); } } } var keys = _value.Select(z => z.Key).ToArray(); for(i = _items.Count - 1; i >= 0; i--) { if(!keys.Contains(_items[i].name)) { if(_isVisible && _isExpanded) { _items[i].Deleted(); } _items.RemoveAt(i); } } } if(editor == null) { editor = InspectorForm.GetEdititor(_view, this, _schema); PropertyChangedReise("editor"); } else { editor.ValueChanged(_value); } }
private void _data_PropertyChanged(DTopic.Art art, DTopic child) { if(art==DTopic.Art.schema) { UpdateSchema(_data.schema); } else if(art==DTopic.Art.value) { _value = _data.value; UpdateSchema(_data.schema); UpdateData(_data.value); } }