本文整理汇总了C#中System.Drawing.Region.ReleaseHrgn方法的典型用法代码示例。如果您正苦于以下问题:C# Region.ReleaseHrgn方法的具体用法?C# Region.ReleaseHrgn怎么用?C# Region.ReleaseHrgn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Region
的用法示例。
在下文中一共展示了Region.ReleaseHrgn方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScrollableRegion
private NativeMethods.RECT[] CreateScrollableRegion(Rectangle scroll)
{
if (this.cachedScrollableRegion != null)
{
return this.cachedScrollableRegion;
}
using (Region region = new Region(scroll))
{
IntPtr handle = IntPtr.Zero;
using (Graphics graphics = CreateGraphicsInternal())
{
handle = region.GetHrgn(graphics);
}
if (handle != IntPtr.Zero)
{
this.cachedScrollableRegion = UnsafeNativeMethods.GetRectsFromRegion(handle);
// SECREVIEW : This assert is safe since we created the native region.
//
IntSecurity.ObjectFromWin32Handle.Assert();
try
{
region.ReleaseHrgn(handle);
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
}
return this.cachedScrollableRegion;
}
示例2: ReleaseHrng_Zero
public void ReleaseHrng_Zero ()
{
Region r = new Region (new GraphicsPath ());
r.ReleaseHrgn (IntPtr.Zero);
}
示例3: ReleaseHrng
public void ReleaseHrng ()
{
Region r = new Region (new GraphicsPath ());
IntPtr ptr = r.GetHrgn (graphic);
Assert.IsFalse (IntPtr.Zero == ptr, "ptr");
r.ReleaseHrgn (ptr);
}
示例4: GetHrgn_TwiceFromSameRegionInstance
public void GetHrgn_TwiceFromSameRegionInstance ()
{
Region r = new Region (new GraphicsPath ());
IntPtr h1 = r.GetHrgn (graphic);
IntPtr h2 = r.GetHrgn (graphic);
Assert.IsFalse (h1 == h2, "Handle_1!=Handle_2");
r.ReleaseHrgn (h1);
r.ReleaseHrgn (h2);
}
示例5: GetHrgn_FromHrgn
public void GetHrgn_FromHrgn ()
{
Region r1 = new Region (new GraphicsPath ());
IntPtr h1 = r1.GetHrgn (graphic);
Assert.IsFalse (h1 == IntPtr.Zero, "Handle_1!=0");
Region r2 = Region.FromHrgn (h1);
IntPtr h2 = r2.GetHrgn (graphic);
Assert.IsFalse (h2 == IntPtr.Zero, "Handle_2!=0");
Assert.IsFalse (h1 == h2, "Handle_1!=Handle_2");
r1.ReleaseHrgn (h1);
r2.ReleaseHrgn (h2);
}
示例6: GetHrgn_Empty_MakeInfinite
public void GetHrgn_Empty_MakeInfinite ()
{
Region r = new Region (new GraphicsPath ());
Assert.IsTrue (r.IsEmpty (graphic), "Empty");
Assert.IsFalse (r.IsInfinite (graphic), "!Infinite");
IntPtr h = r.GetHrgn (graphic);
Assert.IsFalse (h == IntPtr.Zero, "Handle!=0");
r.MakeInfinite ();
Assert.IsFalse (r.IsEmpty (graphic), "!Empty");
Assert.IsTrue (r.IsInfinite (graphic), "Infinite");
Assert.AreEqual (IntPtr.Zero, r.GetHrgn (graphic), "Handle==0");
r.ReleaseHrgn (h);
}
示例7: NcPaint
//.........这里部分代码省略.........
RECT rectScreen = new RECT();
Win32Api.GetWindowRect(_parentForm.Handle, ref rectScreen);
Rectangle rectBounds = rectScreen.ToRectangle();
rectBounds.Offset(-rectBounds.X, -rectBounds.Y);
// prepare clipping
Rectangle rectClip = rectBounds;
region = new Region(rectClip);
rectClip.Inflate(-borderSize.Width, -borderSize.Height);
rectClip.Y += captionHeight;
rectClip.Height -= captionHeight;
// create graphics handle
hdc = Win32Api.GetDCEx(_parentForm.Handle, (IntPtr)0,
(DCXFlags.DCX_CACHE | DCXFlags.DCX_CLIPSIBLINGS | DCXFlags.DCX_WINDOW));
g = Graphics.FromHdc(hdc);
// Apply clipping
region.Exclude(rectClip);
hrgn = region.GetHrgn(g);
Win32Api.SelectClipRgn(hdc, hrgn);
// create new buffered graphics if needed
if (_bufferGraphics == null || _currentCacheSize != rectBounds.Size)
{
if (_bufferGraphics != null)
_bufferGraphics.Dispose();
_bufferGraphics = _bufferContext.Allocate(g, new Rectangle(0, 0,
rectBounds.Width, rectBounds.Height));
_currentCacheSize = rectBounds.Size;
invalidateBuffer = true;
}
if (invalidateBuffer)
{
// Create painting meta data for form
SkinningFormPaintData paintData = new SkinningFormPaintData(_bufferGraphics.Graphics, rectBounds)
{
Borders = borderSize,
CaptionHeight = captionHeight,
Active = _formIsActive,
HasMenu = FormExtenders.HasMenu(_parentForm),
IconSize = SystemInformation.SmallIconSize,
IsSmallCaption =
captionHeight ==
SystemInformation.ToolWindowCaptionHeight,
Text = _parentForm.Text
};
// create painting meta data for caption buttons
if (_captionButtons.Count > 0)
{
paintData.CaptionButtons = new CaptionButtonPaintData[_captionButtons.Count];
for (int i = 0; i < _captionButtons.Count; i++)
{
CaptionButton button = _captionButtons[i];
CaptionButtonPaintData buttonData = new CaptionButtonPaintData(_bufferGraphics.Graphics, button.Bounds)
{
Pressed = button.Pressed,
Hovered = button.Hovered,
Enabled = button.Enabled,
HitTest = button.HitTest
};
paintData.CaptionButtons[i] = buttonData;
}
}
// paint
result = _manager.CurrentSkin.OnNcPaint(_parentForm, paintData);
}
// render buffered graphics
if (_bufferGraphics != null)
_bufferGraphics.Render(g);
}
catch (Exception)
{// error drawing
result = false;
}
// cleanup data
if (hdc != (IntPtr)0)
{
Win32Api.SelectClipRgn(hdc, (IntPtr)0);
Win32Api.ReleaseDC(_parentForm.Handle, hdc);
}
if (region != null && hrgn != (IntPtr)0)
region.ReleaseHrgn(hrgn);
if (region != null)
region.Dispose();
if (g != null)
g.Dispose();
return result;
}
示例8: GetHrgn_Infinite_MakeEmpty
public void GetHrgn_Infinite_MakeEmpty ()
{
Region r = new Region ();
Assert.IsFalse (r.IsEmpty (graphic), "!Empty");
Assert.IsTrue (r.IsInfinite (graphic), "Infinite");
Assert.AreEqual (IntPtr.Zero, r.GetHrgn (graphic), "Handle==0");
r.MakeEmpty ();
Assert.IsTrue (r.IsEmpty (graphic), "Empty");
Assert.IsFalse (r.IsInfinite (graphic), "!Infinite");
IntPtr h = r.GetHrgn (graphic);
Assert.IsFalse (h == IntPtr.Zero, "Handle!=0");
#if NET_2_0
r.ReleaseHrgn (h);
#endif
}
示例9: CreateScrollableRegion
private System.Windows.Forms.NativeMethods.RECT[] CreateScrollableRegion(Rectangle scroll)
{
if (this.cachedScrollableRegion == null)
{
bool rightToLeft = this.isRightToLeft();
using (Region region = new Region(scroll))
{
int numVisibleRows = this.numVisibleRows;
int y = this.layout.Data.Y;
int x = this.layout.Data.X;
DataGridRow[] dataGridRows = this.DataGridRows;
for (int i = this.firstVisibleRow; i < numVisibleRows; i++)
{
int height = dataGridRows[i].Height;
Rectangle nonScrollableArea = dataGridRows[i].GetNonScrollableArea();
nonScrollableArea.X += x;
nonScrollableArea.X = this.MirrorRectangle(nonScrollableArea, this.layout.Data, rightToLeft);
if (!nonScrollableArea.IsEmpty)
{
region.Exclude(new Rectangle(nonScrollableArea.X, nonScrollableArea.Y + y, nonScrollableArea.Width, nonScrollableArea.Height));
}
y += height;
}
using (Graphics graphics = base.CreateGraphicsInternal())
{
IntPtr hrgn = region.GetHrgn(graphics);
if (hrgn != IntPtr.Zero)
{
this.cachedScrollableRegion = System.Windows.Forms.UnsafeNativeMethods.GetRectsFromRegion(hrgn);
System.Windows.Forms.IntSecurity.ObjectFromWin32Handle.Assert();
try
{
region.ReleaseHrgn(hrgn);
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
}
}
}
return this.cachedScrollableRegion;
}
示例10: CreateScrollableRegion
private System.Windows.Forms.NativeMethods.RECT[] CreateScrollableRegion(Rectangle scroll)
{
if (this.cachedScrollableRegion == null)
{
using (Region region = new Region(scroll))
{
IntPtr zero = IntPtr.Zero;
using (Graphics graphics = base.CreateGraphicsInternal())
{
zero = region.GetHrgn(graphics);
}
if (zero != IntPtr.Zero)
{
this.cachedScrollableRegion = System.Windows.Forms.UnsafeNativeMethods.GetRectsFromRegion(zero);
System.Windows.Forms.IntSecurity.ObjectFromWin32Handle.Assert();
try
{
region.ReleaseHrgn(zero);
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
}
}
return this.cachedScrollableRegion;
}