Ejemplo n.º 1
0
        public BgDxLayer(D2D.RenderTarget renderTarget, DxLoadObject settings, OsuModel osuModel)
            : base(renderTarget, settings, osuModel)
        {
            _status = OsuModel.Status;
            string defName   = "default.png";
            string covName   = "cover.png";
            var    defBgPath = Path.Combine(OsuLivePlayerPlugin.GeneralConfig.WorkPath, defName);
            var    covBgPath = Path.Combine(OsuLivePlayerPlugin.GeneralConfig.WorkPath, covName);

            if (File.Exists(defBgPath))
            {
                _defaultBg = renderTarget.LoadBitmap(defBgPath);
            }
            else
            {
                LogUtil.LogError($"Can not find \"{defName}\"");
            }

            if (File.Exists(covBgPath))
            {
                _coverBg = renderTarget.LoadBitmap(covBgPath);
            }
            else
            {
                LogUtil.LogError($"Can not find \"{covName}\"");
            }

            var size = Settings.Render.WindowSize;

            _windowRect = new Mathe.RawRectangleF(0, 0, size.Width, size.Height);
        }
Ejemplo n.º 2
0
        public override void Measure() //todo: Will lead to NullReferenceException when recreated window on some maps: s/552702
        {
            if (!_isStart && _status != OsuModel.Status)
            {
                _isStart = true;
            }

            if (!_isStart)
            {
                return;
            }

            if (_currentMapPath != OsuModel.Idle.NowMap.Folder)
            {
                _currentMapPath = OsuModel.Idle.NowMap.Folder;
                var currentBgPath = Path.Combine(_currentMapPath, OsuModel.Idle.NowMap.BackgroundFilename);

                if (File.Exists(currentBgPath))
                {
                    _oldBg        = _newBg;
                    _newBg        = RenderTarget.LoadBitmap(currentBgPath);
                    _lastBgIsNull = false;
                }
                else if (_defaultBg != null)
                {
                    if (_lastBgIsNull)
                    {
                        return;
                    }
                    _oldBg        = _newBg;
                    _newBg        = _defaultBg;
                    _lastBgIsNull = true;
                }
                else
                {
                    return;
                }

                _fixedRectOld = _fixedRect;

                _fixedRect = GetBgPosition(_newBg.Size);
                var size = Settings.Render.WindowSize;
                if (_newBg != null)
                {
                    _newBgObj = new BitmapObject(RenderTarget, _newBg, Origin.Default,
                                                 new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                }
                if (_oldBg != null)
                {
                    _oldBgObj = new BitmapObject(RenderTarget, _oldBg, Origin.Default,
                                                 new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                }
                _transformStyle = _rnd.Next(0, 3);
                if (sw.ElapsedMilliseconds < 600 && sw.ElapsedMilliseconds != 0)
                {
                    _transformStyle = 99;
                }
                sw.Restart();
            }
        }
Ejemplo n.º 3
0
        public void OnClicked(MouseEventArgs e, Mathe.RawRectangleF recF)
        {
            if (!_isBoxing)
            {
                _selectedRec = recF;


                if (!_boardMap.Keys.Contains(recF))
                {
                    return;
                }

                int i = _boardMap[recF];
                Debug.WriteLine(i);
                ShowBox(e, recF, i);
            }
            else
            {
                Rectangles = _tmpRectangles.ToArray().ToList();
                _tmpRectangles.Clear();
                _boxBitmap = null;
                _boxRec    = default;
                _isBoxing  = false;
            }
        }
Ejemplo n.º 4
0
        private void DrawEntityGrenade(float x, float y, float distance, int ClassID, string Model)
        {
            float width  = 20;
            float height = 30;

            x -= width / 2;
            y -= 4500 / distance;

            DrawTypes.RawRectangleF ImageArea = new DrawTypes.RawRectangleF(x, y, x + width, y + height);
            switch (ClassID)
            {
            case (int)BHelper.AcceptedGrenadeIDS.CSmokeGrenadeProjectile:
                device.DrawBitmap(bmGrenadeSmoke, ImageArea, 1.0f, BitmapInterpolationMode.Linear);
                break;

            case (int)BHelper.AcceptedGrenadeIDS.CBaseCSGrenadeProjectile:
                if (Model.Contains("flash"))
                {
                    device.DrawBitmap(bmGrenadeFlashbang, ImageArea, 1.0f, BitmapInterpolationMode.Linear);
                }
                else
                {
                    device.DrawBitmap(bmGrenadeHE, ImageArea, 1.0f, BitmapInterpolationMode.Linear);
                }
                break;

            case (int)BHelper.AcceptedGrenadeIDS.CDecoyProjectile:
                device.DrawBitmap(bmGrenadeDecoy, ImageArea, 1.0f, BitmapInterpolationMode.Linear);
                break;

            case (int)BHelper.AcceptedGrenadeIDS.CMolotovProjectile:
                device.DrawBitmap(bmGrenadeMolotov, ImageArea, 1.0f, BitmapInterpolationMode.Linear);
                break;
            }
        }
Ejemplo n.º 5
0
 internal ComplexLayer(D2D1.RenderTarget target, ref DXM.RawRectangleF clipBounds, D2D1.Geometry geometryPath,
                       float opacity)
 {
     _target   = target;
     _geometry = geometryPath;
     target.PushLayer(clipBounds, geometryPath, opacity);
 }
Ejemplo n.º 6
0
        public static IDisposable Create(D2D1.RenderTarget target, PxSize size, float opacity)
        {
            var bounds = new DXM.RawRectangleF(0, 0, size.Width, size.Height);

            return(opacity < 1f
        ? new ComplexLayer(target, ref bounds, null, opacity)
        : new SimpleLayer(target, ref bounds) as IDisposable);
        }
Ejemplo n.º 7
0
        } // Draw()

        /// <summary>
        /// desenha um texto. Há que ter os métodos Begin() e End() para efetivar a renderização.
        /// </summary>
        public void Draw(vetor2 location, float opacity, RawRectangleF rectSource)
        {
            SetMatrixTranslation(location); // a coisa mais certa é setar a matriz transform do RenderTarget, e depois setar a transform para Identity.

            MyDevice2D.render[this.idRender].DrawBitmap(this.imageDirect2D, 1.0f, BitmapInterpolationMode.Linear, rectSource);

            SetMatrixIdentity();// restaura a matriz identidade , para a matriz transform do RenderTarget.
        } // Draw()
Ejemplo n.º 8
0
 static PrimitiveExtensions()
 {
     RectangleInfinite = new RawRectangleF
     {
         Left = float.NegativeInfinity,
         Top = float.NegativeInfinity,
         Right = float.PositiveInfinity,
         Bottom = float.PositiveInfinity
     };
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LayerParameters1"/> struct.
 /// </summary>
 /// <param name="contentBounds">The content bounds.</param>
 /// <param name="geometryMask">The geometry mask.</param>
 /// <param name="maskAntialiasMode">The mask antialias mode.</param>
 /// <param name="maskTransform">The mask transform.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="opacityBrush">The opacity brush.</param>
 /// <param name="layerOptions">The layer options.</param>
 public LayerParameters1(RawRectangleF contentBounds, Geometry geometryMask, AntialiasMode maskAntialiasMode, RawMatrix3x2 maskTransform, float opacity, Brush opacityBrush, LayerOptions1 layerOptions)
     : this()
 {
     ContentBounds = contentBounds;
     geometricMask_ = geometryMask.NativePointer;
     MaskAntialiasMode = maskAntialiasMode;
     MaskTransform = maskTransform;
     Opacity = opacity;
     opacityBrush_ = opacityBrush.NativePointer;
     LayerOptions = layerOptions;
 }
Ejemplo n.º 10
0
        public static IDisposable Create(RendererDirect2D render, IElement element, IFrameContext context, PxSize clipSize)
        {
            var clip = new DXM.RawRectangleF(0f, 0f, clipSize.Width, clipSize.Height);

            return(Create(
                       render.Target,
                       render.GetClipGeometry(element, context, element.GetClipPath()),
                       element.GetOpacity(),
                       true,
                       ref clip
                       ));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// todo: Still have bugs.
        /// </summary>
        public void FreeCutRect(EasingEnum easingEnum, int startTime, int endTime, Mathe.RawRectangleF startRect,
                                Mathe.RawRectangleF endRect)
        {
            if (_inRectTime.Max == int.MaxValue || endTime > _inRectTime.Max)
            {
                _inRectTime.Max = endTime;
                _inX.Target     = endRect.Left;
                _inY.Target     = endRect.Top;
                _inW.Target     = endRect.Right - endRect.Left;
                _inH.Target     = endRect.Bottom - endRect.Top;
            }

            if (_inRectTime.Min == int.MinValue || startTime < _inRectTime.Min)
            {
                _inRectTime.Min = startTime;
                _inX.Source     = startRect.Left;
                _inY.Source     = startRect.Top;
                _inW.Source     = startRect.Right - startRect.Left;
                _inH.Source     = startRect.Bottom - startRect.Top;
            }

            float ms = _watch.ElapsedMilliseconds;

            if (!IsFinished && ms <= _inRectTime.Min)
            {
                _inX.RealTimeToSource();
                _inY.RealTimeToSource();
                _inW.RealTimeToSource();
                _inH.RealTimeToSource();
            }

            if (!IsFinished && ms >= startTime && ms <= endTime)
            {
                var t = (ms - startTime) / (endTime - startTime);
                _inX.RealTime = startRect.Left + (float)easingEnum.Ease(t) * (endRect.Left - startRect.Left);
                _inY.RealTime = startRect.Top + (float)easingEnum.Ease(t) * (endRect.Top - startRect.Top);
                float r = startRect.Right + (float)easingEnum.Ease(t) * (endRect.Right - startRect.Right);
                float b = startRect.Bottom + (float)easingEnum.Ease(t) * (endRect.Bottom - startRect.Bottom);
                _inW.RealTime = r - _inX.RealTime;
                _inH.RealTime = b - _inY.RealTime;
            }

            if (ms >= _inRectTime.Max)
            {
                _inX.RealTimeToTarget();
                _inY.RealTimeToTarget();
                _inW.RealTimeToTarget();
                _inH.RealTimeToTarget();
            }
        }
Ejemplo n.º 12
0
        private static bool IsInRecs(MouseEventArgs e, ILayer layer, out Mathe.RawRectangleF recF)
        {
            foreach (var item in layer.Rectangles)
            {
                if (e.X >= item.Left && e.X <= item.Right && e.Y >= item.Top && e.Y <= item.Bottom)
                {
                    recF = item;
                    return(true);
                }
            }

            recF = default;
            return(false);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Do not use with any MOVE or any SCALE at same time!
        /// </summary>
        public void FreeRect(EasingType easingEnum, int startTime, int endTime, Mathe.RawRectangleF startRect,
                             Mathe.RawRectangleF endRect)
        {
            if (_movTime.Max == int.MaxValue || endTime > _movTime.Max)
            {
                _movTime.Max = endTime;
                _x.Target    = endRect.Left;
                _y.Target    = endRect.Top;
                _w.Target    = endRect.Right - endRect.Left;
                _h.Target    = endRect.Bottom - endRect.Top;
            }

            if (_movTime.Min == int.MinValue || startTime < _movTime.Min)
            {
                _movTime.Min = startTime;
                _x.Source    = startRect.Left;
                _y.Source    = startRect.Top;
                _w.Source    = startRect.Right - startRect.Left;
                _h.Source    = startRect.Bottom - startRect.Top;
            }

            float ms = Offset;

            if (!IsFinished && ms <= _movTime.Min)
            {
                _x.RealTimeToSource();
                _y.RealTimeToSource();
                _w.RealTimeToSource();
                _h.RealTimeToSource();
            }

            if (!IsFinished && ms >= startTime && ms <= endTime)
            {
                var t = (ms - startTime) / (endTime - startTime);
                _x.RealTime = startRect.Left + (float)easingEnum.Ease(t) * (endRect.Left - startRect.Left);
                _y.RealTime = startRect.Top + (float)easingEnum.Ease(t) * (endRect.Top - startRect.Top);
                float r = startRect.Right + (float)easingEnum.Ease(t) * (endRect.Right - startRect.Right);
                float b = startRect.Bottom + (float)easingEnum.Ease(t) * (endRect.Bottom - startRect.Bottom);
                _w.RealTime = r - _x.RealTime;
                _h.RealTime = b - _y.RealTime;
            }

            if (ms >= _movTime.Max)
            {
                _x.RealTimeToTarget();
                _y.RealTimeToTarget();
                _w.RealTimeToTarget();
                _h.RealTimeToTarget();
            }
        }
Ejemplo n.º 14
0
        } // Draw()

        /// <summary>
        /// desenha um texto. Há que ter os métodos Begin() e End() para efetivar a renderização.
        /// </summary>
        public void Draw(string texto, RectangleF rectDEstiny, Color cor, Font fonte)
        {
            // a coisa mais certa é setar a matriz transform do RenderTarget, e depois setar a transform para Identity.
            SetMatrixTranslation(new vetor2(rectDEstiny.Left, rectDEstiny.Top));

            rectDEstiny.Left = 0;
            rectDEstiny.Top  = 0;

            SharpDX.DirectWrite.TextFormat format = new SharpDX.DirectWrite.TextFormat(MyDevice2D.FactoryDirectWrite, "Arial", fonte.Size); // "formato" do texto a ser desenhado.

            SolidColorBrush brush = new SolidColorBrush(MyDevice2D.render[this.idRender], new RawColor(cor.R, cor.G, cor.B, cor.A));        // "brush" para o desenho.


            MyDevice2D.render[this.idRender].DrawText(texto, format, rectDEstiny, brush);  // desenha o texto


            SetMatrixIdentity();// restaura a matriz identidade , para a matriz transform do RenderTarget.
        } // DrawText()
Ejemplo n.º 15
0
        public static void PushLayer(
            this D2D1.RenderTarget target,
            DXM.RawRectangleF clipBounds,
            D2D1.Geometry geometryPath,
            float opacity)
        {
            var layerParameters = new D2D1.LayerParameters()
            {
                GeometricMask = geometryPath,
                MaskTransform = Identity,
                ContentBounds = clipBounds,
                LayerOptions  = D2D1.LayerOptions.None,
                Opacity       = opacity,
                OpacityBrush  = null
            };

            target.PushLayer(ref layerParameters, null);
        }
Ejemplo n.º 16
0
        private void DrawPlayerHealth(float x, float y, float distance, float value)
        {
            float width  = 2000 / distance;
            float height = 55000 / distance;

            float offsetX = 5000 / distance;
            float offsetY = offsetX / 2;

            x += (20000 / distance) / 2;
            y -= 4500 / distance;
            x += offsetX;
            y += offsetY;

            DrawTypes.RawRectangleF espHealthRectRed = new DrawTypes.RawRectangleF(x, y, x + width, y + height);
            device.FillRectangle(espHealthRectRed, brushSolidRed);

            DrawTypes.RawRectangleF espHealthRectGreen = new DrawTypes.RawRectangleF(x, y, x + width, y + ((height / 100) * value));
            device.FillRectangle(espHealthRectGreen, brushSolidGreen);
        }
Ejemplo n.º 17
0
 public void OnClicked(MouseEventArgs e, Mathe.RawRectangleF recF)
 {
 }
Ejemplo n.º 18
0
 /// <summary>	
 ///  Creates an <see cref="SharpDX.Direct2D1.RectangleGeometry"/>. 	
 /// </summary>	
 /// <param name="factory">an instance of <see cref = "SharpDX.Direct2D1.Factory" /></param>
 /// <param name="rectangle">The coordinates of the rectangle geometry. </param>
 public RectangleGeometry(Factory factory, RawRectangleF rectangle)
     : base(IntPtr.Zero)
 {
     factory.CreateRectangleGeometry(rectangle, this);
 }
        public void DrawBarV(int x, int y, int width, int height, float value, float stroke, int brush, int interiorBrush)
        {
            var first = new RawRectangleF(x, y, x + width, y + height);

            _device.DrawRectangle(first, _brushContainer[brush], stroke);

            if (value == 0)
                return;

            first.Right -= width - (width / 100.0f * value);

            _device.FillRectangle(first, _brushContainer[interiorBrush]);
        }
        public void DrawRectangle3D(int x, int y, int width, int height, int length, float stroke, int brush)
        {
            var first = new RawRectangleF(x, y, x + width, y + height);
            var second = new RawRectangleF(x + length, y - length, first.Right + length, first.Bottom - length);

            var lineStart = new RawVector2(x, y);
            var lineEnd = new RawVector2(second.Left, second.Top);

            _device.DrawRectangle(first, _brushContainer[brush], stroke);
            _device.DrawRectangle(second, _brushContainer[brush], stroke);

            //up left line
            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //up right
            lineStart.X += width;
            lineEnd.X = lineStart.X + length;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //down rigth
            lineStart.Y += height;
            lineEnd.Y += height;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //down left
            lineStart.X -= width;
            lineEnd.X -= width;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);
        }
Ejemplo n.º 21
0
 /// <summary>	
 /// Draws the specified bitmap after scaling it to the size of the specified rectangle. 	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawBitmap}}) failed, check the result returned by the <see cref="EndDraw()"/> or <see cref="Flush()"/> methods.  	
 /// </remarks>	
 /// <param name="bitmap">The bitmap to render. </param>
 /// <param name="destinationRectangle">The size and position, in device-independent pixels in the render target's coordinate space, of the area to which the bitmap is drawn; NULL to draw the selected portion of the bitmap at the origin of the render target.  If the rectangle is specified but not well-ordered, nothing is drawn, but the render target does not enter an error state. </param>
 /// <param name="opacity">A value between 0.0f and 1.0f, inclusive, that specifies an opacity value to apply to the bitmap; this value is multiplied against the alpha values of the bitmap's contents.  The default value is 1.0f. </param>
 /// <param name="interpolationMode">The interpolation mode to use if the bitmap is scaled or rotated by the drawing operation. The default value is <see cref="SharpDX.Direct2D1.BitmapInterpolationMode.Linear"/>.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawBitmap([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D1_RECT_F* destinationRectangle,[None] float opacity,[None] D2D1_BITMAP_INTERPOLATION_MODE interpolationMode,[In, Optional] const D2D1_RECT_F* sourceRectangle)</unmanaged>
 public void DrawBitmap(SharpDX.Direct2D1.Bitmap bitmap, RawRectangleF destinationRectangle, float opacity, SharpDX.Direct2D1.BitmapInterpolationMode interpolationMode)
 {
     DrawBitmap(bitmap, destinationRectangle, opacity, interpolationMode, null);
 }
Ejemplo n.º 22
0
 /// <summary>	
 /// No documentation for Direct3D12	
 /// </summary>	
 /// <param name="gdiMetafile">No documentation.</param>	
 /// <param name="destinationRectangle">No documentation.</param>	
 /// <param name="sourceRectangle">No documentation.</param>	
 /// <returns>No documentation.</returns>	
 /// <include file='.\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1CommandSink2::DrawGdiMetafile']/*"/>	
 /// <unmanaged>HRESULT ID2D1CommandSink2::DrawGdiMetafile([In] ID2D1GdiMetafile* gdiMetafile,[In, Optional] const D2D_RECT_F* destinationRectangle,[In, Optional] const D2D_RECT_F* sourceRectangle)</unmanaged>	
 /// <unmanaged-short>ID2D1CommandSink2::DrawGdiMetafile</unmanaged-short>	
 public void DrawGdiMetafile(GdiMetafile gdiMetafile, RawRectangleF? destinationRectangle, RawRectangleF? sourceRectangle)
 {
     DrawGdiMetafile_(gdiMetafile, destinationRectangle, sourceRectangle);
 }
Ejemplo n.º 23
0
        void IDrawingSurfaceContentProviderNative.GetTexture(Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out RawRectangleF textureSubRectangle)
        {
            try
            {
                if (!Exiting)
                {
                    // TODO Check if surfaceSize changed to reinitialize the buffers?
                    currentSize = surfaceSize;

                    if (!isInitialized)
                    {
                        InitCallback();
                        isInitialized = true;
                    }
                    else if (this.synchronizedTexture == null)
                    {
                        // Dispose the graphics device
                        if (graphicsDeviceService.GraphicsDevice != null)
                        {
                            graphicsDeviceService.GraphicsDevice.Dispose();
                        }

                        // Make sure that the graphics device is created
                        // This will create indirectly the synchronizedTexture on this instance.
                        graphicsDeviceManager.CreateDevice();
                    }

                    this.synchronizedTexture.BeginDraw();

                    RunCallback();

                    host.RequestAdditionalFrame();

                    this.synchronizedTexture.EndDraw();
                }
            }
            catch (Exception ex)
            {
                // TODO: As we are in a callback from a native code, we cannot pass back this exception,
                // so how to pass back this exception to the user at an appropriate time?
                drawException = ex;
                Debug.WriteLine(drawException);
            }

            // Set output parameters.
            var output = new RectangleF(0f, 0f, surfaceSize.Width, surfaceSize.Height);
            textureSubRectangle = new RawRectangleF { Left = output.Left, Top = output.Top, Right = output.Right, Bottom = output.Bottom };
            synchronizedTexture = this.synchronizedTexture;
        }
Ejemplo n.º 24
0
 /// <unmanaged>HRESULT ID2D1CommandSink::FillOpacityMask([In] ID2D1Bitmap* opacityMask,[In] ID2D1Brush* brush,[In, Optional] const D2D_RECT_F* destinationRectangle,[In, Optional] const D2D_RECT_F* sourceRectangle)</unmanaged>	
 public void FillOpacityMask(Bitmap opacityMask, Brush brush, RawRectangleF? destinationRectangle, RawRectangleF? sourceRectangle)
 {
     FillOpacityMask_(opacityMask, brush, destinationRectangle, sourceRectangle);
 }
Ejemplo n.º 25
0
 /// <unmanaged>HRESULT ID2D1CommandSink::PushAxisAlignedClip([In] const D2D_RECT_F* clipRect,[In] D2D1_ANTIALIAS_MODE antialiasMode)</unmanaged>	
 public void PushAxisAlignedClip(RawRectangleF clipRect, AntialiasMode antialiasMode)
 {
     PushAxisAlignedClip_(clipRect, antialiasMode);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Gets the effect invalid rectangles.
 /// </summary>
 /// <param name="effect">The effect.</param>
 /// <returns></returns>
 /// <unmanaged>HRESULT ID2D1DeviceContext::GetEffectInvalidRectangles([In] ID2D1Effect* effect,[Out, Buffer] D2D_RECT_F* rectangles,[In] unsigned int rectanglesCount)</unmanaged>
 public RawRectangleF[] GetEffectInvalidRectangles(SharpDX.Direct2D1.Effect effect)
 {
     var invalidRects = new RawRectangleF[GetEffectInvalidRectangleCount(effect)];
     if (invalidRects.Length == 0)
         return invalidRects;
     GetEffectInvalidRectangles(effect, invalidRects, invalidRects.Length);
     return invalidRects;
 }
Ejemplo n.º 27
0
        private static IDisposable Create(D2D1.RenderTarget target, D2D1.Geometry geometryPath, float opacity, bool clipElement, ref DXM.RawRectangleF clipBounds)
        {
            var complexClip = geometryPath != null || opacity < 1.0f;
            var simpleClip  = !complexClip && clipElement;

            return(complexClip
        ? new ComplexLayer(target, ref clipBounds, geometryPath, opacity)
        : simpleClip
          ? new SimpleLayer(target, ref clipBounds)
          : (IDisposable)null);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Draws the bitmap.
 /// </summary>
 /// <param name="bitmap">The bitmap.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="interpolationMode">The interpolation mode.</param>
 /// <param name="sourceRectangle">The source rectangle.</param>
 /// <param name="perspectiveTransformRef">The perspective transform ref.</param>
 /// <unmanaged>void ID2D1DeviceContext::DrawBitmap([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_F* destinationRectangle,[In] float opacity,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In, Optional] const D2D_RECT_F* sourceRectangle,[In, Optional] const D2D_MATRIX_4X4_F* perspectiveTransform)</unmanaged>
 public void DrawBitmap(SharpDX.Direct2D1.Bitmap bitmap, float opacity, SharpDX.Direct2D1.InterpolationMode interpolationMode, RawRectangleF sourceRectangle, RawMatrix perspectiveTransformRef)
 {
     DrawBitmap(bitmap, null, opacity, interpolationMode, sourceRectangle, perspectiveTransformRef);
 }
Ejemplo n.º 29
0
        public Chessboard()
        {
            _centerPointF = new PointF(RenderForm.Width / 2f, RenderForm.Height / 2f);

            // Create colors
            var cRed     = new Mathe.RawColor4(237 / 255f, 28 / 255f, 36 / 255f, 1);
            var cGreen   = new Mathe.RawColor4(34 / 255f, 177 / 255f, 76 / 255f, 1);
            var cYellow  = new Mathe.RawColor4(255 / 255f, 243 / 255f, 0 / 255f, 1);
            var cPirple  = new Mathe.RawColor4(163 / 255f, 72 / 255f, 165 / 255f, 1);
            var cBlue    = new Mathe.RawColor4(0 / 255f, 163 / 255f, 233 / 255f, 1);
            var cGrey    = new Mathe.RawColor4(195 / 255f, 195 / 255f, 195 / 255f, 1);
            var cWhite   = new Mathe.RawColor4(1, 1, 1, 1);
            var cYellow2 = new Mathe.RawColor4(226 / 255f, 234 / 255f, 152 / 255f, 0.8f);

            // Create brushes
            _yellowBrush = new D2D.SolidColorBrush(RenderForm.RenderTarget, cYellow2);
            _blueBrush   = new D2D.SolidColorBrush(RenderForm.RenderTarget, cBlue);
            _redBrush    = new D2D.SolidColorBrush(RenderForm.RenderTarget, cRed);
            _maskBrush   = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0, 0, 0, 0.5f));

            LoadSettings();
            int intI = 0;

            // Create rectangles
            for (var index = 0; index < Boards.Count; index++)
            {
                var item = Boards[index];
                _rectangles.Add(new Mathe.RawRectangleF[item.X, item.Y]);
                _brushes.Add(new D2D.Brush[item.X, item.Y]);
                const float recWidth = 51, margin = 5;

                float widthC  = recWidth * item.X + margin * (item.X - 1),
                      heightC = recWidth * item.Y + margin * (item.Y - 1),
                      leftC   = _centerPointF.X - widthC / 2,
                      topC    = _centerPointF.Y - heightC / 2;

                for (var i = 0; i < item.X; i++)
                {
                    for (var j = 0; j < item.Y; j++)
                    {
                        if (item.VisibleBoard[i, j] == 0)
                        {
                            continue;
                        }
                        float left = leftC + i * (recWidth + margin), top = topC + j * (recWidth + margin);
                        _rectangles[index][i, j] = new Mathe.RawRectangleF(left, top, left + recWidth, top + recWidth);
                        _brushes[index][i, j]    = new D2D.SolidColorBrush(RenderForm.RenderTarget, item.Color[i, j]);
                        Rectangles.Add(_rectangles[index][i, j]);
                        _boardMap.Add(_rectangles[index][i, j], intI);
                        intI++;
                    }
                }
            }

            #region ImageNormal settings
            //_boardCentre.SetNormalImage(0, 2, LoadFromFile(Path.Combine(_resPath, "13.png")));

            //_boardCentre.SetNormalImage(1, 1, LoadFromFile(Path.Combine(_resPath, "1A.png")));
            //_boardCentre.SetNormalImage(1, 2, LoadFromFile(Path.Combine(_resPath, "6.png")));
            //_boardCentre.SetNormalImage(1, 3, LoadFromFile(Path.Combine(_resPath, "9.png")));

            //_boardCentre.SetNormalImage(2, 0, LoadFromFile(Path.Combine(_resPath, "12.png")));
            //_boardCentre.SetNormalImage(2, 1, LoadFromFile(Path.Combine(_resPath, "2.png")));
            //_boardCentre.SetNormalImage(2, 2, LoadFromFile(Path.Combine(_resPath, "7C.png")));
            //_boardCentre.SetNormalImage(2, 3, LoadFromFile(Path.Combine(_resPath, "8.png")));
            //_boardCentre.SetNormalImage(2, 4, LoadFromFile(Path.Combine(_resPath, "10.png")));

            //_boardCentre.SetNormalImage(3, 1, LoadFromFile(Path.Combine(_resPath, "3.png")));
            //_boardCentre.SetNormalImage(3, 2, LoadFromFile(Path.Combine(_resPath, "4.png")));
            //_boardCentre.SetNormalImage(3, 3, LoadFromFile(Path.Combine(_resPath, "5.png")));

            //_boardCentre.SetNormalImage(4, 2, LoadFromFile(Path.Combine(_resPath, "11.png")));
            #endregion
        }
Ejemplo n.º 30
0
        private void ShowBox(MouseEventArgs e, Mathe.RawRectangleF recF, int i)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (true)
                {
                    switch (i)
                    {
                    case 24:
                        Boards[1].IsActive[0, 2] = !Boards[1].IsActive[0, 2];
                        break;

                    case 25:
                        Boards[1].IsActive[1, 1] = !Boards[1].IsActive[1, 1];
                        break;

                    case 26:
                        Boards[1].IsActive[1, 2] = !Boards[1].IsActive[1, 2];
                        break;

                    case 27:
                        Boards[1].IsActive[1, 3] = !Boards[1].IsActive[1, 3];
                        break;

                    case 28:
                        Boards[1].IsActive[2, 0] = !Boards[1].IsActive[2, 0];
                        break;

                    case 29:
                        Boards[1].IsActive[2, 1] = !Boards[1].IsActive[2, 1];
                        break;

                    case 30:
                        if (!Boards[1].IsActive[2, 2])
                        {
                            Boards[1].IsActive[2, 2] = true;
                        }
                        else
                        {
                            switch (_sevenLv)
                            {
                            case 0:
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7B.png")));
                                _sevenLv = 1;
                                break;

                            case 1:
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7C.png")));
                                _sevenLv = 2;
                                break;

                            default:
                                Boards[1].IsActive[2, 2] = false;
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7A.png")));
                                _sevenLv = 0;
                                break;
                            }
                        }
                        break;

                    case 31:
                        Boards[1].IsActive[2, 3] = !Boards[1].IsActive[2, 3];
                        break;

                    case 32:
                        Boards[1].IsActive[2, 4] = !Boards[1].IsActive[2, 4];
                        break;

                    case 33:
                        Boards[1].IsActive[3, 1] = !Boards[1].IsActive[3, 1];
                        break;

                    case 34:
                        Boards[1].IsActive[3, 2] = !Boards[1].IsActive[3, 2];
                        break;

                    case 35:
                        Boards[1].IsActive[3, 3] = !Boards[1].IsActive[3, 3];
                        break;

                    case 36:
                        Boards[1].IsActive[4, 2] = !Boards[1].IsActive[4, 2];
                        break;
                    }
                }
                switch (i)
                {
                case 0:
                case 16:
                    if (Boards[0].IsActive[0, 2] && Boards[0].IsActive[4, 6])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 4] = false;
                        Boards[0].IsActive[0, 2] = false;
                        Boards[0].IsActive[4, 6] = false;
                        HasActive = false;
                    }
                    break;

                case 1:
                case 22:
                    if (Boards[0].IsActive[0, 3] && Boards[0].IsActive[6, 3])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 2] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 2] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[0, 3] = false;
                        Boards[0].IsActive[6, 3] = false;
                        HasActive = false;
                    }
                    break;

                case 2:
                case 13:
                    if (Boards[0].IsActive[0, 4] && Boards[0].IsActive[4, 0])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 0] = false;
                        Boards[0].IsActive[0, 4] = false;
                        Boards[0].IsActive[4, 0] = false;
                        HasActive = false;
                    }
                    break;

                case 3:
                case 20:
                    if (Boards[0].IsActive[1, 1] && Boards[0].IsActive[5, 5])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[1, 1] = false;
                        Boards[0].IsActive[5, 5] = false;
                        HasActive = false;
                    }
                    break;

                case 4:
                case 18:
                    if (Boards[0].IsActive[1, 2] && Boards[0].IsActive[5, 2])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 1] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[0].IsActive[1, 2] = false;
                        Boards[0].IsActive[5, 2] = false;
                        HasActive = false;
                    }
                    break;

                case 5:
                case 19:
                    if (Boards[0].IsActive[1, 4] && Boards[0].IsActive[5, 4])
                    {
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 3] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[1, 4] = false;
                        Boards[0].IsActive[5, 4] = false;
                        HasActive = false;
                    }
                    break;

                case 6:
                case 17:
                    if (Boards[0].IsActive[1, 5] && Boards[0].IsActive[5, 1])
                    {
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[0].IsActive[1, 5] = false;
                        Boards[0].IsActive[5, 1] = false;
                        HasActive = false;
                    }
                    break;

                case 7:
                case 23:
                    if (Boards[0].IsActive[2, 0] && Boards[0].IsActive[6, 4])
                    {
                        Boards[1].IsActive[2, 0] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[2, 0] = false;
                        Boards[0].IsActive[6, 4] = false;
                        HasActive = false;
                    }
                    break;

                case 8:
                case 9:
                    if (Boards[0].IsActive[2, 1] && Boards[0].IsActive[2, 5])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[1, 2] = false;
                        Boards[1].IsActive[1, 3] = false;
                        Boards[0].IsActive[2, 1] = false;
                        Boards[0].IsActive[2, 5] = false;
                        HasActive = false;
                    }
                    break;

                case 10:
                case 21:
                    if (Boards[0].IsActive[2, 6] && Boards[0].IsActive[6, 2])
                    {
                        Boards[1].IsActive[2, 4] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[2, 6] = false;
                        Boards[0].IsActive[6, 2] = false;
                        HasActive = false;
                    }
                    break;

                case 11:
                case 12:
                    if (Boards[0].IsActive[3, 0] && Boards[0].IsActive[3, 6])
                    {
                        Boards[1].IsActive[2, 0] = false;
                        Boards[1].IsActive[2, 1] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[2, 3] = false;
                        Boards[1].IsActive[2, 4] = false;
                        Boards[0].IsActive[3, 0] = false;
                        Boards[0].IsActive[3, 6] = false;
                        HasActive = false;
                    }
                    break;

                case 14:
                case 15:
                    if (Boards[0].IsActive[4, 1] && Boards[0].IsActive[4, 5])
                    {
                        Boards[1].IsActive[3, 1] = false;
                        Boards[1].IsActive[3, 2] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[4, 1] = false;
                        Boards[0].IsActive[4, 5] = false;
                        HasActive = false;
                    }
                    break;

                default:
                    return;
                }
                return;
            }
            string fileName;

            switch (i)
            {
            case 0:
            case 16:
                fileName = "des_7.png";
                break;

            case 1:
            case 22:
                fileName = "des_5.png";
                break;

            case 2:
            case 13:
                fileName = "des_10.png";
                break;

            case 3:
            case 20:
                fileName = "des_11.png";
                break;

            case 4:
            case 18:
                fileName = "des_3.png";
                break;

            case 5:
            case 19:
                fileName = "des_2.png";
                break;

            case 6:
            case 17:
                fileName = "des_4.png";
                break;

            case 7:
            case 23:
                fileName = "des_12.png";
                break;

            case 8:
            case 9:
                fileName = "des_9.png";
                break;

            case 10:
            case 21:
                fileName = "des_0.png";
                break;

            case 11:
            case 12:
                fileName = "des_6.png";
                break;

            case 14:
            case 15:
                fileName = "des_8.png";
                break;

            case 30:
                fileName = "des_1.png";
                break;

            default:
                return;
            }

            PointF loc = new PointF(recF.Left, recF.Top);

            _boxBitmap = DxHelper.LoadFromFile(Path.Combine(_resPath, fileName));

            const float scaled  = 2f;
            float       scaledW = _boxBitmap.Size.Width / scaled,
                        scaledH = _boxBitmap.Size.Height / scaled;
            float left          = loc.X - 35,
                  top           = loc.Y - scaledH + 30,
                  right         = left + scaledW,
                  bottom        = top + scaledH;

            _boxRec        = new Mathe.RawRectangleF(left, top, right, bottom);
            _tmpRectangles = Rectangles.ToArray().ToList();
            Rectangles.Clear();
            Rectangles.AddRange(new[]
            {
                new Mathe.RawRectangleF(0, 0, RenderForm.Width, top),
                new Mathe.RawRectangleF(0, top, left, bottom),
                new Mathe.RawRectangleF(right, top, RenderForm.Width, bottom),
                new Mathe.RawRectangleF(0, bottom, RenderForm.Width, RenderForm.Height),
            });
            _isBoxing = true;
        }
Ejemplo n.º 31
0
 public static Rectangle ToEto(this smi.RawRectangleF value)
 {
     return(new Rectangle((int)value.Left, (int)value.Top, (int)(value.Right - value.Left), (int)(value.Bottom - value.Top)));
 }
Ejemplo n.º 32
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawBitmap([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_F* destinationRectangle,[In] float opacity,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In, Optional] const D2D_RECT_F* sourceRectangle,[In, Optional] const D2D_MATRIX_4X4_F* perspectiveTransform)</unmanaged>	
 public void DrawBitmap(Bitmap bitmap, RawRectangleF? destinationRectangle, float opacity, InterpolationMode interpolationMode, RawRectangleF? sourceRectangle, RawMatrix? erspectiveTransformRef)
 {
     DrawBitmap_(bitmap, destinationRectangle, opacity, interpolationMode, sourceRectangle, erspectiveTransformRef);
 }
Ejemplo n.º 33
0
 public static Rectangle ToSeal(this D2D.RawRectangleF r)
 {
     return(new Rectangle(r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top));
 }
Ejemplo n.º 34
0
        public override void Measure() //todo: Will lead to NullReferenceException when recreated window on some maps: s/552702
        {
            if (!_isStart && _status != OsuModel.Status)
            {
                _isStart = true;
            }

            if (!_isStart)
            {
                return;
            }

            if (_crtMapFile != OsuModel.Idle.NowMap.FilenameFull)
            {
                string oldMapBg   = _crtMapBg;
                string oldMapPath = _crtMapPath;
                _crtMapFile = OsuModel.Idle.NowMap.FilenameFull;
                _crtMapBg   = OsuModel.Idle.NowMap.BackgroundFilename;
                _crtMapPath = OsuModel.Idle.NowMap.Folder;

                LogUtil.LogInfo((_crtMapBg == null).ToString());
                if (oldMapPath != _crtMapPath || oldMapBg != _crtMapBg)
                {
                    var currentBgPath = Path.Combine(_crtMapPath, OsuModel.Idle.NowMap.BackgroundFilename);
                    if (File.Exists(currentBgPath))
                    {
                        _oldBg        = _newBg;
                        _newBg        = RenderTarget.LoadBitmap(currentBgPath);
                        _lastBgIsNull = false;
                    }
                    else if (_defaultBg != null)
                    {
                        if (_lastBgIsNull)
                        {
                            return;
                        }
                        _oldBg        = _newBg;
                        _newBg        = _defaultBg;
                        _lastBgIsNull = true;
                    }
                    else
                    {
                        return;
                    }

                    _fixedRectOld = _fixedRect;

                    _fixedRect = GetBgPosition(_newBg.Size);
                    var size = Settings.Render.WindowSize;
                    if (_newBg != null)
                    {
                        _newBgObj = new BitmapObject(RenderTarget, _newBg, Origin.Default,
                                                     new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                        _newBgObjEffect = new BitmapObject(RenderTarget, _newBg, Origin.Default,
                                                           new Mathe.RawPoint(size.Width / 2, size.Height / 2), true);
                    }
                    if (_oldBg != null)
                    {
                        _oldBgObj = new BitmapObject(RenderTarget, _oldBg, Origin.Default,
                                                     new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                    }
                    _transformStyle = _rnd.Next(0, 3);
                    if (_sw.ElapsedMilliseconds < 600 && _sw.ElapsedMilliseconds != 0)
                    {
                        _transformStyle = 99;
                    }
                }

                try
                {
                    OsuFile file = OsuFile.ReadFromFileAsync(OsuModel.Idle.NowMap.FilenameFull).Result;
                    _barList  = file.TimingPoints.GetTimingBars();
                    _11List   = file.TimingPoints.GetTimings(1);
                    _kiaiList = file.TimingPoints.GetTimingKiais();
                }
                catch (NotSupportedException e)
                {
                    LogUtil.LogError(e.Message);
                    _barList  = new double[0];
                    _11List   = new double[0];
                    _kiaiList = new RangeValue <double> [0];
                }

                _sw.Restart();
            }
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Draws the given bitmap.
        /// </summary>
        /// <param name="bitmap">The bitmap.</param>
        /// <param name="destinationOrigin">The point where to start rendering.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="interpolationMode">The interpolation mode.</param>
        /// <param name="frameIndex">The frame of the bitmap to be rendered.</param>
        public void DrawBitmap(
            BitmapResource bitmap,
            Vector2 destinationOrigin,
            float opacity = 1f,
            BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.NearestNeighbor,
            int frameIndex = 0)
        {
            if (m_renderTarget == null)
            {
                return;
            }

            bitmap.EnsureNotNull(nameof(bitmap));
            opacity.EnsureInRange(0f, 1f, nameof(opacity));

            int bitmapFrameCount = bitmap.TotalFrameCount;

            frameIndex.EnsureInRange(0, bitmapFrameCount - 1, nameof(frameIndex));

            // Render the bitmap
            if (bitmapFrameCount > 1)
            {
                // Get the native bitmap object first
                // (if not, we may not have loaded it already and therefore
                //  missing size information)
                D2D.Bitmap nativeBitmap = bitmap.GetBitmap(m_device);

                // Calculate destination rectangle
                int        singleFrameWidth     = bitmap.SingleFramePixelWidth;
                int        singleFrameHeight    = bitmap.SingleFramePixelHeight;
                RectangleF destinationRectangle = new RectangleF(
                    destinationOrigin.X, destinationOrigin.Y,
                    singleFrameWidth, singleFrameHeight);

                // Calculate source rectangle
                int        framesX         = bitmap.FrameCountX;
                int        xFrameIndex     = frameIndex % framesX;
                int        yFrameIndex     = (frameIndex - xFrameIndex) / framesX;
                RectangleF sourceRectangle = new RectangleF(
                    xFrameIndex * singleFrameWidth,
                    yFrameIndex * singleFrameHeight,
                    singleFrameWidth, singleFrameHeight);

                // Render tiled bitmap
                m_renderTarget.DrawBitmap(
                    nativeBitmap,
                    destinationRectangle.ToDXRectangle(),
                    opacity,
                    (D2D.BitmapInterpolationMode)interpolationMode,
                    sourceRectangle.ToDXRectangle());
            }
            else
            {
                SharpDX.Mathematics.Interop.RawRectangleF destinationRectangle = new SharpDX.Mathematics.Interop.RawRectangleF(
                    destinationOrigin.X, destinationOrigin.Y,
                    destinationOrigin.X + bitmap.PixelWidth, destinationOrigin.Y + bitmap.PixelHeight);

                // Render non-tiled bitmap
                m_renderTarget.DrawBitmap(
                    bitmap.GetBitmap(m_device),
                    destinationRectangle,
                    opacity,
                    (D2D.BitmapInterpolationMode)interpolationMode);
            }
        }
Ejemplo n.º 36
0
 /// <summary>	
 /// Draws the specified bitmap after scaling it to the size of the specified rectangle. 	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawBitmap}}) failed, check the result returned by the <see cref="EndDraw()" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="bitmap">The bitmap to render. </param>
 /// <param name="opacity">A value between 0.0f and 1.0f, inclusive, that specifies an opacity value to apply to the bitmap; this value is multiplied against the alpha values of the bitmap's contents.  The default value is 1.0f. </param>
 /// <param name="interpolationMode">The interpolation mode to use if the bitmap is scaled or rotated by the drawing operation. The default value is <see cref="F:SharpDX.Direct2D1.BitmapInterpolationMode.Linear" />.  </param>
 /// <param name="sourceRectangle">The size and position, in device-independent pixels in the bitmap's coordinate space, of the area within the bitmap to be drawn; NULL to draw the entire bitmap.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawBitmap([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D1_RECT_F* destinationRectangle,[None] float opacity,[None] D2D1_BITMAP_INTERPOLATION_MODE interpolationMode,[In, Optional] const D2D1_RECT_F* sourceRectangle)</unmanaged>
 public void DrawBitmap(Bitmap bitmap, float opacity, BitmapInterpolationMode interpolationMode, RawRectangleF sourceRectangle)
 {
     DrawBitmap(bitmap, null, opacity, interpolationMode, sourceRectangle);
 }
Ejemplo n.º 37
0
 /// <unmanaged>HRESULT ID2D1CommandSink::FillRectangle([In] const D2D_RECT_F* rect,[In] ID2D1Brush* brush)</unmanaged>	
 public void FillRectangle(RawRectangleF rect, Brush brush)
 {
     FillRectangle_(rect, brush);
 }
Ejemplo n.º 38
0
 /// <summary>	
 /// Draws the outline of a rectangle that has the specified dimensions and stroke style. 	
 /// </summary>	
 /// <remarks>	
 /// When this method fails, it does not return an error code. To determine whether a drawing method (such as {{DrawRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> method.  	
 /// </remarks>	
 /// <param name="rect">The dimensions of the rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rectangle's stroke. </param>
 /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the rectangle's stroke. The stroke is centered on the rectangle's outline. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRectangle([In] const D2D1_RECT_F* rect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRectangle(RawRectangleF rect, Brush brush, float strokeWidth)
 {
     DrawRectangle(rect, brush, strokeWidth, null);
 }
Ejemplo n.º 39
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawRectangle([In] const D2D_RECT_F* rect,[In] ID2D1Brush* brush,[In] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>	
 public void DrawRectangle(RawRectangleF rect, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
 {
     DrawRectangle_(rect, brush, strokeWidth, strokeStyle);
 }
Ejemplo n.º 40
0
 /// <summary>	
 /// Draws the specified text using the format information provided by an <see cref="T:SharpDX.DirectWrite.TextFormat" /> object. 	
 /// </summary>	
 /// <remarks>	
 /// To create an <see cref="T:SharpDX.DirectWrite.TextFormat" /> object, create an <see cref="T:SharpDX.DirectWrite.Factory" /> and call its {{CreateTextFormat}} method. This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawText}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="text">A reference to an array of Unicode characters to draw.  </param>
 /// <param name="textFormat">An object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.   </param>
 /// <param name="layoutRect">The size and position of the area in which the text is drawn.  </param>
 /// <param name="defaultForegroundBrush">The brush used to paint the text. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawTextA([In, Buffer] const wchar_t* string,[None] int stringLength,[In] IDWriteTextFormat* textFormat,[In] const D2D1_RECT_F* layoutRect,[In] ID2D1Brush* defaultForegroundBrush,[None] D2D1_DRAW_TEXT_OPTIONS options,[None] DWRITE_MEASURING_MODE measuringMode)</unmanaged>
 public void DrawText(string text, TextFormat textFormat, RawRectangleF layoutRect, Brush defaultForegroundBrush)
 {
     DrawText(text, text.Length, textFormat, layoutRect, defaultForegroundBrush, DrawTextOptions.None, MeasuringMode.Natural);
 }
Ejemplo n.º 41
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawImage([In] ID2D1Image* image,[In, Optional] const D2D_POINT_2F* targetOffset,[In, Optional] const D2D_RECT_F* imageRectangle,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In] D2D1_COMPOSITE_MODE compositeMode)</unmanaged>	
 public void DrawImage(Image image, RawVector2? targetOffset, RawRectangleF? imageRectangle, InterpolationMode interpolationMode, CompositeMode compositeMode)
 {
     DrawImage_(image, targetOffset, imageRectangle, interpolationMode, compositeMode);
 }
Ejemplo n.º 42
0
 /// <summary>	
 /// Draws the specified text using the format information provided by an <see cref="T:SharpDX.DirectWrite.TextFormat" /> object. 	
 /// </summary>	
 /// <remarks>	
 /// To create an <see cref="T:SharpDX.DirectWrite.TextFormat" /> object, create an <see cref="T:SharpDX.DirectWrite.Factory" /> and call its {{CreateTextFormat}} method. This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawText}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="text">A reference to an array of Unicode characters to draw.  </param>
 /// <param name="textFormat">An object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.   </param>
 /// <param name="layoutRect">The size and position of the area in which the text is drawn.  </param>
 /// <param name="defaultForegroundBrush">The brush used to paint the text. </param>
 /// <param name="options">A value that indicates whether the text should be snapped to pixel boundaries and whether the text should be clipped to the layout rectangle. The default value is <see cref="F:SharpDX.Direct2D1.DrawTextOptions.None" />, which indicates that text should be snapped to pixel boundaries and it should not be clipped to the layout rectangle. </param>
 /// <param name="measuringMode">A value that indicates how glyph metrics are used to measure text when it is formatted.  The default value is DWRITE_MEASURING_MODE_NATURAL.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawTextA([In, Buffer] const wchar_t* string,[None] int stringLength,[In] IDWriteTextFormat* textFormat,[In] const D2D1_RECT_F* layoutRect,[In] ID2D1Brush* defaultForegroundBrush,[None] D2D1_DRAW_TEXT_OPTIONS options,[None] DWRITE_MEASURING_MODE measuringMode)</unmanaged>
 public void DrawText(string text, TextFormat textFormat, RawRectangleF layoutRect, Brush defaultForegroundBrush, DrawTextOptions options, MeasuringMode measuringMode)
 {
     DrawText(text, text.Length, textFormat, layoutRect, defaultForegroundBrush, options, measuringMode);
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Gets the effect required input rectangles.
 /// </summary>
 /// <param name="renderEffect">The render effect.</param>
 /// <param name="renderImageRectangle">The render image rectangle.</param>
 /// <param name="inputDescriptions">The input descriptions.</param>
 /// <returns></returns>
 /// <unmanaged>HRESULT ID2D1DeviceContext::GetEffectRequiredInputRectangles([In] ID2D1Effect* renderEffect,[In, Optional] const D2D_RECT_F* renderImageRectangle,[In, Buffer] const D2D1_EFFECT_INPUT_DESCRIPTION* inputDescriptions,[Out, Buffer] D2D_RECT_F* requiredInputRects,[In] unsigned int inputCount)</unmanaged>
 public RawRectangleF[] GetEffectRequiredInputRectangles(SharpDX.Direct2D1.Effect renderEffect, RawRectangleF renderImageRectangle, SharpDX.Direct2D1.EffectInputDescription[] inputDescriptions)
 {
     var result = new RawRectangleF[inputDescriptions.Length];
     GetEffectRequiredInputRectangles(renderEffect, renderImageRectangle, inputDescriptions, result, inputDescriptions.Length);
     return result;
 }
Ejemplo n.º 44
0
 internal SimpleLayer(D2D1.RenderTarget target, ref DXM.RawRectangleF clipBounds)
 {
     _target = target;
     target.PushAxisAlignedClip(clipBounds, D2D1.AntialiasMode.PerPrimitive);
 }