예제 #1
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;
 }
예제 #2
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());
      }
    }
예제 #3
0
        private void miAdd_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var mi = sender as MenuItem;

            if (mi == null)
            {
                return;
            }
            bool pc_items = false;
            var  tag      = mi.Tag as JSC.JSValue;

            if (tag != null)
            {
                if ((bool)tag["willful"])
                {
                    if (_items == null)
                    {
                        lock (this._sync) {
                            if (_items == null)
                            {
                                _items   = new List <InBase>();
                                pc_items = true;
                            }
                        }
                    }
                    if (!IsExpanded && HasChildren)
                    {
                        IsExpanded = true;
                        base.PropertyChangedReise("IsExpanded");
                    }
                    var ni = new InTopic(tag, this);
                    _items.Insert(0, ni);
                    _collFunc(ni, true);
                }
                else
                {
                    _owner.CreateAsync((mi.Header as string).Replace("__", "_"), tag["default"], tag["manifest"]);
                }
            }
            if (pc_items)
            {
                PropertyChangedReise("items");
                PropertyChangedReise("HasChildren");
            }
        }
예제 #4
0
        public InTopic(DTopic owner, InTopic parent, Action <InBase, bool> collFunc)
        {
            _owner            = owner;
            _parent           = parent;
            base._compactView = true;
            _collFunc         = collFunc;
            IsGroupHeader     = _parent == null;
            _owner.changed   += _owner_PropertyChanged;
            if (IsGroupHeader)
            {
                if (owner.Connection.root == _owner)
                {
                    name   = string.IsNullOrWhiteSpace(owner.Connection.alias)?owner.Connection.server:owner.Connection.alias;
                    editor = veEsStatus.Create(this, _owner.Manifest);
                }
                else
                {
                    name   = "children";
                    editor = null;
                }
                _manifest    = _owner.Manifest; // if(IsGroupHeader) don't use UpdateType(...)
                icon         = App.GetIcon("children");
                levelPadding = 1;

                if (_owner.children != null && _owner.children.Any())
                {
                    _populated = true;
                    if (_owner.children != null)
                    {
                        var tsk = InsertItems(_owner.children);
                    }
                }
                base._isExpanded = true;
            }
            else
            {
                name = _owner.name;
                base.UpdateType(_owner.Manifest);
                levelPadding     = _parent.levelPadding + 8;
                base._isExpanded = false;
            }
            base._isVisible = IsGroupHeader || (_parent._isVisible && _parent._isExpanded);
        }
예제 #5
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);
                }
            }
        }
예제 #6
0
        private async Task ShowTopicT2(DTopic t)
        {
            List <DTopic> lst = new List <DTopic>();
            InTopic       tv  = null;

            while (t != null)
            {
                lst.Add(t);
                t = t.parent;
            }
            for (int i = lst.Count - 1; i >= 0; i--)
            {
                tv = _valueVC.OfType <InTopic>().FirstOrDefault(z => z.Owner == lst[i]);
                if (tv != null)
                {
                    await tv.Expand();
                }
            }
            if (tv != null)
            {
                lvValue.SelectedItem = tv;
                lvValue.ScrollIntoView(tv);
            }
        }
예제 #7
0
 public InTopic(DTopic owner, InTopic parent, Action<InBase, bool> collFunc) {
   _owner = owner;
   _parent = parent;
   _collFunc = collFunc;
   _root = _parent == null;
   IsGroupHeader = _root;
   _owner.changed += _owner_PropertyChanged;
   if(_root) {
     name = "children";
     icon = App.GetIcon("children");
     editor = null;
     levelPadding = 5;
     _populated = true;
     if(_owner.children != null) {
       InsertItems(_owner.children);
     }
   } else {
     name = _owner.name;
     base.UpdateSchema(_owner.schema);
     levelPadding = _parent.levelPadding + 7;
   }
   base._isExpanded = _root && _owner.children!=null && _owner.children.Any();
   base._isVisible = _root || (_parent._isVisible && _parent._isExpanded);
 }
예제 #8
0
 private void miAdd_Click(object sender, System.Windows.RoutedEventArgs e) {
   if(!IsExpanded) {
     IsExpanded = true;
     base.PropertyChangedReise("IsExpanded");
   }
   bool pc_items = false;
   var decl = (sender as MenuItem).Tag as JSC.JSValue;
   if(decl != null) {
     var mName = decl["name"];
     if(mName.ValueType == JSC.JSValueType.String && !string.IsNullOrEmpty(mName.Value as string)) {
       _owner.CreateAsync(mName.Value as string, decl["schema"].Value as string, decl["default"]);
     } else {
       if(_items == null) {
         lock(this) {
           if(_items == null) {
             _items = new List<InBase>();
             pc_items = true;
           }
         }
       }
       var ni = new InTopic(decl, this, _collFunc);
       _items.Insert(0, ni);
       _collFunc(ni, true);
     }
   }
   if(pc_items) {
     PropertyChangedReise("items");
   }
 }
예제 #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);
   }
 }