コード例 #1
0
ファイル: Effect.cs プロジェクト: prshreshtha/ultraviolet
        /// <summary>
        /// Draws the specified render target at its desired visual bounds.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        /// <param name="effect">The shader effect to apply to the render target, if any.</param>
        public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
        {
            Contract.Require(dc, "dc");
            Contract.Require(element, "element");
            Contract.Require(target, "rtarget");

            if (element.View == null)
                return;

            var state = dc.GetCurrentState();

            dc.End();
            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);
            dc.Draw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }
コード例 #2
0
ファイル: Effect.cs プロジェクト: hayate891/ultraviolet
        /// <summary>
        /// Draws the specified render target at its desired visual bounds.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        /// <param name="effect">The shader effect to apply to the render target, if any.</param>
        public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
        {
            Contract.Require(dc, nameof(dc));
            Contract.Require(element, nameof(element));
            Contract.Require(target, nameof(target));

            if (element.View == null)
            {
                return;
            }

            var state = dc.GetCurrentState();

            dc.End();
            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var position        = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.RawDraw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }