Esempio n. 1
0
        /// <summary>Sets how many pixels of space this renderer has. The actual world space size is dictated by this and
        /// <see cref="PowerUI.WorldUI.SetResolution"/>. The amount of pixels and pixels per world unit (resolution).</summary>
        /// <param name="widthPX">The width in pixels.</param>
        /// <param name="heightPX">The height in pixels.</param>
        public virtual bool SetDimensions(int widthPX, int heightPX)
        {
            if (widthPX == pixelWidth && heightPX == pixelHeight)
            {
                return(false);
            }

            // Inform media rules if we have any too:
            var media = document.MediaIfExists;

            // Resize:
            if (widthPX != pixelWidth)
            {
                pixelWidth = widthPX;
                document.Viewport.Width = widthPX;

                if (media != null)
                {
                    // Nudge it!
                    media.Width = widthPX;
                }
            }

            if (heightPX != pixelHeight)
            {
                pixelHeight              = heightPX;
                PixelHeightF             = (float)pixelHeight;
                document.Viewport.Height = heightPX;

                if (media != null)
                {
                    // Nudge it!
                    media.Height = heightPX;
                }
            }

            // Update ratio:
            Ratio = (float)pixelWidth / PixelHeightF;

            // Reset the origin position:
            SetOrigin(OriginLocation.x, OriginLocation.y);

            // Fire the resize event:
            if (document.body != null)
            {
                Dom.Event e = new Dom.Event("resize");
                e.SetTrusted();
                document.dispatchEvent(e);
            }

            // Request a layout too:
            document.RequestLayout();

            return(true);
        }
Esempio n. 2
0
        /// <summary>Sets how many pixels of space this renderer has. The actual world space size is dictated by this and
        /// <see cref="PowerUI.WorldUI.SetResolution"/>. The amount of pixels and pixels per world unit (resolution).</summary>
        /// <param name="widthPX">The width in pixels.</param>
        /// <param name="heightPX">The height in pixels.</param>
        public virtual bool SetDimensions(int widthPX, int heightPX)
        {
            if (widthPX == pixelWidth && heightPX == pixelHeight)
            {
                return(false);
            }

            if (widthPX != pixelWidth)
            {
                pixelWidth = widthPX;
                document.Viewport.Width = widthPX;
            }

            if (heightPX != pixelHeight)
            {
                pixelHeight              = heightPX;
                PixelHeightF             = (float)pixelHeight;
                document.Viewport.Height = heightPX;
            }

            // Update ratio:
            Ratio = (float)pixelWidth / PixelHeightF;

            // Reset the origin position:
            SetOrigin(OriginLocation.x, OriginLocation.y);

            // Fire the resize event:
            if (document.body != null)
            {
                Dom.Event e = new Dom.Event("resize");
                e.SetTrusted();
                document.dispatchEvent(e);
            }

            return(true);
        }