本文整理汇总了C#中IDeviceContext类的典型用法代码示例。如果您正苦于以下问题:C# IDeviceContext类的具体用法?C# IDeviceContext怎么用?C# IDeviceContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDeviceContext类属于命名空间,在下文中一共展示了IDeviceContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureString
private static SizeF MeasureString(IDeviceContext g, char chr, Font font, FontData data)
{
var chrValue = (int)chr;
if ((font.Bold && font.Italic) || font.Bold)
{
if (chrValue > 255 && data.BoldCharacter[chrValue].Width == 0)
{
data.BoldCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
}
return data.BoldCharacter[chrValue];
}
if (font.Italic)
{
if (chrValue > 255 && data.ItalicCharacter[chrValue].Width == 0)
{
data.ItalicCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
}
return data.ItalicCharacter[chrValue];
}
if (chrValue > 255 && data.NormalCharacter[chrValue].Width == 0)
{
data.NormalCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
}
return data.NormalCharacter[chrValue];
}
示例2: DrawText
public static void DrawText(this VisualStyleRenderer rnd, IDeviceContext dc, ref Rectangle bounds, string text, System.Windows.Forms.TextFormatFlags flags, NativeMethods.DrawThemeTextOptions options)
{
NativeMethods.RECT rc = new NativeMethods.RECT(bounds);
using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
NativeMethods.DrawThemeTextEx(rnd.Handle, hdc, rnd.Part, rnd.State, text, text.Length, (int)flags, ref rc, ref options);
bounds = rc;
}
示例3: GetMargins2
public static System.Windows.Forms.Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc, MarginProperty prop)
{
NativeMethods.RECT rc;
using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
NativeMethods.GetThemeMargins(rnd.Handle, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
return new System.Windows.Forms.Padding(rc.Left, rc.Top, rc.Right, rc.Bottom);
}
示例4: UxThemeDrawThemeBackground
public int UxThemeDrawThemeBackground (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds)
{
XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
int result = UXTheme.DrawThemeBackground(hTheme, dc.GetHdc (), iPartId, iStateId, ref BoundsRect, IntPtr.Zero);
dc.ReleaseHdc ();
return result;
}
示例5: UxThemeDrawThemeText
public int UxThemeDrawThemeText (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, string text, TextFormatFlags textFlags, Rectangle bounds)
{
XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
int result = UXTheme.DrawThemeText (hTheme, dc.GetHdc (), iPartId, iStateId, text, text.Length, (uint)textFlags, 0, ref BoundsRect);
dc.ReleaseHdc ();
return result;
}
示例6: UxThemeDrawThemeEdge
public int UxThemeDrawThemeEdge (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result)
{
XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
XplatUIWin32.RECT retval;
int hresult = UXTheme.DrawThemeEdge (hTheme, dc.GetHdc (), iPartId, iStateId, ref BoundsRect, (uint)style, (uint)edges + (uint)effects, out retval);
dc.ReleaseHdc ();
result = retval.ToRectangle();
return hresult;
}
示例7: SwapBgraToRgba
public void SwapBgraToRgba(IDeviceContext context, ITexture2D target, ITexture2D texture)
{
var uav = target.ViewAsUnorderedAccessResource(rgbaFormat, 0);
var srv = texture.ViewAsShaderResource(bgraFormat, 0, 1);
context.ShaderForDispatching = computeShader;
context.ComputeStage.ShaderResources[0] = srv;
context.ComputeStage.UnorderedAccessResources[0] = uav;
context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1);
}
示例8: StyleContext
public StyleContext(IDeviceContext deviceContext, IStyleProxy proxy, IControlDecoratorFactory decoratorFactory)
{
DeviceContext = deviceContext;
_proxy = proxy;
_decoratorFactory = decoratorFactory;
Current = this;
RegisterDefaultControlDectorators();
}
示例9: Renderer
protected Renderer(IDeviceContext deviceContext)
{
DeviceContext = deviceContext;
DeviceContext.DeviceDisposing += OnDisposing;
DeviceContext.DeviceResize += OnDeviceResize;
DeviceContext.DeviceSuspend += OnDeviceSuspend;
DeviceContext.DeviceResume += OnDeviceResume;
Scene = new SceneManager();
Camera = new QuaternionCam();
buffers = new List<SlimDX.Direct3D11.Buffer>();
}
示例10: IsSupported
/// <summary>
/// Check whether one of the extention strings is supported.
/// </summary>
/// <param name="ctx">
/// A <see cref="GraphicsContext"/> that specifies the current OpenGL version to test for extension support. In the case this
/// parameter is null, the test fallback to the current OpenGL version.
/// </param>
public bool IsSupported(GraphicsContext ctx, IDeviceContext deviceContext)
{
if (IsSupportedExtension(ctx, deviceContext, mExtensionString) == true)
return (true);
if (mExtensionAlternatives != null) {
foreach (string ext in mExtensionAlternatives)
if (IsSupportedExtension(ctx, deviceContext, ext) == true)
return (true);
}
return (false);
}
示例11: DrawGlassBackground
public static void DrawGlassBackground(this VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle)
{
DrawWrapper(rnd, dc, bounds,
delegate(IntPtr memoryHdc)
{
RECT rBounds = new RECT(bounds);
RECT rClip = new RECT(clipRectangle);
// Draw background
DrawThemeBackground(rnd.Handle, memoryHdc, rnd.Part, rnd.State, ref rBounds, ref rClip);
}
);
}
示例12: UxThemeDrawThemeParentBackground
public int UxThemeDrawThemeParentBackground (IDeviceContext dc, Rectangle bounds, Control childControl)
{
int result;
XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
using (Graphics g = Graphics.FromHwnd (childControl.Handle)) {
IntPtr hdc = g.GetHdc ();
result = UXTheme.DrawThemeParentBackground (childControl.Handle, hdc, ref BoundsRect);
g.ReleaseHdc (hdc);
}
return result;
}
示例13: DrawGlassBackground
public static void DrawGlassBackground(this VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle, bool rightToLeft = false)
{
DrawWrapper(rnd, dc, bounds,
delegate(IntPtr memoryHdc)
{
NativeMethods.RECT rBounds = new NativeMethods.RECT(bounds);
NativeMethods.RECT rClip = new NativeMethods.RECT(clipRectangle);
// Draw background
if (rightToLeft) NativeMethods.SetLayout(memoryHdc, 1);
NativeMethods.DrawThemeBackground(rnd.Handle, memoryHdc, rnd.Part, rnd.State, ref rBounds, ref rClip);
NativeMethods.SetLayout(memoryHdc, 0);
}
);
}
示例14: WidgetTextureRenderer
public WidgetTextureRenderer(int width, int height, IDeviceContext deviceContext)
: base(deviceContext)
{
this.width = width;
this.height = height;
Hud = Hud.FromDescription(Game.Context.Device,
new HudDescription(
cameraEnabled: false,
width: width,
height: height,
zFar: Camera.FarClip,
zNear: Camera.NearClip,
multithreaded: false
));
Camera.ChangeScreenSize(width, height);
command = new RenderToTextureCommand(width, height, Scene);
}
示例15: Query
/// <summary>
/// Query OpenGL implementation extensions.
/// </summary>
/// <param name="ctx"></param>
/// <returns></returns>
public static GraphicsCapabilities Query(GraphicsContext ctx, IDeviceContext deviceContext)
{
GraphicsCapabilities graphicsCapabilities = new GraphicsCapabilities();
FieldInfo[] capsFields = typeof(GraphicsCapabilities).GetFields(BindingFlags.Public | BindingFlags.Instance);
#region Platform Extension Reload
// Since at this point there's a current OpenGL context, it's possible to use
// {glx|wgl}GetExtensionsString to retrieve platform specific extensions
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32Windows:
case PlatformID.Win32S:
case PlatformID.WinCE:
Wgl.SyncDelegates();
break;
}
#endregion
// Only boolean fields are considered
FieldInfo[] extsFields = Array.FindAll<FieldInfo>(capsFields, delegate(FieldInfo info) {
return (info.FieldType == typeof(bool));
});
foreach (FieldInfo field in extsFields) {
Attribute[] graphicsExtensionAttributes = Attribute.GetCustomAttributes(field, typeof(GraphicsExtensionAttribute));
GraphicsExtensionDisabledAttribute graphicsExtensionDisabled = (GraphicsExtensionDisabledAttribute)Attribute.GetCustomAttribute(field, typeof(GraphicsExtensionDisabledAttribute));
bool implemented = false;
// Check whether at least one extension is implemented
implemented = Array.Exists(graphicsExtensionAttributes, delegate(Attribute item) {
return ((GraphicsExtensionAttribute)item).IsSupported(ctx, deviceContext);
});
// Check whether the required extensions are artifically disabled
if (graphicsExtensionDisabled != null)
implemented = false;
field.SetValue(graphicsCapabilities, implemented);
}
return (graphicsCapabilities);
}