public override bool IsInside(DominoInCanvas dic, Rect boundingBox, bool includeBoundary) { if (IsInsideBoundingBox(boundingBox, dic, includeBoundary)) { var insidePoly = dic.canvasPoints.Count(x => IsPointInPolygon(points, new System.Windows.Point(x.X, x.Y))); return(CheckBoundary(dic, insidePoly)); } return(false); }
public override bool IsInside(DominoInCanvas dic, Rect boundingBox, bool includeBoundary) { var radius = boundingBox.Width / 2; var center = new System.Windows.Point(boundingBox.X + radius, boundingBox.Y + radius); if (IsInsideBoundingBox(boundingBox, dic, includeBoundary)) { var insideCircle = dic.canvasPoints.Count(x => Math.Sqrt((x.X - center.X) * (x.X - center.X) + (x.Y - center.Y) * (x.Y - center.Y)) < radius); return(CheckBoundary(dic, insideCircle)); } return(false); }
private void Dic_MouseDown(object sender, MouseButtonEventArgs e) { DominoInCanvas dic = (DominoInCanvas)sender; if (e.LeftButton == MouseButtonState.Pressed) { if (IsSelected(dic.idx)) { SelectionTool.Select(new int[] { dic.idx }, true); } } else if (e.RightButton == MouseButtonState.Pressed) { SelectionTool.Select(new int[] { dic.idx }, false); } }
public bool IsInsideBoundingBox(Rect BoundingBox, DominoInCanvas dic, bool includeBoundary) { if (includeBoundary) { return(dic.canvasPoints.Max(x => x.X) > BoundingBox.Left && dic.canvasPoints.Min(x => x.X) < BoundingBox.Right && dic.canvasPoints.Min(x => x.Y) < BoundingBox.Bottom && dic.canvasPoints.Max(x => x.Y) > BoundingBox.Top); } else { return(dic.canvasPoints.Min(x => x.X) > BoundingBox.Left && dic.canvasPoints.Max(x => x.X) < BoundingBox.Right && dic.canvasPoints.Max(x => x.Y) < BoundingBox.Bottom && dic.canvasPoints.Min(x => x.Y) > BoundingBox.Top); } }
public bool CheckBoundary(DominoInCanvas dic, int pointsInsideSelection) { if (IncludeBoundary) { if (pointsInsideSelection > 0) { return(true); } } else { if (pointsInsideSelection == dic.canvasPoints.Length) { return(true); } } return(false); }
public override bool IsInside(DominoInCanvas dic, Rect boundingBox, bool includeBoundary) { return(IsInsideBoundingBox(boundingBox, dic, includeBoundary)); }
public abstract bool IsInside(DominoInCanvas dic, Rect boundingBox, bool includeBoundary);