本文整理汇总了C#中System.Windows.Forms.VisualStyles.VisualStyleRenderer类的典型用法代码示例。如果您正苦于以下问题:C# VisualStyleRenderer类的具体用法?C# VisualStyleRenderer怎么用?C# VisualStyleRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VisualStyleRenderer类属于System.Windows.Forms.VisualStyles命名空间,在下文中一共展示了VisualStyleRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBoxColumnHeaderHandler
/// ------------------------------------------------------------------------------------
/// <summary>
/// Constructor.
/// </summary>
/// ------------------------------------------------------------------------------------
public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
{
Debug.Assert(col != null);
Debug.Assert(col is DataGridViewCheckBoxColumn);
Debug.Assert(col.DataGridView != null);
m_col = col;
m_grid = col.DataGridView;
m_grid.HandleDestroyed += HandleHandleDestroyed;
m_grid.CellPainting += HandleHeaderCellPainting;
m_grid.CellMouseMove += HandleHeaderCellMouseMove;
m_grid.ColumnHeaderMouseClick += HandleHeaderCellMouseClick;
m_grid.CellContentClick += HandleDataCellCellContentClick;
m_grid.Scroll += HandleGridScroll;
m_grid.RowsAdded += HandleGridRowsAdded;
m_grid.RowsRemoved += HandleGridRowsRemoved;
if (!Application.RenderWithVisualStyles)
{
m_szCheckBox = new Size(13, 13);
}
else
{
var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
var renderer = new VisualStyleRenderer(element);
using (var g = m_grid.CreateGraphics())
m_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
}
m_stringFormat = new StringFormat(StringFormat.GenericTypographic);
m_stringFormat.Alignment = StringAlignment.Center;
m_stringFormat.LineAlignment = StringAlignment.Center;
m_stringFormat.Trimming = StringTrimming.EllipsisCharacter;
m_stringFormat.FormatFlags |= StringFormatFlags.NoWrap;
}
示例2: DrawHorizontalThumb
public static void DrawHorizontalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
{
if (!IsSupported)
throw new InvalidOperationException ();
VisualStyleRenderer vsr;
switch (state) {
case TrackBarThumbState.Disabled:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Disabled);
break;
case TrackBarThumbState.Hot:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Hot);
break;
case TrackBarThumbState.Normal:
default:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Normal);
break;
case TrackBarThumbState.Pressed:
vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Pressed);
break;
}
vsr.DrawBackground (g, bounds);
}
示例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: 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();
}
}
示例5: OnRenderButtonBackground
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
{
TabStrip tabStrip = e.ToolStrip as TabStrip;
ToolStripButton button = e.Item as ToolStripButton;
Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size);
if (tabStrip != null) {
System.Windows.Forms.VisualStyles.TabItemState tabState = System.Windows.Forms.VisualStyles.TabItemState.Normal;
if (button.Checked) {
tabState |= System.Windows.Forms.VisualStyles.TabItemState.Selected;
}
if (button.Selected) {
tabState |= System.Windows.Forms.VisualStyles.TabItemState.Hot;
}
TabRenderer.DrawTabItem(e.Graphics, bounds, tabState);
if (button.Checked) {
VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Hot);
Padding borderPadding = button.Padding;
borderPadding.Top += 4;
borderPadding.Bottom += 2;
borderPadding.Left -= 2;
borderPadding.Right -= 2;
Rectangle rect = LayoutUtils.DeflateRect(bounds, borderPadding);
ControlPaint.DrawFocusRectangle(e.Graphics, rect);
}
}
else {
base.OnRenderButtonBackground(e);
}
}
示例6: getRenderer
private static VisualStyleRenderer getRenderer(int x, int y)
{
Dictionary<int, VisualStyleRenderer> subDict;
try
{
subDict = renderers[x];
}
catch (KeyNotFoundException)
{
subDict = new Dictionary<int, VisualStyleRenderer>();
renderers[x] = subDict;
}
VisualStyleRenderer renderer;
try
{
renderer = subDict[y];
}
catch (KeyNotFoundException)
{
renderer = new VisualStyleRenderer("Explorer::TreeView", x, y);
subDict[y] = renderer;
}
return renderer;
}
示例7: DrawThemeTextActive
public static void DrawThemeTextActive(
Graphics aGraph,
string aText,
Point aLocation,
SUxTextProperties aProp
)
{
IntPtr lPriHdc = aGraph.GetHdc();
VisualStyleRenderer lRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
DTTOPTS lOpts = new DTTOPTS();
lOpts.dwSize = Marshal.SizeOf(lOpts);
lOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
lOpts.crText = ColorTranslator.ToWin32(aProp.color);
lOpts.iGlowSize = aProp.glowSize;
RECT ltBounds = new RECT(0, 0, aProp.bounds.Width, aProp.bounds.Height);
DrawThemeTextEx(
lRenderer.Handle,
lPriHdc,
0, 0,
aText,
-1,
(int)(aProp.flags),
ref ltBounds,
ref lOpts
);
}
示例8: 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);
}
}
}
示例9: Draw
public override void Draw(TreeNodeAdv node, DrawContext context)
{
if (node.CanExpand)
{
Rectangle r = context.Bounds;
int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer renderer;
if (node.IsExpanded)
renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
else
renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
}
else
{
Image img;
if (node.IsExpanded)
img = _minus;
else
img = _plus;
context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy));
}
}
}
示例10: RefreshVisualStyles
public void RefreshVisualStyles()
{
if (ExplorerVisualStyle.VisualStylesEnabled)
{
try
{
_openedRenderer = ExplorerVisualStyle.TvOpenedRenderer;
_closedRenderer = ExplorerVisualStyle.TvClosedRenderer;
}
catch
{
_openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
_closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
}
}
else
{
try
{
_openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
_closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
}
catch
{
}
}
}
示例11: TreeGridView
public TreeGridView()
{
try
{
rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
rClosed = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
}
catch (Exception)
{
rOpen = null;
rClosed = null;
}
// Control when edit occurs because edit mode shouldn't start when expanding/collapsing
this.EditMode = DataGridViewEditMode.EditProgrammatically;
this.RowTemplate = new TreeGridNode() as DataGridViewRow;
// This sample does not support adding or deleting rows by the user.
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this._root = new TreeGridNode(this);
this._root.IsRoot = true;
// Ensures that all rows are added unshared by listening to the CollectionChanged event.
base.Rows.CollectionChanged += delegate(object sender, System.ComponentModel.CollectionChangeEventArgs e){};
}
示例12: CheckBoxColumnHeaderHandler
/// ------------------------------------------------------------------------------------
public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
{
Debug.Assert(col != null);
Debug.Assert(col is DataGridViewCheckBoxColumn);
Debug.Assert(col.DataGridView != null);
_col = col;
_owningGrid = col.DataGridView;
_owningGrid.HandleDestroyed += HandleHandleDestroyed;
_owningGrid.CellPainting += HandleHeaderCellPainting;
_owningGrid.CellMouseMove += HandleHeaderCellMouseMove;
_owningGrid.CellMouseClick += HandleHeaderCellMouseClick;
_owningGrid.CellContentClick += HandleDataCellCellContentClick;
_owningGrid.Scroll += HandleGridScroll;
_owningGrid.RowsAdded += HandleGridRowsAdded;
_owningGrid.RowsRemoved += HandleGridRowsRemoved;
if (!BetterGrid.CanPaintVisualStyle())
_szCheckBox = new Size(13, 13);
else
{
var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
var renderer = new VisualStyleRenderer(element);
using (var g = _owningGrid.CreateGraphics())
_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
}
}
示例13: Draw
public override void Draw(TreeNodeAdv node, DrawContext context)
{
Rectangle bounds = GetBounds(node, context);
CheckState state = GetCheckState(node);
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer renderer;
if (state == CheckState.Indeterminate)
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
else if (state == CheckState.Checked)
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
else
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, ImageSize, ImageSize));
}
else
{
Image img;
if (state == CheckState.Indeterminate)
img = _unknown;
else if (state == CheckState.Checked)
img = _check;
else
img = _uncheck;
context.Graphics.DrawImage(img, bounds.Location);
}
}
示例14: Remit
/// <summary>
/// Class constructor accepting a starting time value
/// </summary>
/// <param name="time">Array of integers specifying
/// <code>{days,hours,minutes,seconds}</code>
/// </param>
public Remit(int[] time)
{
/* set the timer values, so that it can continue if it just
* switched over from normal mode */
days = time[0];
hours = time[1];
minutes = time[2];
seconds = time[3];
bool vs = true; // visual styles work
InitializeComponent();
/* Just encase something odd happens and visual styles aren't available, don't
* break the program entirely :) */
try
{
vse = VisualStyleElement.Taskbar.BackgroundTop.Normal;
vsr = new VisualStyleRenderer(vse);
}
catch (Exception ex)
{
vs = false; // ok, no they don't :(
MessageBox.Show(
String.Format("Unable to aquire Visual Style renderer:\n {0}", ex.Message),
"Problem", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
// don't bother forcing user painting if we couldn't get the vsr
if (vs)
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
}
示例15: 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());
}
}