public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref RawPoint pptDst, ref RawSize psize, IntPtr hdcSrc, ref RawPoint pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
Exemple #2
0
 private unsafe static int DrawImpl(IntPtr thisPtr, IntPtr target, IntPtr drawRect, RawPoint targetOrigin)
 {
     try
     {
         var shadow   = ToShadow <SourceTransformShadow>(thisPtr);
         var callback = (SourceTransform)shadow.Callback;
         callback.Draw(new Bitmap1(target), *(RawRectangle *)drawRect, targetOrigin);
     }
     catch (Exception exception)
     {
         return((int)SharpDX.Result.GetResultFromException(exception));
     }
     return(Result.Ok.Code);
 }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bitmap">
        ///
        /// </param>
        /// <param name="opacity">
        /// Specifies an alpha transparency value to be used on the entire source
        /// bitmap. The SourceConstantAlpha value is combined with any per-pixel
        /// alpha values in the source bitmap. The value ranges from 0 to 255. If
        /// you set SourceConstantAlpha to 0, it is assumed that your image is
        /// transparent. When you only want to use per-pixel alpha values, set
        /// the SourceConstantAlpha value to 255 (opaque).
        /// </param>
        public void SelectBitmap(Bitmap bitmap, int opacity)
        {
            if (bitmap == null)
            {
                return;
            }

            // Does this bitmap contain an alpha channel?
            if (bitmap.PixelFormat != PixelFormat.Format32bppArgb && bitmap.PixelFormat != PixelFormat.Format32bppPArgb)
            {
                throw new ApplicationException("The bitmap must be 32bpp with alpha-channel.");
            }

            // Get device contexts
            IntPtr screenDc   = GetDC(IntPtr.Zero);
            IntPtr memDc      = CreateCompatibleDC(screenDc);
            IntPtr hBitmap    = IntPtr.Zero;
            IntPtr hOldBitmap = IntPtr.Zero;

            try
            {
                // Get handle to the new bitmap and select it into the current
                // device context.
                hBitmap    = bitmap.GetHbitmap(Color.FromArgb(0));
                hOldBitmap = SelectObject(memDc, hBitmap);

                // Set parameters for layered window update.
                RawSize       newSize        = new RawSize(bitmap.Width, bitmap.Height);
                RawPoint      sourceLocation = new RawPoint(0, 0);
                RawPoint      newLocation    = new RawPoint(this.Left, this.Top);
                BLENDFUNCTION blend          = new BLENDFUNCTION();
                blend.BlendOp             = AC_SRC_OVER;
                blend.BlendFlags          = 0;
                blend.SourceConstantAlpha = (byte)opacity;
                blend.AlphaFormat         = AC_SRC_ALPHA;

                // Update the window.
                UpdateLayeredWindow(
                    this.Handle,        // Handle to the layered window
                    screenDc,           // Handle to the screen DC
                    ref newLocation,    // New screen position of the layered window
                    ref newSize,        // New size of the layered window
                    memDc,              // Handle to the layered window surface DC
                    ref sourceLocation, // Location of the layer in the DC
                    0,                  // Color key of the layered window
                    ref blend,          // Transparency of the layered window
                    ULW_ALPHA           // Use blend as the blend function
                    );
            }
            finally
            {
                // Release device context.
                ReleaseDC(IntPtr.Zero, screenDc);
                if (hBitmap != IntPtr.Zero)
                {
                    SelectObject(memDc, hOldBitmap);
                    DeleteObject(hBitmap);
                }
                DeleteDC(memDc);
            }
        }
Exemple #4
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <param name="transform">The transform to apply to the stroked geometry.  </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(RawPoint point, float strokeWidth, StrokeStyle strokeStyle, RawMatrix3x2 transform)
 {
     return StrokeContainsPoint(point, strokeWidth, strokeStyle, transform, FlatteningTolerance);
 }
Exemple #5
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <param name="transform">The transform to apply to the stroked geometry.  </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the stroke by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(RawPoint point, float strokeWidth, StrokeStyle strokeStyle, RawMatrix3x2 transform, float flatteningTolerance)
 {
     return StrokeContainsPoint(new RawVector2 { X = point.X, Y = point.Y}, strokeWidth, strokeStyle, transform, flatteningTolerance);
 }
Exemple #6
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(RawPoint point, float strokeWidth)
 {
     return StrokeContainsPoint(point, strokeWidth, null);
 }
Exemple #7
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(RawPoint point, float strokeWidth, StrokeStyle strokeStyle)
 {
     return StrokeContainsPoint(new RawVector2 { X = point.X, Y = point.Y }, strokeWidth, strokeStyle);
 }
Exemple #8
0
 /// <summary>	
 /// Indicates whether the area filled by the geometry would contain the specified point given the specified flattening tolerance. 	
 /// </summary>	
 /// <param name="point">The point to test. </param>
 /// <param name="worldTransform">The transform to apply to the geometry prior to testing for containment, or NULL. </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the fill by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution.  </param>
 /// <returns>When this method returns, contains a bool value that is true if the area filled by the geometry contains point; otherwise, false.You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::FillContainsPoint([None] D2D1_POINT_2F point,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool FillContainsPoint(RawPoint point, RawMatrix3x2 worldTransform, float flatteningTolerance)
 {
     return FillContainsPoint(new RawVector2 {X = point.X, Y = point.Y}, worldTransform, flatteningTolerance);
 }
Exemple #9
0
 /// <summary>	
 /// Indicates whether the area filled by the geometry would contain the specified point given the specified flattening tolerance. 	
 /// </summary>	
 /// <param name="point">The point to test. </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the fill by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution.  </param>
 /// <returns>When this method returns, contains a bool value that is true if the area filled by the geometry contains point; otherwise, false.You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::FillContainsPoint([None] D2D1_POINT_2F point,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool FillContainsPoint(RawPoint point, float flatteningTolerance)
 {
     return FillContainsPoint(new RawVector2 { X = point.X, Y = point.Y}, null, flatteningTolerance);
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of <see cref="OffsetTransform"/> class
 /// </summary>
 /// <param name="context">The effect context</param>
 /// <param name="offset">The offset transformation</param>
 /// <unmanaged>HRESULT ID2D1EffectContext::CreateOffsetTransform([In] POINT offset,[Out, Fast] ID2D1OffsetTransform** transform)</unmanaged>
 public OffsetTransform(EffectContext context, RawPoint offset) : base(IntPtr.Zero)
 {
     context.CreateOffsetTransform(offset, this);
 }
Exemple #11
0
 bool IsInRect(RawPoint aPoint)
 {
     return(_rect.xMin < aPoint.x && aPoint.x < _rect.xMax &&
            _rect.yMin < aPoint.y && aPoint.y < _rect.yMax);
 }
Exemple #12
0
 /// <inheritdoc/>
 public void Draw(SharpDX.Direct2D1.Bitmap1 target, RawRectangle drawRect, RawPoint targetOrigin)
 {
     Draw_(target, drawRect, targetOrigin);
 }