当前位置: 首页>>代码示例>>C#>>正文


C# DrawingContext.GetCurrentState方法代码示例

本文整理汇总了C#中DrawingContext.GetCurrentState方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.GetCurrentState方法的具体用法?C# DrawingContext.GetCurrentState怎么用?C# DrawingContext.GetCurrentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DrawingContext的用法示例。


在下文中一共展示了DrawingContext.GetCurrentState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        /// <inheritdoc/>
        protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var state = dc.GetCurrentState();
            
            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.End();

            effect.Value.Radius = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

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

            var shadowTexture = target.Next.ColorBuffer;
            dc.Draw(shadowTexture, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            
            dc.End();
            dc.Begin(state);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:21,代码来源:BlurEffect.cs

示例2: DrawRenderTargetAtVisualBounds

        /// <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);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:28,代码来源:Effect.cs

示例3: DrawCore

        /// <inheritdoc/>
        protected override void DrawCore(UltravioletTime time, DrawingContext dc)
        {
            if (clonedElement != null)
            {
                var dcState = dc.GetCurrentState();
                dc.End();

                var offsetRaw = Display.DipsToPixels(clonedElement.UntransformedAbsoluteBounds.Location - clonedElement.UntransformedRelativeBounds.Location);
                var offsetX = dc.IsTransformed ? offsetRaw.X : Math.Round(offsetRaw.X, MidpointRounding.AwayFromZero);
                var offsetY = dc.IsTransformed ? offsetRaw.Y : Math.Round(offsetRaw.Y, MidpointRounding.AwayFromZero);
                var offset = new Vector2((Single)offsetX, (Single)offsetY);

                var mtxTransform = Matrix.CreateTranslation(-offset.X, -offset.Y, 0);
                var mtxTransformToView = GetTransformToViewMatrix(true);
                var mtxTransformGlobal = dcState.GlobalTransform;
                Matrix.Concat(ref mtxTransform, ref mtxTransformToView, out mtxTransform);
                Matrix.Concat(ref mtxTransform, ref mtxTransformGlobal, out mtxTransform);

                if (!dc.IsTransformed && !clonedElement.HasNonIdentityTransform)
                {
                    mtxTransform = new Matrix(
                        mtxTransform.M11, mtxTransform.M12, mtxTransform.M13, (Single)Math.Round(mtxTransform.M14, MidpointRounding.AwayFromZero),
                        mtxTransform.M21, mtxTransform.M22, mtxTransform.M23, (Single)Math.Round(mtxTransform.M24, MidpointRounding.AwayFromZero),
                        mtxTransform.M31, mtxTransform.M32, mtxTransform.M33, (Single)Math.Round(mtxTransform.M34, MidpointRounding.AwayFromZero),
                        mtxTransform.M41, mtxTransform.M42, mtxTransform.M43, mtxTransform.M44);
                }

                dc.IsOutOfBandRenderingSuppressed = true;
                dc.GlobalTransform = mtxTransform;

                dc.Begin(Graphics.Graphics2D.SpriteSortMode.Deferred, null, Matrix.Identity);
                clonedElement.Draw(null, dc);
                dc.End();

                dc.IsOutOfBandRenderingSuppressed = false;
                dc.Begin(dcState);
            }

            base.DrawCore(time, dc);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:41,代码来源:VisualClone.cs


注:本文中的DrawingContext.GetCurrentState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。