private Point GetClickedRectanglePos(int mouseX, int mouseY) { int dx = mouseX - LeftPos; int dy = mouseY - TopPos; int indexX = (int)Math.Floor((decimal)dx / 44); int indexY = (int)Math.Floor((decimal)dy / 26); GraphicsPath gp = new GraphicsPath(); if ((indexX % 2 == 1 && indexY % 2 == 1) || (indexX % 2 == 0 && indexY % 2 == 0)) { Point[] pts = { new Point(LeftPos + indexX * 44, TopPos + indexY * 26), new Point(LeftPos + indexX * 44, TopPos + indexY * 26 + 25), new Point(LeftPos + indexX * 44 + 13, TopPos + indexY * 26 + 25) }; gp.AddPolygon(pts); if (gp.IsVisible(mouseX, mouseY)) { indexX--; } } else { Point[] pts = { new Point(LeftPos + indexX * 44, TopPos + indexY * 26), new Point(LeftPos + indexX * 44 + 13, TopPos + indexY * 26), new Point(LeftPos + indexX * 44, TopPos + indexY * 26 + 25) }; gp.AddPolygon(pts); if (gp.IsVisible(mouseX, mouseY)) { indexX--; } } return(new Point(indexX, indexY)); }
public static void addPlace(Panel panel, Zone z) { Point[] polygon = Fonction.convertCoordonnee(z.Coordonnee); Point[] rectangle = Fonction.createRectangle(polygon); //le rectangle mcontenir anle polygone GraphicsPath path = new GraphicsPath(); path.AddPolygon(polygon); int index = 0; Point temp = rectangle[index]; //mitady anle coins anaky telo amle rectangle conteneur du polygone for (int i = 1; i < rectangle.Length; i++) // tetezina le points zoronle rectangle { if (rectangle[i].X < temp.X && rectangle[i].Y < temp.Y) //? { index = i; // } } int indexFin = index + 2; if (indexFin > 3) { indexFin = indexFin - 4; } int indexMil = indexFin - 1; if (indexMil < 0) { indexMil = 3; } int x = rectangle[index].X; int y = rectangle[index].Y; //maka ny coin anakroa meme coté (tsy opposé) int nbPlace = 0; while (x < rectangle[indexFin].X && y < rectangle[indexFin].Y) { x += (int)z.EspacementCote; Point A, B, C, D; //coins anle sieges A = new Point(x, y); x += 5; B = new Point(x, y); C = new Point(x, B.Y + 5); D = new Point(x - 5, y + 5); Point[] place = { A, B, C, D }; if (path.IsVisible(A) && path.IsVisible(B) && path.IsVisible(C) && path.IsVisible(D)) { Fonction.drawFigure(panel, place, "Red"); nbPlace++; } if (x >= rectangle[indexMil].X) { x = rectangle[index].X; y += (int)z.EspacementHaut + 5; } } z.NbPlace = nbPlace; }
public bool CanCreate(PointF Begin, PointF End, string NameObj = null) { if ((!RectWindow.IsVisible(Begin)) || (!RectWindow.IsVisible(End))) { return(false); } foreach (OpticObject index in ListOpticObject) { if (index.Intersect(Begin, End)) { if (index is PrismObject) { if (((PrismObject)index).Name != NameObj) { return(false); } } else { return(false); } } } return(true); }
private void cropMouseDown(object sender, MouseEventArgs e) { if (horizontalMarginUnlocked) { //Check if left tab is being clicked if (leftTabPath.IsVisible(e.Location)) { leftTabMouseDown = true; } //Check if right tab is being clicked if (rightTabPath.IsVisible(e.Location)) { rightTabMouseDown = true; } } //Check if top tab is being clicked if (topTabPath.IsVisible(e.Location)) { topTabMouseDown = true; } //Check if bottom tab is being clicked if (bottomTabPath.IsVisible(e.Location)) { bottomTabMouseDown = true; } }
override public bool Intersect(PointF Begin_in, PointF End_in) { PointF Cross = new PointF(); PointF TmpDot = new PointF(); double angle = 0; GraphicsPath PrismContour = new GraphicsPath(); PrismContour.AddPolygon(ArrayVertices); for (int i = 0; i != ArrayVertices.Length; i++) { if (i == ArrayVertices.Length - 1) { TmpDot = ArrayVertices[0]; } else { TmpDot = ArrayVertices[i + 1]; } angle = Crossing(Begin_in, End_in, ArrayVertices[i], TmpDot, ref Cross); if (angle != 0) { return(true); } } if ((PrismContour.IsVisible(Begin_in)) && (PrismContour.IsVisible(End_in))) { return(true); } return(false); }
/// <summary> /// 点point是否在折线的区域内 /// </summary> /// <param name="point">逻辑坐标点</param> /// <param name="lines">折线(N条线)</param> /// <param name="thick">线的粗细</param> /// <returns>True:在区域内,False:不在区域内</returns> public static bool IsVisible_PointInLines(PointF point, List <PointF> lines, float thick = 3) { GraphicsPath path = new GraphicsPath(); float thick2 = thick / 2.0f; for (int i = 0; i < lines.Count - 1; i++) { PointF[] pts = GetLineRegion(lines[i], lines[i + 1], thick); path.AddLines(pts); path.CloseFigure(); if (path.IsVisible(point)) { return(true); } path.AddEllipse(lines[i].X - thick2, lines[i].Y - thick2, thick, thick); path.AddEllipse(lines[i + 1].X - thick2, lines[i + 1].Y - thick2, thick, thick); path.CloseFigure(); if (path.IsVisible(point)) { return(true); } path.Reset(); } return(false); }
//Input: PointF to check if it's on an object in the objectList //Output: If the PointF is on an object in the objectList return it's index if isn't one return -1 public static int DetectCollision(PointF point) { GraphicsPath path = new GraphicsPath(); try { if (Main_Form.highlightedIndex != -1) { path = Main_Form.objectsList[Main_Form.highlightedIndex].GetPath(); if (path.IsVisible(point)) { return(Main_Form.highlightedIndex); } } for (int i = 0; i < Main_Form.objectsList.Count; i++) { path = Main_Form.objectsList[i].GetPath(); if (path.IsVisible(point)) { return(i); } } return(-1); } catch { return(-1); } }
public Rectangle GetTabCloserRect(int index) { Rectangle closerRect = new Rectangle(); using (GraphicsPath path = this._StyleProvider.GetTabBorder(index)) { RectangleF rect = path.GetBounds(); rect.Y += 4; rect.Height -= 6; if (this.RightToLeftLayout) { closerRect = new Rectangle((int)rect.Left, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 6) / 2), 6, 6); while (!path.IsVisible(closerRect.Left, closerRect.Y) && closerRect.Right < this.Width) { closerRect.X += 1; } closerRect.X += 4; } else { closerRect = new Rectangle((int)rect.Right, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 6) / 2), 6, 6); while (!path.IsVisible(closerRect.Right, closerRect.Y) && closerRect.Right > -6) { closerRect.X -= 1; } closerRect.X -= 4; } } return(closerRect); }
// Determines if the click is within the shape public bool HitTest(RectangleF r, float x, float y) { GraphicsPath path = new GraphicsPath(); Matrix matrix = new Matrix(); matrix.RotateAt(this.angle, this.Center); path.AddRectangle(r); path.Transform(matrix); this.selected = path.IsVisible(x, y); return(path.IsVisible(x, y)); }
public static void addPlaceHorizontalementInverse(Panel panel, Zone z) { Point[] polygon = Fonction.convertCoordonnee(z.Coordonnee); Point[] rectangle = Fonction.createRectangle(polygon); //le rectangle mcontenir anle polygone GraphicsPath path = new GraphicsPath(); path.AddPolygon(polygon); int indexFin = 1; int index = 3; int limiteBody = rectangle[2].X; int x = rectangle[index].X; int y = rectangle[index].Y; //maka ny coin anakroa meme coté (tsy opposé) int nbPlace = z.NumDepart; //atao numero depart z.Sieges = new List <Seza>(); while (x > rectangle[indexFin].X && y < rectangle[indexFin].Y) { x -= (int)z.EspacementCote; Point A, B, C, D; //coins anle sieges A = new Point(x, y); x -= (int)z.TailleSeza; B = new Point(x, y); C = new Point(x, B.Y + (int)z.TailleSeza); D = new Point(x + (int)z.TailleSeza, y + (int)z.TailleSeza); Point[] place = { A, B, C, D }; String numStr = "" + nbPlace; if (path.IsVisible(A) && path.IsVisible(B) && path.IsVisible(C) && path.IsVisible(D)) { Seza temp = new Seza(nbPlace, Fonction.convertString(place), 0); z.Sieges.Add(temp); Fonction.drawSeza(panel, place, "Red", numStr); nbPlace++; } if (x <= limiteBody) { x = rectangle[index].X; y += (int)z.EspacementHaut + (int)z.TailleSeza; ; } } //ETO NO MI-INSERT NY SEZA reetra anle zone ANATY BASE (VITA) Fonction f = new Fonction(); DBConnect dbc = new DBConnect(); f.insertSeza(dbc, z.Sieges, z.Id); z.NbPlace = nbPlace; }
protected Tab TabHitTest(Point ptMouse) { foreach (DockState state in DockStates) { Rectangle rectTabStrip = GetTabStripRectangle(state); if (!rectTabStrip.Contains(ptMouse)) { continue; } foreach (Pane pane in GetPanes(state)) { foreach (TabVS2012 tab in pane.AutoHideTabs) { GraphicsPath path = GetTabOutline(tab, true); if (path.IsVisible(ptMouse)) { return(tab); } } } } return(null); }
/// <summary> /// 图片不规则截图 /// </summary> /// <param name="bitmap">原图</param> /// <param name="path">裁剪路径</param> /// <returns></returns> public static System.Drawing.Image BitmapCrop(Bitmap bitmap, GraphicsPath path) { RectangleF rect = path.GetBounds(); int left = (int)rect.Left; int top = (int)rect.Top; int width = (int)rect.Width; int height = (int)rect.Height; Bitmap image = (Bitmap)bitmap.Clone(); Bitmap outputBitmap = new Bitmap(width, height); for (int i = left; i < left + width; i++) { for (int j = top; j < top + height; j++) { //判断坐标是否在路径中 if (path.IsVisible(i, j)) { //复制原图区域的像素到输出图片 outputBitmap.SetPixel(i - left, j - top, image.GetPixel(i, j)); //设置原图这部分区域为透明 image.SetPixel(i, j, Color.FromArgb(0, image.GetPixel(i, j))); } else { outputBitmap.SetPixel(i - left, j - top, Color.FromArgb(0, 255, 255, 255)); } } } bitmap.Dispose(); return((System.Drawing.Image)outputBitmap); }
public override IHitTestObject HitTest(HitTestPointData htd) { HitTestObjectBase result = null; GraphicsPath gp = GetPath(); if (_fillBrush.IsVisible && gp.IsVisible((PointF)htd.GetHittedPointInWorldCoord(_transformation))) { result = new GraphicBaseHitTestObject(this); } else if (_linePen.IsVisible && gp.IsOutlineVisible((PointF)htd.GetHittedPointInWorldCoord(_transformation), _linePen)) { result = new GraphicBaseHitTestObject(this); } else { gp.Transform(htd.GetTransformation(_transformation)); // Transform to page coord if (gp.IsOutlineVisible((PointF)htd.HittedPointInPageCoord, new Pen(Color.Black, 6))) { result = new GraphicBaseHitTestObject(this); } } if (result != null) { result.DoubleClick = EhHitDoubleClick; } return(result); }
static unsafe void _SetAlpha(BitmapData d, RECT r, GraphicsPath path = null) { //remove alpha. Will compress better. //APerf.First(); byte *p = (byte *)d.Scan0, pe = p + r.Width * r.Height * 4; for (p += 3; p < pe; p += 4) { *p = 0xff; } //APerf.NW(); //1100 for max window //if path used, set alpha=0 for outer points if (path != null) { int *k = (int *)d.Scan0; for (int y = r.top; y < r.bottom; y++) { for (int x = r.left; x < r.right; x++, k++) { //AOutput.Write(x, y, path.IsVisible(x, y)); if (!path.IsVisible(x, y)) { *k = 0xFFFFFF; //white, 0 alpha } } } } }
/// <summary> /// Tests whether the mouse hits this shape. /// </summary> /// <param name="p"></param> /// <returns></returns> public override bool Hit(Point p) { GraphicsPath path = new GraphicsPath(); path.AddEllipse(Rectangle); return(path.IsVisible(p)); }
protected override IDockContent HitTest(Point ptMouse) { foreach (DockState state in DockStates) { Rectangle rectTabStrip = GetLogicalTabStripRectangle(state, true); if (!rectTabStrip.Contains(ptMouse)) { continue; } foreach (Pane pane in GetPanes(state)) { DockState dockState = pane.DockPane.DockState; foreach (TabVS2005 tab in pane.AutoHideTabs) { GraphicsPath path = GetTabOutline(tab, true, true); if (path.IsVisible(ptMouse)) { return(tab.Content); } } } } return(null); }
protected override void OnMouseMove(MouseEventArgs e) { var isVisible = _graphicsPath.IsVisible(e.Location); if (isVisible == _graphicsPathIsVisible) { return; } const int zoom = 5; if (isVisible) { if (!_graphicsPathIsVisible) { _rectangle.Inflate(zoom, zoom); _graphicsPath.Reset(); _graphicsPath.AddRectangle(_rectangle); } } else { if (_graphicsPathIsVisible) { _rectangle.Inflate(-zoom, -zoom); _graphicsPath.Reset(); _graphicsPath.AddRectangle(_rectangle); } } _graphicsPathIsVisible = isVisible; Invalidate(); base.OnMouseMove(e); }
public Bitmap BitmapCrop(Bitmap bitmap, GraphicsPath path, out Bitmap outputBitmap) { RectangleF rect = path.GetBounds(); int left = (int)rect.Left; int top = (int)rect.Top; int width = (int)rect.Width; int height = (int)rect.Height; Bitmap image = bitmap; outputBitmap = new Bitmap(width, height); for (int i = left; i < left + width; i++) { for (int j = top; j < top + height; j++) { //判断坐标是否在路径中 if (path.IsVisible(i, j)) { //复制原图区域的像素到输出图片 Color tmp = image.GetPixel(i, j); outputBitmap.SetPixel(i - left, j - top, tmp); //设置原图这部分区域为透明 image.SetPixel(i, j, Color.FromArgb(0, image.GetPixel(i, j))); pcxelnumber++; } else { outputBitmap.SetPixel(i - left, j - top, Color.FromArgb(0, 0, 0, 0)); } } } bitmap.Dispose(); return(image); }
public override bool Touch(int xx, int yy) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddEllipse(x, y, width, height); return(graphicsPath.IsVisible(xx, yy)); }
public override int HitTest(Point point) { if (!IsVisible) { return(-1); } if (IsSelected) { for (int i = 1; i <= HandleCount; i++) { GraphicsPath gp = new GraphicsPath(); gp.AddRectangle(GetHandleRectangle(i)); bool vis = gp.IsVisible(point); gp.Dispose(); if (vis) { return(i); } } } // OK, so the point is not on a selection handle, is it anywhere else on the line? if (PointInObject(point)) { return(0); } return(-1); }
public bool checkPointInside(Point pt) { GraphicsPath path = new GraphicsPath(); path.AddPolygon(lines.Select(it => it.start).ToArray()); return(path.IsVisible(pt)); }
public override bool HitTest(Point point) { float width = this.Width; if (this.AutoSize) { width = (float)((double)this.width * (double)this.owner.GaugeOtherSizeLength / 100.0); } using (GraphicsPath path = this.Path) { using (Matrix gdiMatrix = this.TotalTransform.ToGdiMatrix()) { path.Transform(gdiMatrix); using (Pen pen = new Pen(Color.Red, width)) { if (!path.IsOutlineVisible(point, pen)) { if (!path.IsVisible(point)) { goto label_17; } } return(true); } } } label_17: return(false); }
private void GraphicsPathHit_MouseDown(object sender, MouseEventArgs e) { if (path.IsVisible(e.X, e.Y)) { MessageBox.Show("You clicked inside the figure."); } }
public override ShapeClickAction GetShapeActionByPoint(GraphicsPath path, Point point) { if (IsPointOverShape(path, point)) { if (KeyboardController.IsMoveDown) { return(ShapeClickAction.Drag); } // Determine if not overlapping border, and drag. otherwise resize. path.Reset(); path.AddEllipse(Rectangle.Inflate(Position, -Shape.EDGE_WIDTH, -Shape.EDGE_WIDTH)); if (path.IsVisible(point)) { return(ShapeClickAction.Drag); } else { return(ShapeClickAction.Resize); } } else { return(ShapeClickAction.None); } }
public void MouseDownEsferas(PointF PointPer) { GraphicsPath graphicsPathIzquierda = new GraphicsPath(); graphicsPathIzquierda.AddRectangles(new RectangleF[] { cFunctionsProgram.CrearCirculo(C_F_Izquierda.Escaladas) }); if (graphicsPathIzquierda.IsVisible(PointPer)) { C_F_Izquierda.IsSelect = true; } else { C_F_Izquierda.IsSelect = false; } GraphicsPath graphicsPathDerecha = new GraphicsPath(); graphicsPathDerecha.AddRectangles(new RectangleF[] { cFunctionsProgram.CrearCirculo(C_F_Derecha.Escaladas) }); if (graphicsPathDerecha.IsVisible(PointPer)) { C_F_Derecha.IsSelect = true; } else { C_F_Derecha.IsSelect = false; } C_F_Central.IsSelect = false; }
public override bool HitTest(Point point) { if (this.Size.Width == 0 || this.Size.Height == 0) { return(false); } if (this.Shape == null) { return(base.HitTest(point)); } Size size = this.Size; if (this.BorderAndFillOrientation == PageViewContentOrientation.Vertical270 || this.BorderAndFillOrientation == PageViewContentOrientation.Vertical90) { size = new Size(this.Size.Height, this.Size.Width); } using (GraphicsPath path = this.Shape.CreatePath(new Rectangle(Point.Empty, size))) { bool flag = false; using (Matrix gdiMatrix = this.TotalTransform.ToGdiMatrix()) { float angle = 0.0f; float offsetX = 0.0f; float offsetY = 0.0f; this.CalculateRotationAndOffset(this.BorderAndFillOrientation, ref angle, ref offsetX, ref offsetY); gdiMatrix.Translate(offsetX, offsetY); gdiMatrix.Rotate(angle); path.Transform(gdiMatrix); flag = path.IsVisible(point); } return(flag); } }
public override bool IsPointOverShape(GraphicsPath path, Point point) { // Determine if overlapping border, and resize. path.Reset(); path.AddEllipse(Position); return(path.IsVisible(point)); }
public override bool Contains(int x, int y) { if (base.Contains(x, y)) { return(true); } Point clickedPoint = new Point(x, y); if (Status != EditStatus.UNDRAWN) { int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS); Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR); using (Pen pen = new Pen(lineColor, lineThickness)) { using (GraphicsPath bubblePath = CreateBubble(lineThickness)) { bubblePath.Widen(pen); if (bubblePath.IsVisible(clickedPoint)) { return(true); } } using (GraphicsPath tailPath = CreateTail()) { tailPath.Widen(pen); if (tailPath.IsVisible(clickedPoint)) { return(true); } } } } return(false); }
static unsafe void _SetAlpha(uint *pixels, RECT r, GraphicsPath path = null) { //remove alpha. Will compress better. //perf.first(); byte *p = (byte *)pixels, pe = p + r.Width * r.Height * 4; for (p += 3; p < pe; p += 4) { *p = 0xff; } //perf.nw(); //1100 for max window //if path used, set alpha=0 for outer points if (path != null) { uint *k = pixels; for (int y = r.top; y < r.bottom; y++) { for (int x = r.left; x < r.right; x++, k++) { //print.it(x, y, path.IsVisible(x, y)); if (!path.IsVisible(x, y)) { *k = 0xFFFFFF; //white, 0 alpha } } } } }
//Выбор треугольника public override bool Select(int sx, int sy) { GraphicsPath path = new GraphicsPath(); path.AddEllipse(x1, y1, x2 - x1, y2 - y1); return(path.IsVisible(sx, sy)); }