예제 #1
0
 private void model_changed(DTopic.Art a, DTopic t)
 {
     if (t == model)
     {
         if (a == DTopic.Art.type || a == DTopic.Art.addChild)
         {
             Render(3);
         }
     }
     else if (t.parent == model)
     {
         loPin p;
         p = _pins.FirstOrDefault(z => z.GetModel() == t);
         if (p == null)
         {
             if (a == DTopic.Art.addChild)
             {
                 t.GetAsync(null).ContinueWith(PinLoaded, TaskScheduler.FromCurrentSynchronizationContext());
             }
             return;
         }
         if (a == DTopic.Art.RemoveChild)
         {
             lv.DeleteVisual(p);
             _pins.Remove(p);
             t.changed -= pin_changed;
         }
         this.Render(3);
     }
 }
예제 #2
0
 private void ModelChanged(DTopic.Art a, DTopic t)
 {
     if (t == _model)
     {
         if (a == DTopic.Art.type)
         {
             this.Width  = JsLib.OfInt(JsLib.GetField(_model.Manifest, "Logram.width"), 32 * CELL_SIZE);
             this.Height = JsLib.OfInt(JsLib.GetField(_model.Manifest, "Logram.height"), 18 * CELL_SIZE);
         }
     }
     else if (t.parent == _model)
     {
         if (a == DTopic.Art.addChild)
         {
             t.GetAsync(null).ContinueWith(MChildrenLoad, TaskScheduler.FromCurrentSynchronizationContext());
         }
         else if (a == DTopic.Art.RemoveChild)
         {
             foreach (var it in _visuals.OfType <loElement>().Where(z => z.GetModel() == t).ToArray())
             {
                 it.Dispose();
             }
         }
     }
 }
예제 #3
0
            public static loBlock Create(DTopic model, LogramView owner)
            {
                var lb = new loBlock(model, owner);

                owner.AddVisual(lb);
                model.GetAsync(null).ContinueWith(lb.ModelLoaded, TaskScheduler.FromCurrentSynchronizationContext());

                return(lb);
            }
예제 #4
0
        public override ObservableCollection <Control> MenuItems(System.Windows.FrameworkElement src)
        {
            var l = new ObservableCollection <Control>();

            JSC.JSValue v1;
            MenuItem    mi;

            if (!IsGroupHeader)
            {
                mi = new MenuItem()
                {
                    Header = "Open in new tab"
                };
                mi.Click += miOpen_Click;
                l.Add(mi);
                l.Add(new Separator());
            }
            if (_owner.Connection.Status != ClientState.Ready)
            {
                if (_owner.Connection.root == _owner && (_owner.Connection.Status == ClientState.Idle || _owner.Connection.Status == ClientState.Offline))
                {
                    mi = new MenuItem()
                    {
                        Header = "Connect"
                    };
                    mi.Click += miConnect_Click;
                    l.Add(mi);
                    mi = new MenuItem()
                    {
                        Header = "Delete connection"
                    };
                    mi.Click += miDelConn_Click;
                    l.Add(mi);
                }
            }
            else if (_manifest != null && (v1 = _manifest["Children"]).ValueType == JSC.JSValueType.Object)
            {
                var ad = new Dictionary <string, JSC.JSValue>();
                Jso2Acts(v1, ad);
                FillContextMenu(l, ad);
            }
            else if (_manifest != null && (v1 = _manifest["Children"]).ValueType == JSC.JSValueType.String)
            {
                _owner.GetAsync(v1.Value as string).ContinueWith(tt => FillContextMenuFromChildren(l, tt), TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                _owner.Connection.CoreTypes.GetAsync(null).ContinueWith(tt => FillContextMenuFromChildren(l, tt), TaskScheduler.FromCurrentSynchronizationContext());
            }
            return(l);
        }
예제 #5
0
        public ObservableCollection <Control> MenuItems(DTopic t, loItem ctrl)
        {
            var l = new ObservableCollection <Control>();

            JSC.JSValue v1;
            MenuItem    mi;

            mi = new MenuItem()
            {
                Header = "Open in new tab", Tag = t
            };
            mi.Click += miOpen_Click;
            l.Add(mi);
            mi = new MenuItem()
            {
                Header = "Show in Workspace", Tag = t
            };
            mi.Click += miShow_Click;
            l.Add(mi);

            l.Add(new Separator());
            if (ctrl is loPin)
            {
                bool ic = JsLib.ofBool(JsLib.GetField(t.Manifest, "Logram.trace"), false);
                mi = new MenuItem()
                {
                    Header = "Trace", Tag = t, IsCheckable = true, IsChecked = ic
                };
                mi.Click += miTrace_Click;
                l.Add(mi);
                l.Add(new Separator());
            }
            if (t.Manifest != null && (v1 = t.Manifest["Children"]).ValueType == JSC.JSValueType.Object)
            {
                var ad = new Dictionary <string, JSC.JSValue>();
                Jso2Acts(v1, ad);
                FillContextMenu(t, l, ad);
            }
            else if (t.Manifest != null && (v1 = t.Manifest["Children"]).ValueType == JSC.JSValueType.String)
            {
                t.GetAsync(v1.Value as string).ContinueWith(tt => FillContextMenuFromChildren(t, l, tt), TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                t.Connection.CoreTypes.GetAsync(null).ContinueWith(tt => FillContextMenuFromChildren(t, l, tt), TaskScheduler.FromCurrentSynchronizationContext());
            }
            return(l);
        }
예제 #6
0
 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());
 }
예제 #7
0
        private async Task AddTopic(DTopic t)
        {
            InTopic tmp;
            var     tt = await t.GetAsync(null);

            if (tt != null)
            {
                bool o_hc = _items != null && _items.Any();
                if ((tmp = _items.OfType <InTopic>().FirstOrDefault(z => z.name == tt.name)) != null)
                {
                    _items.Remove(tmp);
                    _collFunc(tmp, false);
                    tmp.RefreshOwner(tt);
                }
                else
                {
                    tmp = new InTopic(tt, this, _collFunc);
                }
                int i;
                for (i = 0; i < _items.Count; i++)
                {
                    if (string.Compare(_items[i].name, tt.name) > 0)
                    {
                        break;
                    }
                }
                _items.Insert(i, tmp);
                if (!o_hc)
                {
                    PropertyChangedReise("items");
                    PropertyChangedReise("HasChildren");
                }
                if (_isVisible && _isExpanded)
                {
                    _collFunc(tmp, true);
                }
            }
        }
예제 #8
0
            public override void Render(int chLevel)
            {
                if (model == null || model.State == null || model.Manifest == null)
                {
                    return;
                }
                if (_mode != 0 && chLevel == 3)
                {
                    var src_s = JsLib.OfString(JsLib.GetField(model.Manifest, "cctor.LoBind"), null);
                    if (src_s == null)
                    {
                        _mode = 1;
                    }
                    else if (_source == null || _source.path != src_s || (_mode == 2 && _srcBinding == null && lv._dataIsLoaded))
                    {
                        model.GetAsync(src_s).ContinueWith(SourceLoaded, TaskScheduler.FromCurrentSynchronizationContext());
                        return;
                    }
                    if (_mode != 2 && _srcBinding != null)
                    {
                        _source = null;
                        _srcBinding.Dispose();
                        _srcBinding = null;
                    }
                }
                this.Offset = _owner.Offset + _ownerOffset;
                if (chLevel == 3)
                {
                    lv.MapRemove(this);
                    lv.MapSet(_mode == 0 ? 3 : 0, (int)(Offset.X / CELL_SIZE + 0.5), (int)(Offset.Y / CELL_SIZE + 0.5), this);
                }

                var   tc = model.State.ValueType;
                Brush br;

                switch (tc)
                {
                case JSC.JSValueType.Object:
                    if (model.State is ByteArray || model.State.Value is ByteArray)
                    {
                        br = brByteArray;
                    }
                    else
                    {
                        br = Brushes.MediumOrchid;
                    }
                    break;

                case JSC.JSValueType.String:
                    br = Brushes.Gold;
                    break;

                case JSC.JSValueType.Double:
                case JSC.JSValueType.Integer: {
                    double val = (double)model.State;
                    br = val > 0 ? (val == 1 ? Brushes.LawnGreen : Brushes.LightSeaGreen) : (val == 0 ? brValueFalse : Brushes.DodgerBlue); //-V3024
                }
                break;

                case JSC.JSValueType.Boolean:
                    br = (bool)model.State.Value ? Brushes.LawnGreen : brValueFalse; //-V3095
                    break;

                default:
                    br = Brushes.Black;
                    break;
                }
                bool ic = (!(_owner is loVariable) || _mode == 0) && JsLib.ofBool(JsLib.GetField(model.Manifest, "Logram.trace"), false);

                if (!ic && chLevel == 1 && this.brush == br)
                {
                    return;
                }
                this.brush = br;
                string val_s = string.Empty;

                if (ic)
                {
                    var v = model.State;
                    if (v != null)
                    {
                        switch (v.ValueType)
                        {
                        case JSC.JSValueType.Boolean:
                        case JSC.JSValueType.Integer:
                        case JSC.JSValueType.String:
                            val_s = v.Value.ToString();
                            break;

                        case JSC.JSValueType.Double: {
                            double d = (double)v;
                            int    p = (int)Math.Log10(Math.Abs(d));
                            switch (p)
                            {
                            case -2:
                                val_s = d.ToString("0.000##");
                                break;

                            case -1:
                                val_s = d.ToString("0.00##");
                                break;

                            case 0:
                                val_s = d.ToString("0.0##");
                                break;

                            case 1:
                                val_s = d.ToString("0.##");
                                break;

                            case 2:
                                val_s = d.ToString("0.#");
                                break;

                            case 3:
                                val_s = d.ToString("0.#");
                                break;

                            case 4:
                                val_s = d.ToString("0");
                                break;

                            default:
                                val_s = d.ToString("G4");
                                break;
                            }
                        }
                        break;

                        case JSC.JSValueType.Date: {
                            var dt = (v.Value as JSL.Date).ToDateTime();
                            val_s = dt.ToString("yyMMdd HH:mm:ss");
                            break;
                        }
                        }
                    }
                }
                using (DrawingContext dc = this.RenderOpen()) {
                    if (_mode == 3)
                    {
                        dc.DrawRectangle(_selected ? brItemSelected : this.brush, null, new Rect(-2, -5, 4, 10));
                    }
                    else
                    {
                        dc.DrawEllipse(_selected ? brItemSelected : this.brush, null, new Point(0, 0), 3, 3);
                    }
                    if (ic)
                    {
                        var   ft = new FormattedText(val_s, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, LogramView.LFont, CELL_SIZE * 0.7, Brushes.Black);
                        Point p;
                        if (_mode == 0)
                        {
                            p = new Point(2, 2 - CELL_SIZE);
                        }
                        else
                        {
                            p = new Point(-2 - ft.WidthIncludingTrailingWhitespace, 2 - CELL_SIZE);
                        }
                        dc.DrawText(ft, p);
                    }
                }
                if (_mode != 0 && _srcBinding != null && chLevel > 1)
                {
                    _srcBinding.Render(chLevel);
                }
                if (_mode == 0 && chLevel > 0)
                {
                    foreach (loBinding w in _connections.ToArray())
                    {
                        w.Render(chLevel);
                    }
                }
            }
예제 #9
0
 private async Task AddTopic(DTopic t) {
   InTopic tmp;
   var tt = await t.GetAsync(null);
   if(tt != null) {
     if((tmp = _items.OfType<InTopic>().FirstOrDefault(z => z.name == tt.name)) != null) {
       _items.Remove(tmp);
       _collFunc(tmp, false);
       tmp.RefreshOwner(tt);
     } else {
       tmp = new InTopic(tt, this, _collFunc);
       if(_isVisible && _isExpanded) {
         _collFunc(tmp, true);
       }
     }
     int i;
     for(i = 0; i < _items.Count; i++) {
       if(string.Compare(_items[i].name, tt.name) > 0) {
         break;
       }
     }
     _items.Insert(i, tmp);
   }
 }