예제 #1
0
 public void ResetClip()
 {
     if (clipLayer != null)
     {
         Control.PopLayer();
         clipLayer.Dispose();
         clipLayer  = null;
         clipBounds = new RectangleF(Control.Size.ToEto());
     }
 }
예제 #2
0
        public void SetClip(IGraphicsPath path)
        {
            ResetClip();
            clipBounds = path.Bounds;
            var parameters = new sd.LayerParameters
            {
                ContentBounds     = clipBounds.ToDx(),
                GeometricMask     = path.ToGeometry(),
                MaskAntialiasMode = Control.AntialiasMode,
                MaskTransform     = s.Matrix3x2.Identity,
                Opacity           = 1f
            };

            clipLayer = new sd.Layer(Control);
            Control.PushLayer(ref parameters, clipLayer);
        }
예제 #3
0
        public void SetClip(RectangleF rect)
        {
            ResetClip();
            clipBounds = rect;
            var parameters = new sd.LayerParameters
            {
                ContentBounds     = clipBounds.ToDx(),
                GeometricMask     = new sd.RectangleGeometry(SDFactory.D2D1Factory, rect.ToDx()),
                MaskAntialiasMode = Control.AntialiasMode,
                MaskTransform     = s.Matrix3x2.Identity,
                Opacity           = 1f
            };

            clipLayer = new sd.Layer(Control);
            Control.PushLayer(ref parameters, clipLayer);
        }
예제 #4
0
        /// <summary>
        /// Creates and pushes a D2D layer if necessary. Returns the layer or null if not required.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="renderTarget">The render target.</param>
        /// <param name="rootElement"></param>
        /// <returns></returns>
        public static D2D.Layer CreateAndPushLayerIfNecessary(this Jupiter.FrameworkElement element, D2D.RenderTarget renderTarget, Jupiter.FrameworkElement rootElement)
        {
            if (element.Opacity >= 1)
                //element.Clip == null &&
                //element.RenderTransform == null)
            {
                return null;
            }

            var layer = new D2D.Layer(renderTarget);
            var layerParameters = new D2D.LayerParameters();
            layerParameters.Opacity = (float)element.Opacity;
            layerParameters.ContentBounds = element.GetBoundingRect(rootElement).ToSharpDX();
            renderTarget.PushLayer(ref layerParameters, layer);

            return layer;
        }
예제 #5
0
        /// <summary>
        /// Creates and pushes a D2D layer if necessary. Returns the layer or null if not required.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="renderTarget">The render target.</param>
        /// <param name="rootElement"></param>
        /// <returns></returns>
        public static D2D.Layer CreateAndPushLayerIfNecessary(this Jupiter.FrameworkElement element, D2D.RenderTarget renderTarget, Jupiter.FrameworkElement rootElement)
        {
            if (element.Opacity >= 1)
            //element.Clip == null &&
            //element.RenderTransform == null)
            {
                return(null);
            }

            var layer           = new D2D.Layer(renderTarget);
            var layerParameters = new D2D.LayerParameters();

            layerParameters.Opacity       = (float)element.Opacity;
            layerParameters.ContentBounds = element.GetBoundingRect(rootElement).ToSharpDX();
            renderTarget.PushLayer(ref layerParameters, layer);

            return(layer);
        }
예제 #6
0
        /// <summary>
        /// Pushes an opacity value.
        /// </summary>
        /// <param name="opacity">The opacity.</param>
        /// <returns>A disposable used to undo the opacity.</returns>
        public IDisposable PushOpacity(double opacity)
        {
            if (opacity < 1)
            {
                var parameters = new LayerParameters
                {
                    ContentBounds = RectangleF.Infinite,
                    MaskTransform = Matrix3x2.Identity,
                    Opacity = (float)opacity,
                };

                var layer = new Layer(this.renderTarget);

                this.renderTarget.PushLayer(ref parameters, layer);

                return Disposable.Create(() =>
                {
                    this.renderTarget.PopLayer();
                });
            }
            else
            {
                return Disposable.Empty;
            }
        }
예제 #7
0
 /// <unmanaged>HRESULT ID2D1CommandSink::PushLayer([In] const D2D1_LAYER_PARAMETERS1* layerParameters1,[In, Optional] ID2D1Layer* layer)</unmanaged>	
 public void PushLayer(ref LayerParameters1 layerParameters1, Layer layer)
 {
     PushLayer_(ref layerParameters1, layer);
 }
 public override void PushOpacity(double opacity)
 {
     Layer layer = new Layer(this.target);
     LayerParameters p = new LayerParameters();
     p.Opacity = (float)opacity;
     this.target.PushLayer(ref p, layer);
     this.stack.Push(layer);
 }
예제 #9
0
 /// <unmanaged>HRESULT ID2D1CommandSink::PushLayer([In] const D2D1_LAYER_PARAMETERS1* layerParameters1,[In, Optional] ID2D1Layer* layer)</unmanaged>
 public void PushLayer(ref LayerParameters1 layerParameters1, Layer layer)
 {
     PushLayer_(ref layerParameters1, layer);
 }