private void RecalculateAndSetPoints(PointF point1, PointF point2) { this.АncillaryValues = DimentionCalculator.GetShapesParamsByTwoPoints(point1, point2); this.Point1 = new PointF(this.АncillaryValues.Item1, this.АncillaryValues.Item2); this.MinDimentionsDifference = Math.Min(this.АncillaryValues.Item5, this.АncillaryValues.Item6); this.Point2 = new PointF(this.Point1.X + this.MinDimentionsDifference, this.Point1.Y + this.MinDimentionsDifference); }
public override bool Contains(PointF point) { var centroid = new PointF(this.АncillaryValues.Item1 + this.MinDimentionsDifference / 2f , this.АncillaryValues.Item2 + this.MinDimentionsDifference / 2f); point = PolygonHlp.RotatePoint(point, centroid, this.RotationAngleInRadians); var distance = DimentionCalculator.DistanceBetweenTwoPoints(centroid.X, centroid.Y, point.X, point.Y); var radius = this.MinDimentionsDifference / 2f; return(point.X > centroid.X && point.Y < centroid.Y && distance <= radius); }
private void ViewPortMouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { dialogProcessor.OnMouseUpPoint = e.Location; dialogProcessor.IsDragging = false; if (ButtonMultiSelect.Checked) { ButtonMultiSelect.Checked = false; dialogProcessor.MultiSelectFlag = false; dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); var setOfShapesThatHasToBeRotated = TraverseOverSelectedMatrix(false); ChageBorderOfSetOfShapes(this.dialogProcessor.ShapeList[dialogProcessor.CurrentTab], GlobalConstants.DefaultDashStyle); ChageBorderOfSetOfShapes(setOfShapesThatHasToBeRotated, DashStyle.Dot); } var shapeParams = DimentionCalculator.GetShapesParamsByTwoPoints( dialogProcessor.OnMouseDownPoint, dialogProcessor.OnMouseUpPoint); if (ButtonFillColor.Checked) { ButtonFillColor.Checked = false; } if (ButtonBorderColor.Checked) { ButtonBorderColor.Checked = false; } if (ButtonMultiMove.Checked) { ButtonMultiMove.Checked = false; ChageBorderOfSetOfShapes(this.dialogProcessor.ShapeList[dialogProcessor.CurrentTab], GlobalConstants.DefaultDashStyle); ResetRotationProcess(GlobalConstants.DefaultDashStyle, false, true); } if (ButtonDrawRectangle.Checked && dialogProcessor.DrawTemporaryRectangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddRectangle( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Solid, false); ButtonDrawRectangle.Checked = false; dialogProcessor.DrawTemporaryRectangle = false; } if (ButtonDrowTriangle.Checked && dialogProcessor.DrawTemporaryTriangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddTriangle( new PointF(shapeParams.Item1, shapeParams.Item4), new PointF(shapeParams.Item1, shapeParams.Item2), new PointF(shapeParams.Item3, shapeParams.Item2), DashStyle.Solid, false); ButtonDrowTriangle.Checked = false; dialogProcessor.DrawTemporaryTriangle = false; } if (ButtonDrawEllipse.Checked && dialogProcessor.DrawTemporaryEllipse) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddEllipse( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Solid, false); ButtonDrawEllipse.Checked = false; dialogProcessor.DrawTemporaryEllipse = false; } if (ButtonDrawLine.Checked && dialogProcessor.DrawTemporaryLine) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddLine(dialogProcessor.OnMouseDownPoint, dialogProcessor.OnMouseUpPoint, DashStyle.Solid, false); ButtonDrawLine.Checked = false; dialogProcessor.DrawTemporaryLine = false; } if (ButtonDrawReuleauxTriangle.Checked && dialogProcessor.DrawTemporaryReuleauxTriangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddReuleauxTriangle(dialogProcessor.OnMouseDownPoint, dialogProcessor.OnMouseUpPoint, DashStyle.Solid, false); ButtonDrawReuleauxTriangle.Checked = false; dialogProcessor.DrawTemporaryReuleauxTriangle = false; } if (ButtonDrawEnvelope.Checked && dialogProcessor.DrawTemporaryEnvelope) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddEnvelope( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Solid, false); ButtonDrawEnvelope.Checked = false; dialogProcessor.DrawTemporaryEnvelope = false; } if (ButtonDrawGenericCircle.Checked && dialogProcessor.DrawTemporaryGenericCircle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddGenericCircle( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Solid, false); ButtonDrawGenericCircle.Checked = false; dialogProcessor.DrawTemporaryGenericCircle = false; } if (ButtonCopy.Checked && dialogProcessor.DrawTemporaryCopyShape) { ButtonCopy.Checked = false; dialogProcessor.DrawTemporaryCopyShape = false; dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.SelectionCopy.TemporaryFlag = false; dialogProcessor.ShapeList[dialogProcessor.CurrentTab].Add(dialogProcessor.SelectionCopy); dialogProcessor.SelectionCopy = null; } RerenderMainCanvas(); }
private void ViewPortMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (dialogProcessor.IsDragging && !ButtonMultiMove.Checked) { dialogProcessor.TranslateTo(dialogProcessor.Selection, dialogProcessor.LastLocation, e.Location); dialogProcessor.LastLocation = e.Location; } if (ButtonMultiMove.Checked && dialogProcessor.IsDragging && dialogProcessor.MultiSelection != null) { dialogProcessor.MultiMoveTo(dialogProcessor.LastLocation, e.Location); dialogProcessor.LastLocation = e.Location; } var startPoint = dialogProcessor.OnMouseDownPoint; var endPoint = e.Location; var shapeParams = DimentionCalculator.GetShapesParamsByTwoPoints(startPoint, endPoint); if (ButtonMultiSelect.Checked && dialogProcessor.MultiSelectFlag) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddRectangle( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true, 0); } if (ButtonDrawRectangle.Checked && dialogProcessor.DrawTemporaryRectangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddRectangle( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true); } if (ButtonDrowTriangle.Checked && dialogProcessor.DrawTemporaryTriangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddTriangle( new PointF(shapeParams.Item1, shapeParams.Item4), new PointF(shapeParams.Item1, shapeParams.Item2), new PointF(shapeParams.Item3, shapeParams.Item2), DashStyle.Dot, true); } if (ButtonDrawLine.Checked && dialogProcessor.DrawTemporaryLine) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddLine(startPoint, endPoint, DashStyle.Dot, true); } if (ButtonDrawEllipse.Checked && dialogProcessor.DrawTemporaryEllipse) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddEllipse( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true); } if (ButtonDrawReuleauxTriangle.Checked && dialogProcessor.DrawTemporaryReuleauxTriangle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddReuleauxTriangle(startPoint, endPoint, DashStyle.Dot, true); } if (ButtonDrawEnvelope.Checked && dialogProcessor.DrawTemporaryEnvelope) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddEnvelope( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true); } if (ButtonDrawGenericCircle.Checked && dialogProcessor.DrawTemporaryGenericCircle) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.AddGenericCircle( shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true); } if (ButtonCopy.Checked && dialogProcessor.DrawTemporaryCopyShape && dialogProcessor.SelectionCopy != null) { dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag); dialogProcessor.SelectionCopy.MoveToNextDestination(e.Location, dialogProcessor.LastLocation); dialogProcessor.SelectionCopy.UniqueIdentifier = Guid.NewGuid(); dialogProcessor.ShapeList[dialogProcessor.CurrentTab].Add(dialogProcessor.SelectionCopy); dialogProcessor.LastLocation = e.Location; } RerenderMainCanvas(); }