本文整理匯總了C#中System.Drawing.Region.Complement方法的典型用法代碼示例。如果您正苦於以下問題:C# Region.Complement方法的具體用法?C# Region.Complement怎麽用?C# Region.Complement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Region
的用法示例。
在下文中一共展示了Region.Complement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
var iRegion = new Region(e.ClipRectangle);
e.Graphics.FillRegion(new SolidBrush(BackColor), iRegion);
if (Items.Count > 0)
{
for (int i = 0; i < Items.Count; ++i)
{
Rectangle irect = GetItemRectangle(i);
if (e.ClipRectangle.IntersectsWith(irect))
{
if ((SelectionMode == SelectionMode.One && SelectedIndex == i)
|| (SelectionMode == SelectionMode.MultiSimple && SelectedIndices.Contains(i))
|| (SelectionMode == SelectionMode.MultiExtended && SelectedIndices.Contains(i)))
{
OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
irect, i,
DrawItemState.Selected, ForeColor,
BackColor));
}
else
{
OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
irect, i,
DrawItemState.Default, ForeColor,
BackColor));
}
iRegion.Complement(irect);
}
}
}
base.OnPaint(e);
}
示例2: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Region iRegion = new Region(e.ClipRectangle);
e.Graphics.FillRegion(new SolidBrush(this.BackColor), iRegion);
if (this.Items.Count > 0)
{
Debug.WriteLine("Hello");
for (int i = 0; i < this.Items.Count; ++i)
{
System.Drawing.Rectangle irect = this.GetItemRectangle(i);
if (e.ClipRectangle.IntersectsWith(irect))
{
if ((this.SelectionMode == SelectionMode.One && this.SelectedIndex == i)
|| (this.SelectionMode == SelectionMode.MultiSimple && this.SelectedIndices.Contains(i))
|| (this.SelectionMode == SelectionMode.MultiExtended && this.SelectedIndices.Contains(i)))
{
OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font,
irect, i, DrawItemState.Selected, this.ForeColor,
this.BackColor));
}
else
{
OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font,
irect, i, DrawItemState.Default, this.ForeColor,
this.BackColor));
}
iRegion.Complement(irect);
}
}
}
base.OnPaint(e);
}
示例3: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Region region = new Region(e.ClipRectangle);
e.Graphics.FillRegion(this.backBrush, region);
if (base.Items.Count > 0)
{
for (int i = 0; i < base.Items.Count; i++)
{
Rectangle itemRectangle = base.GetItemRectangle(i);
if (e.ClipRectangle.IntersectsWith(itemRectangle))
{
if ((this.SelectionMode == SelectionMode.One && this.SelectedIndex == i) || (this.SelectionMode == SelectionMode.MultiSimple && base.SelectedIndices.Contains(i)) || (this.SelectionMode == SelectionMode.MultiExtended && base.SelectedIndices.Contains(i)))
{
this.OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font, itemRectangle, i, DrawItemState.Selected, this.ForeColor, this.BackColor));
}
else
{
this.OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font, itemRectangle, i, DrawItemState.Default, this.ForeColor, this.BackColor));
}
region.Complement(itemRectangle);
}
}
}
base.OnPaint(e);
}
示例4: DrawRegionOperation
void DrawRegionOperation()
{
g = this.CreateGraphics();
Rectangle rect1 = new Rectangle(100, 100, 120, 120);
Rectangle rect2 = new Rectangle(70, 70, 120, 120);
Region rgn1 = new Region(rect1);
Region rgn2 = new Region(rect2);
g.DrawRectangle(Pens.Blue, rect1);
g.DrawRectangle(Pens.Red, rect2);
switch(rgnOperation)
{
case RegionOperation.Union:
rgn1.Union(rgn2);
break;
case RegionOperation.Complement:
rgn1.Complement(rgn2);
break;
case RegionOperation.Intersect:
rgn1.Intersect(rgn2);
break;
case RegionOperation.Exclude:
rgn1.Exclude(rgn2);
break;
case RegionOperation.Xor:
rgn1.Xor(rgn2);
break;
default:
break;
}
g.FillRegion(Brushes.Tomato, rgn1);
g.Dispose();
}
示例5: DrawRegionOperations
private void DrawRegionOperations()
{
g = this.CreateGraphics();
// Создаем два прямоугольника
Rectangle rect1 = new Rectangle(100, 100, 120, 120);
Rectangle rect2 = new Rectangle(70, 70, 120, 120);
// Создаем два региона
Region rgn1 = new Region(rect1);
Region rgn2 = new Region(rect2);
// рисуем прямоугольники
g.DrawRectangle(Pens.Green, rect1);
g.DrawRectangle(Pens.Black, rect2);
// обработаем перечисление и вызовем соответствующий метод
switch (rgnOperation)
{
case RegionOperations.Union:
rgn1.Union(rgn2);
break;
case RegionOperations.Complement:
rgn1.Complement(rgn2);
break;
case RegionOperations.Intersect:
rgn1.Intersect(rgn2);
break;
case RegionOperations.Exclude:
rgn1.Exclude(rgn2);
break;
case RegionOperations.Xor:
rgn1.Xor(rgn2);
break;
default:
break;
}
// Рисуем регион
g.FillRegion(Brushes.Blue, rgn1);
g.Dispose();
}
示例6: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Region region = new Region(e.ClipRectangle);
Graphics g = e.Graphics;
g.FillRegion(new SolidBrush(this.BackColor), region);
for (int i = 0; i < this.Items.Count; i++)
{
Rectangle rect = GetItemRectangle(i);
if (e.ClipRectangle.IntersectsWith(rect))
{
bool selected = (this.SelectionMode == SelectionMode.One && this.SelectedIndex == i)
|| (this.SelectionMode == SelectionMode.MultiSimple && this.SelectedIndices.Contains(i))
|| (this.SelectionMode == SelectionMode.MultiExtended && this.SelectedIndices.Contains(i));
OnDrawItem(new DrawItemEventArgs(
g, Font, rect, i,
selected ? DrawItemState.Selected : DrawItemState.Default,
ForeColor, BackColor));
}
region.Complement(rect);
}
base.OnPaint(e);
}
示例7: SmallComplement2
public void SmallComplement2 ()
{
Region region = new Region (sp2);
region.Complement (sp1);
CompareSmallRegion (region, sexclude1, 7, 7);
RectangleF[] scans = region.GetRegionScans (matrix);
Assert.AreEqual (2, scans.Length, "GetRegionScans");
CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
}
示例8: OnPaint
/// <summary>
/// Handle the paint event and work out if item needs redrawing
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
using (var brush = new SolidBrush(this.BackColor))
{
Region region = new Region(e.ClipRectangle);
e.Graphics.FillRegion(brush, region);
if (this.Items.Count > 0)
{
for (int i = 0; i < this.Items.Count; ++i)
{
Rectangle irect = this.GetItemRectangle(i);
if (e.ClipRectangle.IntersectsWith(irect))
{
if ((this.SelectionMode == SelectionMode.One && this.SelectedIndex == i)
|| (this.SelectionMode == SelectionMode.MultiSimple && this.SelectedIndices.Contains(i))
|| (this.SelectionMode == SelectionMode.MultiExtended && this.SelectedIndices.Contains(i)))
{
DrawItemEventArgs diea = new DrawItemEventArgs(e.Graphics, this.Font,
irect, i,
DrawItemState.Selected, this.ForeColor,
this.BackColor);
OnDrawItem(diea, e.ClipRectangle);
base.OnDrawItem(diea);
}
else
{
DrawItemEventArgs diea = new DrawItemEventArgs(e.Graphics, this.Font,
irect, i,
DrawItemState.Default, this.ForeColor,
this.BackColor);
OnDrawItem(diea, e.ClipRectangle);
base.OnDrawItem(diea);
}
region.Complement(irect);
}
}
}
}
base.OnPaint(e);
}
示例9: 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");
}
示例10: TestComplementGroup2
public void TestComplementGroup2 ()
{
Bitmap bmp = new Bitmap (600, 800);
Graphics dc = Graphics.FromImage (bmp);
Matrix matrix = new Matrix ();
Rectangle rect1, rect2;
Region rgn1, rgn2;
RectangleF [] rects;
rect1 = new Rectangle (20, 30, 60, 80);
rect2 = new Rectangle (50, 40, 60, 80);
rgn1 = new Region (rect1);
rgn2 = new Region (rect2);
dc.DrawRectangle (Pens.Green, rect1);
dc.DrawRectangle (Pens.Red, rect2);
rgn1.Complement (rgn2);
dc.FillRegion (Brushes.Blue, rgn1);
dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
rects = rgn1.GetRegionScans (matrix);
Assert.AreEqual (2, rects.Length);
Assert.AreEqual (80, rects[0].X);
Assert.AreEqual (40, rects[0].Y);
Assert.AreEqual (30, rects[0].Width);
Assert.AreEqual (70, rects[0].Height);
Assert.AreEqual (50, rects[1].X);
Assert.AreEqual (110, rects[1].Y);
Assert.AreEqual (60, rects[1].Width);
Assert.AreEqual (10, rects[1].Height);
}
示例11: TestComplementGroup1
public void TestComplementGroup1 ()
{
RectangleF[] rects;
Region r1 = new Region ();
Region r2 = new Region ();
Rectangle rect1 = Rectangle.Empty;
Rectangle rect2 = Rectangle.Empty;
Rectangle rect3 = Rectangle.Empty;
Rectangle rect4 = Rectangle.Empty;
Rectangle rect5 = Rectangle.Empty;
Rectangle rect6 = Rectangle.Empty;
Rectangle rect7 = Rectangle.Empty;
{ // TEST1
rect1 = new Rectangle (20, 20, 20, 20);
rect2 = new Rectangle (20, 80, 20, 10);
rect3 = new Rectangle (60, 60, 30, 10);
r1 = new Region (rect1);
r2 = new Region (rect2);
r2.Union (rect3);
r1.Complement (r2);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (2, rects.Length, "TCG1Test1");
AssertEqualRectangles (new RectangleF (60, 60, 30, 10), rects[0], "TCG1Test2");
AssertEqualRectangles (new RectangleF (20, 80, 20, 10), rects[1], "TCG1Test3");
}
{ // TEST2
rect1 = new Rectangle (10, 10, 100, 100);
rect2 = new Rectangle (40, 60, 100, 20);
r1 = new Region (rect1);
r1.Complement (rect2);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (1, rects.Length, "TCG2Test1");
AssertEqualRectangles (new RectangleF (110, 60, 30, 20), rects[0], "TCG2Test2");
}
{ // TEST3
rect1 = new Rectangle (70, 10, 100, 100);
rect2 = new Rectangle (40, 60, 100, 20);
r1 = new Region (rect1);
r1.Complement (rect2);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (1, rects.Length, "TCG3Test1");
AssertEqualRectangles (new RectangleF (40, 60, 30, 20), rects[0], "TCG3Test2");
}
{ // TEST4
rect1 = new Rectangle (40, 100, 100, 100);
rect2 = new Rectangle (70, 80, 50, 40);
r1 = new Region (rect1);
r1.Complement (rect2);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (1, rects.Length, "TCG4Test1");
AssertEqualRectangles (new RectangleF (70, 80, 50, 20), rects[0], "TCG4Test2");
}
{ // TEST5
rect1 = new Rectangle (40, 10, 100, 100);
rect2 = new Rectangle (70, 80, 50, 40);
r1 = new Region (rect1);
r1.Complement (rect2);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (1, rects.Length, "TCG5Test1");
AssertEqualRectangles (new RectangleF (70, 110, 50, 10), rects[0], "TCG5Test2");
}
{ // TEST6: Multiple regions
rect1 = new Rectangle (30, 30, 80, 80);
rect2 = new Rectangle (45, 45, 200, 200);
rect3 = new Rectangle (160, 260, 10, 10);
rect4 = new Rectangle (170, 260, 10, 10);
r1 = new Region (rect1);
r1.Complement (rect2);
r1.Complement (rect3);
r1.Complement (rect4);
rects = r1.GetRegionScans (new Matrix ());
Assert.AreEqual (1, rects.Length, "TCG6Test1");
AssertEqualRectangles (new RectangleF (170, 260, 10, 10), rects[0], "TCG6Test2");
}
//.........這裏部分代碼省略.........
示例12: 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");
}
}
示例13: MultiCombinedPathRegion
public void MultiCombinedPathRegion ()
{
// note: seems identical to PathRegion but it test another code path inside libgdiplus
Region r1 = new Region (sp1);
r1.Xor (sp2);
Region r2 = new Region (sp2);
r2.Complement (sp1);
Region r = r1.Clone ();
r.Union (r2);
RegionData data = r.GetRegionData ();
Assert.IsNotNull (data.Data, "Data");
Region region = new Region (data);
Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
}
示例14: GetHRegion
private IntPtr GetHRegion()
{
//Define a Clip Region to pass back to WM_NCPAINTs wParam.
//Must be in Screen Coordinates.
IntPtr hRgn;
Rectangle winRect = this.Parent.RectangleToScreen(this.Bounds);
Rectangle clientRect =
this.RectangleToScreen(this.ClientRectangle);
Region updateRegion = new Region(winRect);
updateRegion.Complement(clientRect);
using (Graphics g = this.CreateGraphics())
hRgn = updateRegion.GetHrgn(g);
updateRegion.Dispose();
return hRgn;
}
示例15: CombineClippingRegion
/// <summary>
/// Combines the local clippingRegion with the given region.
/// </summary>
/// <param name="combineMode">The combine mode to use.</param>
/// <param name="region">The region to combine with the clippingRegion.</param>
private void CombineClippingRegion(CombineMode combineMode, Region region)
{
switch(combineMode)
{
case CombineMode.Replace:
clippingRegion = region;
break;
case CombineMode.Intersect:
clippingRegion.Intersect(region);
break;
case CombineMode.Union:
clippingRegion.Union(region);
break;
case CombineMode.Xor:
clippingRegion.Xor(region);
break;
case CombineMode.Exclude:
clippingRegion.Exclude(region);
break;
case CombineMode.Complement:
clippingRegion.Complement(region);
break;
default:
throw new ArgumentOutOfRangeException("combineMode");
}
}