private object GetMemberValue(string member)
        {
            if (String.IsNullOrEmpty(member) || _dataBoundItem == null)
            {
                return(null);
            }
            object result = ReflectionPool.GetPropertyValue(_dataBoundItem, member);

            return(result);
        }
Example #2
0
        internal object GetItemPropertyValue(object itemValue, string propertyName)
        {
            if (itemValue == null || String.IsNullOrEmpty(propertyName))
            {
                Debug.Assert(false, "itemValue 或 propertyName 为空");
                throw new ArgumentNullException();
            }

            return(ReflectionPool.GetPropertyValue(itemValue, propertyName));
        }
 public void Update(object obj)
 {
     if (_dataBoundItem == null || obj == null)
     {
         Debug.Assert(false, "_dataBoundItem 或 obj 为 null");
         return;
     }
     ReflectionPool.SetPropertyValue(_dataBoundItem, TextMember,
                                     ReflectionPool.GetPropertyValue(obj, TextMember));
     SetText();
 }
Example #4
0
            public T obtain <T> (Type type)
            {
                ReflectionPool <Component> pool = pools.ContainsKey(type) ? pools[type] : null;

                if (pool == null)
                {
                    pool = new ReflectionPool <Component> (type, initialSize, maxSize);
                    pools.Add(typeof(T), pool);
                }

                return((T)pool.obtain());
            }
Example #5
0
            public void free(Component obj)
            {
                if (obj == null)
                {
                    throw new ArgumentException("object cannot be null.");
                }

                ReflectionPool <Component> pool = pools[obj.GetType()];

                if (pool == null)
                {
                    return;                     // Ignore freeing an object that was never retained.
                }

                pool.free(obj);
            }
Example #6
0
        private void SetText()
        {
            if (String.IsNullOrEmpty(TextMember) || _dataBoundItem == null)
            {
                return;
            }

            object textObject = ReflectionPool.GetPropertyValue(_dataBoundItem, TextMember);

            if (textObject == null)
            {
                return;
            }

            this.Text = textObject.ToString();
        }
Example #7
0
        /// <summary>
        /// 获取当前选定对象的下钻对象集合
        /// </summary>
        /// <returns></returns>
        private IList GetGoingDownItems()
        {
            if (_currentCodon == null || SelectedItemsCount != 1)
            {
                return(null);
            }

            object selectedObject = GetSelectedItem();

            if (String.IsNullOrEmpty(_currentCodon.ItemsMember) || selectedObject == null)
            {
                return(null);
            }

            object listObject = ReflectionPool.GetPropertyValue(selectedObject, _currentCodon.ItemsMember);

            if (listObject == null)
            {
                return(null);
            }

            return(listObject as IList);
        }
Example #8
0
        /// <summary>
        /// 绘制文本
        /// </summary>
        /// <param name="g"></param>
        private void DrawText(Graphics g)
        {
            object selectedValue = GetSelectedValue();

            if (selectedValue == null)
            {
                return;
            }

            #region 绘制标题文本

            object textObj = ReflectionPool.GetPropertyValue(selectedValue, DisplayMember);
            if (textObj != null)
            {
                string text = textObj.ToString();
                if (text != String.Empty)
                {
                    Color textColor;
                    if (this.Selected)
                    {
                        textColor = _theme.SelectedTextColor;
                    }
                    else if (this.Hovered)
                    {
                        textColor = _theme.HoveredTextColor;
                    }
                    else
                    {
                        textColor = _theme.TextColor;
                    }

                    Font      textFont      = new System.Drawing.Font(this.Font, FontStyle.Bold);
                    Rectangle textRectangle = GetTextRectangle();
                    //  g.FillRectangle(Brushes.Red, textRectangle);
                    TextRenderer.DrawText(g, text, textFont, textRectangle, textColor, _textFlags);
                }
            }

            #endregion

            if (this.ShowDescription)
            {
                #region 绘制Description

                object descriptionObj = ReflectionPool.GetPropertyValue(selectedValue, DescriptionMember);
                if (descriptionObj != null)
                {
                    string description = descriptionObj.ToString();
                    if (description != String.Empty)
                    {
                        Color textColor;
                        if (this.Selected)
                        {
                            textColor = _theme.SelectedDescriptionTextColor;
                        }
                        else if (this.Hovered)
                        {
                            textColor = _theme.HoveredDescriptionColor;
                        }
                        else
                        {
                            textColor = _theme.DescriptionTextColor;
                        }

                        Rectangle descriptionRectangle = GetDescriptionRectangle();
                        //    g.FillRectangle(Brushes.Red, descriptionRectangle);
                        TextRenderer.DrawText(g, description, this.Font, descriptionRectangle, textColor, _textFlags);
                    }
                }

                #endregion
            }
        }