private void PbDrawSpace_MouseMove(object sender, MouseEventArgs e) { pbDrawSpace.Focus(); if (selectedpolygon != null && PolyEditMode.ToString().Contains("Vert")) { PointF pointA = Point.Empty; if (PolyEditMode != EnumPolyEditMode.NewVertInLine) { pointA = selectedpolygon.Vertices.FindClosest(e.Location.ReCalcInvertZoom(Percent)); } else { var arr = selectedpolygon.Vertices; var src = arr.FindClosest(e.Location.ReCalcInvertZoom(Percent)); var res = arr.GetNeighbors(src).FindClosest(e.Location.ReCalcInvertZoom(Percent)); if (res != Point.Empty) { Line = new PointF[] { src, res }; } else { Line = null; } Overlay.Refresh(); } if (PolyEditMode == EnumPolyEditMode.MoveVertorPoly && e.Button == MouseButtons.Left) { if (ModifierKeys == Keys.Shift) { selectedpolygon.MovePolygon(e.Location.ReCalcInvertZoom(Percent)); } else { selectedpolygon.MoveVert(e.Location.ReCalcInvertZoom(Percent)); } Overlay.Refresh(); } if (pointA != nearest) { nearest = pointA; Overlay.Refresh(); } } else if (selectedImage != null && PolyEditMode.ToString().Contains("Image") && MouseImgModifyStartLocation != PointF.Empty) { ModifyImage(e); } tslblMouseReal.Text = $"MouseCoord {e.Location}"; tslblMouseWorld.Text = $"WorldSpace {e.Location.ReCalcInvertZoom(Percent)}"; }
private void PbDrawSpace_MouseDown(object sender, MouseEventArgs e) { if (selectedScene != null) { if (e.Button == MouseButtons.Right) { if (PolyEditMode.ToString().Contains("Vert")) { SelectPolygon(e); } else if (PolyEditMode.ToString().Contains("Image")) { SelectedImage(e); if (selectedImage != null) { tslblState.Text = $"Center SelectedImage: {selectedImage.Middle(Percent)}"; } } } else { if (PolyEditMode.ToString().Contains("Vert")) { if (selectedpolygon != null) { ModifyPolygon(e); } } else if (PolyEditMode.ToString().Contains("Image")) { MouseImgModifyStartLocation = e.Location; if (selectedImage != null) { MouseImgModifyInitialScale = selectedImage.TTScale; MouseImgModifyInitialCenter = selectedImage.Middle(Percent); MouseMoveInitImageLocation = selectedImage.TTLocation; MouseImgModifyStartOffset = MouseImgModifyStartLocation.ReCalcInvertZoom(Percent).Sub(MouseMoveInitImageLocation); MouseMoveInitLength = MouseImgModifyStartOffset.ReCalcInvertZoom(Percent).Length(MouseMoveInitImageLocation); } } } } }