本文整理汇总了C#中System.Drawing.Region.MakeInfinite方法的典型用法代码示例。如果您正苦于以下问题:C# Region.MakeInfinite方法的具体用法?C# Region.MakeInfinite怎么用?C# Region.MakeInfinite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Region
的用法示例。
在下文中一共展示了Region.MakeInfinite方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmptyRegionWithInfiniteRegion
public void EmptyRegionWithInfiniteRegion ()
{
Region empty = new Region ();
empty.MakeEmpty ();
Assert.IsTrue (empty.IsEmpty (graphic), "IsEmpty");
Region region = new Region ();
Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
region.Union (empty);
Assert.IsTrue (region.IsInfinite (graphic), "Union-IsInfinite");
region.Xor (empty);
Assert.IsTrue (region.IsInfinite (graphic), "Xor-IsInfinite");
region.Exclude (empty);
Assert.IsTrue (region.IsInfinite (graphic), "Exclude-IsInfinite");
region.Intersect (empty);
Assert.IsTrue (region.IsEmpty (graphic), "Intersect-IsEmpty");
region.MakeInfinite ();
region.Complement (empty);
Assert.IsTrue (region.IsEmpty (graphic), "Complement-IsEmpty");
}
示例2: cropHandWindow
private void cropHandWindow()
{
Graphics g = Graphics.FromImage(this.bitmap);
Point point2D = convertPoint3D(lastPoint);
int length = this.bitmap.Height / 2;
int x = point2D.X - length / 2;
int y = point2D.Y - length / 2;
Rectangle rect = new Rectangle(x, y, length, length);
Region region = new Region();
region.MakeInfinite();
region.Exclude(rect);
g.FillRegion(Brushes.Black, region);
g.Dispose();
}
示例3: EmptyPathWithInfiniteRegion
public void EmptyPathWithInfiniteRegion ()
{
GraphicsPath gp = new GraphicsPath ();
Region region = new Region ();
Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
region.Union (gp);
Assert.IsTrue (region.IsInfinite (graphic), "Union-IsInfinite");
region.Xor (gp);
Assert.IsTrue (region.IsInfinite (graphic), "Xor-IsInfinite");
region.Exclude (gp);
Assert.IsTrue (region.IsInfinite (graphic), "Exclude-IsInfinite");
region.Intersect (gp);
Assert.IsTrue (region.IsEmpty (graphic), "Intersect-IsEmpty");
region.MakeInfinite ();
region.Complement (gp);
Assert.IsTrue (region.IsEmpty (graphic), "Complement-IsEmpty");
}
示例4: VisitRadialGradientBrush
public override void VisitRadialGradientBrush( Types.Rectangle bounds, Paint.Brushes.RadialGradientBrush radialGradientBrush )
{
double dx = radialGradientBrush.InnerPoint.X - radialGradientBrush.OuterPoint.X;
double dy = radialGradientBrush.InnerPoint.Y - radialGradientBrush.OuterPoint.Y;
float radius = (float) Math.Sqrt( dx * dx + dy * dy );
if( radius == 0 )
{
return;
}
using( GraphicsPath gp = new GraphicsPath() )
{
gp.StartFigure();
gp.AddEllipse( (float) radialGradientBrush.InnerPoint.X - radius, (float) radialGradientBrush.InnerPoint.Y - radius, radius * 2, radius * 2 );
Region around = new Region();
around.MakeInfinite();
around.Xor( gp );
SolidBrush b = new SolidBrush( GdiPlusUtility.Convert.Color( radialGradientBrush.OuterColor ) );
_brushes.Add( new ClippedStandardBrushStage( _graphics, b, around ) );
PathGradientBrush radialBrush = new PathGradientBrush( gp );
radialBrush.CenterColor = GdiPlusUtility.Convert.Color( radialGradientBrush.InnerColor );
radialBrush.CenterPoint = GdiPlusUtility.Convert.Point( radialGradientBrush.InnerPoint );
radialBrush.SurroundColors = new Color[] { GdiPlusUtility.Convert.Color( radialGradientBrush.OuterColor ) };
radialBrush.WrapMode = WrapMode.Clamp;
_brushes.Add( new StandardBrushStage( radialBrush ) );
}
}
示例5: EnsureRegion
private void EnsureRegion()
{
if (invalidRegion == null)
{
invalidRegion = new Region();
invalidRegion.MakeInfinite();
}
}
示例6: DrawGradient
//.........这里部分代码省略.........
}
}
else if (this._CustomGradient != null &&
this._CustomGradient.Length == 2)
{
using (var lgb =
new LinearGradientBrush(
this.ClientRectangle,
this._CustomGradient[1],
this._CustomGradient[0],
gradientAngle,
false))
{
g.FillRectangle(lgb, gradientRect);
}
}
else
{
using (var lgb =
new LinearGradientBrush(
this.ClientRectangle,
this._MaxColor,
this._MinColor,
gradientAngle,
false))
{
g.FillRectangle(lgb, gradientRect);
}
}
// fill background
using (var nonGradientRegion = new Region())
{
nonGradientRegion.MakeInfinite();
nonGradientRegion.Exclude(gradientRect);
using (var sb = new SolidBrush(this.BackColor))
{
//g.FillRegion(sb, nonGradientRegion.GetRegionReadOnly());
g.FillRegion(sb, nonGradientRegion);
}
}
// draw value triangles
for (int i = 0; i < this._Values.Length; i++)
{
int pos = ValueToPosition(this._Values[i]);
Brush brush;
Pen pen;
if (i == this._Highlight)
{
brush = Brushes.Blue;
pen = (Pen)Pens.White.Clone();
}
else
{
brush = Brushes.Black;
pen = (Pen)Pens.Gray.Clone();
}
g.SmoothingMode = SmoothingMode.AntiAlias;
Point a1;
Point b1;
Point c1;
示例7: SetWindowRegion
protected void SetWindowRegion(Size winSize)
{
// Style specific handling
if (_style == VisualStyle.IDE)
{
int shadowHeight = _position[(int)_style, (int)PI.ShadowHeight];
int shadowWidth = _position[(int)_style, (int)PI.ShadowWidth];
// Create a new region object
using (Region drawRegion = new Region())
{
// Can draw anywhere
drawRegion.MakeInfinite();
// Remove the area above the right hand shadow
drawRegion.Xor(new Rectangle(winSize.Width - shadowWidth, 0, shadowWidth, shadowHeight));
// When drawing upwards from a vertical menu we need to allow a connection between the
// MenuControl selection box and the PopupMenu shadow
if (!((_direction == Direction.Vertical) && !_excludeTop))
{
// Remove the area left of the bottom shadow
drawRegion.Xor(new Rectangle(0, winSize.Height - shadowHeight, shadowWidth, shadowHeight));
}
// Define a region to prevent drawing over exposed corners of shadows
using(Graphics g = Graphics.FromHwnd(this.Handle))
WindowsAPI.SetWindowRgn(this.Handle, drawRegion.GetHrgn(g), false);
}
}
}
示例8: ExcludeBug402613
public void ExcludeBug402613 ()
{
Region r = new Region();
r.MakeInfinite ();
r.Exclude (new Rectangle (387,292,189,133));
r.Exclude (new Rectangle (387,66,189,133));
Assert.IsTrue (r.IsVisible (new Rectangle (66,292,189,133)));
}
示例9: 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);
}
示例10: Complement_383878
public void Complement_383878 ()
{
using (Region clipRegion = new Region ()) {
clipRegion.MakeInfinite ();
Rectangle smaller = new Rectangle (5, 5, -10, -10);
Rectangle bigger = new Rectangle (-5, -5, 12, 12);
clipRegion.Intersect (smaller);
clipRegion.Complement (bigger);
Assert.IsFalse (clipRegion.IsEmpty (graphic), "IsEmpty");
Assert.IsFalse (clipRegion.IsInfinite (graphic), "IsInfinite");
RectangleF [] rects = clipRegion.GetRegionScans (new Matrix ());
Assert.AreEqual (2, rects.Length, "Length");
Assert.AreEqual (new RectangleF (5, -5, 2, 10), rects [0], "0");
Assert.AreEqual (new RectangleF (-5, 5, 12, 2), rects [1], "1");
}
}
示例11: TestInfiniteAndEmpty
public void TestInfiniteAndEmpty()
{
Bitmap bmp = new Bitmap (600, 800);
Graphics dc = Graphics.FromImage (bmp);
Rectangle rect1, rect2;
Region rgn1;
RectangleF [] rects;
Matrix matrix = new Matrix ();
rect1 = new Rectangle (500, 30, 60, 80);
rect2 = new Rectangle (520, 40, 60, 80);
rgn1 = new Region (rect1);
rgn1.Union (rect2);
Assert.AreEqual (false, rgn1.IsEmpty (dc));
Assert.AreEqual (false, rgn1.IsInfinite (dc));
rgn1.MakeEmpty();
Assert.AreEqual (true, rgn1.IsEmpty (dc));
rgn1 = new Region (rect1);
rgn1.Union (rect2);
rgn1.MakeInfinite ();
rects = rgn1.GetRegionScans (matrix);
Assert.AreEqual (1, rects.Length);
Assert.AreEqual (-4194304, rects[0].X);
Assert.AreEqual (-4194304, rects[0].Y);
Assert.AreEqual (8388608, rects[0].Width);
Assert.AreEqual (8388608, rects[0].Height);
Assert.AreEqual (true, rgn1.IsInfinite (dc));
}
示例12: TilesetView_PaintTiles
private void TilesetView_PaintTiles(object sender, TilesetViewPaintTilesEventArgs e)
{
Color highlightColor = Color.FromArgb(255, 255, 255);
Color baseTileDrawColor = Color.FromArgb(255, 192, 128);
Color externalDrawColor = Color.FromArgb(128, 192, 255);
Color nonConnectedColor = Color.FromArgb(128, 0, 0, 0);
Brush brushNonConnected = new SolidBrush(nonConnectedColor);
TilesetAutoTileInput autoTile = this.SelectedAutoTile;
// Early-out if there is nothing we can edit right now
if (autoTile == null)
return;
// If we're in a special draw mode, switch highlight colors to indicate this.
if (this.isExternalDraw)
highlightColor = externalDrawColor;
else if (this.isBaseTileDraw)
highlightColor = baseTileDrawColor;
// Set up shared working data
TilesetAutoTileItem[] tileInput = autoTile.TileInput.Data;
TilesetViewPaintTileData hoveredData = default(TilesetViewPaintTileData);
TilesetAutoTileItem hoveredItem = default(TilesetAutoTileItem);
GraphicsPath connectedOutlines = new GraphicsPath();
GraphicsPath connectedRegion = new GraphicsPath();
// Draw all the tiles that we're supposed to paint
for (int i = 0; i < e.PaintedTiles.Count; i++)
{
TilesetViewPaintTileData paintData = e.PaintedTiles[i];
// Prepare some data we'll need for drawing the per-tile info overlay
bool tileHovered = this.TilesetView.HoveredTileIndex == paintData.TileIndex;
bool isBaseTile = autoTile.BaseTileIndex == paintData.TileIndex;
TilesetAutoTileItem item = (autoTile.TileInput.Count > paintData.TileIndex) ?
tileInput[paintData.TileIndex] :
default(TilesetAutoTileItem);
// Remember hovered item data for later (post-overlay)
if (tileHovered)
{
hoveredData = paintData;
hoveredItem = item;
}
// Accumulate a shared region for displaying connectivity, as well as a path of all their outlines
if (item.IsAutoTile)
{
Rectangle centerRect = GetConnectivityRegionRect(TileConnection.None, paintData.ViewRect);
connectedRegion.AddRectangle(centerRect);
DrawConnectivityRegion(connectedRegion, item.Neighbours, paintData.ViewRect);
DrawConnectivityOutlines(connectedOutlines, item.Neighbours, paintData.ViewRect);
}
else if (item.ConnectsToAutoTile)
{
connectedRegion.AddRectangle(paintData.ViewRect);
}
// Highlight base tile and external connecting tiles
if (isBaseTile)
DrawTileHighlight(e.Graphics, paintData.ViewRect, baseTileDrawColor);
else if (!item.IsAutoTile && item.ConnectsToAutoTile)
DrawTileHighlight(e.Graphics, paintData.ViewRect, externalDrawColor);
}
// Fill all non-connected regions with the overlay brush
Region surroundingRegion = new Region();
surroundingRegion.MakeInfinite();
surroundingRegion.Exclude(connectedRegion);
e.Graphics.IntersectClip(surroundingRegion);
e.Graphics.FillRectangle(brushNonConnected, this.TilesetView.ClientRectangle);
e.Graphics.ResetClip();
// Draw connected region outlines
e.Graphics.DrawPath(Pens.White, connectedOutlines);
// Draw a tile-based hover indicator
if (!hoveredData.ViewRect.IsEmpty && !this.isBaseTileDraw && !this.isExternalDraw)
DrawHoverIndicator(e.Graphics, hoveredData.ViewRect, 64, highlightColor);
// Draw a hover indicator for a specific hovered region
if (!hoveredData.ViewRect.IsEmpty)
{
if (!this.isBaseTileDraw && !this.isExternalDraw)
DrawHoverIndicator(e.Graphics, GetConnectivityRegionRect(this.hoveredArea, hoveredData.ViewRect), 255, highlightColor);
else
DrawHoverIndicator(e.Graphics, hoveredData.ViewRect, 255, highlightColor);
}
}