Example #1
0
        public virtual void CheckNode(BindableNode <T> node)
        {
            var item = (T)node.Data;

            if (item is IGroup group)
            {
                InitItems(group.GetGroups(), node, node.Visible);
            }
            node.IsCompaund = node.Nodes.Count > 0;
            node.CheckNodes = true;
        }
Example #2
0
        private void HandleViewListChanged(object sender, ListChangedEventArgs e)
        {
            if (listSource == null)
            {
                return;
            }
            var pe = e as ListPropertyChangedEventArgs;

            Application.Invoke(() =>
            {
                var view       = (ISelectable)sender;
                string name    = GetName(sender);
                var nodeParent = Nodes.Find(name);
                if (e.ListChangedType == ListChangedType.Reset)
                {
                    InitItem((ISelectable)view, true);
                }
                else if (e.ListChangedType == ListChangedType.ItemDeleted)
                {
                    var item = (T)pe.Sender;
                    var node = Find(item);
                    if (node != null)
                    {
                        if (node.Group != null)
                        {
                            node.Group = null;
                        }
                        Nodes.Remove(node);
                    }
                }
                else if (pe.Sender != null)
                {
                    BindableNode <T> node = null;
                    var item = (T)pe.Sender;

                    node = InitItem(item);
                    if (item is IGroup group && group.Group != null)
                    {
                        nodeParent = (BindableNode <T>)Find((T)group.Group);
                    }

                    //if (nodeParent == null && rowview.Group!=null && node.Group != null && node.Group.Tag)
                    //    nodeParent = node.Group;
                    if (node != null && nodeParent != null)
                    {
                        node.Group = nodeParent;
                    }
                    if (node != null)
                    {
                        InvalidateRow(listSource.IndexOf(node));
                    }
                }
            });
        }
Example #3
0
        public BindableNode <T> InitItemBase(T item)
        {
            var name = GetName(item);
            var node = Find(name);

            if (node == null)
            {
                node = new BindableNode <T>
                {
                    Name       = name,
                    Data       = item,
                    IsCompaund = true
                };
            }
            return(node);
        }
Example #4
0
        public override void CheckNode(BindableNode <object> node)
        {
            var item = (DBItem)node.Item;

            if (item is Position)
            {
                InitItems(((Position)item).GetUsers(), node, ShowUser);
            }
            else if (item.Table.GroupKey != null && item.PrimaryId != null)
            {
                InitItems(item.Table.SelectItems(item.Table.GroupKey, CompareType.Equal, item.PrimaryId), node, node.Visible);
            }
            if (item is Department)
            {
                InitItems(((Department)item).GetUsers(), node, ShowUser && !ShowPosition);
                InitItems(((Department)item).GetPositions(), node, ShowPosition);
            }
            node.IsCompaund = node.Nodes.Count > 0;
            node.CheckNodes = true;
        }
Example #5
0
 public void InitItems(IEnumerable items, BindableNode <T> pnode, bool show)
 {
     foreach (T item in items)
     {
         if (item.Equals(pnode.Data))
         {
             Helper.OnException(new Exception($"Warning - self reference!({item})"));
         }
         if (show && CheckVisible(item))
         {
             var node = InitItem(item);
             node.Group = pnode;
         }
         else
         {
             var node = Find(GetName(item));
             if (node != null)
             {
                 node.Hide();
             }
         }
     }
 }