Пример #1
0
        void UpdateNode(TreeControl.Node node)
        {
            Translators.HierarchyTranslator trans = Translators.HierarchyTranslator.GetTranslator(node.Tag.GetType());
            if (trans != null)
            {
                node.Clear();
                FontStyle fs = node.FontStyle;
                node.Label      = trans.GetLabel(node.Tag, out fs);
                node.FontStyle  = fs;
                node.ImageIndex = trans.GetImage(node.Tag);
                object statusTag = trans.GetStatusTag(node.Tag);
                node.Expanded = expansionStatus.ContainsKey(statusTag) && expansionStatus[statusTag];

                List <object> children = trans.GetChildren(node.Tag);
                if (children != null && children.Count > 0)
                {
                    node.IsLeaf = false;
                    foreach (object o in children)
                    {
                        Fill(node, o);
                    }
                }
                else
                {
                    node.IsLeaf = true;
                }
            }
        }
Пример #2
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     Sce.Atf.DragDropExtender extender = new Sce.Atf.DragDropExtender(this);
     {
         HitRecord hit = Pick(e.Location);
         if (hit.Node != null && hit.Node.Tag != null)
         {
             Translators.HierarchyTranslator trans = Translators.HierarchyTranslator.GetTranslator(hit.Node.Tag.GetType());
             if (trans != null && trans.CanDrag())
             {
                 extender.DoDragDrop(hit.Node, DragDropEffects.All, null, e.Location);
             }
         }
     }
     base.OnMouseDown(e);
 }
Пример #3
0
        void Fill(TreeControl.Node parentNode, object obj)
        {
            Translators.HierarchyTranslator trans = Translators.HierarchyTranslator.GetTranslator(obj.GetType());
            if (trans != null)
            {
                TreeControl.Node nd = parentNode.Add(obj);
                UpdateNode(nd);

                // Attach a property changed notifier
                if (nd.Tag is INotifyPropertyChanged)
                {
                    ((INotifyPropertyChanged)nd.Tag).PropertyChanged += (sender, args) =>
                    {
                        // Only ever concerned about updating our label
                        FontStyle fs = nd.FontStyle;
                        nd.Label     = trans.GetLabel(nd.Tag, out fs);
                        nd.FontStyle = fs;
                    };
                }
            }
        }