Ejemplo n.º 1
0
        public UiTreeNode(ContextObject contextObject)
            : base(string.Empty, 0, 0)
        {
            this.contextObject = contextObject;

            contextObject.PropertyChanged += new PropertyChangedEventHandler(contextObject_PropertyChanged);


            object [] o = this.contextObject.GetType().GetCustomAttributes(typeof(UiNodeAttribute), false);
            if (o != null && o.Length > 0)
            {
                UiNodeAttribute attribute = o[0] as UiNodeAttribute;
                this.Text               = string.IsNullOrEmpty(attribute.Text) ? this.contextObject.ToString() : attribute.Text;
                this.ImageIndex         = attribute.ImageIndex;
                this.SelectedImageIndex = attribute.ImageIndex;
            }

            if (contextObject is ForeignKeyConstraint)
            {
                ForeignKeyConstraint referenceInfo = (ForeignKeyConstraint)contextObject;
                //TODO:
                //if (referenceInfo.RelatedTableName == referenceInfo.ReferencedTableName)
                //{
                //    return;
                //}
            }

            AddProperty();
        }
Ejemplo n.º 2
0
        public UiTreeNode(object contextObject, string propertyName, Type typeObject)
            : base(string.Empty, 0, 0)
        {
            this.contextObject = contextObject;

            if (contextObject is ContextObject)
            {
                (contextObject as ContextObject).PropertyChanged += new PropertyChangedEventHandler(contextObject_PropertyChanged);
            }

            object[] o = typeObject.GetProperty(propertyName).GetCustomAttributes(typeof(UiNodeAttribute), false);
            if (o != null && o.Length > 0)
            {
                UiNodeAttribute attribute = o[0] as UiNodeAttribute;
                this.Text               = string.IsNullOrEmpty(attribute.Text) ? contextObject.ToString() : attribute.Text;
                this.ImageIndex         = attribute.ImageIndex;
                this.SelectedImageIndex = attribute.ImageIndex;
            }
            if (contextObject is IDictionary)
            {
                ICollection values = (contextObject as IDictionary).Values;
                foreach (object value in values)
                {
                    ContextObject xobject = (ContextObject)value;
                    UiTreeNode    node    = new UiTreeNode((ContextObject)value);

                    this.Nodes.Add(node);
                }
            }

            // AddProperty();
        }