CCT.NUI.Samples.ImageManipulation.InteractiveImage.Resize C# (CSharp) Method

Resize() public method

public Resize ( CCT.NUI.Core.Point startDragPoint, CCT.NUI.Core.Point startDragPoint2, CCT.NUI.Core.Point center1, CCT.NUI.Core.Point center2 ) : void
startDragPoint CCT.NUI.Core.Point
startDragPoint2 CCT.NUI.Core.Point
center1 CCT.NUI.Core.Point
center2 CCT.NUI.Core.Point
return void
        public void Resize(Point startDragPoint, Point startDragPoint2, Point center1, Point center2)
        {
            this.transformation.FindTransformation(startDragPoint, startDragPoint2, center1, center2);
            var newSize = new Size(this.size.Width * transformation.Scale, this.size.Height * transformation.Scale);
            if (transformation.Scale > 1.4 || transformation.Scale < 0.6)
            {
                return;
            }

            this.position.X -= (newSize.Width - this.size.Width) / 2;
            this.position.Y -= (newSize.Height - this.size.Height) / 2;
            this.SetSize(newSize);
        }

Usage Example

 private void HandleResize(Point p1, Point p2)
 {
     if (isResizing)
     {
         hoveredImage.Resize(startDragPoint, startDragPoint2, p1, p2);
     }
     startDragPoint  = p1;
     startDragPoint2 = p2;
 }