private void miAdd_Click(object sender, RoutedEventArgs e) { var mi = sender as MenuItem; JSC.JSValue decl; if (!IsReadonly && mi != null && (decl = mi.Tag as JSC.JSValue) != null) { if ((bool)decl["willful"]) { bool o_hc = _items.Any(); var ni = new InManifest(decl, this); _items.Insert(0, ni); _collFunc(ni, true); if (!o_hc) { PropertyChangedReise("HasChildren"); } if (!IsExpanded) { IsExpanded = true; base.PropertyChangedReise("IsExpanded"); } } else { string fName = mi.Header as string; _data.SetField(IsGroupHeader ? fName : _path + "." + fName, decl["default"]); } } }
private InManifest(JSC.JSValue manifest, InManifest parent) { _signature = System.Threading.Interlocked.Increment(ref SIGNATURE_CNT); 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 InManifest(InManifest parent, string name, JSC.JSValue value, JSC.JSValue type) { _signature = System.Threading.Interlocked.Increment(ref SIGNATURE_CNT); this._parent = parent; base._compactView = false; this._data = _parent._data; base._collFunc = _parent._collFunc; base.name = name; this._path = string.IsNullOrEmpty(_parent._path) ? name : (_parent._path + "." + name); base._isVisible = _parent._isExpanded; base._items = new List <InBase>(); base.IsGroupHeader = false; base.levelPadding = _parent.levelPadding + 8; this._value = value; UpdateType(type, value); }
public InManifest(DTopic data, Action <InBase, bool> collFunc) { _signature = System.Threading.Interlocked.Increment(ref SIGNATURE_CNT); _data = data; _parent = null; base._compactView = false; base._collFunc = collFunc; name = "Manifest"; _path = string.Empty; base._isVisible = true; base._isExpanded = true; base.IsGroupHeader = true; base.levelPadding = 1; base._items = new List <InBase>(); _data.changed += _data_PropertyChanged; _data.GetAsync("/$YS/TYPES/Ext/Manifest").ContinueWith(ManifestLoaded, TaskScheduler.FromCurrentSynchronizationContext()); }
private void UpdateType(JSC.JSValue type, JSC.JSValue val) { _value = val; #region Trace /*{ * StringBuilder sb = new StringBuilder(); * sb.Append(this.ToString()); * sb.Append(" $UpdateType( m{"); * if(type == null) { * sb.Append("null"); * } else { * foreach(var kv in type) { * sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString()); * } * sb.Append("}"); * if(type.__proto__.ValueType == JSC.JSValueType.Object && type.__proto__.Any()) { * sb.Append(" mp{"); * foreach(var kv in type.__proto__) { * sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString()); * } * sb.Append("}"); * } * } * if(val!=null && val.ValueType == JSC.JSValueType.Object) { * sb.Append(", s{"); * foreach(var kv in val) { * sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString()); * } * sb.Append("}"); * if(val.__proto__.ValueType == JSC.JSValueType.Object && val.__proto__.Any()) { * sb.Append(" proto{"); * foreach(var kv in val.__proto__) { * sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString()); * } * sb.Append("}"); * } * } else { * sb.Append(", s=" + JSL.JsLib.Stringify(_value, null, null)); * } * sb.Append(")"); * Log.Debug("{0}", sb.ToString()); * }*/ #endregion Trace bool o_hc = _items.Any(); base.UpdateType(type); base.editor.ValueChanged(_value); if (_value.ValueType == JSC.JSValueType.Object) { InManifest vc; int i; JSC.JSValue cs, cs_mi, cs_p; foreach (var kv in _value.OrderBy(z => z.Key)) { if (_manifest == null || _manifest.ValueType != JSC.JSValueType.Object || _manifest.Value == null || (cs_mi = _manifest["mi"]).ValueType != JSC.JSValueType.Object || cs_mi.Value == null || (cs = cs_mi[kv.Key]).ValueType != JSC.JSValueType.Object || cs.Value == null) { cs = JSC.JSObject.CreateObject(); } if ((cs_mi = (IsGroupHeader ? _value : _manifest)["mi"]).ValueType == JSC.JSValueType.Object && cs_mi.Value != null) { if ((cs_p = cs_mi[kv.Key]).ValueType == JSC.JSValueType.Object && cs_p.Value != null && cs != cs_p) { if (cs["mi"].ValueType == JSC.JSValueType.Object) { cs["mi"].__proto__ = cs_p["mi"].ToObject(); } cs.__proto__ = cs_p.ToObject(); } } vc = _items.OfType <InManifest>().FirstOrDefault(z => z.name == kv.Key); if (vc != null) { vc.UpdateType(cs, kv.Value); } else { var ni = new InManifest(this, kv.Key, kv.Value, cs); for (i = _items.Count - 1; i >= 0; i--) { if (string.Compare(_items[i].name, kv.Key) < 0) { break; } } _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 (o_hc != _items.Any()) { if (o_hc) // now has now children { IsExpanded = false; } PropertyChangedReise("HasChildren"); } }