Пример #1
0
        protected override void RenderOverride(DrawingContext context)
        {
            // TODO support rotation
            var currentTransform = context.TotalTransform;
            var parentTransform  = layer.Parent.TotalTransform;
            var parentOffsetX    = parentTransform.m31;
            var parentOffsetY    = parentTransform.m32;
            var offsetX          = currentTransform.m31 * (parentTransform.m11 / currentTransform.m11);
            var offsetY          = currentTransform.m32 * (parentTransform.m22 / currentTransform.m22);

            offsetX -= parentOffsetX;
            offsetY -= parentOffsetY;
            control.Arrange(new global::System.Windows.Rect(offsetX, offsetY, Size.Width, Size.Height));
            layer.Parent.OnChildRendered(control);
        }
Пример #2
0
        protected override void OnRender(WpfDrawingContext drawingContext)
        {
            var source = PresentationSource.FromVisual(this);
            var dpix   = (float)source.CompositionTarget.TransformToDevice.M11;
            var dpiy   = (float)source.CompositionTarget.TransformToDevice.M22;

            var skPictureRecorder = new SKPictureRecorder();

            // TODO: Can we restrict the culling rect here?
            SKRect   skCullingRect = SKRect.Create(float.MinValue, float.MinValue, float.MaxValue, float.MaxValue);
            SKCanvas canvas        = skPictureRecorder.BeginRecording(skCullingRect);

            DrawingContext context = new DrawingContext(canvas);

            context.Push(Matrix.Scale(dpix, dpiy));
            RenderLayer(context);
            renderCache = skPictureRecorder.EndRecording();

            if (context.IsVisible)
            {
                if (element != null)
                {
                    element.InvalidateVisual();
                }
                else
                {
                    element = new();
                    element.PaintSurface += Element_PaintSurface;
                    AddVisualChild(element);
                    element.Measure(size);
                    element.Arrange(new(size));
                }
            }

            if (renderedChildren.Count > 0)
            {
                // In some cases children will be removed before measure is called again.
                // Don't update child order unless we're up to date.
                if (children.Count == renderedChildren.Count)
                {
                    children = renderedChildren;
                }
                renderedChildren = new List <UIElement>();
            }

            base.OnRender(drawingContext);
        }
Пример #3
0
 protected abstract void RenderLayer(DrawingContext context);
Пример #4
0
 public void OnRender(DrawingContext drawingContext) => throw new NotImplementedException();