public double GetClosestDistance(double x, double y, double z) { PointReference closestPointRef = GetClosestPoint(x, y, z); return(MoreMath.GetDistanceBetween( closestPointRef.X, closestPointRef.Y, closestPointRef.Z, x, y, z)); }
private void RecordingOverlay_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.Control) { if (e.KeyCode == Keys.Z) { var toRemove = drawList.Last(); formForControls.Controls.Remove(toRemove.NameLabel); formForControls.Invalidate(toRemove.OuterRectangle); drawList.Remove(toRemove); pointList.RemoveAt(pointList.Count - 1); } } else { if (e.Shift && (e.KeyCode == Keys.ShiftKey)) { currentReference++; if ((int)currentReference > Enum.GetValues(typeof(PointReference)).Length - 1) { currentReference = PointReference.TopLeft; } captionLabel.Text = string.Format(windowCaption, Enum.GetName(typeof(PointReference), currentReference)); captionLabel.ForeColor = ((SolidBrush)ReferenceToBrush(currentReference)).Color; } } }
/// <summary> /// We use a borderless form when we record the points, therefore we get screen coordinates right away /// TODO: consider getting client rectangle for the window and calculate client coordinates /// </summary> /// <param name="r">Reference corner</param> /// <param name="window">Target window rectangle</param> /// <returns></returns> public Point GetPoint(PointReference r, Rectangle window) { if (r == RawReference) { return(RawPoint); } return(TopLeftToSpecified(ToTopLeft(window), r, window)); }
public void AddReference(MonoBehaviour mb, Vector3?offset = null) { PointReference pr = new PointReference(); pr.mb = mb; pr.referenceIndex = points.Count; pr.offset = offset ?? Vector3.zero; pointRef.Add(pr); AddPoint(mb.transform.position); }
public void SetReference(int index, MonoBehaviour mb, Vector3?offset = null) { PointReference pr = new PointReference(); pr.mb = mb; pr.referenceIndex = index; pr.offset = offset ?? Vector3.zero; for (int i = 0; i < pointRef.Count; i++) { if (pointRef[i].referenceIndex == index) { pointRef.Remove(pointRef[i]); } } pointRef.Add(pr); SetPoint(index, mb.transform.position + pr.offset); }
public PointReference GetClosestPoint(double x, double y, double z) { PointReference closestPointRef = _pointDictionary[0]; double closestDistance = Double.MaxValue; foreach (int index in _pointDictionary.Keys) { PointReference pointRef = _pointDictionary[index]; double distance = MoreMath.GetDistanceBetween( pointRef.X, pointRef.Y, pointRef.Z, x, y, z); if (distance < closestDistance) { closestPointRef = pointRef; closestDistance = distance; } } return(closestPointRef); }
private Point TopLeftToSpecified(Point p, PointReference r, Rectangle w) { switch (r) { case PointReference.TopLeft: return(p); case PointReference.TopRight: return(new Point(p.X - w.Width, p.Y)); case PointReference.BottomLeft: return(new Point(p.X, p.Y - w.Height)); case PointReference.BottomRight: return(new Point(p.X - w.Width, p.Y - w.Height)); default: throw new ArgumentException("Point reference type is out of range!"); } }
private Brush ReferenceToBrush(PointReference r) { switch (r) { case PointReference.TopLeft: return(Brushes.Orange); case PointReference.TopRight: return(Brushes.Cyan); case PointReference.BottomLeft: return(Brushes.LightGreen); case PointReference.BottomRight: return(Brushes.Yellow); default: return(Brushes.Black); } }
private void DrawPoint(string name, Point e, PointReference r) { var b = ReferenceToBrush(r); //Set up a label var lbl = new Label() { Text = name, BackColor = Color.DarkMagenta, Location = new Point(e.X - 10, e.Y + 10), AutoSize = true, ForeColor = ((SolidBrush)b).Color }; formForControls.Controls.Add(lbl); //Create redraw/undo data drawList.Add(new DrawnPoint( new Rectangle(e.X - 10, e.Y - 10, 20, 20), new Rectangle(e.X - 5, e.Y - 5, 10, 10), b, new SolidBrush(Native.GetPixelColor(PointToScreen(e))), lbl)); formForControls.Invalidate(); }
public ClickPoint(int x, int y, PointReference r, string n) : this(new Point(x, y), r, n) { }
public ClickPoint(Point p, PointReference r, string n) { RawPoint = p; RawReference = r; Name = n; }
public int GetClosestIndex(double x, double y, double z) { PointReference closestPointRef = GetClosestPoint(x, y, z); return(closestPointRef.Index); }