Paint.AppDelegate.NewImage C# (CSharp) Method

NewImage() private method

Start painting a new image
private NewImage ( PictureOrientation orientation ) : void
orientation PictureOrientation /// The orientation of the new image ///
return void
        private void NewImage(PictureOrientation orientation)
        {
            // If the device is still mid turn then the reported width and height may be wrong - hence we are using
            // Math.Max and Math.Min to ensure we get the right size.  [Actually I've delayed the turning until we are
            // ready to display the app  (inside call to EditImage) so it wouldn't have turned yet anyway]
            ImageStateData imageStateData = null;

            int deviceWidth = (int)UIScreen.MainScreen.Bounds.Width * this.deviceScale;
            int deviceHeight = (int)UIScreen.MainScreen.Bounds.Height * this.deviceScale;

            if (orientation == PictureOrientation.Landscape)
            {
                imageStateData = new ImageStateData(Math.Max(deviceHeight, deviceWidth), Math.Min(deviceHeight, deviceWidth), UndoRedoBufferSize);
            }
            else
            {
                imageStateData = new ImageStateData(Math.Min(deviceHeight, deviceWidth), Math.Max(deviceHeight, deviceWidth), UndoRedoBufferSize);
            }

            this.EditImage(Guid.NewGuid(), imageStateData);
        }