本文整理汇总了C#中System.Windows.Forms.VisualStyles.VisualStyleRenderer.DrawBackground方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStyleRenderer.DrawBackground方法的具体用法?C# VisualStyleRenderer.DrawBackground怎么用?C# VisualStyleRenderer.DrawBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.VisualStyles.VisualStyleRenderer
的用法示例。
在下文中一共展示了VisualStyleRenderer.DrawBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBottomPointingThumb
public static void DrawBottomPointingThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)
{
if (!IsSupported)
throw new InvalidOperationException ();
VisualStyleRenderer vsr;
switch (state) {
case TrackBarThumbState.Disabled:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Disabled);
break;
case TrackBarThumbState.Hot:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Hot);
break;
case TrackBarThumbState.Normal:
default:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Normal);
break;
case TrackBarThumbState.Pressed:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Pressed);
break;
}
vsr.DrawBackground (g, bounds);
}
示例2: Draw
protected override void Draw(Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
{
if (IsDefined(VisualStyleElement.ToolTip.BalloonTitle.Normal) && IsDefined(VisualStyleElement.ToolTip.Balloon.Normal))
{
VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
balloonRenderer.DrawBackground(dc, rect);
// drawing title
titleRenderer.DrawText(dc,
new Rectangle(Padding.Left + iconWidth, Padding.Top, rect.Width - iconWidth - (Padding.Left + Padding.Right), titleRect.Height),
title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);
// drawing text
Rectangle balloonTextBounds = new Rectangle(Padding.Left + iconWidth, Padding.Top + titleRect.Height, rect.Width - iconWidth - (Padding.Left + Padding.Right), rect.Height - (Padding.Top + titleRect.Height + Padding.Bottom));
balloonRenderer.DrawText(dc, balloonTextBounds,
text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
}
else
{
dc.FillRectangle(SystemBrushes.Info, rect);
dc.DrawRectangle(Pens.Black, new Rectangle(0, 0, rect.Width - 1, rect.Height - 1));
dc.DrawString(title, new Font(SystemFonts.DefaultFont, FontStyle.Bold), SystemBrushes.InfoText,
new PointF(Padding.Left + iconWidth, Padding.Top), new StringFormat(StringFormatFlags.NoWrap));
dc.DrawString(text, SystemFonts.DefaultFont, SystemBrushes.InfoText,
new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
new StringFormat());
}
}
示例3: DrawCloseButton
public static void DrawCloseButton(IDeviceContext dc, Rectangle rect, Padding padding, ToolTipBalloonCloseButtonState buttonState)
{
VisualStyleElement btn = GetCloseButtonVS(buttonState);
VisualStyleRenderer renderer = new VisualStyleRenderer(btn);
Rectangle btnRect = GetCloseButtonRect(dc, rect, padding, buttonState);
renderer.DrawBackground(dc, btnRect);
}
示例4: OnRendererTabPageArea
public override void OnRendererTabPageArea(Graphics gfx, Rectangle tabPageAreaRct)
{
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
renderer.DrawBackground(gfx, tabPageAreaRct);
}
else
{
Rectangle linesRct = tabPageAreaRct;
// Draw top 2px line.
using (Brush brush = new SolidBrush(Color.FromArgb(2, 111, 194)))
gfx.FillRectangle(brush, linesRct.Left, linesRct.Top, linesRct.Width, 2);
// Draw left, right and bottom 1px lines.
using (Pen pen = new Pen(Color.FromArgb(183, 192, 197)))
{
// Create border points.
Point[] points = new Point[]
{
// Left point.
new Point(linesRct.Left, linesRct.Top + 2),
// Bottom points.
new Point(linesRct.Left, linesRct.Bottom - 1),
new Point(linesRct.Right - 1, linesRct.Bottom - 1),
// Right point.
new Point(linesRct.Right - 1, linesRct.Top + 2)
};
gfx.DrawLines(pen, points);
}
}
}
示例5: Draw
public static void Draw(IDeviceContext dc, Size minSize, Size maxSize, string title, string text, Rectangle titleRect, Rectangle rect, ToolTipIcon icon, Padding padding)
{
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
balloonRenderer.DrawBackground(dc, rect);
if (icon == ToolTipIcon.None)
{
titleRenderer.DrawText(dc, new Rectangle(padding.Left, padding.Top, rect.Width - (padding.Left + padding.Right), titleRect.Height),
title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);
Rectangle balloonTextBounds = new Rectangle(padding.Left, padding.Top + titleRect.Height, rect.Width - (padding.Left + padding.Right), rect.Height - (padding.Top + titleRect.Height + padding.Bottom));
balloonRenderer.DrawText(dc, balloonTextBounds,
text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
}
else
{
throw new NotImplementedException();
}
}
else
{
throw new NotImplementedException();
}
}
示例6: DrawThemeBackground
private static void DrawThemeBackground(IDeviceContext dc, VisualStyleElement element, Rectangle bounds, Rectangle clipRectangle)
{
if( DialogHelper.IsTaskDialogThemeSupported )
{
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
renderer.DrawBackground(dc, bounds, clipRectangle);
}
}
示例7: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
if(g == null) { base.OnPaint(e); return; }
int nNormalizedPos = m_nPosition - m_nMinimum;
int nNormalizedMax = m_nMaximum - m_nMinimum;
Rectangle rectClient = this.ClientRectangle;
Rectangle rectDraw;
if(VisualStyleRenderer.IsSupported)
{
VisualStyleRenderer vsr = new VisualStyleRenderer(
VisualStyleElement.ProgressBar.Bar.Normal);
vsr.DrawBackground(g, rectClient);
rectDraw = vsr.GetBackgroundContentRectangle(g, rectClient);
}
else
{
g.FillRectangle(SystemBrushes.Control, rectClient);
g.DrawLine(Pens.Gray, 0, 0, rectClient.Width - 1, 0);
g.DrawLine(Pens.Gray, 0, 0, 0, rectClient.Height - 1);
g.DrawLine(Pens.White, rectClient.Width - 1, 0,
rectClient.Width - 1, rectClient.Height - 1);
g.DrawLine(Pens.White, 0, rectClient.Height - 1,
rectClient.Width - 1, rectClient.Height - 1);
rectDraw = new Rectangle(rectClient.X + 1, rectClient.Y + 1,
rectClient.Width - 2, rectClient.Height - 2);
}
Rectangle rectGradient = new Rectangle(rectDraw.X, rectDraw.Y,
rectDraw.Width, rectDraw.Height);
if((rectGradient.Width & 1) == 0) ++rectGradient.Width;
int nDrawWidth = (int)((float)rectDraw.Width * ((float)nNormalizedPos /
(float)nNormalizedMax));
Color clrStart = Color.FromArgb(255, 128, 0);
Color clrEnd = Color.FromArgb(0, 255, 0);
bool bRtl = (this.RightToLeft == RightToLeft.Yes);
if(bRtl)
{
Color clrTemp = clrStart;
clrStart = clrEnd;
clrEnd = clrTemp;
}
using(LinearGradientBrush brush = new LinearGradientBrush(rectGradient,
clrStart, clrEnd, LinearGradientMode.Horizontal))
{
g.FillRectangle(brush, (bRtl ? (rectDraw.Width - nDrawWidth + 1) :
rectDraw.Left), rectDraw.Top, nDrawWidth, rectDraw.Height);
}
}
示例8: OnPaintBackground
// If possible, give the window that nice gradient look
protected override void OnPaintBackground(PaintEventArgs e)
{
if (VisualStyleRenderer.IsSupported) {
VisualStyleRenderer VSR = new VisualStyleRenderer(VisualStyleElement.Tab.Body.Normal);
VSR.DrawBackground(e.Graphics, this.ClientRectangle, e.ClipRectangle);
}
else
base.OnPaintBackground(e);
}
示例9: DrawVerticalChunks
public static void DrawVerticalChunks (Graphics g, Rectangle bounds)
{
if (!IsSupported)
throw new InvalidOperationException ();
VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.ChunkVertical.Normal);
vsr.DrawBackground (g, bounds);
}
示例10: DrawGroupBox
public static void DrawGroupBox (Graphics g, Rectangle bounds, string groupBoxText, Font font, Color textColor, TextFormatFlags flags, GroupBoxState state)
{
Size font_size = TextRenderer.MeasureText (groupBoxText, font);
if (Application.RenderWithVisualStyles || always_use_visual_styles == true) {
VisualStyleRenderer vsr;
Rectangle new_bounds;
switch (state) {
case GroupBoxState.Normal:
default:
vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Normal);
new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2) - 1, bounds.Width, bounds.Height - (int)(font_size.Height / 2) + 1);
break;
case GroupBoxState.Disabled:
vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Disabled);
new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2) - 2, bounds.Width, bounds.Height - (int)(font_size.Height / 2) + 2);
break;
}
if (groupBoxText == String.Empty)
vsr.DrawBackground (g, bounds);
else
vsr.DrawBackgroundExcludingArea (g, new_bounds, new Rectangle (bounds.Left + 9, bounds.Top, font_size.Width - 3, font_size.Height));
if (textColor == Color.Empty)
textColor = vsr.GetColor (ColorProperty.TextColor);
if (groupBoxText != String.Empty)
TextRenderer.DrawText (g, groupBoxText, font, new Point (bounds.Left + 8, bounds.Top), textColor, flags);
}
else {
// MS has a pretty big bug when rendering the non-visual styles group box. Instead of using the height
// part of the bounds as height, they use it as the bottom, so the boxes are drawn in completely different
// places. Rather than emulate this bug, we do it correctly. After googling for a while, I don't think
// anyone has ever actually used this class for anything, so it should be fine. :)
Rectangle new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2), bounds.Width, bounds.Height - (int)(font_size.Height / 2));
// Don't paint over the background where we are going to put the text
Region old_clip = g.Clip;
g.SetClip (new Rectangle (bounds.Left + 9, bounds.Top, font_size.Width - 3, font_size.Height), System.Drawing.Drawing2D.CombineMode.Exclude);
ControlPaint.DrawBorder3D (g, new_bounds, Border3DStyle.Etched);
g.Clip = old_clip;
if (groupBoxText != String.Empty) {
if (textColor == Color.Empty)
textColor = state == GroupBoxState.Normal ? SystemColors.ControlText :
SystemColors.GrayText;
TextRenderer.DrawText (g, groupBoxText, font, new Point (bounds.Left + 8, bounds.Top), textColor, flags);
}
}
}
示例11: DrawCloseButton
public override void DrawCloseButton(Graphics dc, Rectangle rect, TooltipCloseButtonState buttonState)
{
VisualStyleElement btn = GetCloseButtonVS(buttonState);
Rectangle btnRect = GetCloseButtonRect(dc, rect, buttonState);
if (IsDefined(btn))
{
VisualStyleRenderer renderer = new VisualStyleRenderer(btn);
renderer.DrawBackground(dc, btnRect);
}
else
base.DrawCloseButton(dc, rect, buttonState);
}
示例12: VerticleProgressBar_Paint
private void VerticleProgressBar_Paint(object sender, PaintEventArgs e)
{
VisualStyleRenderer rBar = new VisualStyleRenderer(VisualStyleElement.ProgressBar.BarVertical.Normal);
rBar.DrawBackground(e.Graphics, e.ClipRectangle);
VisualStyleRenderer rChunk = new VisualStyleRenderer(VisualStyleElement.ProgressBar.ChunkVertical.Normal);
rChunk.DrawBackground(e.Graphics, new Rectangle(
new Point(e.ClipRectangle.Left + 1, e.ClipRectangle.Top + 1 + (int)(this.Size.Height * (1 - _value))),
new Size(this.Size.Width - 2, (int)(this.Size.Height * _value) - 2)));
}
示例13: OnPaintBackground
// The UseVisualStyleBackColor only uses a plain background color, not the background rendering for
// the current visual style. This corrects that error.
protected override void OnPaintBackground(PaintEventArgs e)
{
if (!VisualStyleRenderer.IsSupported || !this.UseVisualStyleBackColor) {
base.OnPaintBackground(e);
return;
}
TabControl P = this.Parent as TabControl;
if (P == null || P.Appearance != TabAppearance.Normal) {
base.OnPaintBackground(e);
return;
}
VisualStyleRenderer VSR = new VisualStyleRenderer(VisualStyleElement.Tab.Body.Normal);
VSR.DrawBackground(e.Graphics, this.ClientRectangle, e.ClipRectangle);
}
示例14: DrawHeaderBackground
private static void DrawHeaderBackground(Graphics gr, VisualStyleRenderer renderer, Rectangle rect)
{
if (renderer != null)
renderer.DrawBackground(gr, rect);
else
{
gr.FillRectangle(SystemBrushes.Control, rect);
gr.DrawLine(SystemPens.ControlDark, rect.X, rect.Bottom - 2, rect.Right, rect.Bottom - 2);
gr.DrawLine(SystemPens.ControlLightLight, rect.X, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
gr.DrawLine(SystemPens.ControlDark, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 2);
gr.DrawLine(SystemPens.ControlLightLight, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
}
}
示例15: DrawBackground
private void DrawBackground() {
if (_backgroundOverlay == null) {
_backgroundOverlay = Utilities.ResourceHelper.GetResourcePNG("shell32.dll", "632");
}
VisualStyleElement cpGradient = VisualStyleElement.CreateElement("CONTROLPANEL", 1, 0);
VisualStyleRenderer renderer = new VisualStyleRenderer(cpGradient);
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
using (Graphics g = Graphics.FromImage(_background)) {
renderer.DrawBackground(g, rect);
g.DrawImage(_backgroundOverlay, 0, 0, _backgroundOverlay.Width, _backgroundOverlay.Height);
}
}