Esempio n. 1
0
 public void ValueChanged(JSC.JSValue value)
 {
     if (value != null && value.ValueType == JSC.JSValueType.String)
     {
         textEditor.Text = value.Value as string;
     }
 }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 public veMsStatus(InBase owner, JSC.JSValue manifest)
 {
     _owner = owner;
     InitializeComponent();
     ValueChanged(_owner.value);
     TypeChanged(manifest);
 }
Esempio n. 4
0
 public TopicField(DTopic t, string fPath, JSC.JSValue value)
 {
     _topic = t;
     _fPath = fPath;
     _value = value;
     _tcs   = new TaskCompletionSource <JSC.JSValue>();
 }
Esempio n. 5
0
        public Task <bool> SetValue(JSC.JSValue val)
        {
            var ds = new TopicPublish(this, val);

            App.PostMsg(ds);
            return(ds.Task);
        }
Esempio n. 6
0
 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]);
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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;
            }
        }
Esempio n. 10
0
        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);
                    }
                }
            }
        }
Esempio n. 11
0
        public Task <JSC.JSValue> SetField(string fPath, JSC.JSValue val)
        {
            var ds = new TopicField(this, fPath, val);

            App.PostMsg(ds);
            return(ds.Task);
        }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
 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"]);
 }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
 public void SetValue(JSC.JSValue value, Topic prim)
 {
     if (!JsLib.Equal(_value, value))
     {
         _value_new = value;
         _prim      = prim;
         _pl.EnqueuePr(this);
     }
 }
Esempio n. 17
0
 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>();
 }
Esempio n. 18
0
 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;
     }
   }
 }
Esempio n. 19
0
        public veSliderBool(InBase owner, JSC.JSValue type) //-V3117
        {
            _owner = owner;
            InitializeComponent();
            ValueChanged(_owner.value);

            tbBoolean.Checked   += cbBool_Checked;
            tbBoolean.Unchecked += cbBool_Unchecked;
        }
Esempio n. 20
0
 public new void ValueChanged(JSC.JSValue value)
 {
     try {
         _oldValue  = (double)value;
         base.Value = _oldValue;
     }
     catch (Exception) {
         base.Value = null;
     }
 }
Esempio n. 21
0
 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();
 }
Esempio n. 22
0
 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"]);
 }
Esempio n. 23
0
 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;
 }
Esempio n. 24
0
 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;
 }
Esempio n. 25
0
 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);
   }
 }
Esempio n. 26
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;
 }
Esempio n. 27
0
 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;
 }
Esempio n. 28
0
    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());
      }
    }
Esempio n. 29
0
 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;
 }
Esempio n. 30
0
 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);
 }
Esempio n. 31
0
 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);
     }
 }
Esempio n. 32
0
 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;
 }
Esempio n. 33
0
 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;
 }
Esempio n. 34
0
 public void Response(DWorkspace ws, bool success, JSC.JSValue value) {
   _resp = value;
   _success = success;
 }
Esempio n. 35
0
 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);
   }
 }
Esempio n. 36
0
 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);
   }
 }