public void Refresh(System.Drawing.Graphics graphics, bool bSystemColorEvent) { if(!bSystemColorEvent) { ResetChangedFlag(); } if (m_PredefinedColorScheme == ePredefinedColorScheme.Blue2003) SchemeXpBlue2003(); else if (m_PredefinedColorScheme == ePredefinedColorScheme.OliveGreen2003) SchemeXpOliveGreen2003(); else if (m_PredefinedColorScheme == ePredefinedColorScheme.Silver2003) SchemeXpSilver2003(); else if (m_PredefinedColorScheme == ePredefinedColorScheme.SystemColors) GenerateScheme(); else { if (Style == eDotNetBarStyle.Office2007) SchemeOffice2007(); else { eWinXPColorScheme xpc = BarFunctions.WinXPColorScheme; if (xpc != eWinXPColorScheme.Undetermined) { if (xpc == eWinXPColorScheme.Blue) { if (Style == eDotNetBarStyle.Office2003) SchemeXpBlue2003(); else if (Style == eDotNetBarStyle.VS2005) SchemeXpBlueVS2005(); else SchemeXpBlue(); } else if (xpc == eWinXPColorScheme.Silver) { if (Style == eDotNetBarStyle.Office2003) SchemeXpSilver2003(); else if (Style == eDotNetBarStyle.VS2005) SchemeXpSilverVS2005(); else SchemeXpSilver(); } else if (xpc == eWinXPColorScheme.OliveGreen) { if (Style == eDotNetBarStyle.Office2003) SchemeXpOliveGreen2003(); else if (Style == eDotNetBarStyle.VS2005) SchemeXpOliveGreenVS2005(); else SchemeXpOliveGreen(); } else GenerateScheme(); } else GenerateScheme(); } } bool bDisposeGraphics=false; if(graphics==null) { IntPtr wnd=NativeFunctions.GetDesktopWindow(); if(wnd!=IntPtr.Zero) { graphics=System.Drawing.Graphics.FromHwnd(wnd); bDisposeGraphics=true; } } try { if(graphics!=null) { if(!m_BarCaptionBackground.IsSystemColor && !m_BarCaptionBackground.IsEmpty) m_BarCaptionBackground=graphics.GetNearestColor(m_BarCaptionBackground); if(!m_BarCaptionBackground2.IsSystemColor && !m_BarCaptionBackground2.IsEmpty) m_BarCaptionBackground2=graphics.GetNearestColor(m_BarCaptionBackground2); if(!m_BarStripeColor.IsSystemColor && !m_BarStripeColor.IsEmpty) m_BarStripeColor=graphics.GetNearestColor(m_BarStripeColor); if(!m_BarCaptionInactiveBackground.IsSystemColor && !m_BarCaptionInactiveBackground.IsEmpty) m_BarCaptionInactiveBackground=graphics.GetNearestColor(m_BarCaptionInactiveBackground); if(!m_BarCaptionInactiveBackground2.IsSystemColor && !m_BarCaptionInactiveBackground2.IsEmpty) m_BarCaptionInactiveBackground2=graphics.GetNearestColor(m_BarCaptionInactiveBackground2); if(!m_BarCaptionInactiveText.IsSystemColor && !m_BarCaptionInactiveText.IsEmpty) m_BarCaptionInactiveText=graphics.GetNearestColor(m_BarCaptionInactiveText); if(!m_BarCaptionText.IsSystemColor && !m_BarCaptionText.IsEmpty) m_BarCaptionText=graphics.GetNearestColor(m_BarCaptionText); if(!m_BarFloatingBorder.IsSystemColor && !m_BarFloatingBorder.IsEmpty) m_BarFloatingBorder=graphics.GetNearestColor(m_BarFloatingBorder); if(!m_BarPopupBackground.IsSystemColor && !m_BarPopupBackground.IsEmpty) m_BarPopupBackground=graphics.GetNearestColor(m_BarPopupBackground); if(!m_BarPopupBorder.IsSystemColor && !m_BarPopupBorder.IsEmpty) m_BarPopupBorder=graphics.GetNearestColor(m_BarPopupBorder); if(!m_BarDockedBorder.IsSystemColor && !m_BarDockedBorder.IsEmpty) m_BarDockedBorder=graphics.GetNearestColor(m_BarDockedBorder); if(!m_BarBackground.IsSystemColor && !m_BarBackground.IsEmpty) m_BarBackground=graphics.GetNearestColor(m_BarBackground); if(!m_BarBackground2.IsEmpty && !m_BarBackground2.IsSystemColor) m_BarBackground2=graphics.GetNearestColor(m_BarBackground2); if(!m_ItemBackground.IsEmpty) m_ItemBackground=graphics.GetNearestColor(m_ItemBackground); if(!m_ItemBackground2.IsEmpty) m_ItemBackground2=graphics.GetNearestColor(m_ItemBackground2); if(!m_ItemCheckedBackground.IsSystemColor) m_ItemCheckedBackground=graphics.GetNearestColor(m_ItemCheckedBackground); if(!m_ItemCheckedBackground2.IsEmpty && !m_ItemCheckedBackground2.IsSystemColor) m_ItemCheckedBackground2=graphics.GetNearestColor(m_ItemCheckedBackground2); if(!m_ItemCheckedBorder.IsSystemColor) m_ItemCheckedBorder=graphics.GetNearestColor(m_ItemCheckedBorder); if(!m_ItemCheckedText.IsSystemColor) m_ItemCheckedText=graphics.GetNearestColor(m_ItemCheckedText); if(!m_ItemDisabledBackground.IsEmpty && !m_ItemDisabledBackground.IsSystemColor) m_ItemDisabledBackground=graphics.GetNearestColor(m_ItemDisabledBackground); if(!m_ItemDisabledText.IsSystemColor) m_ItemDisabledText=graphics.GetNearestColor(m_ItemDisabledText); if(!m_ItemExpandedShadow.IsSystemColor && !m_ItemExpandedShadow.IsEmpty) m_ItemExpandedShadow=graphics.GetNearestColor(m_ItemExpandedShadow); if(!m_ItemExpandedBackground.IsSystemColor) m_ItemExpandedBackground=graphics.GetNearestColor(m_ItemExpandedBackground); if(!m_ItemExpandedText.IsSystemColor) m_ItemExpandedText=graphics.GetNearestColor(m_ItemExpandedText); if(!m_ItemExpandedBorder.IsSystemColor) m_ItemExpandedBorder=graphics.GetNearestColor(m_ItemExpandedBorder); if(!m_ItemHotBackground.IsSystemColor) m_ItemHotBackground=graphics.GetNearestColor(m_ItemHotBackground); if(!m_ItemHotBackground2.IsEmpty && !m_ItemHotBackground2.IsSystemColor) m_ItemHotBackground2=graphics.GetNearestColor(m_ItemHotBackground2); if(!m_ItemHotBorder.IsSystemColor) m_ItemHotBorder=graphics.GetNearestColor(m_ItemHotBorder); if(!m_ItemHotText.IsSystemColor) m_ItemHotText=graphics.GetNearestColor(m_ItemHotText); if(!m_ItemPressedBackground.IsSystemColor) m_ItemPressedBackground=graphics.GetNearestColor(m_ItemPressedBackground); if(!m_ItemPressedBackground2.IsEmpty && !m_ItemPressedBackground2.IsSystemColor) m_ItemPressedBackground2=graphics.GetNearestColor(m_ItemPressedBackground2); if(!m_ItemPressedBorder.IsSystemColor) m_ItemPressedBorder=graphics.GetNearestColor(m_ItemPressedBorder); if(!m_ItemPressedText.IsSystemColor) m_ItemPressedText=graphics.GetNearestColor(m_ItemPressedText); if(!m_ItemSeparator.IsSystemColor) m_ItemSeparator=graphics.GetNearestColor(m_ItemSeparator); if(!m_ItemSeparatorShade.IsSystemColor && !m_ItemSeparatorShade.IsEmpty) m_ItemSeparatorShade=graphics.GetNearestColor(m_ItemSeparatorShade); if(!m_ItemText.IsSystemColor) m_ItemText=graphics.GetNearestColor(m_ItemText); if(!m_MenuBackground.IsSystemColor) m_MenuBackground=graphics.GetNearestColor(m_MenuBackground); if(!m_MenuBarBackground.IsSystemColor) m_MenuBarBackground=graphics.GetNearestColor(m_MenuBarBackground); if(!m_MenuBarBackground2.IsEmpty && !m_MenuBarBackground2.IsSystemColor) m_MenuBarBackground2=graphics.GetNearestColor(m_MenuBarBackground2); if(!m_MenuBorder.IsSystemColor) m_MenuBorder=graphics.GetNearestColor(m_MenuBorder); if(!m_MenuSide.IsSystemColor) m_MenuSide=graphics.GetNearestColor(m_MenuSide); if(!m_MenuUnusedBackground.IsSystemColor) m_MenuUnusedBackground=graphics.GetNearestColor(m_MenuUnusedBackground); if(!m_MenuUnusedSide.IsSystemColor) m_MenuUnusedSide=graphics.GetNearestColor(m_MenuUnusedSide); if(!m_ItemDesignTimeBorder.IsSystemColor) m_ItemDesignTimeBorder=graphics.GetNearestColor(m_ItemDesignTimeBorder); if(!m_CustomizeBackground.IsEmpty && !m_CustomizeBackground.IsSystemColor) m_CustomizeBackground=graphics.GetNearestColor(m_CustomizeBackground); if(!m_CustomizeBackground2.IsEmpty && !m_CustomizeBackground2.IsSystemColor) m_CustomizeBackground2=graphics.GetNearestColor(m_CustomizeBackground2); if(!m_CustomizeText.IsEmpty && !m_CustomizeText.IsSystemColor) m_CustomizeText=graphics.GetNearestColor(m_CustomizeText); } } finally { if(bDisposeGraphics) graphics.Dispose(); } }
/// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.PaintLabel"]/*' /> /// <devdoc> /// Paints the label portion of this GridEntry into the given Graphics object. This /// is called by the GridEntry host (the PropertyGridView) when this GridEntry is /// to be painted. /// </devdoc> public virtual void PaintLabel(System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { PropertyGridView gridHost = this.GridEntryHost; Debug.Assert(gridHost != null, "No propEntryHost"); string strLabel = this.PropertyLabel; int borderWidth = gridHost.GetOutlineIconSize()+OUTLINE_ICON_PADDING; // fill the background if necessary Brush bkBrush = selected ? gridHost.GetSelectedItemWithFocusBackBrush(g) : this.GetBackgroundBrush(g); // if we don't have focus, paint with the line color if (selected && !hasFocus) { bkBrush = gridHost.GetLineBrush(g); } bool fBold = ((this.Flags & GridEntry.FLAG_LABEL_BOLD) != 0); Font font = GetFont(fBold); int labelWidth = GetLabelTextWidth(strLabel, g, font); int neededWidth = paintFullLabel ? labelWidth : 0; int stringX = rect.X + this.PropertyLabelIndent; Brush blank = bkBrush; if (paintFullLabel && (neededWidth >= (rect.Width-(stringX+2)))) { int totalWidth = stringX + neededWidth + PropertyGridView.GDIPLUS_SPACE; // 5 = extra needed to ensure text draws completely and isn't clipped. #if PBRS_PAINT_DEBUG blank = Brushes.Green; #endif // blank out the space we're going to use g.FillRectangle(blank, borderWidth-1, rect.Y, totalWidth-borderWidth+3, rect.Height); // draw an end line Pen linePen = new Pen(gridHost.GetLineColor()); g.DrawLine(linePen, totalWidth, rect.Y, totalWidth, rect.Height); linePen.Dispose(); // set the new width that we can draw into rect.Width = totalWidth - rect.X; } else { // Normal case -- no pseudo-tooltip for the label #if PBRS_PAINT_DEBUG blank = Brushes.Red; #endif // Debug.WriteLine(rect.X.ToString() +" "+ rect.Y.ToString() +" "+ rect.Width.ToString() +" "+ rect.Height.ToString()); g.FillRectangle(blank, rect.X, rect.Y, rect.Width, rect.Height); } // draw the border stripe on the left Brush stripeBrush = gridHost.GetLineBrush(g); g.FillRectangle(stripeBrush, rect.X, rect.Y, borderWidth, rect.Height); if (selected && hasFocus) { g.FillRectangle(gridHost.GetSelectedItemWithFocusBackBrush(g), stringX, rect.Y, rect.Width - stringX - 1, rect.Height); } int maxSpace = Math.Min(rect.Width-stringX-1, labelWidth + PropertyGridView.GDIPLUS_SPACE); Rectangle textRect = new Rectangle(stringX, rect.Y + 1, maxSpace, rect.Height - 1); if (!Rectangle.Intersect(textRect, clipRect).IsEmpty) { Region oldClip = g.Clip; g.SetClip(textRect); // Do actual drawing // A brush is needed if using GDI+ only (UseCompatibleTextRendering); if using GDI, only the color is needed. Color textColor = (selected && hasFocus) ? gridHost.GetSelectedItemWithFocusForeColor() : g.GetNearestColor(this.LabelTextColor); if( this.ownerGrid.UseCompatibleTextRendering ) { using( Brush textBrush = new SolidBrush(textColor)){ StringFormat stringFormat = new StringFormat(StringFormatFlags.NoWrap); stringFormat.Trimming = StringTrimming.None; g.DrawString(strLabel, font, textBrush, textRect, stringFormat); } } else{ TextRenderer.DrawText( g, strLabel, font, textRect, textColor, PropertyGrid.MeasureTextHelper.GetTextRendererFlags() ); } #if PBRS_PAINT_DEBUG textRect.Width --; textRect.Height--; g.DrawRectangle(new Pen(Color.Blue), textRect); #endif g.SetClip(oldClip, CombineMode.Replace); oldClip.Dispose(); // clip is actually copied out. if (maxSpace <= labelWidth) { this.labelTipPoint = new Point(stringX+2, rect.Y+1); } else { this.labelTipPoint = InvalidPoint; } } rect.Y -= 1; rect.Height += 2; PaintOutline(g, rect); }
public static System.Drawing.Color MenuFocusBorderColor(System.Drawing.Graphics g) { return g.GetNearestColor(MenuFocusBorderColor()); }
public static System.Drawing.Color MenuBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(MenuBackColor()); }
public static System.Drawing.Color ToolMenuFocusBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(ToolMenuFocusBackColor()); }
public static System.Drawing.Color SideRecentlyBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(SideRecentlyBackColor()); }
public static System.Drawing.Color RecentlyUsedOfficeBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(RecentlyUsedOfficeBackColor()); }
public static System.Drawing.Color CheckBoxBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(CheckBoxBackColor()); }
public static System.Drawing.Color PressedBackColor(System.Drawing.Graphics g) { return g.GetNearestColor(PressedBackColor()); }