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;
 }
        public BitmapObject(D2D.RenderTarget target, D2D.Bitmap bitmap, Origin origin, Mathe.RawPoint initPosision, bool enableLog = false)
        {
            Target = target;
            Bitmap = bitmap;
            Origin = origin;
#if DEBUG
            _redBrush = new D2D.SolidColorBrush(target, new Mathe.RawColor4(1, 0, 0, 1));
#endif
            _x  = (Static <float>)initPosision.X;
            _y  = (Static <float>)initPosision.Y;
            _f  = (Static <float>) 1;
            _r  = (Static <float>) 0;
            _vx = (Static <float>) 1;
            _vy = (Static <float>) 1;

            // rects
            _w = (Static <float>)bitmap.Size.Width;
            _h = (Static <float>)bitmap.Size.Height;

            _inX = (Static <float>) 0;
            _inY = (Static <float>) 0;
            _inW = (Static <float>)bitmap.Size.Width;
            _inH = (Static <float>)bitmap.Size.Height;

            //origion
            switch (origin.Enum)
            {
            case Origin.OriginEnum.Free:
                _originOffsetX = (origin.X ?? 0) - initPosision.X;
                _originOffsetY = (origin.Y ?? 0) - initPosision.Y;
                break;

            case Origin.OriginEnum.BottomLeft:
                _originOffsetX = 0;
                _originOffsetY = (int)(Height);
                break;

            case Origin.OriginEnum.BottomCentre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = (int)(Height);
                break;

            case Origin.OriginEnum.BottomRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = (int)(Height);
                break;

            case Origin.OriginEnum.CentreLeft:
                _originOffsetX = 0;
                _originOffsetY = (int)(Height / 2);
                break;

            case Origin.OriginEnum.Centre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = (int)(Height / 2);
                break;

            case Origin.OriginEnum.CentreRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = (int)(Height / 2);
                break;

            case Origin.OriginEnum.TopLeft:
                _originOffsetX = 0;
                _originOffsetY = 0;
                break;

            case Origin.OriginEnum.TopCentre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = 0;
                break;

            case Origin.OriginEnum.TopRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = 0;
                break;
            }

            EnableLog = enableLog;
        }
 public BitmapObject Reset(Origin origin, Mathe.RawPoint posision) =>
 new BitmapObject(Target, Bitmap, origin, posision, EnableLog);
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>
 /// <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 #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>
 /// <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 #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>
 /// <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 #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>
 /// <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 #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
        public BitmapInstance(D2D.RenderTarget target, D2D.Bitmap bitmap, OriginType origin, Mathe.RawPoint initPosision, Stopwatch sw,
                              bool enableLog = false)
        {
            _target = target;
            _bitmap = bitmap;
            Origin  = origin;
#if DEBUG
            _redBrush = new D2D.SolidColorBrush(target, new Mathe.RawColor4(1, 0, 0, 1));
#endif
            _x  = (Static <float>)initPosision.X;
            _y  = (Static <float>)initPosision.Y;
            _f  = (Static <float>) 1;
            _r  = (Static <float>) 0;
            _vx = (Static <float>) 1;
            _vy = (Static <float>) 1;

            // rects
            _w = (Static <float>)bitmap.Size.Width;
            _h = (Static <float>)bitmap.Size.Height;

            _inX = (Static <float>) 0;
            _inY = (Static <float>) 0;
            _inW = (Static <float>)bitmap.Size.Width;
            _inH = (Static <float>)bitmap.Size.Height;

            //origion
            switch (origin)
            {
            //case OriginType.Free:
            //    _originOffsetX = (origin.X ?? 0) - initPosision.X;
            //    _originOffsetY = (origin.Y ?? 0) - initPosision.Y;
            //    break;
            case OriginType.BottomLeft:
                _originOffsetX = 0;
                _originOffsetY = (int)(Height);
                break;

            case OriginType.BottomCentre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = (int)(Height);
                break;

            case OriginType.BottomRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = (int)(Height);
                break;

            case OriginType.CentreLeft:
                _originOffsetX = 0;
                _originOffsetY = (int)(Height / 2);
                break;

            case OriginType.Centre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = (int)(Height / 2);
                break;

            case OriginType.CentreRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = (int)(Height / 2);
                break;

            case OriginType.TopLeft:
                _originOffsetX = 0;
                _originOffsetY = 0;
                break;

            case OriginType.TopCentre:
                _originOffsetX = (int)(Width / 2);
                _originOffsetY = 0;
                break;

            case OriginType.TopRight:
                _originOffsetX = (int)(Width);
                _originOffsetY = 0;
                break;
            }

            if (sw != null)
            {
                _watch         = sw;
                _useInnerWatch = false;
            }
            else
            {
                _watch = new Stopwatch();
            }

            _enableLog = enableLog;
        }
Exemple #11
0
 public BitmapInstance(D2D.RenderTarget target, D2D.Bitmap bitmap, OriginType origin, Mathe.RawPoint initPosision,
                       bool enableLog = false) : this(target, bitmap, origin, initPosision, null, enableLog)
 {
 }
Exemple #12
0
 public BitmapInstance Reset(OriginType origin, Mathe.RawPoint posision) =>
 new BitmapInstance(_target, _bitmap, origin, posision, _enableLog);
Exemple #13
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);
 }
 public StringObject(RenderTarget target, Bitmap bitmap, Origin origin, Mathe.RawPoint initPosision, bool enableLog = false)
     : base(target, bitmap, origin, initPosision, enableLog)
 {
 }
 public StringObject(RenderTarget target, string words, Gdip.Font font, Gdip.Brush brush, Origin origin,
                     Mathe.RawPoint initPosision, bool enableLog = false)
     : base(target, GetStringBitmap(target, words, font, brush), origin, initPosision, enableLog)
 {
 }
 /// <inheritdoc/>
 public void Draw(SharpDX.Direct2D1.Bitmap1 target, RawRectangle drawRect, RawPoint targetOrigin)
 {
     Draw_(target, drawRect, targetOrigin);
 }