public static void Paint(SimpleNodeDisplayInfo di) { Rectangle r=di.Element.Bounds; //di.Graphics.SetClip(r); Region oldClip = di.Graphics.Clip; if (oldClip != null) di.Graphics.SetClip(r, CombineMode.Intersect); else di.Graphics.SetClip(r, CombineMode.Replace); //r.Inflate(1,1); ElementStyleDisplayInfo displayInfo=new ElementStyleDisplayInfo(di.Style,di.Graphics,r); ElementStyleDisplay.Paint(displayInfo); di.Graphics.ResetClip(); if(di.Element.ImageVisible) SimpleNodeDisplay.PaintImage(di); if(di.Element.TextVisible) { displayInfo.Bounds=(di.TextBounds.IsEmpty?di.Element.TextBounds:di.TextBounds); eTextFormat format = di.Style.TextFormat; if (di.RightToLeft) format |= eTextFormat.RightToLeft; ElementStyleDisplay.PaintText(displayInfo,di.Element.Text,di.Font, false, format); } if (oldClip != null) di.Graphics.Clip = oldClip; else di.Graphics.ResetClip(); }
private static void PaintImage(SimpleNodeDisplayInfo di) { if(di.Element.ImageLayoutSize.IsEmpty || di.Element.Image==null) return; Rectangle r=di.Element.ImageBounds; di.Graphics.DrawImage(di.Element.Image,r.X+(r.Width-di.Element.Image.Width)/2, r.Y+(r.Height-di.Element.Image.Height)/2); }
protected override void PaintControlBackground(ItemPaintArgs pa) { bool mouseOver = m_MouseOver; bool fade = m_FadeImageState!=null; if (fade) mouseOver = false; GraphicsPath insideClip = null; ElementStyle backStyle = GetBackgroundStyle(); bool disposeBackStyle = fade; try { if (backStyle != null) { Rectangle r = GetBackgroundRectangle(); pa.Graphics.SetClip(r, CombineMode.Replace); ElementStyle mouseOverStyle = GetBackgroundMouseOverStyle(); if (mouseOver && backStyle != null && mouseOverStyle != null && mouseOverStyle.Custom) { backStyle = backStyle.Copy(); disposeBackStyle = true; backStyle.ApplyStyle(mouseOverStyle); } ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(backStyle, pa.Graphics, r, EffectiveStyle == eDotNetBarStyle.Office2007); ElementStyleDisplay.Paint(displayInfo); pa.Graphics.ResetClip(); displayInfo.Bounds = GetBackgroundRectangle(); // Adjust so the title shows over the inside light border line displayInfo.Bounds.X--; displayInfo.Bounds.Width++; insideClip = ElementStyleDisplay.GetInsideClip(displayInfo); displayInfo.Bounds.X++; displayInfo.Bounds.Width--; } if (insideClip != null) pa.Graphics.SetClip(insideClip, CombineMode.Replace); m_DialogLauncherRect = Rectangle.Empty; if (m_TitleVisible && !this.OverflowState) { ElementStyle style = GetTitleStyle(); ElementStyle styleMouseOver = GetTitleMouseOverStyle(); if (mouseOver && style != null && styleMouseOver != null && styleMouseOver.Custom) { style = style.Copy(); style.ApplyStyle(styleMouseOver); } if (style != null) { SimpleNodeDisplayInfo info = new SimpleNodeDisplayInfo(style, pa.Graphics, m_TitleElement, this.Font, (this.RightToLeft == RightToLeft.Yes)); if (m_DialogLauncherVisible) { if (m_DialogLauncherButton == null) { Rectangle textRect = m_TitleElement.TextBounds; textRect.Width -= m_TitleRectangle.Height; if (this.RightToLeft == RightToLeft.Yes) textRect.X += m_TitleRectangle.Height; info.TextBounds = textRect; } else { if (m_MouseOverDialogLauncher && m_DialogLauncherMouseOverButton != null) m_TitleElement.Image = m_DialogLauncherMouseOverButton; else m_TitleElement.Image = m_DialogLauncherButton; } } SimpleNodeDisplay.Paint(info); if (m_DialogLauncherVisible && m_TitleElement.Image == null) PaintDialogLauncher(pa); else m_DialogLauncherRect = m_TitleElement.ImageBounds; } } pa.Graphics.ResetClip(); m_FadeImageLock.AcquireReaderLock(-1); try { if (m_FadeImageState != null) { Graphics g = pa.Graphics; Rectangle r = new Rectangle(0, 0, this.Width, this.Height); System.Drawing.Imaging.ColorMatrix matrix1 = new System.Drawing.Imaging.ColorMatrix(); matrix1[3, 3] = (float)((float)m_FadeAlpha / 255); using (System.Drawing.Imaging.ImageAttributes imageAtt = new System.Drawing.Imaging.ImageAttributes()) { imageAtt.SetColorMatrix(matrix1); g.DrawImage(m_FadeImageState, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, imageAtt); } return; } } finally { m_FadeImageLock.ReleaseReaderLock(); } } finally { if (insideClip != null) insideClip.Dispose(); if (disposeBackStyle && backStyle != null) backStyle.Dispose(); } }