本文整理汇总了C#中System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsBackgroundPartiallyTransparent方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStyleRenderer.IsBackgroundPartiallyTransparent方法的具体用法?C# VisualStyleRenderer.IsBackgroundPartiallyTransparent怎么用?C# VisualStyleRenderer.IsBackgroundPartiallyTransparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.VisualStyles.VisualStyleRenderer
的用法示例。
在下文中一共展示了VisualStyleRenderer.IsBackgroundPartiallyTransparent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManagedWindowGetWindowRegion
Region ManagedWindowGetWindowRegion (Form form)
{
if (form.WindowManager is MdiWindowManager && form.WindowManager.IsMaximized)
return null;
VisualStyleElement title_bar_element = ManagedWindowGetTitleBarVisualStyleElement (form.WindowManager);
if (!VisualStyleRenderer.IsElementDefined (title_bar_element))
return null;
VisualStyleRenderer renderer = new VisualStyleRenderer (title_bar_element);
if (!renderer.IsBackgroundPartiallyTransparent ())
return null;
IDeviceContext dc = GetMeasurementDeviceContext ();
Rectangle title_bar_rectangle = ManagedWindowGetTitleBarRectangle (form.WindowManager);
Region region = renderer.GetBackgroundRegion (dc, title_bar_rectangle);
ReleaseMeasurementDeviceContext (dc);
region.Union (new Rectangle (0, title_bar_rectangle.Bottom, form.Width, form.Height));
return region;
}
示例2: IsBackgroundPartiallyTransparent
public static bool IsBackgroundPartiallyTransparent (GroupBoxState state)
{
if (!VisualStyleRenderer.IsSupported)
return false;
VisualStyleRenderer vsr;
switch (state) {
case GroupBoxState.Normal:
default:
vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Normal);
break;
case GroupBoxState.Disabled:
vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Disabled);
break;
}
return vsr.IsBackgroundPartiallyTransparent ();
}
示例3: DataGridViewColumnHeaderCellDrawBackground
public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
{
if (!RenderClientAreas ||
!cell.DataGridView.EnableHeadersVisualStyles || cell is DataGridViewTopLeftHeaderCell)
return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
VisualStyleElement element = DataGridViewColumnHeaderCellGetVisualStyleElement (cell);
if (!VisualStyleRenderer.IsElementDefined (element))
return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
bounds.Height--;
VisualStyleRenderer renderer = new VisualStyleRenderer (element);
if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (g, bounds);
renderer.DrawBackground (g, bounds);
return true;
}
示例4: DataGridViewRowHeaderCellDrawBackground
public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
{
if (!RenderClientAreas ||
!cell.DataGridView.EnableHeadersVisualStyles)
return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
VisualStyleElement element = DataGridViewRowHeaderCellGetVisualStyleElement (cell);
if (!VisualStyleRenderer.IsElementDefined (element))
return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
bounds.Width--;
Bitmap bitmap = new Bitmap (bounds.Height, bounds.Width);
Graphics bitmap_g = Graphics.FromImage (bitmap);
Rectangle bitmap_rectangle = new Rectangle (Point.Empty, bitmap.Size);
VisualStyleRenderer renderer = new VisualStyleRenderer (element);
if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (bitmap_g, bitmap_rectangle);
renderer.DrawBackground (bitmap_g, bitmap_rectangle);
bitmap_g.Dispose ();
g.Transform = new Matrix(0, 1, 1, 0, 0, 0);
g.DrawImage (bitmap, bounds.Y, bounds.X);
bitmap.Dispose ();
g.ResetTransform ();
return true;
}
示例5: PaintNonClientRegion
private void PaintNonClientRegion(ref Message m)
{
IntPtr handle = Handle;
NativeMethods.RECT windowRect;
NativeMethods.GetWindowRect(handle, out windowRect);
windowRect = new NativeMethods.RECT(
0,
0,
windowRect.Right - windowRect.Left,
windowRect.Bottom - windowRect.Top);
using (var deviceContext = new NativeMethods.DeviceContext(handle))
{
var renderer = new VisualStyleRenderer(
Enabled
? ReadOnly
? VisualStyleElement.TextBox.TextEdit.ReadOnly
: VisualStyleElement.TextBox.TextEdit.Normal
: VisualStyleElement.TextBox.TextEdit.Disabled);
int clipResult =
NativeMethods.ExcludeClipRect(
deviceContext.GetHdc(),
_borderRect.Left,
_borderRect.Top,
windowRect.Right - _borderRect.Right,
windowRect.Bottom - _borderRect.Bottom);
if (clipResult == NativeMethods.SIMPLEREGION
|| clipResult == NativeMethods.COMPLEXREGION)
{
if (renderer.IsBackgroundPartiallyTransparent())
renderer.DrawParentBackground(deviceContext, windowRect.ToRectangle(), this);
renderer.DrawBackground(deviceContext, windowRect.ToRectangle());
}
}
m.Result = IntPtr.Zero;
}
示例6: PaintPriv
private void PaintPriv(PaintEventArgs e)
{
Graphics g = e.Graphics;
if(g == null) { base.OnPaint(e); return; }
int nNormPos = m_nPosition - m_nMinimum;
int nNormMax = m_nMaximum - m_nMinimum;
if(nNormMax <= 0) { Debug.Assert(false); nNormMax = 100; }
if(nNormPos < 0) { Debug.Assert(false); nNormPos = 0; }
if(nNormPos > nNormMax) { Debug.Assert(false); nNormPos = nNormMax; }
Rectangle rectClient = this.ClientRectangle;
Rectangle rectDraw;
VisualStyleElement vse = VisualStyleElement.ProgressBar.Bar.Normal;
if(VisualStyleRenderer.IsSupported &&
VisualStyleRenderer.IsElementDefined(vse))
{
VisualStyleRenderer vsr = new VisualStyleRenderer(vse);
if(vsr.IsBackgroundPartiallyTransparent())
vsr.DrawParentBackground(g, rectClient, this);
vsr.DrawBackground(g, rectClient);
rectDraw = vsr.GetBackgroundContentRectangle(g, rectClient);
}
else
{
g.FillRectangle(SystemBrushes.Control, rectClient);
Pen penGray = SystemPens.ControlDark;
Pen penWhite = SystemPens.ControlLight;
g.DrawLine(penGray, 0, 0, rectClient.Width - 1, 0);
g.DrawLine(penGray, 0, 0, 0, rectClient.Height - 1);
g.DrawLine(penWhite, rectClient.Width - 1, 0,
rectClient.Width - 1, rectClient.Height - 1);
g.DrawLine(penWhite, 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);
}
int nDrawWidth = (int)((float)rectDraw.Width * (float)nNormPos /
(float)nNormMax);
Color clrStart = Color.FromArgb(255, 128, 0);
Color clrEnd = Color.FromArgb(0, 255, 0);
if(!this.Enabled)
{
clrStart = UIUtil.ColorToGrayscale(SystemColors.ControlDark);
clrEnd = UIUtil.ColorToGrayscale(SystemColors.ControlLight);
}
bool bRtl = (this.RightToLeft == RightToLeft.Yes);
if(bRtl)
{
Color clrTemp = clrStart;
clrStart = clrEnd;
clrEnd = clrTemp;
}
// Workaround for Windows <= XP
Rectangle rectGrad = new Rectangle(rectDraw.X, rectDraw.Y,
rectDraw.Width, rectDraw.Height);
if(!WinUtil.IsAtLeastWindowsVista && !NativeLib.IsUnix())
rectGrad.Inflate(1, 0);
using(LinearGradientBrush brush = new LinearGradientBrush(rectGrad,
clrStart, clrEnd, LinearGradientMode.Horizontal))
{
g.FillRectangle(brush, (bRtl ? (rectDraw.Width - nDrawWidth + 1) :
rectDraw.Left), rectDraw.Top, nDrawWidth, rectDraw.Height);
}
PaintText(g, rectDraw);
}
示例7: OnRenderToolStripBackground
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
{
if (e.ToolStrip.IsDropDown && IsSupported)
{
var renderer = new VisualStyleRenderer("menu", 9, 0);
if (renderer.IsBackgroundPartiallyTransparent())
{
renderer.DrawParentBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.ToolStrip);
}
renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds);
}
else
{
base.OnRenderToolStripBackground(e);
}
}