示例#1
0
        public void Run()
        {
            SharpDX.Threading.TaskUtil.Run(() =>
            {
                while (!_cancelTask.IsCancellationRequested)
                {
                    lock (_lockObj)
                    {
                        hwndRenderTarget.BeginDraw();
                        hwndRenderTarget.Clear(Color.White);

                        if (_opacity > 0.0f)//表示切换中
                        {
                            RectangleF preRenderRect = ZoomBitmap(RenderTargetClientSize, _preBmp.Size);
                            hwndRenderTarget.DrawBitmap(_preBmp.Bmp, preRenderRect, _opacity, BitmapInterpolationMode.NearestNeighbor, _preBmp.BitmapRectangleF);

                            _opacity -= 0.02f;
                        }
                        else
                        {
                            if (_preBmp != null)
                            {
                                _preBmp.Dispose();
                            }
                        }
                        RectangleF renderRect = ZoomBitmap(RenderTargetClientSize, _bmp.Size);
                        hwndRenderTarget.DrawBitmap(_bmp.Bmp, renderRect, 1f - _opacity, BitmapInterpolationMode.NearestNeighbor, _bmp.BitmapRectangleF);

                        hwndRenderTarget.EndDraw();
                    }
                    Thread.Sleep(40);
                }
            });
        }
示例#2
0
        private void Render(bool shouldRecompose, bool shouldRetry)
        {
            var interpolationMode = false ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor;

            _windowRenderTarget.BeginDraw();

            if (BorderVisible)
            {
                CreateCompositeRenderTarget();

                _compositeRenderTarget.BeginDraw();
                _compositeRenderTarget.Clear(_clearColor);
                _compositeRenderTarget.DrawBitmap(_screenRenderTarget.Bitmap, new RawRectangleF(48, 40, 48 + 160, 40 + 144), 1.0f, BitmapInterpolationMode.NearestNeighbor);
                _compositeRenderTarget.DrawBitmap(_borderBitmap, 1.0f, BitmapInterpolationMode.NearestNeighbor);
                _compositeRenderTarget.EndDraw();
                _windowRenderTarget.DrawBitmap(_compositeRenderTarget.Bitmap, _drawRectangle, 1.0f, interpolationMode);
            }
            else
            {
                _windowRenderTarget.DrawBitmap(_screenRenderTarget.Bitmap, _drawRectangle, 1.0f, interpolationMode);
            }

            try { _windowRenderTarget.EndDraw(); }
            catch (COMException)
            {
                // If needed, try to recreate the target.
                ResetRendering();
                // Try to render again, but only once. (We don't want to enter an infinite recursion… AKA Stack Overflow)
                if (shouldRetry)
                {
                    Render(true, false);
                }
            }
        }
示例#3
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;
            }
        }
示例#4
0
 /// <summary>
 /// This method renders the player character.  This method MUST be called after RenderWorld() or the world would be drawn on top of the player
 /// character, causing the player character to be effectively invisible.
 /// </summary>
 public void RenderPlayer()
 {
     // Render the player character.
     m_RenderTarget.DrawBitmap(m_PlayerSprites,
                               new Rectangle((int)(m_Player.PositionX * 32), (int)(m_Player.PositionY * 32), 32, 32),
                               1.0f,
                               InterpolationMode.Linear,
                               new Rectangle(m_Player.AnimFrame * 32, 0, 32, 32));
 }
示例#5
0
        public void RenderBuffer(int[] buffer)
        {
            int widthOfBox  = _box.Width;
            int heightOfBox = _box.Height;
            int newWidth    = Math.Min(widthOfBox, heightOfBox * 256 / 224);
            int newHeight   = newWidth * 224 / 256;
            int leftOffSet  = (_box.Width - newWidth) / 2;
            int topOffSet   = (_box.Height - newHeight) / 2;

            var d2dBitmap = Bitmap.New(_renderTarget2D, new Size2(256, 224), buffer,
                                       new BitmapProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

            if (_renderTarget2D.Size.Width != _box.Width || _renderTarget2D.Size.Height != _box.Height)
            {
                _renderTarget2D.Resize(new Size2(_box.Width, _box.Height));
            }
            _renderTarget2D.BeginDraw();
            _renderTarget2D.AntialiasMode = AntialiasMode.Aliased;
            _renderTarget2D.DrawBitmap(d2dBitmap,
                                       new RawRectangleF(leftOffSet, topOffSet, leftOffSet + newWidth, topOffSet + newHeight),
                                       1.0f, BitmapInterpolationMode.Linear);

            try
            {
                _renderTarget2D.EndDraw();
            }
            catch (SharpDXException ex) when((uint)ex.HResult == 0x8899000C)
            {
            }
            d2dBitmap.Dispose();
        }
示例#6
0
 public void DrawBitmap(float left, float top, float right, float bottom)
 {
     if (CurrentBitmap == null)
     {
         return;
     }
     _device.DrawBitmap(CurrentBitmap, new RawRectangleF(left, top, right, bottom), 1.0f, BitmapInterpolationMode.Linear);
 }
 public void DrawImage(System.Drawing.Bitmap bitmap, System.Drawing.Rectangle rectangle)
 {
     _renderTarget2D.DrawBitmap(
         bitmap: _bitmapHelper.LoadFromFile(_renderTarget2D, bitmap),
         destinationRectangle: _rectangleConverter.Convert(rectangle),
         opacity: 1.0f,
         interpolationMode: BitmapInterpolationMode.Linear);
 }
示例#8
0
        public void Render()
        {
            d2dWindowRenderTarget.BeginDraw();
            d2dWindowRenderTarget.Clear(new Color4(Color.Black));
            int sizex, sizey;

            foreach (gameobject curr in ToDraw)
            {
                if (curr.Game_object_state == 0)
                {
                    sizex = targetControl.Width;
                    sizey = targetControl.Height;
                }
                else
                {
                    sizex = 200;
                    sizey = 200;
                }
                if (curr.D2dbm == null)
                {
                    d2dPixelFormat                  = new PixelFormat(SlimDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied);
                    d2dBitmapProperties             = new BitmapProperties();
                    d2dBitmapProperties.PixelFormat = d2dPixelFormat;

                    bitmapData = curr.Game_object_bitmap.LockBits(new Rectangle(new Point(0, 0), new Size(curr.Game_object_bitmap.Width, curr.Game_object_bitmap.Height)), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                    dataStream = new DataStream(bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, true, false);
                    SlimDX.Direct2D.Bitmap temp = new SlimDX.Direct2D.Bitmap(d2dWindowRenderTarget, new Size(curr.Game_object_bitmap.Width, curr.Game_object_bitmap.Height), dataStream, bitmapData.Stride, d2dBitmapProperties);
                    curr.D2dbm = temp;
                    curr.Game_object_bitmap.UnlockBits(bitmapData);
                    d2dWindowRenderTarget.DrawBitmap(curr.D2dbm);
                    dataStream.Dispose();
                }
                else
                {
                    //d2dWindowRenderTarget.DrawBitmap(curr.D2dbm, new Rectangle(curr.Game_object_position.X, curr.Game_object_position.Y, targetControl.Width, targetControl.Height));
                    d2dWindowRenderTarget.DrawBitmap(curr.D2dbm, new Rectangle(curr.Game_object_position.X, curr.Game_object_position.Y, sizex, sizey), 1.0f, InterpolationMode.Linear, new Rectangle(1024 * curr.Game_object_state, 0, 1024, curr.Game_object_bitmap.Height));
                }
            }



            d2dWindowRenderTarget.DrawRectangle(new SolidColorBrush(d2dWindowRenderTarget, new Color4(Color.Red)), new Rectangle(20, 20, targetControl.Width - 40, targetControl.Height - 40));
            d2dWindowRenderTarget.DrawText(Form1.counter.ToString(), new TextFormat(wrtFactory, "Arial", SlimDX.DirectWrite.FontWeight.Normal, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 18, "en-us"), new Rectangle(new Point(0, 0), new Size(200, 20)), new SolidColorBrush(d2dWindowRenderTarget, new Color4(Color.Blue)));
            d2dWindowRenderTarget.EndDraw();
            Form1.tempcounter++;
        }
示例#9
0
 /// <summary>
 /// 绘制图片
 /// </summary>
 /// <param name="pic1"></param>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="pic2"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 private void DrawPicture(SharpDX.Direct2D1.Bitmap pic1, float x1, float y1,
                          SharpDX.Direct2D1.Bitmap pic2, float x2, float y2)
 {
     _renderTarget.BeginDraw();
     _renderTarget.Clear(SharpDX.Color.White.ToColor4());
     if (pic1 != null)
     {
         RawRectangleF point1    = new RawRectangleF(x1, y1, _imageSize.Width + x1, _imageSize.Height + y1);
         RawRectangleF pointdes1 = new RawRectangleF(0, 0, _imageSize.Width, _imageSize.Height);
         _renderTarget.DrawBitmap(pic1, point1, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor, _pointImg);
     }
     if (pic2 != null)
     {
         RawRectangleF point2    = new RawRectangleF(x2, y2, _imageSize.Width + x2, _imageSize.Height + y2);
         RawRectangleF pointdes2 = new RawRectangleF(0, 0, _imageSize.Width, _imageSize.Height);
         _renderTarget.DrawBitmap(pic2, point2, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor, _pointImg);
     }
     _renderTarget.EndDraw();
 }
示例#10
0
        private void Draw()
        {
            Converter.Render(objects, this);

            SceneBuffer.CopyFromMemory(SceneCache, 4 * Width);
            CameraView.BeginDraw();
            CameraView.Clear(new Color4(0, 0, 0, 1f));
            CameraView.DrawBitmap(SceneBuffer, 1f, BitmapInterpolationMode.Linear);
            CameraView.EndDraw();
        }
示例#11
0
 private void RenderScene(WindowRenderTarget renderTarget)
 {
     renderTarget.DrawBitmap(_bitmap, new RectF(0, 0, 200, 133), 1, BitmapInterpolationMode.Linear);
     renderTarget.FillRect(_brush, new RectF(0, 0, 25, 25));
     renderTarget.FillRect(_brush, new RectF(25, 25, 25, 25));
     renderTarget.FillRect(_brush, new RectF(50, 50, 25, 25));
     renderTarget.FillRect(_brush, new RectF(75, 75, 25, 25));
     renderTarget.FillRect(_brush, new RectF(100, 100, 25, 25));
     renderTarget.FillRect(_brush, new RectF(125, 125, 25, 25));
 }
示例#12
0
        /// <summary>
        /// 绘制图片
        /// </summary>
        /// <param name="pic1"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="pic2"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        private void DrawPicture(SharpDX.Direct2D1.Bitmap pic)
        {
            _renderTarget.BeginDraw();
            _renderTarget.Clear(SharpDX.Color.White.ToColor4());

            RawRectangleF point = new RawRectangleF(0, 0, _picContainer.Width, _picContainer.Height);

            _renderTarget.DrawBitmap(pic, point, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor);

            _renderTarget.EndDraw();
        }
示例#13
0
 private void MainWindow_Paint(object sender, PaintEventArgs e)
 {
     _renderTarget.BeginDraw();
     _renderTarget.Clear(Color.FromKnown(Colors.Black, 1));
     if (_cache != null)
     {
         _renderTarget.DrawBitmap(_cache, new RectF(0, 0, ClientSize.Width, ClientSize.Height),
                                  1, BitmapInterpolationMode.Linear);
     }
     _renderTarget.EndDraw();
 }
示例#14
0
        private void _loop_DXThread(object sender)
        {
            while (true)
            {
                device.BeginDraw();
                device.Clear(Color.Transparent);
                device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased;

                device.DrawText("Overlay text using direct draw with DirectX", font, new SharpDX.Mathematics.Interop.RawRectangleF(5, 100, 500, 30), solidColorBrush);

                device.DrawBitmap(_bitmap, 1, BitmapInterpolationMode.Linear, new SharpDX.Mathematics.Interop.RawRectangleF(600, 400, 0, 0));
                //place your rendering things here

                device.EndDraw();
            }
        }
示例#15
0
 protected override void OnRender(WindowRenderTarget renderTarget)
 {
     if (this._image != null)
     {
         renderTarget.Transform = Matrix3x2.Rotation(this.RotationAngle, new PointF(ClientSize.Width / 2, ClientSize.Height / 2));
         SizeU  imageSize   = this._image.PixelSize;
         double scale       = Math.Min((double)(ClientSize.Width - 20) / imageSize.Width, (double)(ClientSize.Height - 20) / imageSize.Height);
         int    imageWidth  = (int)(imageSize.Width * scale);
         int    imageHeight = (int)(imageSize.Height * scale);
         RectF  imageBounds = new RectF((ClientSize.Width - imageWidth) / 2, (ClientSize.Height - imageHeight) / 2, imageWidth, imageHeight);
         renderTarget.DrawBitmap(this._image, imageBounds, 1, BitmapInterpolationMode.Linear);
         if (ShowBorder)
         {
             renderTarget.DrawRect(this._borderBrush, 8, imageBounds);
         }
     }
 }
示例#16
0
 public void DrawBitmap(Bitmap bmp, float x, float y, float opacity = 1.0f)
 {
     renderTarget.DrawBitmap(bmp, new RawRectangleF(x, y, x + bmp.Size.Width, y + bmp.Size.Height), opacity, BitmapInterpolationMode.NearestNeighbor);
 }
示例#17
0
 protected override void OnRender(WindowRenderTarget renderTarget)
 {
     if (this._image != null)
     {
         renderTarget.Transform = Matrix3x2.Rotation(this.RotationAngle, new PointF(ClientSize.Width / 2, ClientSize.Height / 2));
         SizeU imageSize = this._image.PixelSize;
         double scale = Math.Min((double)(ClientSize.Width - 20) / imageSize.Width, (double)(ClientSize.Height - 20) / imageSize.Height);
         int imageWidth = (int)(imageSize.Width * scale);
         int imageHeight = (int)(imageSize.Height * scale);
         RectF imageBounds = new RectF((ClientSize.Width - imageWidth) / 2, (ClientSize.Height - imageHeight) / 2, imageWidth, imageHeight);
         renderTarget.DrawBitmap(this._image, imageBounds, 1, BitmapInterpolationMode.Linear);
         if (ShowBorder)
             renderTarget.DrawRect(this._borderBrush, 8, imageBounds);
     }
 }
示例#18
0
        private void DrawPlayer(WindowRenderTarget device, Player currentPlayer, Player player)
        {
            if (player == null)
            {
                return;
            }
            if (player.Index == currentPlayer.Index)
            {
                return;
            }
            if (!player.IsValid())
            {
                return;
            }
            if (csgo.GetValue <Target>("espDrawTarget") == Target.Enemies && player.InTeam == currentPlayer.InTeam)
            {
                return;
            }
            if (csgo.GetValue <Target>("espDrawTarget") == Target.Allies && player.InTeam != currentPlayer.InTeam)
            {
                return;
            }

            player.CheckYaw();

            Vector2 point = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, (player.Vector3));

            if (point == Vector2.Zero)
            {
                return;
            }
            float distance    = Geometry.GetDistanceToPoint(currentPlayer.Vector3, player.Vector3);
            float height      = 36000f / distance;
            float width       = 18100f / distance;
            Color colorPlayer = player.InTeam == Team.Terrorists ?
                                (player.SeenBy(currentPlayer) ? colorTSpotted : colorT) :
                                (player.SeenBy(currentPlayer) ? colorCTSpotted : colorCT);

            float distanceMeter = currentPlayer.DistanceToOtherEntityInMetres(player);
            float head          = 3200f / distance;
            float boxBorder     = 6400f / distance;
            bool  highlighted   = csgo.Highlighted[player.Index - 1];
            //Paint bones
            List <Vector3> allBones = new List <Vector3>();

            allBones.AddRange(player.Skeleton.Legs);
            allBones.AddRange(player.Skeleton.Spine);
            allBones.Add(player.Skeleton.HeadEnd);

            Vector2[] all = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, allBones.ToArray());
            foreach (Vector2 vec in all)
            {
                if (vec == Vector2.Zero)
                {
                    return;
                }
            }
            Vector2[] arms  = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, player.Skeleton.Arms);
            Vector2[] legs  = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, player.Skeleton.Legs);
            Vector2[] spine = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, player.Skeleton.Spine);
            allBones.Clear();
            allBones = null;

            float rectX = GetSmallestX(all) + 5, rectW = GetBiggestX(all) + 5, rectY = GetSmallestY(all) + 5, rectH = GetBiggestY(all) + 5;

            //rectW -= rectX;
            rectH -= rectY;
            rectW  = rectH * 0.3f;
            rectX  = point.X - rectW / 2f;
            #region glow
            if (csgo.GetValue <YesNo>("espGlowEnabled") == YesNo.Yes)
            {
                if (csgo.GlowObjects != null)
                {
                    CSGOGameController controller = (CSGOGameController)Program.GameController;
                    int idx = controller.MemoryUpdater.GetGlowObjectByAddress((int)player.Address);
                    if (idx != -1)
                    {
                        GlowObjectDefinition def = csgo.GlowObjects[idx];
                        def.a = (float)(colorPlayer.A / 255f);
                        def.r = (float)(colorPlayer.R / 255f);
                        def.g = (float)(colorPlayer.G / 255f);
                        def.b = (float)(colorPlayer.B / 255f);
                        def.m_bRenderWhenOccluded   = true;
                        def.m_bRenderWhenUnoccluded = true;
                        def.m_bFullBloom            = false;
                        if (csgo.GetValue <YesNo>("espGlowFadingEnabled") == YesNo.Yes)
                        {
                            float dist  = currentPlayer.DistanceToOtherEntityInMetres(player);
                            float range = csgo.GetValue <float>("espGlowFadingDistance");
                            if (dist <= range)
                            {
                                def.a = 1f - 1f / range * dist;
                                controller.MemoryUpdater.WriteGlowObject(def, idx);
                            }
                        }
                        else
                        {
                            controller.MemoryUpdater.WriteGlowObject(def, idx);
                        }
                    }
                }
            }
            #endregion
            #region skeleton
            if (csgo.GetValue <OnOff>("espDrawSkeleton") == OnOff.On)
            {
                if (distanceMeter < 20)
                {
                    DrawBones(device,
                              colorPlayer,
                              arms,
                              1.5f,
                              player.InTeam
                              );
                }
                DrawBones(device,
                          colorPlayer,
                          legs,
                          1.5f,
                          player.InTeam
                          );
                DrawBones(device,
                          colorPlayer,
                          spine,
                          1.5f,
                          player.InTeam
                          );
            }
            if (player.Skeleton.AllBones != null)
            {
                for (int i = 0; i < player.Skeleton.AllBones.Length; i++)
                {
                    Vector2 boneHead = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, player.Skeleton.AllBones[i]);
                    DrawText(device,
                             foreColor,
                             backColor,
                             boneHead.X,
                             boneHead.Y,
                             100f,
                             20f,
                             1f,
                             1f,
                             i.ToString(),
                             FactoryManager.GetFont("largeSegoe"));
                }
            }
            #endregion
            #region lines
            if (csgo.GetValue <OnOff>("espDrawLines") == OnOff.On)
            {
                Color color = colorPlayer;
                if (!player.IsSpotted)
                {
                    color *= 0.5f;
                }
                else
                {
                    color *= (0.75f + 0.25f * GetColorMultiplier());
                }
                FillPolygon(device,
                            color,
                            new Vector2(csgo.ScreenSize.Width / 2f, csgo.ScreenSize.Height),
                            new Vector2(point.X - width / 2f, point.Y),
                            new Vector2(point.X + width / 2f, point.Y));
            }
            #endregion
            #region box
            //Draw box
            if (csgo.GetValue <OnOff>("espDrawBox") == OnOff.On)
            {
                this.DrawRectangle(device,
                                   colorPlayer,
                                   rectX,
                                   rectY,
                                   rectW,
                                   rectH,
                                   1f);
            }
            #endregion
            #region circle
            if (csgo.GetValue <OnOff>("espDrawCircle") == OnOff.On)
            {
                Vector3[] circPoints = Geometry.Create3DFlatCircle(
                    player.Vector3,
                    32f + (player.IsSpotted ? 16f * GetColorMultiplier() : 0f),
                    32);
                Vector2[] scrCircPoints = Geometry.WorldToScreen(csgo.ViewMatrix, csgo.ScreenSize, circPoints);
                DrawLines(device, colorPlayer, 15f / distanceMeter, scrCircPoints);
            }
            #endregion
            #region distance
            if (csgo.GetValue <OnOff>("espDrawDistance") == OnOff.On)
            {
                string     distString = Math.Round(distanceMeter, 0).ToString() + "m";
                RectangleF distSize   = Control.MeasureString(this.Font, distString);
                //Draw text
                DrawText(device,
                         foreColor,
                         backColor,
                         rectX + rectW / 2f - distSize.Width / 2f,
                         rectY + rectH,
                         100f,
                         20f,
                         1f,
                         1f,
                         distString,
                         FactoryManager.GetFont("smallSegoe"));
            }
            #endregion
            #region highlight
            if (highlighted)
            {
                float size  = (float)Math.Max(rectW + boxBorder, rectH + boxBorder) * 2f;
                Color color = (colorPlayer) * (0.5f + 0.5f * GetColorMultiplier());
                FillEllipse(
                    device,
                    color * 0.5f,
                    rectX + rectW / 2f,
                    rectY + rectH / 2f,
                    size,
                    size,
                    true);
                DrawEllipse(device,
                            color, //* (DateTime.Now.Millisecond % 1000f / 1000f),
                            rectX + rectW / 2f,
                            rectY + rectH / 2f,
                            size,
                            size,
                            true,
                            1.5f);
            }
            #endregion
            #region name
            if (csgo.GetValue <OnOff>("espDrawName") == OnOff.On)
            {
                ////Name
                //DrawText(device,
                //    foreColor,
                //    backColor,
                //    rectX + rectW,
                //    rectY - boxBorder,
                //    100f,
                //    20f,
                //    1f,
                //    1f,
                //    (player.IsDormant ? "[DORMANT] " : "") + player.Name,
                //    FactoryManager.GetFont("smallSegoe"));
                ////Info
                //string weaponInfo = "-";
                //if (player.WeaponIndex >= 0 && player.WeaponIndex < csgo.Entities.Length)
                //{
                //    if (csgo.Entities[player.WeaponIndex] != null)
                //        weaponInfo = csgo.Entities[player.WeaponIndex].Name;
                //}

                //string data = String.Format(
                //"Weapon: {0}",
                //    /*player.Health, player.Armor,*/ weaponInfo);

                //if (csgo.GetValue<OnOff>("espDrawDetails") == OnOff.On)
                //    data = String.Format("{0}\n" +
                //    "Balance: ${1}\n" +
                //    "Kills: {2}\n" +
                //    "Assists: {3}\n" +
                //    "Deaths: {4}\n" +
                //    "Score: {5}",
                //    data, player.Money, player.Kills, player.Assists, player.Deaths, player.Score);

                //DrawText(device,
                //    foreColor,
                //    backColor,
                //    rectX + rectW,
                //    rectY - boxBorder + 16f,
                //    100f,
                //    20f,
                //    1f,
                //    1f,
                //    data,
                //    FactoryManager.GetFont("tinySegoe"));
                string weaponInfo = "-";
                if (player.WeaponIndex >= 0 && player.WeaponIndex < csgo.Entities.Length)
                {
                    if (csgo.Entities[player.WeaponIndex] != null)
                    {
                        weaponInfo = csgo.Entities[player.WeaponIndex].Name;
                    }
                }
                string     str  = string.Format("{0}\n[{1}]", player.Name, weaponInfo);
                RectangleF size = Control.MeasureString(this.Font, str);
                //Name
                DrawText(device,
                         foreColor,
                         backColor,
                         rectX + rectW / 2f - size.Width / 2f,
                         rectY - 40,
                         100f,
                         20f,
                         2f,
                         2f,
                         str,
                         FactoryManager.GetFont("smallSegoe"));
            }
            #endregion
            #region health
            if (csgo.GetValue <OnOff>("espDrawHealth") == OnOff.On)
            {
                ////HP
                //FillRectangle(device,
                //        lifeBarBackground,
                //        rectX,
                //        rectY - lifeBarHeight * 3f,
                //        width, //rectW,
                //        lifeBarHeight /*10f*/);
                //FillRectangle(device,
                //        lifeBarForeground,
                //        rectX,
                //        rectY - lifeBarHeight * 3f,
                //    /*rectW*/ width / 100f * player.Health,
                //        lifeBarHeight /*10f*/);
                //DrawText(device,
                //    lifeBarForeground,
                //    backColor,
                //    rectX + width,
                //    rectY - lifeBarHeight * 3f - 2f,
                //    100f,
                //    20f,
                //    1f,
                //    1f,
                //    player.Health.ToString(),
                //    FactoryManager.GetFont("miniSegoe"));
                ////Armor
                //FillRectangle(device,
                //        lifeBarBackground,
                //        rectX,
                //        rectY - lifeBarHeight * 2f,
                //        width, //rectW,
                //        lifeBarHeight /*10f*/);
                //FillRectangle(device,
                //        viewColorOutline,
                //        rectX,
                //        rectY - lifeBarHeight * 2f,
                //    /*rectW*/ width / 100f * player.Armor,
                //        lifeBarHeight /*10f*/);
                //DrawText(device,
                //    viewColorOutline,
                //    backColor,
                //    rectX + width,
                //    rectY - lifeBarHeight * 2f - 2f,
                //    100f,
                //    20f,
                //    1f,
                //    1f,
                //    player.Armor.ToString(),
                //    FactoryManager.GetFont("miniSegoe"));
                //HP
                FillRectangle(device,
                              lifeBarBackground,
                              rectX - lifeBarWidth,
                              rectY,
                              lifeBarWidth, //rectW,
                              rectH /*10f*/);
                FillRectangle(device,
                              lifeBarForeground,
                              rectX - lifeBarWidth,
                              rectY,
                              lifeBarWidth,
                              rectH / 100f * player.Health /*10f*/);
                DrawText(device,
                         lifeBarForeground,
                         backColor,
                         rectX - lifeBarWidth,
                         rectY + rectH,
                         100f,
                         20f,
                         1f,
                         1f,
                         player.Health.ToString(),
                         FactoryManager.GetFont("miniSegoe"));
                //Armor
                FillRectangle(device,
                              lifeBarBackground,
                              rectX + rectW,
                              rectY,
                              lifeBarWidth, //rectW,
                              rectH /*10f*/);
                FillRectangle(device,
                              viewColorOutline,
                              rectX + rectW,
                              rectY,
                              lifeBarWidth,
                              rectH / 100f * player.Armor /*10f*/);
                DrawText(device,
                         viewColorOutline,
                         backColor,
                         rectX + rectW,
                         rectY + rectH,
                         100f,
                         20f,
                         1f,
                         1f,
                         player.Armor.ToString(),
                         FactoryManager.GetFont("miniSegoe"));
            }
            #endregion
            #region rank
            if (player.Rank > 0)
            {
                //Scaling
                float boxWidth = rectW, boxHeight = rectW * aspect;

                /*
                 * Args:
                 * 1 actual bitmap
                 * 2 destination-rectangle
                 * 3 opacity
                 * 4 interpolation mode
                 * 5 source-rectangle - easy access using rank as index
                 */
                if (ranksBmp != null)
                {
                    device.DrawBitmap(
                        ranksBmp,
                        new RectangleF(point.X - boxWidth / 2f, point.Y + 20f, boxWidth, boxHeight),
                        0.7f,
                        BitmapInterpolationMode.Linear,
                        new RectangleF(0f, 80f * (player.Rank - 1), 200f, 80f));
                    if (boxWidth > 50f)
                    {
                        DrawText(device, foreColor, point.X - boxWidth / 2f, point.Y + 20f + boxHeight + 4f, 200f, 100f, string.Format("MM-wins: {0}", player.Wins.ToString()), this.Font);
                    }
                }
            }
            #endregion
        }
示例#19
0
文件: SHARPDX.cs 项目: ferib/VM86CS
        public override void Cycle()
        {
            // lets not fry my cpu
            SkipCount++;
            if (SkipCount % 10 == 0)
            {
                SkipCount = 0;
            }
            else
            {
                return;
            }

            var fontBuffer    = new byte[0x2000];
            var displayBuffer = new byte[0xfa0];

            x86CS.Memory.BlockRead(0xa0000, fontBuffer, fontBuffer.Length);
            x86CS.Memory.BlockRead(0xb8000, displayBuffer, displayBuffer.Length);

            // convert console display buffer to SharpDX window
            for (var i = 0; i < displayBuffer.Length; i += 2)
            {
                int  currChar   = displayBuffer[i];
                int  fontOffset = currChar * 32;
                byte attribute  = displayBuffer[i + 1];
                int  y          = i / 160 * 16; // height pixels

                Color foreColour = vgaDevice.GetColour(attribute & 0xf);
                Color backColour = vgaDevice.GetColour((attribute >> 4) & 0xf);

                for (var f = fontOffset; f < fontOffset + 16; f++)
                {
                    int x = ((i % 160) / 2) * 8; // width pixels

                    for (var j = 7; j >= 0; j--)
                    {
                        var pixelIndex = Width * 4 * y + x * 4;
                        if (((fontBuffer[f] >> j) & 0x1) != 0)
                        {
                            Memory[pixelIndex + 0] = foreColour.R;
                            Memory[pixelIndex + 1] = foreColour.G;
                            Memory[pixelIndex + 2] = foreColour.B;
                            Memory[pixelIndex + 3] = foreColour.A;
                            var d = fontBuffer[f];
                        }
                        else
                        {
                            Memory[pixelIndex + 0] = backColour.R;
                            Memory[pixelIndex + 1] = backColour.G;
                            Memory[pixelIndex + 2] = backColour.B;
                            Memory[pixelIndex + 3] = backColour.A;
                        }
                        x++;
                    }
                    y++;
                }
            }

            // copy buffer to device
            BitmapBuffer.CopyFromMemory(Memory, Width * 4);

            // Draw bitmap to device
            DrawTarget.BeginDraw();
            DrawTarget.Clear(new SharpDX.Mathematics.Interop.RawColor4(1f, 0f, 1f, 1f));
            DrawTarget.DrawBitmap(BitmapBuffer, 1.0f, BitmapInterpolationMode.Linear);
            DrawTarget.EndDraw();
        }
示例#20
0
 //============================================================
 // <T>绘制位图。</T>
 //
 // @param bitmap 位图
 // @param x 横坐标
 // @param y 纵坐标
 //============================================================
 public void DrawBitmap(FDxBitmap bitmap, int x, int y)
 {
     _target.DrawBitmap(bitmap.Native, new Rectangle(x, y, bitmap.Size.Width, bitmap.Size.Height));
 }
示例#21
0
        public void DrawBitmap(Direct2DBitmap bmp, float x, float y, float opacity)
        {
            Bitmap bitmap = bmp;

            _device.DrawBitmap(bitmap, new RawRectangleF(x, y, x + bitmap.PixelSize.Width, y + bitmap.PixelSize.Height), opacity, BitmapInterpolationMode.Linear);
        }
示例#22
0
        public void DrawBitmap(Bitmap bmp, float x, float y, float scale = 1.0f, float opacity = 1.0f)
        {
            bool filter = (scale % 1.0f) != 0.0f;

            renderTarget.DrawBitmap(bmp, new RawRectangleF(x, y, x + bmp.Size.Width * scale, y + bmp.Size.Height * scale), opacity, filter ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor);
        }
示例#23
0
 public void DrawBitmap(Dx2DBitmap bitmap, float x, float y, float opacity)
 {
     _device.DrawBitmap(bitmap, new RawRectangleF(x, y, x + bitmap.Width, y + bitmap.Height), opacity, BitmapInterpolationMode.Linear);
 }
示例#24
0
        private void sDXThread(object sender)
        {
            SharpDX.Mathematics.Interop.RawRectangleF rec = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec.Bottom = yResolution;
            rec.Top    = 0;
            rec.Right  = xResolution;
            rec.Left   = 0;
            SharpDX.Mathematics.Interop.RawRectangleF rec1 = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec1.Bottom = 187f / 1080f * yResolution;
            rec1.Top    = 31f / 1080f * yResolution;
            rec1.Right  = (1636f - 78f * 4f + xAdjustment) / 1920f * xResolution;
            rec1.Left   = (1559f - 78f * 4f + xAdjustment) / 1920f * xResolution;
            SharpDX.Mathematics.Interop.RawRectangleF rec2 = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec2.Bottom = 187f / 1080f * yResolution;
            rec2.Top    = 31f / 1080f * yResolution;
            rec2.Right  = (1636f - 78f * 3f + xAdjustment) / 1920f * xResolution;
            rec2.Left   = (1559f - 78f * 3f + xAdjustment) / 1920f * xResolution;
            SharpDX.Mathematics.Interop.RawRectangleF rec3 = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec3.Bottom = 187f / 1080f * yResolution;
            rec3.Top    = 31f / 1080f * yResolution;
            rec3.Right  = (1636f - 78f * 2f + xAdjustment) / 1920f * xResolution;
            rec3.Left   = (1559f - 78f * 2f + xAdjustment) / 1920f * xResolution;
            SharpDX.Mathematics.Interop.RawRectangleF rec4 = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec4.Bottom = 187f / 1080f * yResolution;
            rec4.Top    = 31f / 1080f * yResolution;
            rec4.Right  = (1636f - 78f + xAdjustment) / 1920f * xResolution;
            rec4.Left   = (1559f - 78f + xAdjustment) / 1920f * xResolution;
            SharpDX.Mathematics.Interop.RawRectangleF rec5 = new SharpDX.Mathematics.Interop.RawRectangleF();
            rec5.Bottom = 187f / 1080f * yResolution;
            rec5.Top    = 31f / 1080f * yResolution;
            rec5.Right  = (1636f + xAdjustment) / 1920f * xResolution;
            rec5.Left   = (1559f + xAdjustment) / 1920f * xResolution;
            SharpDX.Mathematics.Interop.RawRectangleF recwc = new SharpDX.Mathematics.Interop.RawRectangleF();
            recwc.Bottom = (276f / 1080) * yResolution;
            recwc.Top    = (224f / 1080) * yResolution;
            recwc.Right  = (1641f / 1920f) * xResolution;
            recwc.Left   = (1589f / 1920f) * xResolution;
            List <SharpDX.Mathematics.Interop.RawRectangleF> rectangles = new List <SharpDX.Mathematics.Interop.RawRectangleF>();

            rectangles.Add(rec1);
            rectangles.Add(rec2);
            rectangles.Add(rec3);
            rectangles.Add(rec4);
            rectangles.Add(rec5);
            SharpDX.Mathematics.Interop.RawColor4 r4color2 = new SharpDX.Mathematics.Interop.RawColor4();
            r4color2.A = 255;
            r4color2.R = 125;
            r4color2.G = 0;
            r4color2.B = 0;
            while (true)
            {
                device.BeginDraw();
                SharpDX.Mathematics.Interop.RawColor4 transparent = new SharpDX.Mathematics.Interop.RawColor4();
                transparent.A = 0;
                transparent.R = 255;
                transparent.G = 255;
                transparent.B = 255;
                device.Clear(transparent);
                solidColorBrush.Color = r4color2;
                for (int i = 0; i <= Flasks.Count() - 1; i++)
                {
                    if (Flasks[i].inUse && Flasks[i].visible)
                    {
                        if (Flasks[i].useDuration > 0)
                        {
                            device.DrawBitmap(LoadFromFile(device, Flasks[i].flaskImageLocation), rectangles[i], flaskAlpha / 100, BitmapInterpolationMode.Linear, rec);
                        }
                    }
                }
                if (WCCD && showWC)
                {
                    device.DrawBitmap(LoadFromFile(device, "FlaskImages\\WC.png"), recwc, 1.0f, BitmapInterpolationMode.Linear, rec);
                }
                device.EndDraw();
                Thread.Sleep(200);
            }

            //whatever you want
        }
示例#25
0
 private void RenderScene(WindowRenderTarget renderTarget)
 {
     renderTarget.DrawBitmap(_bitmap, new RectF(0, 0, 200, 133), 1, BitmapInterpolationMode.Linear);
     renderTarget.FillRect(_brush, new RectF(0, 0, 25, 25));
     renderTarget.FillRect(_brush, new RectF(25, 25, 25, 25));
     renderTarget.FillRect(_brush, new RectF(50, 50, 25, 25));
     renderTarget.FillRect(_brush, new RectF(75, 75, 25, 25));
     renderTarget.FillRect(_brush, new RectF(100, 100, 25, 25));
     renderTarget.FillRect(_brush, new RectF(125, 125, 25, 25));
 }
示例#26
0
 private void DrawImage(int X, int Y, int W, int H, Bitmap bitmap)
 {
     device.DrawBitmap(bitmap, new RectangleF(X, Y, W, H), 1.0f, BitmapInterpolationMode.Linear);
 }