示例#1
0
		public virtual void DrawCommentText(Graphics graphics, Rectangle rect, PropertyVisibleDeepEnumerator enumerator)
		{
            Font font = Grid.Font;

            using (Font boldFont = new Font(font, FontStyle.Bold))
            {
                Win32Calls.DrawText(graphics, enumerator.Property.DisplayName, ref rect, boldFont, Grid.CommentsForeColor,
                    Win32Calls.DT_LEFT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_TOP | Win32Calls.DT_NOPREFIX);

                Size size = Win32Calls.GetTextExtent(graphics, enumerator.Property.DisplayName, boldFont);
                rect.Y += size.Height + 3;
                rect.Height -= size.Height + 3;
            }

            string comment = enumerator.Property.Comment;
#if _SPGEVAL
            comment += "\nEvaluation version from VisualHint.\nPurchase it at http://www.visualhint.com";
#endif
            Win32Calls.DrawText(graphics, comment, ref rect, font, Grid.CommentsForeColor,
                Win32Calls.DT_LEFT | Win32Calls.DT_WORDBREAK | Win32Calls.DT_TOP | Win32Calls.DT_NOPREFIX);
        }
示例#2
0
        public virtual void DrawCommentText(Graphics graphics, Rectangle rect, PropertyVisibleDeepEnumerator enumerator)
        {
            Font font = Grid.Font;

            using (Font boldFont = new Font(font, FontStyle.Bold))
            {
                Win32Calls.DrawText(graphics, enumerator.Property.DisplayName, ref rect, boldFont, Grid.CommentsForeColor,
                                    Win32Calls.DT_LEFT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_TOP | Win32Calls.DT_NOPREFIX);

                Size size = Win32Calls.GetTextExtent(graphics, enumerator.Property.DisplayName, boldFont);
                rect.Y      += size.Height + 3;
                rect.Height -= size.Height + 3;
            }

            string comment = enumerator.Property.Comment;

#if _SPGEVAL
            comment += "\nEvaluation version from VisualHint.\nPurchase it at http://www.visualhint.com";
#endif
            Win32Calls.DrawText(graphics, comment, ref rect, font, Grid.CommentsForeColor,
                                Win32Calls.DT_LEFT | Win32Calls.DT_WORDBREAK | Win32Calls.DT_TOP | Win32Calls.DT_NOPREFIX);
        }
示例#3
0
		public virtual void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
		{
	        Color textColor;
	        Color valueColor;

            // Choose the colors of the background and text regarding the item selection
	        if (Selected)
	        {
                if (!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    valueColor = _grid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                        valueColor = Value.DisabledForeColor;
                    else
                    {
                        if (Value.ReadOnly)
                            valueColor = Value.ReadOnlyForeColor;
                        else
                            valueColor = Value.ForeColor;
                    }
                }

                if ((ParentGrid.GridContainsFocus) || (InPlaceCtrlInAction != null))
                    textColor = ParentGrid.HighlightedTextColor;
                else
                    textColor = ForeColor;
            }
	        else										// if not selected
	        {
                if ((!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None)) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    textColor = _grid.DisabledForeColor;
                    valueColor = _grid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                    {
/*                        if (Value.ReadOnly && (ParentGrid.ReadOnlyVisual == PropertyGrid.ReadOnlyVisuals.ReadOnlyFeel))
                        {
                            valueColor = Value.ReadOnlyForeColor;
                            textColor = ReadOnlyForeColor;
                        }
                        else*/
                        {
                            valueColor = Value.DisabledForeColor;
                            textColor = DisabledForeColor;
                        }
                    }
                    else
                    {
                        if (Value.ReadOnly)
                        {
                            valueColor = Value.ReadOnlyForeColor;
                            textColor = ReadOnlyForeColor;
                        }
                        else
                        {
                            textColor = ForeColor;
                            valueColor = Value.ForeColor;
                        }
                    }
                }
            }

	        // Draw the label background
	        //--------------------------

	        Rectangle rect = itemRect;
	        rect.X += ParentGrid.LeftColumnWidth + 1;
	        rect.Width = ParentGrid.LabelColumnWidth;
	        ParentGrid.DrawManager.DrawPropertyLabelBackground(graphics, rect, enumSelf);

            // Draw the +/- sign if needed
	        //----------------------------

	        if (ParentGrid.HasOneVisibleChild(enumSelf))
                ParentGrid.DrawManager.DrawPlusMinusSign(graphics, ParentGrid.Grid, itemRect, enumSelf);

            // Draw checkbox used to be able to manually disable/enable this property
	        //-----------------------------------------------------------------------

	        if (CanBeDisabledManually)
	        {
                Rectangle frameRect = GetManuallyDisableRect(itemRect, enumSelf);
                ParentGrid.DrawManager.DrawCheckBox(graphics, ParentGrid.Grid, frameRect, GetManuallyDisabledVariable(),
                    !ParentGrid.Grid.IsAncestorDisabled(enumSelf));
            }

            // Draw the value background
            //--------------------------

            Rectangle valueRect = GetValueRect(itemRect);
            ParentGrid.DrawManager.DrawPropertyValueBackground(graphics, valueRect, enumSelf);

            // Draw the vertical separation between the columns and the bottom horizontal line
            //--------------------------------------------------------------------------------

            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);
            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

            // Draw label text
	        //----------------

            // Draw icon if any
            Rectangle imgRect = GetImageRect(itemRect, enumSelf);
            if (imgRect != Rectangle.Empty)
            {
                Win32Calls.SetClippingRect(graphics, labelColumnRect);
                ParentGrid.DrawImage(ImageIndex, graphics, imgRect.Left, imgRect.Top);
                Win32Calls.ResetClippingRect(graphics);
            }

            Rectangle labelRect = GetLabelTextRect(itemRect, enumSelf);
            ParentGrid.DrawManager.DrawPropertyLabelText(graphics, labelRect, textColor, enumSelf);

	        // Draw value
	        //-----------

            // The height must be the same than the one assigned to inplace controls
            valueRect.Height--;

            Value.DrawValue(graphics, valueRect, valueColor, enumSelf, null);
		}
示例#4
0
        public override void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
        {
            Rectangle rect = itemRect;

            rect.X     += ParentGrid.LeftColumnWidth + 1;
            rect.Width -= ParentGrid.LeftColumnWidth + 1;

            // Draw a background
            //------------------

            Rectangle labelRect = GetLabelTextRect(itemRect, enumSelf);

            ParentGrid.DrawManager.DrawSubCategoryLabelBackground(graphics, labelRect.Left, rect, enumSelf);

            // Draw the vertical separation between the columns and the bottom horizontal line
            //--------------------------------------------------------------------------------

            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);

            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

            // Choose the colors of the text regarding the item selection
            Color textColor;

            if (Selected)
            {
                if (ParentGrid.GridContainsFocus)
                {
                    textColor = ParentGrid.HighlightedTextColor;
                }
                else
                {
                    textColor = ForeColor;
                }
            }
            else        // if not selected
            {
                textColor = ForeColor;
            }

            // Draw the image if any
            //----------------------

            Win32Calls.SetClippingRect(graphics, labelColumnRect);

            Rectangle imgRect = GetImageRect(itemRect, enumSelf);

            if (imgRect != Rectangle.Empty)
            {
                ParentGrid.DrawImage(ImageIndex, graphics, imgRect.Left, imgRect.Top);
            }

            // Draw the category label
            //------------------------

            ParentGrid.DrawManager.DrawSubCategoryLabelText(graphics, labelRect, textColor, enumSelf);

            // Draw the +/- sign
            //------------------

            if (ParentGrid.HasOneVisibleChild(enumSelf))
            {
                ParentGrid.DrawManager.DrawPlusMinusSign(graphics, ParentGrid.Grid, itemRect, enumSelf);
            }

            // Draw checkbox used to be able to manually disable/enable this category
            //-----------------------------------------------------------------------

            if (CanBeDisabledManually)
            {
                Rectangle frameRect = GetManuallyDisableRect(itemRect, enumSelf);
                ParentGrid.DrawManager.DrawCheckBox(graphics, ParentGrid.Grid, frameRect, GetManuallyDisabledVariable(),
                                                    !ParentGrid.Grid.IsAncestorDisabled(enumSelf));
            }

            Win32Calls.ResetClippingRect(graphics);

            // Draw value text if any
            //-----------------------

            if (ValueText.Length > 0)
            {
                Rectangle valueRect = itemRect;
                int       delta     = ParentGrid.LeftColumnWidth + 1 + ParentGrid.LabelColumnWidth;
                valueRect.X     += delta;
                valueRect.Width -= delta;
                valueRect.Inflate(-ParentGrid.GlobalTextMargin, 0);

                ParentGrid.DrawManager.DrawCategoryValue(graphics, valueRect, textColor, enumSelf);
            }
        }
示例#5
0
        public virtual void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
        {
            Color textColor;
            Color valueColor;

            // Choose the colors of the background and text regarding the item selection
            if (Selected)
            {
                if (!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    valueColor = _grid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                    {
                        valueColor = Value.DisabledForeColor;
                    }
                    else
                    {
                        if (Value.ReadOnly)
                        {
                            valueColor = Value.ReadOnlyForeColor;
                        }
                        else
                        {
                            valueColor = Value.ForeColor;
                        }
                    }
                }

                if ((ParentGrid.GridContainsFocus) || (InPlaceCtrlInAction != null))
                {
                    textColor = ParentGrid.HighlightedTextColor;
                }
                else
                {
                    textColor = ForeColor;
                }
            }
            else                                                                                // if not selected
            {
                if ((!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None)) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    textColor  = _grid.DisabledForeColor;
                    valueColor = _grid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                    {
/*                        if (Value.ReadOnly && (ParentGrid.ReadOnlyVisual == PropertyGrid.ReadOnlyVisuals.ReadOnlyFeel))
 *                      {
 *                          valueColor = Value.ReadOnlyForeColor;
 *                          textColor = ReadOnlyForeColor;
 *                      }
 *                      else*/
                        {
                            valueColor = Value.DisabledForeColor;
                            textColor  = DisabledForeColor;
                        }
                    }
                    else
                    {
                        if (Value.ReadOnly)
                        {
                            valueColor = Value.ReadOnlyForeColor;
                            textColor  = ReadOnlyForeColor;
                        }
                        else
                        {
                            textColor  = ForeColor;
                            valueColor = Value.ForeColor;
                        }
                    }
                }
            }

            // Draw the label background
            //--------------------------

            Rectangle rect = itemRect;

            rect.X    += ParentGrid.LeftColumnWidth + 1;
            rect.Width = ParentGrid.LabelColumnWidth;
            ParentGrid.DrawManager.DrawPropertyLabelBackground(graphics, rect, enumSelf);

            // Draw the +/- sign if needed
            //----------------------------

            if (ParentGrid.HasOneVisibleChild(enumSelf))
            {
                ParentGrid.DrawManager.DrawPlusMinusSign(graphics, ParentGrid.Grid, itemRect, enumSelf);
            }

            // Draw checkbox used to be able to manually disable/enable this property
            //-----------------------------------------------------------------------

            if (CanBeDisabledManually)
            {
                Rectangle frameRect = GetManuallyDisableRect(itemRect, enumSelf);
                ParentGrid.DrawManager.DrawCheckBox(graphics, ParentGrid.Grid, frameRect, GetManuallyDisabledVariable(),
                                                    !ParentGrid.Grid.IsAncestorDisabled(enumSelf));
            }

            // Draw the value background
            //--------------------------

            Rectangle valueRect = GetValueRect(itemRect);

            ParentGrid.DrawManager.DrawPropertyValueBackground(graphics, valueRect, enumSelf);

            // Draw the vertical separation between the columns and the bottom horizontal line
            //--------------------------------------------------------------------------------

            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);

            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

            // Draw label text
            //----------------

            // Draw icon if any
            Rectangle imgRect = GetImageRect(itemRect, enumSelf);

            if (imgRect != Rectangle.Empty)
            {
                Win32Calls.SetClippingRect(graphics, labelColumnRect);
                ParentGrid.DrawImage(ImageIndex, graphics, imgRect.Left, imgRect.Top);
                Win32Calls.ResetClippingRect(graphics);
            }

            Rectangle labelRect = GetLabelTextRect(itemRect, enumSelf);

            ParentGrid.DrawManager.DrawPropertyLabelText(graphics, labelRect, textColor, enumSelf);

            // Draw value
            //-----------

            // The height must be the same than the one assigned to inplace controls
            valueRect.Height--;

            Value.DrawValue(graphics, valueRect, valueColor, enumSelf, null);
        }
示例#6
0
        public virtual void DrawPropertyLabelText(Graphics graphics, Rectangle rect, Color textColor, PropertyVisibleDeepEnumerator enumSelf)
        {
            if (Rectangle.Intersect(rect, Rectangle.Round(graphics.ClipBounds)).IsEmpty)
                return;

            rect.Height = rect.Height / enumSelf.Property.HeightMultiplier;

            // Draw the text, clipped by the given area
            Win32Calls.DrawText(graphics, enumSelf.Property.DisplayName, ref rect, enumSelf.Property.Font, textColor,
                Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_NOPREFIX |
                ((_grid.EllipsisMode & PropertyGrid.EllipsisModes.EllipsisOnLabels) != 0 ? Win32Calls.DT_END_ELLIPSIS : 0));
        }
示例#7
0
        public override void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
        {
	        Rectangle rect = itemRect;
            rect.X += ParentGrid.LeftColumnWidth + 1;
            rect.Width -= ParentGrid.LeftColumnWidth + 1;

            // Draw a background
	        //------------------

            Rectangle labelRect = GetLabelTextRect(itemRect, enumSelf);
            ParentGrid.DrawManager.DrawSubCategoryLabelBackground(graphics, labelRect.Left, rect, enumSelf);

	        // Draw the vertical separation between the columns and the bottom horizontal line
	        //--------------------------------------------------------------------------------

            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);
            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

	        // Choose the colors of the text regarding the item selection
   	        Color textColor;
	        if (Selected)
	        {
                if (ParentGrid.GridContainsFocus)
                    textColor = ParentGrid.HighlightedTextColor;
		        else
			        textColor = ForeColor;
	        }
	        else	// if not selected
		        textColor = ForeColor;

	        // Draw the image if any
	        //----------------------

            Win32Calls.SetClippingRect(graphics, labelColumnRect);

            Rectangle imgRect = GetImageRect(itemRect, enumSelf);
            if (imgRect != Rectangle.Empty)
                ParentGrid.DrawImage(ImageIndex, graphics, imgRect.Left, imgRect.Top);

            // Draw the category label
            //------------------------
            
            ParentGrid.DrawManager.DrawSubCategoryLabelText(graphics, labelRect, textColor, enumSelf);

	        // Draw the +/- sign
	        //------------------

            if (ParentGrid.HasOneVisibleChild(enumSelf))
                ParentGrid.DrawManager.DrawPlusMinusSign(graphics, ParentGrid.Grid, itemRect, enumSelf);

	        // Draw checkbox used to be able to manually disable/enable this category
	        //-----------------------------------------------------------------------

            if (CanBeDisabledManually)
            {
                Rectangle frameRect = GetManuallyDisableRect(itemRect, enumSelf);
                ParentGrid.DrawManager.DrawCheckBox(graphics, ParentGrid.Grid, frameRect, GetManuallyDisabledVariable(),
                    !ParentGrid.Grid.IsAncestorDisabled(enumSelf));
            }

            Win32Calls.ResetClippingRect(graphics);

            // Draw value text if any
            //-----------------------

            if (ValueText.Length > 0)
            {
                Rectangle valueRect = itemRect;
                int delta = ParentGrid.LeftColumnWidth + 1 + ParentGrid.LabelColumnWidth;
                valueRect.X += delta;
                valueRect.Width -= delta;
                valueRect.Inflate(-ParentGrid.GlobalTextMargin, 0);

                ParentGrid.DrawManager.DrawCategoryValue(graphics, valueRect, textColor, enumSelf);
            }
        }
示例#8
0
        public override void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
        {
            // Fill the label background
            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);

            ParentGrid.DrawManager.DrawPropertyLabelBackground(graphics, labelColumnRect, enumSelf);

            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

            // Draw label text
            //----------------

            // Set the font to underline
            Font underlinedFont = new Font(Font, FontStyle.Underline);

            Color textColor;

            // Choose the colors of the background and text regarding the item selection
            if (Selected)
            {
                if (ParentGrid.GridContainsFocus)
                {
                    textColor = SystemColors.HighlightText;
                }
                else
                {
                    textColor = SystemColors.WindowText;
                }
            }
            else                                                                                // if not selected
            {
                if (!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    textColor = ParentGrid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                    {
                        textColor = DisabledForeColor;
                    }
                    else
                    {
                        textColor = ForeColor;
                    }
                }
            }

            labelColumnRect.X     += ParentGrid.GlobalTextMargin;
            labelColumnRect.Width -= 2 * ParentGrid.GlobalTextMargin;
            labelColumnRect.Height--;

            // Draw the text, clipped by the given area
            Size textSize = Win32Calls.GetTextExtent(graphics, DisplayName, underlinedFont);

            if (textSize.Width <= labelColumnRect.Width)
            {
                Win32Calls.DrawText(graphics, DisplayName, ref labelColumnRect, underlinedFont, textColor,
                                    Win32Calls.DT_RIGHT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_NOPREFIX);
            }
            else
            {
                Win32Calls.DrawText(graphics, DisplayName, ref labelColumnRect, underlinedFont, textColor,
                                    Win32Calls.DT_LEFT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_END_ELLIPSIS |
                                    Win32Calls.DT_NOPREFIX);
            }

            underlinedFont.Dispose();
        }
示例#9
0
        public virtual void DrawPropertyLabelText(Graphics graphics, Rectangle rect, Color textColor, PropertyVisibleDeepEnumerator enumSelf)
        {
            if (Rectangle.Intersect(rect, Rectangle.Round(graphics.ClipBounds)).IsEmpty)
            {
                return;
            }

            rect.Height = rect.Height / enumSelf.Property.HeightMultiplier;

            // Draw the text, clipped by the given area
            Win32Calls.DrawText(graphics, enumSelf.Property.DisplayName, ref rect, enumSelf.Property.Font, textColor,
                                Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_NOPREFIX |
                                ((_grid.EllipsisMode & PropertyGrid.EllipsisModes.EllipsisOnLabels) != 0 ? Win32Calls.DT_END_ELLIPSIS : 0));
        }
示例#10
0
        internal void DeletePropertyInternal(PropertyEnumerator propEnum)
        {
            if (_multiSelectMode != PropertyGrid.MultiSelectModes.None)
                _multiSelectedItems.Clear();

            bool changeSelect = (_selectedPropertyEnum.IsDescendantOf(propEnum) || (propEnum == _selectedPropertyEnum));
            bool changeFirstDisplayed = (_firstDisplayedPropertyEnumerator.IsDescendantOf(propEnum) || (propEnum == _firstDisplayedPropertyEnumerator));

            if (changeSelect)
            {
                // Unselect it before deletion
                SelectProperty(_categorizedPropertyCollection.GetVisibleDeepEnumerator().RightBound.GetVisibleDeepEnumerator());
            }

            PropertyEnumerator newEnumerator = _categorizedPropertyCollection.Delete(propEnum);

            if (!IsVerticallyFrozen)
            {
                if (changeFirstDisplayed)
                    _firstDisplayedPropertyEnumerator = newEnumerator.GetVisibleDeepEnumerator();

                if (changeSelect)
                    SelectProperty(newEnumerator.GetVisibleDeepEnumerator());
            }
            else
            {
                if (changeFirstDisplayed)
                    _firstDisplayedPropertyEnumerator = RightBound.GetVisibleDeepEnumerator();

                if (changeSelect)
                    SelectProperty(RightBound);
            }

            InvalidateVisibleItemCount();
        }
示例#11
0
        public InternalGrid(PropertyGrid parentCtrl)
        {
#if _XHEOSOURCECODE
            _license = System.ComponentModel.LicenseManager.Validate(typeof(InternalGrid), this);
#endif
            _parentCtrl = parentCtrl;

            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
                Utilities.DoubleBufferStyle | ControlStyles.Opaque, true);

            UpdateStyles();

            LeftColumnWidth = 16;

            GridColor = SystemColors.ActiveBorder;

            _activePropertyCollection = _categorizedPropertyCollection;

            _firstDisplayedPropertyEnumerator = _activePropertyCollection.GetVisibleDeepEnumerator().RightBound.GetVisibleDeepEnumerator();
            _selectedPropertyEnum = _activePropertyCollection.GetVisibleDeepEnumerator().RightBound.GetVisibleDeepEnumerator();

            TabStop = true;

            BackColor = SystemColors.Window;

            _mouseHook = new MouseHook(this, this);
            _messageHook = new MessageHook(this, this);
            _keyboardHook = new KeyboardHook(this, this);
        }
示例#12
0
        public void Clear()
        {
	        InvalidateVisibleItemCount();

	        HideInPlaceControl();

            _categorizedPropertyCollection.Clear();
            _flatPropertyCollection.Clear();

            _firstDisplayedLine = 1;
            _firstDisplayedPropertyEnumerator = _activePropertyCollection.GetVisibleDeepEnumerator().RightBound.GetVisibleDeepEnumerator();
            _selectedPropertyEnum = _activePropertyCollection.GetVisibleDeepEnumerator().RightBound.GetVisibleDeepEnumerator();

            Invalidate();

	        if (IsScrollbarVisible())
	        {
                Win32Calls.SetScrollPos(Handle, Win32Calls.SB_VERT, 0, true);
                CheckScrollbar();
	        }
        }
示例#13
0
        public void ShowProperty(PropertyEnumerator propEnum, bool show)
        {
            if (propEnum == propEnum.RightBound)
                return;

            if (propEnum.Property.Visible == show)
                return;

            propEnum.Property.VisibleInternal = show;

            InvalidateVisibleItemCount();

            if (!show)	// The item must be hidden
            {
                if (SelectedPropertyEnumerator == propEnum)
                {
                    PropertyEnumerator nextEnum = SelectedPropertyEnumerator.GetVisibleDeepEnumerator();
                    PropertyEnumerator prevEnum = SelectedPropertyEnumerator.GetVisibleDeepEnumerator().MovePrev();
                    if (nextEnum != nextEnum.RightBound)
                        SelectProperty(nextEnum);
                    else if (prevEnum != prevEnum.LeftBound)
                        SelectProperty(prevEnum);
                    else
                        SelectProperty(nextEnum);
                }

                if (_firstDisplayedPropertyEnumerator == propEnum)
                {
                    PropertyEnumerator nextEnum = _firstDisplayedPropertyEnumerator.GetVisibleDeepEnumerator();
                    PropertyEnumerator prevEnum = _firstDisplayedPropertyEnumerator.GetVisibleDeepEnumerator().MovePrev();
                    if (nextEnum != nextEnum.RightBound)
                        _firstDisplayedPropertyEnumerator = nextEnum as PropertyVisibleDeepEnumerator;
                    else if (prevEnum != prevEnum.LeftBound)
                        _firstDisplayedPropertyEnumerator = prevEnum as PropertyVisibleDeepEnumerator;
                    else
                        _firstDisplayedPropertyEnumerator = nextEnum as PropertyVisibleDeepEnumerator;
                }
            }

            if (!_lockRefresh)
            {
                if (IsHandleCreated)
                {
                    // We call OnSizeChanged here because this method checks to see if there
                    // is some space left at the bottom of the grid and scrolls it accordingly.
                    // It also calls CheckScrollbar()
                    Rectangle rect = ClientRectangle;
                    OnSizeChanged(rect.Width, rect.Height);
                    Refresh();
                }
            }
        }
示例#14
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            // If only Control is clicked we simulate a mouse move so that the cursor could be updated on
            // a hyperlink property.
            if (e.KeyCode == Keys.ControlKey)
            {
                if (_currentInPlaceControl != null)
                {
                    Win32Calls.RECT rect = new Win32Calls.RECT();
                    Win32Calls.GetWindowRect(_currentInPlaceControl.Handle, ref rect);
                    Rectangle bounds = Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom);

                    if (bounds.Contains(MousePosition))
                    {
                        base.OnKeyDown(e);
                        return;
                    }
                }

                Rectangle itemRect;
                Point pt = PointToClient(MousePosition);
                PropertyEnumerator propEnum = PropertyItemFromPoint(pt, out itemRect);

                if (propEnum.Property != null)
                    propEnum.Property.OverrideCursor(pt, itemRect, propEnum);
                
                base.OnKeyDown(e);
                return;
            }

            Property selectedProperty = _selectedPropertyEnum.Property;

            if (selectedProperty != null)
            {
                // Hide the tooltip if it is visible
//                if (ToolTip != null)
  //                  ToolTip.SetText("", null);

                if (_currentInPlaceControl != null)
                {
                    IInPlaceControl c = (_currentInPlaceControl as IInPlaceControl);
                    if ((c != null) && c.OnParentKeyDown(e))
                        return;
                }

                switch (e.KeyCode)
                {
                    case Keys.F4:
                    {
                        if ((_currentInPlaceControl != null) && (e.Modifiers == 0))
                        {
                            IInPlaceControl c = (_currentInPlaceControl as IInPlaceControl);
                            if (c != null)
                            {
                                c.OnF4();
                            }
                        }
                        break;
                    }
                    case Keys.Space:
                    case Keys.Return:
                    {
                        if ((SelectedPropertyEnumerator.Property.CanBeDisabledManually) && (e.KeyCode == Keys.Space))
                        {
                            if (SelectedPropertyEnumerator.HasParent == false)
                            {
                                EnableProperty(SelectedPropertyEnumerator, !SelectedPropertyEnumerator.Property.Enabled);
#if _DOTNET2
                                e.SuppressKeyPress = true;
#else
                                HandleRef handle = new HandleRef(this, this.Handle);
                                Win32Calls.RemovePendingMessages(handle, 0x102, 0x102);
                                Win32Calls.RemovePendingMessages(handle, 0x106, 0x106);
                                Win32Calls.RemovePendingMessages(handle, 0x286, 0x286);
                                e.Handled = true;
#endif
                            }
                            else
                            {
                                // The user can press on the checkbox only if its parent category is enabled
                                if (SelectedPropertyEnumerator.Parent.Property.Enabled)
                                {
                                    EnableProperty(SelectedPropertyEnumerator, !SelectedPropertyEnumerator.Property.Enabled);
#if _DOTNET2
                                    e.SuppressKeyPress = true;
#else
                                    HandleRef handle = new HandleRef(this, this.Handle);
                                    Win32Calls.RemovePendingMessages(handle, 0x102, 0x102);
                                    Win32Calls.RemovePendingMessages(handle, 0x106, 0x106);
                                    Win32Calls.RemovePendingMessages(handle, 0x286, 0x286);
                                    e.Handled = true;
#endif
                                }
                            }
                        }
                        // TODO : the following code should not be in this class.
                        else if (SelectedPropertyEnumerator.Property is PropertyHyperLink)
                        {
                            if (SelectedPropertyEnumerator.Property.Enabled)
                            {
                                PropertyHyperLinkClickedEventArgs ev = new PropertyHyperLinkClickedEventArgs(SelectedPropertyEnumerator, SelectedPropertyEnumerator.Property.HyperLink);
                                _parentCtrl.OnHyperLinkPropertyClicked(ev);
                            }
                        }
                        else if (HasOneVisibleChild(SelectedPropertyEnumerator))
                        {
                            Property property = SelectedPropertyEnumerator.Property;
                            ExpandProperty(SelectedPropertyEnumerator, !property.Expanded);
                        }

                        break;
                    }
                    case Keys.Right:		// Opens the item if it is a closed category
                    case Keys.Add:
                    {
                        if ((e.KeyCode == Keys.Right) && (ModifierKeys == Keys.Control))
                        {
                            SetLabelColumnWidthRatio((double)(LabelColumnWidth + 3) / (ClientRectangle.Width - LeftColumnWidth));
                            break;
                        }

                        if (SelectedPropertyEnumerator.Children.Count > 0)
                        {
                            Property property = SelectedPropertyEnumerator.Property;
                            if (!property.Expanded && HasOneVisibleChild(SelectedPropertyEnumerator))
                            {
                                ExpandProperty(SelectedPropertyEnumerator, true);
                                break;
                            }
                        }

                        if (e.KeyCode == Keys.Add)
                            break;

                        goto case Keys.Down;
                    }
                    case Keys.Down:		// Moves the selected item down
                    {
                        if (e.Modifiers == Keys.Alt)
                        {
                            if (_currentInPlaceControl != null)
                            {
                                IInPlaceControl c = (_currentInPlaceControl as IInPlaceControl);
                                if ((c != null) && !SelectedPropertyEnumerator.Property.Value.IsReadOnly(SelectedPropertyEnumerator))
                                {
                                    c.OnF4();
                                    break;
                                }
                            }
                        }

                        PropertyVisibleDeepEnumerator nextEnum = new PropertyVisibleDeepEnumerator(_selectedPropertyEnum.Node);
                        nextEnum.MoveNext();

                        Property nextProperty = nextEnum.Property;
                        if (nextProperty != null)
                        {
                            Rectangle clientRect = ClientRectangle;
                            Rectangle itemRect = GetAbsoluteItemRect(nextEnum);

                            if (itemRect.Top < clientRect.Top)	// Test if the item is above the top of the grid
                            {
                                while (true)
                                {
                                    Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_LINEUP, 0), 0);
                                    itemRect = GetAbsoluteItemRect(nextEnum);
                                    if (itemRect.Top == clientRect.Top)
                                        break;
                                }
                                Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_ENDSCROLL, 0), 0);
                            }
                            else if (itemRect.Bottom > clientRect.Bottom)		// Test if the item is below the bottom of the grid
                            {
                                // We scroll in a loop because the item may have a row height greater than the base row height
                                // if the current selected item is the last one displayed
                                // (TODO: we could be more performant by avoiding scrolls and directly calculating which property
                                // needs to be the first displayed)
                                _parentCtrl.BeginUpdate();  // To avoid the remancence of the inplace control
                                do
                                {
                                    Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_LINEDOWN, 0), 0);
                                    itemRect = GetAbsoluteItemRect(nextEnum);
                                }
                                while ((itemRect.Bottom > clientRect.Bottom) && (itemRect.Top > clientRect.Top));
                                Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_ENDSCROLL, 0), 0);
                                _parentCtrl.EndUpdate();
                            }

                            SelectProperty(nextEnum);
                        }

                        break;
                    }
                    case Keys.Left:		// Closes the item if it is an expanded category
                    case Keys.Subtract:
                    {
                        if ((e.KeyCode == Keys.Left) && (ModifierKeys == Keys.Control))
                        {
                            SetLabelColumnWidthRatio((double)(LabelColumnWidth - 3) / (ClientRectangle.Width - LeftColumnWidth));
                            break;
                        }

                        if (SelectedPropertyEnumerator.Children.Count > 0)
                        {
                            Property property = SelectedPropertyEnumerator.Property;
                            if (property.Expanded && HasOneVisibleChild(SelectedPropertyEnumerator))
                            {
                                ExpandProperty(SelectedPropertyEnumerator, false);
                                break;
                            }
                        }

                        if (e.KeyCode == Keys.Subtract)
                            break;

                        goto case Keys.Up;
                    }
                    case Keys.Up:		// Moves the selected item up
                    {
                        PropertyVisibleDeepEnumerator prevEnum = new PropertyVisibleDeepEnumerator(_selectedPropertyEnum.Node);
                        prevEnum.MovePrev();

                        Property prevProperty = prevEnum.Property;
                        if (prevProperty != null)
                        {
                            Rectangle clientRect = ClientRectangle;
                            Rectangle itemRect = GetAbsoluteItemRect(prevEnum);

                            if (itemRect.Top < clientRect.Top)
                            {
                                _firstDisplayedLine = 1;
                                FirstDisplayedProperty = prevEnum;
                            }
                            else if (itemRect.Bottom > clientRect.Bottom)
                            {
                                while(true)
                                {
                                    Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_LINEDOWN, 0), 0);
                                    itemRect = GetAbsoluteItemRect(prevEnum);
                                    if (itemRect.Bottom < clientRect.Bottom)
                                        break;
                                }
                                Win32Calls.SendMessage(Handle, Win32Calls.WM_VSCROLL, Win32Calls.MakeLong(Win32Calls.SB_ENDSCROLL, 0), 0);
                            }

                            SelectProperty(prevEnum);
                        }
                        break;
                    }
                    case Keys.Next:
                    {
                        Rectangle clientRect = ClientRectangle;
                        int itemsPerPage = clientRect.Height / _basicPropertyHeight - 1;
                        Rectangle itemRect = GetAbsoluteItemRect(SelectedPropertyEnumerator);

                        // Find the item one page down
                        int count = 0;
                        PropertyEnumerator propEnum = SelectedPropertyEnumerator.GetVisibleDeepEnumerator();
                        int lineCount = (propEnum == FirstDisplayedProperty ? _firstDisplayedLine : 1);
                        while ((count < itemsPerPage) && (propEnum != propEnum.RightBound))
                        {
                            if (lineCount == propEnum.Property.HeightMultiplier)
                            {
                                propEnum.MoveNext();
                                lineCount = 1;
                            }
                            else
                                lineCount++;

                            count++;
                        }

                        // Selected item is above the grid ?
                        if (itemRect.Bottom < clientRect.Top)
                        {
                            if (propEnum == propEnum.RightBound)
                            {
                                propEnum.MovePrev();
                                _firstDisplayedLine = propEnum.Property.HeightMultiplier;
                            }
                            else
                                _firstDisplayedLine = lineCount;

                            SelectProperty(propEnum);
                            EnsureVisible(propEnum);
                        }
                        // Selected item is in or below the grid ?
                        else
                        {
                            if (propEnum == propEnum.RightBound)	// Not a complete page down because at the far bottom ?
                            {
                                propEnum.MovePrev();
                                lineCount = propEnum.Property.HeightMultiplier;
                                PropertyVisibleDeepEnumerator propertyToSelectEnum = propEnum.GetVisibleDeepEnumerator();

                                count = itemsPerPage;
                                while ((propEnum != _activePropertyCollection.GetVisibleDeepEnumerator().MoveFirst()) && (count > 0))
                                {
                                    if (lineCount > 1)
                                        lineCount--;
                                    else
                                    {
                                        propEnum.MovePrev();
                                        lineCount = propEnum.Property.HeightMultiplier;
                                    }

                                    count--;
                                }

                                _firstDisplayedLine = lineCount;
                                FirstDisplayedProperty = propEnum as PropertyVisibleDeepEnumerator;
                                SelectProperty(propertyToSelectEnum);
                            }
                            else
                            {
                                // The grid height is to small to properly page down ?
                                if (itemsPerPage < propEnum.Property.HeightMultiplier)
                                {
                                    // Advance one item
                                    if (propEnum != _activePropertyCollection.GetVisibleDeepEnumerator().MoveLast())
                                    {
                                        if (propEnum == SelectedPropertyEnumerator)
                                            propEnum.MoveNext();

                                        _firstDisplayedLine = 1;
                                        FirstDisplayedProperty = propEnum as PropertyVisibleDeepEnumerator;
                                        SelectProperty(propEnum);
                                    }
                                }
                                else
                                {
                                    FirstDisplayedProperty = SelectedPropertyEnumerator;
                                    SelectProperty(propEnum);
                                }
                            }
                        }

                        Invalidate();

                        break;
                    }
                    case Keys.Prior:
                    {
                        Rectangle clientRect = ClientRectangle;
                        int itemsPerPage = clientRect.Height / _basicPropertyHeight - 1;

                        // Find the item one page up
                        int count = 0;
                        PropertyVisibleDeepEnumerator enumerator = SelectedPropertyEnumerator.GetVisibleDeepEnumerator();
                        int lineCount = enumerator.Property.HeightMultiplier;
                        while ((count < itemsPerPage) && (enumerator != _activePropertyCollection.GetVisibleDeepEnumerator().MoveFirst()))
                        {
                            if (lineCount == 1)
                            {
                                enumerator.MovePrev();
                                lineCount = enumerator.Property.HeightMultiplier;
                            }
                            else
                                lineCount--;

                            count++;
                        }

                        if ((count == 0) && (enumerator != _activePropertyCollection.GetVisibleDeepEnumerator().MoveFirst()))
                        {
                            enumerator.MovePrev();
                            count = 1;
                        }

                        Rectangle itemRect = GetAbsoluteItemRect(enumerator);

                        // Is the new selected item in the grid ?
                        if ((itemRect.Top >= clientRect.Top) && (itemRect.Bottom < clientRect.Bottom))
                            SelectProperty(enumerator);

                        // Is the new selected item below the grid ?
                        else if (itemRect.Bottom > clientRect.Bottom)
                        {
                            PropertyEnumerator currentEnum = enumerator.GetVisibleDeepEnumerator();
                            lineCount = 1;
                            while((count > 0) && (currentEnum != _activePropertyCollection.GetVisibleDeepEnumerator().MoveFirst()))
                            {
                                if (lineCount == 1)
                                {
                                    currentEnum.MovePrev();
                                    lineCount = currentEnum.Property.HeightMultiplier;
                                }
                                else
                                    lineCount--;

                                count--;
                            }

                            FirstDisplayedProperty = currentEnum as PropertyVisibleDeepEnumerator;
                            SelectProperty(enumerator);
                        }

                        // Is the new selected item above the grid ?
                        else if (itemRect.Top < clientRect.Top)
                        {
                            _firstDisplayedLine = 1;
                            FirstDisplayedProperty = enumerator;
                            SelectProperty(FirstDisplayedProperty);
                        }

                        Refresh();

                        break;
                    }
                    case Keys.Home:
                    {
                        Win32Calls.SetScrollPos(Handle, Win32Calls.SB_VERT, 0, true);
                        _firstDisplayedPropertyEnumerator = _activePropertyCollection.GetVisibleDeepEnumerator();
                        _firstDisplayedPropertyEnumerator.MoveFirst();
                        _firstDisplayedLine = 1;
                        SelectProperty(FirstDisplayedProperty);

                        break;
                    }
                    case Keys.End:
                    {
                        Rectangle clientRect = ClientRectangle;

                        _firstDisplayedPropertyEnumerator = _activePropertyCollection.GetVisibleDeepEnumerator();
                        _firstDisplayedPropertyEnumerator.MoveLast();

                        _firstDisplayedLine = 1;
                        PropertyVisibleDeepEnumerator currentEnum = _firstDisplayedPropertyEnumerator.GetVisibleDeepEnumerator();
                        Rectangle itemRect = GetItemRect(currentEnum);
                        while ((_firstDisplayedPropertyEnumerator != _activePropertyCollection.GetVisibleDeepEnumerator().MoveFirst()) && (clientRect.Bottom - itemRect.Bottom > _basicPropertyHeight))
                        {
                            if (_firstDisplayedLine > 1)
                                _firstDisplayedLine--;
                            else
                            {
                                _firstDisplayedPropertyEnumerator.MovePrev();
                                _firstDisplayedLine = _firstDisplayedPropertyEnumerator.Property.HeightMultiplier;
                            }

                            itemRect = GetItemRect(currentEnum);
                        }

                        Win32Calls.SCROLLINFO si = new Win32Calls.SCROLLINFO();
                        si.cbSize = Marshal.SizeOf(si);
                        si.fMask = Win32Calls.SIF_PAGE | Win32Calls.SIF_RANGE;
                        Win32Calls.GetScrollInfo(Handle, Win32Calls.SB_VERT, ref si);
                        Win32Calls.SetScrollPos(Handle, Win32Calls.SB_VERT, si.nMax - (si.nPage - 1), true);

                        PropertyVisibleDeepEnumerator lastEnum = _activePropertyCollection.GetVisibleDeepEnumerator();
                        lastEnum.MoveLast();
                        SelectProperty(lastEnum);

                        break;
                    }
			        case Keys.A:
			        {
				        if (e.Control)
				        {
					        if (_multiSelectMode == PropertyGrid.MultiSelectModes.SameLevel)
					        {
						        // Find the parent of the concerned level
						        PropertyEnumerator ancestorEnum;
                                if (SelectedPropertyEnumerator.Children.Count == 0)
                                    ancestorEnum = SelectedPropertyEnumerator.Parent;
                                else
                                    ancestorEnum = SelectedPropertyEnumerator;

                                // And browse all properties at this level and under
                                PropertyEnumerator propEnum = ancestorEnum.Children.GetVisibleDeepEnumerator();
                                propEnum.RestrictedToThisLevelAndUnder = true;
                                while(propEnum != ancestorEnum.Children.RightBound)
						        {
                                    if (_parentCtrl.OnValidateMultiSelection(SelectedPropertyEnumerator, propEnum as PropertyVisibleDeepEnumerator))
							        {
                                        propEnum.Property.SelectedInternal = true;
								        _multiSelectedItems.Add(propEnum);
							        }

                                    propEnum.MoveNext();
                                }

						        Invalidate();
					        }
					        else if (_multiSelectMode == PropertyGrid.MultiSelectModes.Global)
					        {
                                PropertyEnumerator propEnum = _activePropertyCollection.GetVisibleDeepEnumerator();
                                propEnum.MoveFirst();
                                while (propEnum != propEnum.RightBound)
                                {
                                    if ((propEnum != SelectedPropertyEnumerator) && (propEnum.Children.Count == 0))
                                    {
                                        if (_parentCtrl.OnValidateMultiSelection(SelectedPropertyEnumerator, propEnum as PropertyVisibleDeepEnumerator))
                                        {
                                            propEnum.Property.SelectedInternal = true;
                                            _multiSelectedItems.Add(propEnum);
                                        }
                                    }

                                    propEnum.MoveNext();
                                }

						        Invalidate();
					        }
				        }

				        break;
			        }
                }
            }

            base.OnKeyDown(e);
        }
示例#15
0
        private void SelectProperty(PropertyEnumerator enumerator, Point mousePos)
        {
            if ((enumerator.Property != null) && (CheckPropertyVisibility(enumerator) == false))
                throw new ArgumentException("The property enumerator passed to SelectProperty must point to a visible property.", "enumerator");

	        // Clear multi selected items
	        bool multiSelectionCleared = false;
	        if (!_clickWithControl && (_multiSelectedItems.Count > 0))
	        {
                foreach(PropertyVisibleDeepEnumerator currentEnum in _multiSelectedItems)
		        {
                    if (currentEnum != _selectedPropertyEnum)
                        currentEnum.Property.SelectedInternal = false;
                }

		        _multiSelectedItems.Clear();
		        multiSelectionCleared = true;
	        }

            bool selectedPropertyChanged = ((_selectedPropertyEnum != enumerator) || multiSelectionCleared);
            PropertyEnumerator previousSelectedPropertyEnum = _selectedPropertyEnum;

            if ((enumerator != enumerator.RightBound) && (enumerator.RightBound != null))
            {
                if (selectedPropertyChanged)
                {
                    if (_selectedPropertyEnum != _selectedPropertyEnum.RightBound)
                        _selectedPropertyEnum.Property.SelectedInternal = false;

                    _selectedPropertyEnum = enumerator.GetVisibleDeepEnumerator();

                    if (IsHandleCreated)
                    {
                        Rectangle clientRect = ClientRectangle;
                        Rectangle rect = GetItemRect(enumerator);

                        // Show the inplace control, even if partially visible
                        if ((rect.Top < clientRect.Bottom) && (rect.Bottom > clientRect.Top))
                            ShowInPlaceControl(enumerator, mousePos);
                    }

                    if (selectedPropertyChanged)
                        _selectedPropertyEnum.Property.SelectedInternal = true;
                }
                else
                {
                    // If the selected property didn't change we must still ensure that the text will be selected
                    // if the navigation mode says so
                    if ((_parentCtrl.NavigationKeyMode == PropertyGrid.NavigationKeyModes.TabKey) &&
                        ((_parentCtrl.TabKeyNavigationMode & PropertyGrid.TabKeyNavigationModes.TabKeyWithAutoFocus) != 0))
                    {
                        if (_currentInPlaceControl != null)
                        {
                            if (!_currentInPlaceControl.ContainsFocus)
                                FocusTextBox();
                            SelectAllText();
                        }
                    }
                }
            }
		    else if (selectedPropertyChanged)	// No item selected
		    {
                if (IsHandleCreated)
                {
				    // We hide the in-place control
    			    HideInPlaceControl();
			    }

                if (_selectedPropertyEnum.Property != null)
                    _selectedPropertyEnum.Property.SelectedInternal = false;

                _selectedPropertyEnum = enumerator.GetVisibleDeepEnumerator();
            }

            if (selectedPropertyChanged)
            {
                if (IsHandleCreated)
                {
                    if (_parentCtrl.CommentsVisibility)
                        _parentCtrl.Refresh();
                    else
                        Refresh();
                }

                // Notify the derived class
                if (_selectedPropertyEnum != RightBound)
                    _parentCtrl.OnPropertySelected(new PropertySelectedEventArgs(_selectedPropertyEnum,
                        previousSelectedPropertyEnum));
            }
        }
示例#16
0
        public override void Draw(Graphics graphics, Rectangle itemRect, PropertyVisibleDeepEnumerator enumSelf)
        {
            // Fill the label background
            Rectangle labelColumnRect = GetLabelColumnRect(itemRect, enumSelf);
            ParentGrid.DrawManager.DrawPropertyLabelBackground(graphics, labelColumnRect, enumSelf);

            ParentGrid.DrawManager.DrawSeparationLines(graphics, itemRect, labelColumnRect, enumSelf);

	        // Draw label text
	        //----------------

            // Set the font to underline
            Font underlinedFont = new Font(Font, FontStyle.Underline);

            Color textColor;

            // Choose the colors of the background and text regarding the item selection
            if (Selected)
            {
                if (ParentGrid.GridContainsFocus)
                    textColor = SystemColors.HighlightText;
                else
                    textColor = SystemColors.WindowText;
            }
            else										// if not selected
            {
                if (!ParentGrid.Enabled && (ParentGrid.DisableMode != PropertyGrid.DisableModes.None) &&
                    ParentGrid.DisableModeGrayedOut)
                {
                    textColor = ParentGrid.DisabledForeColor;
                }
                else
                {
                    if (Enabled == false)
                        textColor = DisabledForeColor;
                    else
                        textColor = ForeColor;
                }
            }

            labelColumnRect.X += ParentGrid.GlobalTextMargin;
            labelColumnRect.Width -= 2 * ParentGrid.GlobalTextMargin;
            labelColumnRect.Height--;

        	// Draw the text, clipped by the given area
            Size textSize = Win32Calls.GetTextExtent(graphics, DisplayName, underlinedFont);

            if (textSize.Width <= labelColumnRect.Width)
                Win32Calls.DrawText(graphics, DisplayName, ref labelColumnRect, underlinedFont, textColor,
                    Win32Calls.DT_RIGHT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_NOPREFIX);
            else
                Win32Calls.DrawText(graphics, DisplayName, ref labelColumnRect, underlinedFont, textColor,
                    Win32Calls.DT_LEFT | Win32Calls.DT_SINGLELINE | Win32Calls.DT_VCENTER | Win32Calls.DT_END_ELLIPSIS |
                    Win32Calls.DT_NOPREFIX);

            underlinedFont.Dispose();
        }