本文整理汇总了C#中System.Drawing.Region.IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# Region.IsVisible方法的具体用法?C# Region.IsVisible怎么用?C# Region.IsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Region
的用法示例。
在下文中一共展示了Region.IsVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsPoint
/// <summary>
/// Проверяет попадание точки в фигуру
/// </summary>
/// <param name="p"></param>
/// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
public override int ContainsPoint(Point p)
{
if (this.IsSelected)
{
for (int i = 1; i <= KeyPoints.Length; i++)
{
if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
return i;
}
}
var path = new GraphicsPath();
Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
path.AddEllipse(rect);
path.Widen(pen);
Region region = new Region(path);
pen.Dispose();
if(region.IsVisible(p))
return 0;
Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
double radius = rect.Width / 2;
float dx = p.X - center.X;
float dy = p.Y - center.Y;
if (Math.Sqrt(dx * dx + dy * dy) <= radius)
return 0;
return -1;
}
示例2: GraphicsIsVisibleRectangleF
public void GraphicsIsVisibleRectangleF(Graphics g)
{
Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));
// Create the first rectangle and draw it to the screen in blue.
g.DrawRectangle(myPen, regionRect1);
g.FillRectangle (myBrush, regionRect1);
// Create the second rectangle and draw it to the screen in red.
myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);
g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect1);
// Determine if myRect is contained in the region.
bool contained = myRegion.IsVisible(regionRect2);
// Display the result.
Font myFont = new Font("Arial", 8);
SolidBrush txtBrush = new SolidBrush(Color.Black);
g.DrawString("contained = " + contained.ToString(),
myFont,
txtBrush,
new PointF(regionRectF2.Right + 10, regionRectF2.Top));
regionRect1.Y += 120;
regionRectF2.Y += 120;
regionRectF2.X += 41;
myPen.Color = Color.FromArgb (196, 0xC3, 0xC9, 0xCF);
myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);
// Create the first rectangle and draw it to the screen in blue.
g.DrawRectangle(myPen, regionRect1);
g.FillRectangle (myBrush, regionRect1);
// Create the second rectangle and draw it to the screen in red.
myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);
g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));
// Create a region using the first rectangle.
myRegion = new Region(regionRect1);
// Determine if myRect is contained in the region.
contained = myRegion.IsVisible(regionRectF2);
// Display the result.
g.DrawString("contained = " + contained.ToString(),
myFont,
txtBrush,
new PointF(regionRectF2.Right + 10, regionRectF2.Top));
}
示例3: MouseDown
public override void MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
isMouseDown = true;
if (CurrentMarker == null && isBegin) {
GMapMarker marker = createMarker(rMap1.FromLocalToLatLng(e.X, e.Y));
}
} else if (e.Button == MouseButtons.Right) {
if (isBegin) {
//统计设备
if(routes.Markers.Count<2)return;
List<PS_gt> gtlist = new List<PS_gt>();
List<sd_gt> sdlist = new List<sd_gt>();
int bl = 1000000;
using (GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath()) {
List<PointF> list = new List<PointF>();
foreach (PointLatLng pll in routes.Polygons[0].Points) {
list.Add(new PointF((float)pll.Lng * bl, (float)pll.Lat * bl));
}
gp.AddPolygon(list.ToArray());
Region r = new Region(gp);
foreach (GMapOverlay lay in this.rMap1.Overlays) {
if (!lay.IsVisibile|| !(lay is LineOverlay)) continue;
LineOverlay lo = lay as LineOverlay;
foreach (GMapMarker m in lo.Markers) {
if (r.IsVisible(new PointF((float)m.Position.Lng * bl, (float)m.Position.Lat * bl))) {
if(m.Tag is PS_gt)
gtlist.Add(m.Tag as PS_gt);
else if(m.Tag is sd_gt)
{
sdlist.Add(m.Tag as sd_gt);
}
}
}
}
}
if (gtlist.Count>sdlist.Count)
{
frmQytj dlg = new frmQytj(gtlist);
dlg.StartPosition = FormStartPosition.CenterScreen;
dlg.Show(this.rMap1);
}
else
{
frmSdtj dlg = new frmSdtj(sdlist);
dlg.StartPosition = FormStartPosition.CenterScreen;
dlg.Show(this.rMap1);
}
}
isBegin = false;
}
}
示例4: Hit
/// <summary>
/// Tests whether the mouse hits this shape
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public override bool Hit(System.Drawing.Point p)
{
GraphicsPath path = new GraphicsPath();
path.AddEllipse(Rectangle);
using (Region region = new Region(path))
{
return region.IsVisible(p);
}
}
示例5: IsOnScreen
/// <summary>
/// Returns whether the given rectangle, in screen coordinates, is visible in any screen's
/// working area (the monitor's visible area minus task bars and docked windows)</summary>
/// <param name="rect">Rectangle</param>
/// <returns>Whether the given rectangle is visible</returns>
public static bool IsOnScreen(Rectangle rect)
{
using (Region region = new Region())
{
region.MakeEmpty();
foreach (Screen screen in Screen.AllScreens)
region.Union(screen.WorkingArea);
rect.Inflate(-Margin, -Margin);
return region.IsVisible(rect);
}
}
示例6: TrespassArea
// Returns a percentage of the ErrorArea circle trespassing on the zone.
// If anyone knows calculus better than me I'd welcome you to clean up this function =)
public float TrespassArea(Point3D pntLocation, float flErrorRadius) {
float returnPercentage = 0.0F;
var errorArea = (float) (flErrorRadius * flErrorRadius * Math.PI);
var gpLocationError = new GraphicsPath();
gpLocationError.AddEllipse(new RectangleF(pntLocation.X - flErrorRadius, pntLocation.Y - flErrorRadius, flErrorRadius * 2, flErrorRadius * 2));
gpLocationError.CloseAllFigures();
var regZone = new Region(ZoneGraphicsPath);
regZone.Intersect(gpLocationError);
RectangleF[] scans = regZone.GetRegionScans(new Matrix());
var recIntersection = new Rectangle(int.MaxValue, int.MaxValue, 0, 0);
int iPixelCount = 0;
if (scans.Length > 0) {
for (int i = 0; i < scans.Length; i++) {
recIntersection.X = scans[i].X < recIntersection.X ? (int) scans[i].X : recIntersection.X;
recIntersection.Y = scans[i].Y < recIntersection.Y ? (int) scans[i].Y : recIntersection.Y;
recIntersection.Width = scans[i].Right > recIntersection.Right ? (int) scans[i].Right - recIntersection.X : recIntersection.Width;
recIntersection.Height = scans[i].Bottom > recIntersection.Bottom ? (int) scans[i].Bottom - recIntersection.Y : recIntersection.Height;
}
var pntVisible = new Point(recIntersection.X, recIntersection.Y);
for (pntVisible.X = recIntersection.X; pntVisible.X <= recIntersection.Right; pntVisible.X++) {
for (pntVisible.Y = recIntersection.Y; pntVisible.Y <= recIntersection.Bottom; pntVisible.Y++) {
if (regZone.IsVisible(pntVisible) == true) {
iPixelCount++;
}
}
}
}
returnPercentage = iPixelCount / errorArea;
// Accounts for low error when using this method. (98.4% should be 100%)
// but using regZone.GetRegionScans is slightly lossy.
if (returnPercentage > 0.0F) {
returnPercentage = (float) Math.Min(1.0F, returnPercentage + 0.02);
}
return returnPercentage;
}
示例7: DrawHorizontalComponent
private void DrawHorizontalComponent(int index, Graphics g, LiveSplitState state, float width, float height, Region clipRegion)
{
var component = VisibleComponents.ElementAt(index);
var leftPadding = Math.Min(GetPaddingToLeft(index), component.PaddingLeft) / 2f;
var rightPadding = Math.Min(GetPaddingToRight(index), component.PaddingRight) / 2f;
g.IntersectClip(new RectangleF(leftPadding, 0, component.HorizontalWidth - leftPadding - rightPadding, height));
var scale = g.Transform.Elements.First();
var separatorOffset = component.VerticalHeight * scale < 3 ? 1 : 0;
if (clipRegion.IsVisible(new RectangleF(
-separatorOffset + g.Transform.OffsetX - leftPadding * scale,
g.Transform.OffsetY,
separatorOffset * 2f + scale * (component.HorizontalWidth + rightPadding),
height)))
component.DrawHorizontal(g, state, height, clipRegion);
g.TranslateTransform(component.HorizontalWidth - rightPadding * 2f, 0.0f);
}
示例8: DrawVerticalComponent
private void DrawVerticalComponent(int index, Graphics g, LiveSplitState state, float width, float height, Region clipRegion)
{
var component = VisibleComponents.ElementAt(index);
var topPadding = Math.Min(GetPaddingAbove(index), component.PaddingTop) / 2f;
var bottomPadding = Math.Min(GetPaddingBelow(index), component.PaddingBottom) / 2f;
g.IntersectClip(new RectangleF(0, topPadding, width, component.VerticalHeight - topPadding - bottomPadding));
var scale = g.Transform.Elements.First();
var separatorOffset = component.VerticalHeight * scale < 3 ? 1 : 0;
if (clipRegion.IsVisible(new RectangleF(
g.Transform.OffsetX,
-separatorOffset + g.Transform.OffsetY - topPadding * scale,
width,
separatorOffset * 2f + scale * (component.VerticalHeight + bottomPadding))))
component.DrawVertical(g, state, width, clipRegion);
g.TranslateTransform(0.0f, component.VerticalHeight - bottomPadding * 2f);
}
示例9: ContainsPoint
/// <summary>
/// Проверяет попадание точки в фигуру
/// </summary>
/// <param name="p"></param>
/// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
public int ContainsPoint(Point p)
{
if (this.IsSelected)
{
for (int i = 1; i <= KeyPoints.Length; i++)
{
if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
return i;
}
}
var path = new GraphicsPath();
Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
path.AddCurve(points.ToArray());
path.Widen(pen);
Region region = new Region(path);
pen.Dispose();
if (region.IsVisible(p))
return 0;
return -1;
}
示例10: ContainsPoint
/// <summary>
/// Проверяет попадание точки в фигуру
/// </summary>
/// <param name="p"></param>
/// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
public int ContainsPoint(Point p)
{
if (this.IsSelected)
{
for (int i = 1; i <= KeyPoints.Length; i++)
{
if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
return i;
}
}
var path = new GraphicsPath();
Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
Rectangle rect = PaintHelper.NormalizeRect(startPoint, endPoint);
Point p1 = new Point(rect.X, rect.Y + rect.Height);
Point p2 = new Point(rect.X + rect.Width / 2, rect.Y);
Point p3 = new Point(rect.X + rect.Width, rect.Y + rect.Height);
path.AddPolygon(new Point[] { p1, p2, p3 });
path.Widen(pen);
Region region = new Region(path);
pen.Dispose();
if (region.IsVisible(p))
return 0;
if (IsPointInTriangle(p, p1, p2, p3))
return 0;
return -1;
}
示例11: TestIsVisible
public void TestIsVisible()
{
Bitmap bmp = new Bitmap (600, 800);
Graphics dc = Graphics.FromImage (bmp);
Rectangle rect1, rect2;
Region rgn1, rgn2;
Matrix matrix = new Matrix ();
rect1 = new Rectangle (500, 30, 60, 80);
rect2 = new Rectangle (520, 40, 60, 80);
rgn1 = new Region (new RectangleF (0, 0, 10,10));
Assert.AreEqual (false, rgn1.IsVisible (0,0,0,1));
rgn1 = new Region (rect1);
Assert.AreEqual (false, rgn1.IsVisible (500,29));
Assert.AreEqual (true, rgn1.IsVisible (500,30));
Assert.AreEqual (true, rgn1.IsVisible (rect1));
Assert.AreEqual (true, rgn1.IsVisible (rect2));
Assert.AreEqual (false, rgn1.IsVisible (new Rectangle (50,50,2,5)));
Rectangle r = new Rectangle (1,1, 2,1);
rgn2 = new Region (r);
Assert.AreEqual (true, rgn2.IsVisible (r));
Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 2,2)));
Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 10,10)));
Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 1,1)));
Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (2,2, 1,1)));
Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (0,0, 1,1)));
Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (3,3, 1,1)));
Assert.AreEqual (false, rgn2.IsVisible (0,0));
Assert.AreEqual (false, rgn2.IsVisible (1,0));
Assert.AreEqual (false, rgn2.IsVisible (2,0));
Assert.AreEqual (false, rgn2.IsVisible (3,0));
Assert.AreEqual (false, rgn2.IsVisible (0,1));
Assert.AreEqual (true, rgn2.IsVisible (1,1));
Assert.AreEqual (true, rgn2.IsVisible (2,1));
Assert.AreEqual (false, rgn2.IsVisible (3,1));
Assert.AreEqual (false, rgn2.IsVisible (0,2));
Assert.AreEqual (false, rgn2.IsVisible (1,2));
Assert.AreEqual (false, rgn2.IsVisible (2,2));
Assert.AreEqual (false, rgn2.IsVisible (3,2));
}
示例12: DoubleClick
internal void DoubleClick(Point mouseLocation, MouseButtons button)
{
Region monthRgn = new Region(m_rect);
if (monthRgn.IsVisible(mouseLocation))
{
for (int i = 0;i<42;i++)
{
if (m_days[i].HitTest(mouseLocation))
{
if (this.DayDoubleClick!=null)
this.DayDoubleClick(this,new DayClickEventArgs(m_days[i].Date.ToShortDateString() ,button,
mouseLocation.X - m_days[i].Rectangle.Left, mouseLocation.Y - m_days[i].Rectangle.Top,
mouseLocation.X,mouseLocation.Y,m_days[i].Rectangle));
}
}
}
}
示例13: DisplaySmallRegion
private void DisplaySmallRegion (Region region, int ox, int oy, int width, int height)
{
for (int y = oy ; y < height - 1; y++) {
for (int x = ox; x < width - 1; x++) {
if (region.IsVisible (x, y))
Console.Write ("X");
else
Console.Write (".");
}
Console.WriteLine ();
}
}
示例14: verificarSeEstaEmAreaProibida
internal bool verificarSeEstaEmAreaProibida(Region regiao)
{
if (mListaBlobsENumeroFrame.Count > 0 && regiao != null)
{
int ultimoBlob = mListaBlobsENumeroFrame.Count-1;
Point ponto = new Point(Convert.ToInt32(mListaBlobsENumeroFrame[ultimoBlob].mBlob.Center.X),
Convert.ToInt32(mListaBlobsENumeroFrame[ultimoBlob].mBlob.Center.Y));
return regiao.IsVisible(ponto);
}
return false;
}
示例15: CurveIntersects
private bool CurveIntersects(RectangleF rectangle)
{
//Translate rectangle to local co-ordinates
rectangle.Location = new PointF(rectangle.Location.X - Rectangle.Location.X,rectangle.Location.Y - Rectangle.Location.Y);
//If the rectangle contains the whole line rectangle then return true
if (rectangle.Contains(Rectangle)) return true;
Region region = new Region(GetPathInternal());
return region.IsVisible(rectangle);
}