Smartmobili.Cocoa.NSView.SetBounds C# (CSharp) Method

SetBounds() public method

public SetBounds ( NSRect aRect ) : void
aRect NSRect
return void
        public virtual void SetBounds(NSRect aRect)
        {
            //NSDebugLLog(@"NSView", @"setBounds %@", NSStringFromRect(aRect));
            if (aRect.Size.Width < 0)
            {
                //NSWarnMLog(@"given negative width", 0);
                //aRect.Size.Width = 0;
                aRect.Size = NS.MakeSize(0, aRect.Size.Height);
            }
            if (aRect.Size.Height < 0)
            {
                //NSWarnMLog(@"given negative height", 0);
                //aRect.Size.Height = 0;
                aRect.Size = NS.MakeSize(aRect.Size.Width, 0);
            }

            if (_is_rotated_from_base || (NS.EqualRects(_bounds, aRect) == false))
            {
                NSAffineTransform matrix;
                NSPoint oldOrigin;
                NSSize scale;

                if (_boundsMatrix == null)
                {
                    _boundsMatrix = (NSAffineTransform)NSAffineTransform.Alloc().Init();
                }

                // Adjust scale
                scale = _computeScale(_frame.Size, aRect.Size);
                if (scale.Width != 1 || scale.Height != 1)
                {
                    _is_rotated_or_scaled_from_base = true;
                }
                _boundsMatrix.ScaleTo(scale.Width, scale.Height);
                {
                    matrix = (NSAffineTransform)_boundsMatrix.Copy();
                    matrix.Invert();
                    oldOrigin = matrix.TransformPoint(NS.MakePoint(0, 0));
                    //RELEASE(matrix);
                }
                _boundsMatrix.TranslateXByYBy(oldOrigin.X - aRect.Origin.X, oldOrigin.Y - aRect.Origin.Y);
                if (!_is_rotated_from_base)
                {
                    // Adjust bounds
                    _bounds = aRect;
                }
                else
                {
                    // Adjust bounds
                    NSRect frame = _frame;

                    frame.Origin = NS.MakePoint(0, 0);
                    matrix = (NSAffineTransform)_boundsMatrix.Copy();
                    matrix.Invert();
                    matrix.BoundingRectFor(frame, ref _bounds);
                    //RELEASE(matrix);
                }

                if (_coordinates_valid)
                {
                    //FIXME
                    //(*invalidateImp)(self, invalidateSel);
                }
                this.ResetCursorRects();
                if (_post_bounds_changes)
                {
                    //[nc postNotificationName: NSViewBoundsDidChangeNotification object: self];
                }
            }
        }
NSView