/// <summary> /// Mouse button released in the control. /// </summary> /// <param name="e">Event arguments.</param> internal void OnMouseUp(MouseEventArgs e) { // Check if in annotation placement mode if (this.placingAnnotation != null) { if (!this.placingAnnotation.PlacementMouseUp(new PointF(e.X, e.Y), e.Button)) { return; } } if (e.Button == MouseButtons.Left) { // Reset moving sizing start point this._movingResizingStartPoint = PointF.Empty; this._resizingMode = ResizingMode.None; } // Loop through all annotation objects for (int index = 0; index < this.Count; index++) { Annotation annotation = this[index]; // NOTE: Automatic deleting feature was disabled. -AG. /* * // Delete all annotation objects moved outside clipping region * if( annotation.outsideClipRegion ) * { * this.List.RemoveAt(index); * --index; * } */ // Reset start position/location fields annotation.startMovePositionRel = RectangleF.Empty; annotation.startMoveAnchorLocationRel = PointF.Empty; if (annotation.startMovePathRel != null) { annotation.startMovePathRel.Dispose(); annotation.startMovePathRel = null; } // Fire position changed event if (annotation.positionChanged) { annotation.positionChanged = false; if (this.Chart != null) { this.Chart.OnAnnotationPositionChanged(annotation); } } } }
static string GetMode(ResizingMode mode) { switch (mode) { case ResizingMode.Crop: return "c"; case ResizingMode.Max: return "m"; case ResizingMode.Pad: return "p"; } return "c"; }
static string GetMode(ResizingMode mode) { switch (mode) { case ResizingMode.Crop: return("c"); case ResizingMode.Max: return("m"); case ResizingMode.Pad: return("p"); } return("c"); }
public mModifyResize(ResizingMode Mode, ScalingMode Type, int Width, int Height) { ResizingType = Mode; ScalingType = Type; Effect = new ResizeFilter(); Effect.Mode = (ResizeMode)(int)ResizingType; Effect.BitmapScalingMode = (BitmapScalingMode)(int)ScalingType; Effect.Width = Unit.Pixel(Width); Effect.Height = Unit.Pixel(Height); Effect.Enabled = true; filter = Effect; }
/// <summary> /// Checks if specified point is contained by any of the selection handles. /// </summary> /// <param name="point">Point which is tested in pixel coordinates.</param> /// <param name="resizingMode">Handle containing the point or None.</param> /// <returns>Annotation that contains the point or Null.</returns> internal Annotation HitTestSelectionHandles(PointF point, ref ResizingMode resizingMode) { Annotation annotation = null; if (Common != null && Common.graph != null) { PointF pointRel = Common.graph.GetRelativePoint(point); foreach (Annotation annot in this) { // Reset selcted path point annot.currentPathPointIndex = -1; // Check if annotation is selected if (annot.IsSelected) { if (annot.selectionRects != null) { for (int index = 0; index < annot.selectionRects.Length; index++) { if (!annot.selectionRects[index].IsEmpty && annot.selectionRects[index].Contains(pointRel)) { annotation = annot; if (index > (int)ResizingMode.AnchorHandle) { resizingMode = ResizingMode.MovingPathPoints; annot.currentPathPointIndex = index - 9; } else { resizingMode = (ResizingMode)index; } } } } } } } return(annotation); }
public static string FormatUrl(string format, int width, int height, ResizingMode mode = ResizingMode.Crop) { return $"{Host}{string.Format(format, width, height, GetMode(mode))}"; }
private void changeCursor(MouseEventArgs e) { if ((ModifierKeys&Keys.Control)!=0) { this.Cursor = Cursors.SizeAll; _resizeMode = ResizingMode.None; } else { if ((e.X < 5) && (e.Y < 5)) { this.Cursor = Cursors.SizeNWSE; _resizeMode = ResizingMode.TopLeft; } else if ((e.X < 5) && Math.Abs(e.Y - this.ClientSize.Height) < 5) { this.Cursor = Cursors.SizeNESW; _resizeMode = ResizingMode.BottomLeft; } else if (e.X < 5) { this.Cursor = Cursors.SizeWE; _resizeMode = ResizingMode.Left; } else if (Math.Abs(e.X - this.ClientSize.Width) < 5 && (e.Y < 5)) { this.Cursor = Cursors.SizeNESW; _resizeMode = ResizingMode.TopRight; } else if (Math.Abs(e.X - this.ClientSize.Width) < 5 && Math.Abs(e.Y - this.ClientSize.Height) < 5) { this.Cursor = Cursors.SizeNWSE; _resizeMode = ResizingMode.BottomRight; } else if (Math.Abs(e.X - this.ClientSize.Width) < 5) { this.Cursor = Cursors.SizeWE; _resizeMode = ResizingMode.Right; } else if (Math.Abs(e.Y - this.ClientSize.Height) < 5) { this.Cursor = Cursors.SizeNS; _resizeMode = ResizingMode.Bottom; } else if (e.Y < 5) { this.Cursor = Cursors.SizeNS; _resizeMode = ResizingMode.Top; } else { this.Cursor = Cursors.IBeam; _resizeMode = ResizingMode.None; } } }
/// <summary> /// Sets mouse cursor shape. /// </summary> /// <param name="annotation">Annotation object.</param> /// <param name="currentResizingMode">Resizing mode.</param> private void SetResizingCursor(Annotation annotation, ResizingMode currentResizingMode) { // Change current cursor if (this.Chart != null) { System.Windows.Forms.Cursor newCursor = this.Chart.Cursor; if (annotation != null) { if (currentResizingMode == ResizingMode.MovingPathPoints && annotation.AllowPathEditing) { newCursor = Cursors.Cross; } if (currentResizingMode == ResizingMode.Moving && annotation.AllowMoving) { newCursor = Cursors.SizeAll; } if (currentResizingMode == ResizingMode.AnchorHandle && annotation.AllowAnchorMoving) { newCursor = Cursors.Cross; } if (currentResizingMode != ResizingMode.Moving && annotation.AllowResizing) { if (annotation.SelectionPointsStyle == SelectionPointsStyle.TwoPoints) { if (currentResizingMode == ResizingMode.TopLeftHandle || currentResizingMode == ResizingMode.BottomRightHandle) { newCursor = Cursors.Cross; } } else { if (currentResizingMode == ResizingMode.TopLeftHandle || currentResizingMode == ResizingMode.BottomRightHandle) { newCursor = Cursors.SizeNWSE; } else if (currentResizingMode == ResizingMode.TopRightHandle || currentResizingMode == ResizingMode.BottomLeftHandle) { newCursor = Cursors.SizeNESW; } else if (currentResizingMode == ResizingMode.TopHandle || currentResizingMode == ResizingMode.BottomHandle) { newCursor = Cursors.SizeNS; } else if (currentResizingMode == ResizingMode.LeftHandle || currentResizingMode == ResizingMode.RightHandle) { newCursor = Cursors.SizeWE; } } } } else { newCursor = this.Chart.defaultCursor; } // Set current chart cursor if (newCursor != this.Chart.Cursor) { System.Windows.Forms.Cursor tmpCursor = this.Chart.defaultCursor; this.Chart.Cursor = newCursor; this.Chart.defaultCursor = tmpCursor; } } }
/// <summary> /// Mouse moved in the control. /// </summary> /// <param name="e">Event arguments.</param> internal void OnMouseMove(MouseEventArgs e) { // Check if in annotation placement mode if (this.placingAnnotation != null) { System.Windows.Forms.Cursor newCursor = this.Chart.Cursor; if (this.placingAnnotation.IsValidPlacementPosition(e.X, e.Y)) { newCursor = Cursors.Cross; } else { newCursor = this.Chart.defaultCursor; } // Set current chart cursor if (newCursor != this.Chart.Cursor) { System.Windows.Forms.Cursor tmpCursor = this.Chart.defaultCursor; this.Chart.Cursor = newCursor; this.Chart.defaultCursor = tmpCursor; } this.placingAnnotation.PlacementMouseMove(new PointF(e.X, e.Y)); return; } // Check if currently resizing/moving annotation if (!this._movingResizingStartPoint.IsEmpty && this._resizingMode != ResizingMode.None) { // Calculate how far the mouse was moved SizeF moveDistance = new SizeF( this._movingResizingStartPoint.X - e.X, this._movingResizingStartPoint.Y - e.Y); // Update location of all selected annotation objects foreach (Annotation annot in this) { if (annot.IsSelected && ((this._resizingMode == ResizingMode.MovingPathPoints && annot.AllowPathEditing) || (this._resizingMode == ResizingMode.Moving && annot.AllowMoving) || (this._resizingMode == ResizingMode.AnchorHandle && annot.AllowAnchorMoving) || (this._resizingMode >= ResizingMode.TopLeftHandle && this._resizingMode <= ResizingMode.LeftHandle && annot.AllowResizing))) { annot.AdjustLocationSize(moveDistance, this._resizingMode, true, true); } } // Move last clicked non-selected annotation if (lastClickedAnnotation != null && !lastClickedAnnotation.IsSelected) { if (this._resizingMode == ResizingMode.Moving && lastClickedAnnotation.AllowMoving) { lastClickedAnnotation.AdjustLocationSize(moveDistance, this._resizingMode, true, true); } } // Invalidate and update the chart this.Chart.Invalidate(true); this.Chart.UpdateAnnotations(); } else if (this.Count > 0) { // Check if currently placing annotation from the UserInterface bool process = true; if (process) { // Check if mouse pointer is over the annotation selection handle ResizingMode currentResizingMode = ResizingMode.None; Annotation annotation = HitTestSelectionHandles(new PointF(e.X, e.Y), ref currentResizingMode); // Check if mouse pointer over the annotation object movable area if (annotation == null) { HitTestResult result = this.Chart.HitTest(e.X, e.Y, ChartElementType.Annotation); if (result != null && result.ChartElementType == ChartElementType.Annotation) { annotation = (Annotation)result.Object; if (annotation != null) { // Check if annotation is in the collection if (this.Contains(annotation)) { currentResizingMode = ResizingMode.Moving; if (annotation.AllowMoving == false) { // Movement is not allowed annotation = null; currentResizingMode = ResizingMode.None; } } } } } // Set mouse cursor SetResizingCursor(annotation, currentResizingMode); } } }
/// <summary> /// Mouse button pressed in the control. /// </summary> /// <param name="e">Event arguments.</param> /// <param name="isHandled">Returns true if event is handled and no further processing required.</param> internal void OnMouseDown(MouseEventArgs e, ref bool isHandled) { // Reset last clicked annotation object and stop text editing if (lastClickedAnnotation != null) { TextAnnotation textAnnotation = lastClickedAnnotation as TextAnnotation; if (textAnnotation != null) { // Stop annotation text editing textAnnotation.StopTextEditing(); } lastClickedAnnotation = null; } // Check if in annotation placement mode if (this.placingAnnotation != null) { // Process mouse down this.placingAnnotation.PlacementMouseDown(new PointF(e.X, e.Y), e.Button); // Set handled flag isHandled = true; return; } // Process only left mouse buttons if (e.Button == MouseButtons.Left) { bool updateRequired = false; this._resizingMode = ResizingMode.None; // Check if mouse buton was pressed in any selection handles areas Annotation annotation = HitTestSelectionHandles(new PointF(e.X, e.Y), ref this._resizingMode); // Check if mouse button was pressed over one of the annotation objects if (annotation == null && this.Count > 0) { HitTestResult result = this.Chart.HitTest(e.X, e.Y, ChartElementType.Annotation); if (result != null && result.ChartElementType == ChartElementType.Annotation) { annotation = (Annotation)result.Object; } } // Unselect all annotations if mouse clicked outside any annotations if (annotation == null || !annotation.IsSelected) { if ((Control.ModifierKeys & Keys.Control) != Keys.Control && (Control.ModifierKeys & Keys.Shift) != Keys.Shift) { foreach (Annotation annot in this.Chart.Annotations) { if (annot != annotation && annot.IsSelected) { annot.IsSelected = false; updateRequired = true; // Call selection changed notification if (this.Chart != null) { this.Chart.OnAnnotationSelectionChanged(annot); } } } } } // Process mouse action in the annotation object if (annotation != null) { // Mouse down event handled isHandled = true; // Select/Unselect annotation Annotation selectableAnnotation = annotation; if (annotation.AnnotationGroup != null) { // Select annotation group when click on any child annotations selectableAnnotation = annotation.AnnotationGroup; } if (!selectableAnnotation.IsSelected && selectableAnnotation.AllowSelecting) { selectableAnnotation.IsSelected = true; updateRequired = true; // Call selection changed notification if (this.Chart != null) { this.Chart.OnAnnotationSelectionChanged(selectableAnnotation); } } else if ((Control.ModifierKeys & Keys.Control) == Keys.Control || (Control.ModifierKeys & Keys.Shift) == Keys.Shift) { selectableAnnotation.IsSelected = false; updateRequired = true; // Call selection changed notification if (this.Chart != null) { this.Chart.OnAnnotationSelectionChanged(selectableAnnotation); } } // Remember last clicked and selected annotation lastClickedAnnotation = annotation; // Rember mouse position this._movingResizingStartPoint = new PointF(e.X, e.Y); // Start moving, repositioning or resizing of annotation if (annotation.IsSelected) { // Check if one of selection handles was clicked on this._resizingMode = annotation.GetSelectionHandle(this._movingResizingStartPoint); if (!annotation.AllowResizing && this._resizingMode >= ResizingMode.TopLeftHandle && this._resizingMode <= ResizingMode.LeftHandle) { this._resizingMode = ResizingMode.None; } if (!annotation.AllowAnchorMoving && this._resizingMode == ResizingMode.AnchorHandle) { this._resizingMode = ResizingMode.None; } if (this._resizingMode == ResizingMode.None && annotation.AllowMoving) { // Annotation moving mode this._resizingMode = ResizingMode.Moving; } } else { if (this._resizingMode == ResizingMode.None && annotation.AllowMoving) { // Do not allow moving child annotations inside the group. // Only the whole group can be selected, resized or repositioned. if (annotation.AnnotationGroup != null) { // Move the group instead lastClickedAnnotation = annotation.AnnotationGroup; } // Annotation moving mode this._resizingMode = ResizingMode.Moving; } } } // Update chart if (updateRequired) { // Invalidate and update the chart this.Chart.Invalidate(true); this.Chart.UpdateAnnotations(); } } }
public static bool ResizingModeToBool(ResizingMode mode) { return mode == ResizingMode.Live; }
public static string FormatUrl(string format, int width, int height, ResizingMode mode = ResizingMode.Crop) { return ($"{Host}{string.Format(format, width, height, GetMode(mode))}"); }
private void MatDWindow_MouseMove(object sender, MouseEventArgs e) { if (IsSelected) { if (!resizingOrDragging) { // Change mouse pointer and resizing mode, depending on position of cursor if (Cursor.Position.X > (Left + Width - dragMargin) && Cursor.Position.Y > (Top + Height - dragMargin)) { Cursor.Current = Cursors.SizeNWSE; resizingMode = ResizingMode.CornerRightBottom; } else if (Cursor.Position.X < (Left + dragMargin) && Cursor.Position.Y > (Top + Height - dragMargin)) { Cursor.Current = Cursors.SizeNESW; resizingMode = ResizingMode.CornerLeftBottom; } else if (Cursor.Position.X > (Left + Width - dragMargin) && Cursor.Position.Y < (Top + dragMargin)) { Cursor.Current = Cursors.SizeNESW; resizingMode = ResizingMode.CornerRightTop; } else if (Cursor.Position.X < (Left + dragMargin) && Cursor.Position.Y < (Top + dragMargin)) { Cursor.Current = Cursors.SizeNWSE; resizingMode = ResizingMode.CornerLeftTop; } else { int middleY1 = Top + Height / 2 - dragMargin / 2; int middleY2 = Top + Height / 2 + dragMargin / 2; int middleX1 = Left + Width / 2 - dragMargin / 2; int middleX2 = Left + Width / 2 + dragMargin / 2; if (Cursor.Position.X > (Left + Width - dragMargin) && Cursor.Position.Y > middleY1 && Cursor.Position.Y < middleY2) { Cursor.Current = Cursors.SizeWE; resizingMode = ResizingMode.WidthRight; } else if (Cursor.Position.X < Left + dragMargin && Cursor.Position.Y > middleY1 && Cursor.Position.Y < middleY2) { Cursor.Current = Cursors.SizeWE; resizingMode = ResizingMode.WidthLeft; } else if (Cursor.Position.Y > (Top + Height - dragMargin) && Cursor.Position.X > middleX1 && Cursor.Position.X < middleX2) { Cursor.Current = Cursors.SizeNS; resizingMode = ResizingMode.HeightBottom; } else if (Cursor.Position.Y < (Top + dragMargin) && Cursor.Position.X > middleX1 && Cursor.Position.X < middleX2) { Cursor.Current = Cursors.SizeNS; resizingMode = ResizingMode.HeightTop; } else { Cursor.Current = Cursors.Arrow; resizingMode = ResizingMode.JustDragging; } } } else // resize or move according to mouse position { int prevWidth = Width; int prevHeight = Height; int prevTop = Top; int prevLeft = Left; int newWidth = prevWidth; int newHeight = prevHeight; bool changeTop = false; bool changeLeft = false; Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint)); // move if (resizingMode == ResizingMode.JustDragging) { Point newLocation = Point.Add(dragFormPoint, new Size(dif)); if (areMovesConstrained()) { if (newLocation.X < minX) { newLocation.X = (int)minX; } if (newLocation.X + Width > maxX) { newLocation.X = (int)maxX - Width; } if (newLocation.Y < minY) { newLocation.Y = (int)minY; } if (newLocation.Y + Height > maxY) { newLocation.Y = (int)maxY - Height; } } Location = newLocation; updateAllFields(); } // resize else { if (resizingMode == ResizingMode.CornerRightBottom) { newWidth = originalWidth + dif.X; newHeight = originalHeight + dif.Y; } else if (resizingMode == ResizingMode.CornerLeftBottom) { newWidth = originalWidth - dif.X; newHeight = originalHeight + dif.Y; changeLeft = true; } else if (resizingMode == ResizingMode.CornerLeftTop) { newWidth = originalWidth - dif.X; newHeight = originalHeight - dif.Y; changeLeft = true; changeTop = true; } else if (resizingMode == ResizingMode.CornerRightTop) { newWidth = originalWidth + dif.X; newHeight = originalHeight - dif.Y; changeTop = true; } else if (resizingMode == ResizingMode.HeightBottom) { newHeight = originalHeight + dif.Y; } else if (resizingMode == ResizingMode.HeightTop) { newHeight = originalHeight - dif.Y; changeTop = true; } else if (resizingMode == ResizingMode.WidthRight) { newWidth = originalWidth + dif.X; } else if (resizingMode == ResizingMode.WidthLeft) { newWidth = originalWidth - dif.X; changeLeft = true; } // constrain size to a minimum newWidth = Math.Max(dragMargin * 3, newWidth); newHeight = Math.Max(dragMargin * 3, newHeight); // aspect ratio locked ? if (lockedAspectRatio) { if (ResizingModeImpactingWidth.Contains(resizingMode)) { newHeight = calculateHeightForAspectRatio(newWidth); newWidth = calculateWidthForAspectRatio(newHeight); } else { newWidth = calculateWidthForAspectRatio(newHeight); } } int newTop = changeTop ? prevTop - (newHeight - prevHeight) : prevTop; int newLeft = changeLeft ? prevLeft - (newWidth - prevWidth) : prevLeft; // check limits; if (areMovesConstrained()) { bool needToAdjustWidth = false; bool needToAdjustHeight = false; bool noOtherConstrainCheck = false; if (changeTop && newTop < (int)minY) { newTop = (int)minY; newHeight = prevHeight + Math.Abs(newTop - prevTop); if (lockedAspectRatio) { needToAdjustWidth = true; noOtherConstrainCheck = true; } } if (!noOtherConstrainCheck && changeLeft && newLeft < (int)minX) { newLeft = (int)minX; newWidth = prevWidth; newWidth = prevWidth + Math.Abs(newLeft - prevLeft); if (lockedAspectRatio) { needToAdjustHeight = true; noOtherConstrainCheck = true; } } if (!noOtherConstrainCheck && !changeTop && newTop + newHeight > (int)maxY) { newHeight = (int)maxY - newTop; if (lockedAspectRatio) { needToAdjustWidth = true; noOtherConstrainCheck = true; } } if (!noOtherConstrainCheck && !changeLeft && newLeft + newWidth > (int)maxX) { newWidth = (int)maxX - newLeft; if (lockedAspectRatio) { needToAdjustHeight = true; noOtherConstrainCheck = true; } } if (needToAdjustHeight) { newHeight = calculateHeightForAspectRatio(newWidth); if (changeTop) { newTop = prevTop - (newHeight - prevHeight); } } if (needToAdjustWidth) { newWidth = calculateWidthForAspectRatio(newHeight); if (changeLeft) { newLeft = prevLeft - (newWidth - prevWidth); } } } // redraw if (newWidth != prevWidth || newHeight != prevHeight) { { Width = newWidth; Height = newHeight; Top = newTop; Left = newLeft; updateAllFields(); } } } } } }
public override void AdjustLocationSize(SizeF movingDistance, ResizingMode resizeMode, bool pixelCoord, bool userInput) { if (resizeMode != ResizingMode.MovingPathPoints) { base.AdjustLocationSize(movingDistance, resizeMode, pixelCoord, userInput); } else { PointF empty = PointF.Empty; PointF empty2 = PointF.Empty; SizeF empty3 = SizeF.Empty; ((Annotation)this).GetRelativePosition(out empty, out empty3, out empty2); if (userInput) { GraphicsPath startMovePathRel = base.startMovePathRel; } if (pixelCoord) { movingDistance = base.GetGraphics().GetRelativeSize(movingDistance); } movingDistance.Width /= (float)(base.startMovePositionRel.Width / 100.0); movingDistance.Height /= (float)(base.startMovePositionRel.Height / 100.0); if (this.path.PointCount > 0) { GraphicsPath graphicsPath = userInput ? base.startMovePathRel : this.path; PointF[] array = graphicsPath.PathPoints; byte[] pathTypes = graphicsPath.PathTypes; RectangleF empty4 = RectangleF.Empty; for (int i = 0; i < array.Length; i++) { if (base.currentPathPointIndex == i || base.currentPathPointIndex < 0 || base.currentPathPointIndex >= array.Length) { array[i].X -= movingDistance.Width; array[i].Y -= movingDistance.Height; } } if (userInput && this.AllowResizing) { this.path.Dispose(); this.path = new GraphicsPath(array, pathTypes); RectangleF bounds = this.path.GetBounds(); bounds.X *= (float)(base.startMovePositionRel.Width / 100.0); bounds.Y *= (float)(base.startMovePositionRel.Height / 100.0); bounds.X += base.startMovePositionRel.X; bounds.Y += base.startMovePositionRel.Y; bounds.Width *= (float)(base.startMovePositionRel.Width / 100.0); bounds.Height *= (float)(base.startMovePositionRel.Height / 100.0); base.SetPositionRelative(bounds, empty2); for (int j = 0; j < array.Length; j++) { array[j].X = (float)(base.startMovePositionRel.X + array[j].X * (base.startMovePositionRel.Width / 100.0)); array[j].Y = (float)(base.startMovePositionRel.Y + array[j].Y * (base.startMovePositionRel.Height / 100.0)); array[j].X = (float)((array[j].X - bounds.X) / (bounds.Width / 100.0)); array[j].Y = (float)((array[j].Y - bounds.Y) / (bounds.Height / 100.0)); } } base.positionChanged = true; this.path.Dispose(); this.path = new GraphicsPath(array, pathTypes); this.pathChanged = true; base.Invalidate(); } } }
internal override void AdjustLocationSize(SizeF movingDistance, ResizingMode resizeMode, bool pixelCoord, bool userInput) { if (resizeMode != ResizingMode.MovingPathPoints) { base.AdjustLocationSize(movingDistance, resizeMode, pixelCoord, userInput); return; } PointF location = PointF.Empty; PointF anchorLocation = PointF.Empty; SizeF size = SizeF.Empty; GetRelativePosition(out location, out size, out anchorLocation); if (userInput) { _ = startMovePathRel; } if (pixelCoord) { movingDistance = GetGraphics().GetRelativeSize(movingDistance); } movingDistance.Width /= startMovePositionRel.Width / 100f; movingDistance.Height /= startMovePositionRel.Height / 100f; if (path.PointCount <= 0) { return; } GraphicsPath obj = userInput ? startMovePathRel : path; PointF[] array = obj.PathPoints; byte[] pathTypes = obj.PathTypes; _ = RectangleF.Empty; for (int i = 0; i < array.Length; i++) { if (currentPathPointIndex == i || currentPathPointIndex < 0 || currentPathPointIndex >= array.Length) { array[i].X -= movingDistance.Width; array[i].Y -= movingDistance.Height; } } if (userInput && AllowResizing) { path.Dispose(); path = new GraphicsPath(array, pathTypes); RectangleF bounds = path.GetBounds(); bounds.X *= startMovePositionRel.Width / 100f; bounds.Y *= startMovePositionRel.Height / 100f; bounds.X += startMovePositionRel.X; bounds.Y += startMovePositionRel.Y; bounds.Width *= startMovePositionRel.Width / 100f; bounds.Height *= startMovePositionRel.Height / 100f; SetPositionRelative(bounds, anchorLocation); for (int j = 0; j < array.Length; j++) { array[j].X = startMovePositionRel.X + array[j].X * (startMovePositionRel.Width / 100f); array[j].Y = startMovePositionRel.Y + array[j].Y * (startMovePositionRel.Height / 100f); array[j].X = (array[j].X - bounds.X) / (bounds.Width / 100f); array[j].Y = (array[j].Y - bounds.Y) / (bounds.Height / 100f); } } positionChanged = true; path.Dispose(); path = new GraphicsPath(array, pathTypes); pathChanged = true; Invalidate(); }