public static void DrawCircle(WindowRenderTarget renderTarget, float radius, SharpDX.Mathematics.Interop.RawVector2 center, D2D.Brush brush, float strokeWidth = 1f, StrokeStyle strokeStyle = null)
        {
            Ellipse ellipse = new Ellipse(center, radius, radius);

            if (strokeStyle == null)
            {
                renderTarget.DrawEllipse(ellipse, brush, strokeWidth);
            }
            else
            {
                renderTarget.DrawEllipse(ellipse, brush, strokeWidth, strokeStyle);
            }
        }
Beispiel #2
0
        protected override void OnRender(WindowRenderTarget renderTarget)
        {
            RectF bounds = new RectF(new PointF(), renderTarget.Size);

            renderTarget.FillRect(_gridPatternBrush, bounds);

            RectF brushRect = new RectF(0, 0, 150, 150);
            RectF textRect  = new RectF(0, 165, 150, 35);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(5.5f, 5.5f));
            renderTarget.FillRect(_yellowGreenBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("SolidColorBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(200.5f, 5.5f));
            renderTarget.FillRect(_linearGradientBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("LinearGradientBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(5.5f, 200.5f));
            renderTarget.FillEllipse(_radialGradientBrush, new Ellipse(brushRect));
            renderTarget.DrawEllipse(_blackBrush, 1, new Ellipse(brushRect));
            renderTarget.DrawText("RadialGradientBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(200.5f, 200.5f));
            renderTarget.FillRect(_bitmapBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("BitmapBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);
        }
Beispiel #3
0
        private void Draw()
        {
            //begin rendering
            target.BeginDraw();
            //clear target
            target.Clear(SharpDX.Color.CornflowerBlue);

            //draw a rounded box
            target.FillRoundedRectangle(new RoundedRectangle()
            {
                RadiusX = 10,
                RadiusY = 10,
                Rect    = new SharpDX.RectangleF(0, 0, ClientSize.Width, ClientSize.Height)
            }, gradient);

            //draw some ellipse
            for (int i = 0; i < 20; i++)
            {
                target.DrawEllipse(new Ellipse(new Vector2(ClientSize.Width / 2, ClientSize.Height / 2), 20 * i, 20 * i), redBrush);
            }

            //draw text
            target.DrawText("Hello Direct2D", textFormat, new SharpDX.RectangleF(0, 0, 400, 200), whiteBrush);

            //end drawing
            target.EndDraw();
        }
Beispiel #4
0
        private void DrawPlayerHead(float x, float y, float distance)
        {
            float radius = 4000 / distance;

            DrawTypes.RawVector2 HeadPos = new DrawTypes.RawVector2(x, y);

            Ellipse HeadCricle = new Ellipse(HeadPos, radius, radius);

            device.DrawEllipse(HeadCricle, brushSolidGreenYellow);
        }
Beispiel #5
0
        /// <summary>
        /// Draws a non-filled circle
        /// </summary>
        /// <param name="renderTarget">Used to draw the circle on the target. Needs to have BeginDraw() called before</param>
        /// <param name="brush">Brush used to color the circle</param>
        /// <param name="center">Center of the circle</param>
        /// <param name="radius">Radius of the circle</param>
        /// <param name="strokeWidth">Stroke width of the circle line</param>
        public static void Draw(WindowRenderTarget renderTarget, Brush brush, Vector2 center, float radius, float strokeWidth = 1f, StrokeStyle strokeStyle = null)
        {
            if (renderTarget == null || brush == null || center == null)
            {
                throw new ArgumentNullException("value is null");
            }

            if (renderTarget.IsDisposed)
            {
                throw new ArgumentNullException("Rendertarget is disposed");
            }

            Ellipse ellipse = new Ellipse(center, radius, radius);

            if (strokeStyle == null)
            {
                renderTarget.DrawEllipse(ellipse, brush, strokeWidth);
            }
            else
            {
                renderTarget.DrawEllipse(ellipse, brush, strokeWidth, strokeStyle);
            }
        }
 protected void DrawEllipse(WindowRenderTarget device, Color color, float x, float y, float width, float height, bool centered = false, float strokeWidth = 1f)
 {
     using (SolidColorBrush brush = new SolidColorBrush(device, color))
     {
         device.DrawEllipse(
             new Ellipse(
                 new Vector2(
                     (centered ? x : x - width / 2f),
                     (centered ? y : y - height / 2f)
                     ),
                 width / 2f,
                 height / 2f
                 ),
             brush,
             strokeWidth
             );
     }
 }
Beispiel #7
0
 public override void DrawEllipse(SharpDX.Color color, Vector2 position, Vector2 size, bool centered = false, float strokeWidth = 1f)
 {
     if (device == null)
     {
         throw new SharpDXException("The device was not initialized yet");
     }
     using (SolidColorBrush brush = new SolidColorBrush(device, color))
     {
         device.DrawEllipse(
             new Ellipse(
                 (centered ? position : new Vector2(position.X + size.X / 2f, position.Y + size.Y / 2f)),
                 size.X / 2f,
                 size.Y / 2f
                 ),
             brush,
             strokeWidth
             );
     }
 }
Beispiel #8
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            renderTarget.BeginDraw();
            renderTarget.Clear(new RawColor4(1, 1, 1, 1));
            //renderTarget.DrawGeometry(path, brush);
            //foreach (var point in points)
            //    renderTarget.DrawLine(point, new RawVector2(point.X+4,point.Y+4), red, 4);

            for (int i = 0; i < line.rads.Count; i++)
            {
                Ellipse ellipse = new Ellipse(new RawVector2(line.points[i].X, line.points[i].Y), line.rads[i], line.rads[i]);
                renderTarget.DrawEllipse(ellipse, brush);
            }

            PathGeometry path = new PathGeometry(factory);

            path.FromPoints(contour, line.interpolatedNormals, true);
            renderTarget.FillGeometry(path, blue);
            path.Dispose();

            for (int i = 0; i < contour.Length; i++)
            {
                renderTarget.FillEllipse(new Ellipse(new RawVector2(contour[i].X, contour[i].Y),
                                                     1, 1), red);
            }

            KVector2 a  = new KVector2(200, 200);
            KVector2 a1 = new KVector2(100, 50);
            KVector2 a2 = a1.Orthogonal;

            renderTarget.DrawLine(new RawVector2(a.X, a.Y),
                                  new RawVector2(a.X + a1.X, a.Y + a1.Y), red);
            renderTarget.DrawLine(new RawVector2(a.X, a.Y),
                                  new RawVector2(a.X + a2.X, a.Y + a2.Y), brush);

            renderTarget.EndDraw();
        }
Beispiel #9
0
 public void DrawCircle(float x, float y, float radius, float stroke, Dx2DColor color)
 {
     _brush.Color = color;
     _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), _brush, stroke);
 }
 private void DrawCircle(float X, float Y, float R, Brush color)
 {
     device.DrawEllipse(new Ellipse(new RawVector2(X, Y), R, R), color, 1.0f);
 }
Beispiel #11
0
 public void DrawCircle(float x, float y, float radius, float stroke, System.Drawing.Color color)
 {
     _brush.Color = new RawColor4(color.R, color.G, color.B, color.A / 255.0f);
     _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), _brush, stroke);
 }
Beispiel #12
0
        private static void dxThread()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            gvar.SHUTDOWN++;
            while (gvar.isRunning)
            {
                if (gvar.isShuttingDown)
                {
                    gvar.SHUTDOWN--;
                    break;
                }
                Thread.Sleep(1);
                var frameLength = 1000f / gvar.Fps;

                if (gvar.RefreshID == int.MaxValue)
                {
                    gvar.RefreshID = 0;
                }

                gvar.RefreshID++;

                try
                {
                    #region Begin Device
                    Device.BeginDraw();
                    Device.Clear(new RawColor4(0, 0, 0, 0));
                    Device.TextAntialiasMode = TextAntialiasMode.Aliased;
                    Device.AntialiasMode     = AntialiasMode.Aliased;
                    #endregion

                    if (!isReady)
                    {
                        Device.EndDraw();
                        continue;
                    }

                    if (Settings.userSettings.MiscSettings.Watermark)
                    {
                        DrawText("Darc Euphoria", 4, 4);
                    }

                    if (Settings.userSettings.MiscSettings.LocalTime)
                    {
                        if (Settings.userSettings.MiscSettings.Watermark)
                        {
                            DrawText(DateTime.Now.ToString("h:mm:ss tt"), 4, (int)(MathFuncs.MeasureString("DarcEuphoria").Height) - 4);
                        }
                        else
                        {
                            DrawText(DateTime.Now.ToString("h:mm:ss tt"), 4, 4);
                        }
                    }

                    if (!Local.InGame)
                    {
                        Device.EndDraw();
                        continue;
                    }

                    ESP.Start(Device);

                    if ((Settings.userSettings.VisualSettings.SniperCrosshair && Local.ActiveWeapon.isSniper()) ||
                        Settings.userSettings.VisualSettings.RecoilCrosshair)
                    {
                        using (SolidColorBrush brush = new SolidColorBrush(Device, Color.White.toRawColor4()))
                        {
                            var radAngle = Local.Fov * (3.14f / 180f);
                            var radHFov  = 2 * Math.Atan(Math.Tan(radAngle / 2f) * gvar.AspectRatio);
                            var hFov     = radHFov * (180f / 3.14f);

                            var rcsPunchVec = Local.PunchAngle;
                            var x           = gvar.OverlaySize.Width / 2;
                            var y           = gvar.OverlaySize.Height / 2;
                            var dx          = gvar.OverlaySize.Width / hFov;
                            var dy          = gvar.OverlaySize.Height / Local.Fov;
                            x -= (int)(dx * rcsPunchVec.x);
                            y += (int)(dy * rcsPunchVec.y);
                            var point = new RawVector2(x, y);
                            var p1    = point;
                            var p2    = point;
                            var p3    = point;
                            var p4    = point;
                            p1.X -= 5;
                            p2.X += 5;
                            p3.Y -= 5;
                            p4.Y += 5;
                            Device.DrawLine(p1, p2, brush, 2);
                            Device.DrawLine(p3, p4, brush, 2);
                        }
                    }

                    if (Settings.userSettings.VisualSettings.DrawAimbotFov)
                    {
                        var radAngle = Local.Fov * (3.14f / 180f);
                        var radHFov  = 2 * Math.Atan(Math.Tan(radAngle / 2f) * gvar.AspectRatio);
                        var hFov     = radHFov * (180f / 3.14f);

                        var perc = gvar.OverlaySize.Width / hFov;

                        var radius = Aimbot.AimbotSettings.Fov * (float)perc;

                        var math = Math.Sqrt((gvar.OverlaySize.Width / 2) * (gvar.OverlaySize.Width / 2) +
                                             (gvar.OverlaySize.Height / 2) * (gvar.OverlaySize.Height / 2));

                        if (radius < math)
                        {
                            var rcsPunchVec = Local.PunchAngle;
                            var x           = gvar.OverlaySize.Width / 2;
                            var y           = gvar.OverlaySize.Height / 2;
                            var dx          = gvar.OverlaySize.Width / hFov;
                            var dy          = gvar.OverlaySize.Height / Local.Fov;
                            x -= (int)(dx * rcsPunchVec.x);
                            y += (int)(dy * rcsPunchVec.y);

                            RawVector2 center = new RawVector2(x, y);

                            using (SolidColorBrush brush = new SolidColorBrush(Device, Color.White.toRawColor4()))
                                Device.DrawEllipse(new Ellipse(center, radius, radius), brush);
                        }
                    }
                    Device.EndDraw();
                } catch { Thread.Sleep(10); }



                var delayLength = frameLength - stopwatch.ElapsedMilliseconds;
                if (delayLength > 0 && !float.IsInfinity(frameLength))
                {
                    Thread.Sleep((int)delayLength);
                }

                stopwatch.Restart();
            }
            Device.Dispose();
        }
Beispiel #13
0
 public void DrawCircle(int x, int y, int radius, float stroke, ID2DBrush brush) => _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush.GetBrush(), stroke);
Beispiel #14
0
 public void DrawCircle(float x, float y, float radius, float stroke, Direct2DBrush brush)
 {
     _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush, stroke);
 }
Beispiel #15
0
        private void DirectXThread(object sender)
        {
            MainForm.Mem = new MemoryHelper();

            HealthColorBrush1 = new SolidColorBrush(_Device, new RawColor4(0.003922f, 0.003922f, 0.003922f, 1));

            while (_Running)
            {
                //Calling Colors from MainForm
                BoxColorBrush      = new SolidColorBrush(_Device, new RawColor4(MainForm.BoxColor.R / 255, MainForm.BoxColor.G / 255, MainForm.BoxColor.B / 255, 1));
                CircleColorBrush   = new SolidColorBrush(_Device, new RawColor4(MainForm.CircleColor.R / 255, MainForm.CircleColor.G / 255, MainForm.CircleColor.B / 255, 1));
                SkeletonColorBrush = new SolidColorBrush(_Device, new RawColor4(MainForm.SkeletonColor.R / 255, MainForm.SkeletonColor.G / 255, MainForm.SkeletonColor.B / 255, 1));
                SnaplineColorBrush = new SolidColorBrush(_Device, new RawColor4(MainForm.SnaplineColor.R / 255, MainForm.SnaplineColor.G / 255, MainForm.SnaplineColor.B / 255, 1));
                TextColorBrush     = new SolidColorBrush(_Device, new RawColor4(MainForm.TextColor.R / 255, MainForm.TextColor.G / 255, MainForm.TextColor.B / 255, 1));

                //Getting R6S Window RECT (Coordinates and Size)
                GetWindowRect(FindWindow(null, "Rainbow Six"), out rect);
                screenX = rect.Right;
                screenY = rect.Bottom;
                MainForm.Mem.displayWidth  = rect.Right;
                MainForm.Mem.displayHeight = rect.Bottom;

                _Device.BeginDraw();
                _Device.Clear(new RawColor4(Color.Transparent.R, Color.Transparent.G, Color.Transparent.B, Color.Transparent.A));
                _Device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased;

                //For Distance
                long       LocalPlayerBaseAddress = MainForm.Mem.GetEntity(0);
                PlayerInfo LocalPlayer            = MainForm.Mem.GetAllEntityInfo(LocalPlayerBaseAddress);

                // Render our ESP here
                for (int i = 1 /*0 is local player in situations and lw htunt, set to 0 if playing mp*/; i < 64; i++)
                {
                    long Entity = MainForm.Mem.GetEntity(i);

                    //Get a PlayerInfo struct with all of this entity's info
                    PlayerInfo Player = MainForm.Mem.GetAllEntityInfo(Entity);
                    Player.Health = MainForm.Mem.GetEntityHealth(MainForm.Mem.GetEntity2(i));
                    if (Player.Health > 0 &&            //Health over 0
                        Player.Health <= 100 &&         //Health less than 200
                        Player.w2sPos.z >= 0.1f &&      //Player is actually on the screen
                        Player.w2sHead.z >= 0.1f        //Player is actually on the screen
                        )
                    {
                        HealthColorBrush2 = new SolidColorBrush(_Device, new RawColor4((100 - Player.Health) * 1 / 100, Player.Health * 1 / 100, 0, 1));

                        float BoxHeight = Player.w2sPos.y - Player.ScrenTop.y;
                        float BoxWidth  = BoxHeight / 2.4f;

                        if (MainForm.Box)
                        {
                            //Draw player box
                            _Device.DrawRectangle(new RawRectangleF(Player.ScrenTop.x - BoxWidth / 2, Player.ScrenTop.y - BoxHeight / 12.5f,
                                                                    Player.w2sHead.x + BoxWidth / 2, Player.w2sPos.y), BoxColorBrush);
                        }

                        if (MainForm.Circle)
                        {
                            //Draw a circle around the players head
                            _Device.DrawEllipse(new Ellipse
                            {
                                Point   = new RawVector2(Player.w2sHead.x, Player.w2sHead.y),
                                RadiusX = BoxHeight / 12.5f,
                                RadiusY = BoxHeight / 12.5f
                            }, CircleColorBrush);
                        }

                        if (MainForm.Distance)
                        {
                            //Draw name
                            _Device.DrawText(Math.Round(Vector3.Get3DDistance(LocalPlayer.w2sPos, Player.w2sPos) / 1000, 2).ToString() + "m",
                                             new TextFormat(_FontFactory, _FontFamily, FontSizeSmall),
                                             new RawRectangleF(Player.w2sPos.x - (BoxWidth / 2), Player.w2sPos.y, screenX, Player.w2sPos.y), TextColorBrush);
                        }

                        if (MainForm.Healthbar)
                        {
                            //Draw healthbar
                            if (MainForm.bRight)
                            {
                                _Device.FillRectangle(new RawRectangleF(Player.w2sHead.x + (BoxWidth / 2) + 2, Player.ScrenTop.y - BoxHeight / 12.5f, Player.w2sHead.x + (BoxWidth / 2) + 8, Player.w2sPos.y), HealthColorBrush1);
                                _Device.FillRectangle(new RawRectangleF(Player.w2sHead.x + (BoxWidth / 2) + 4, Player.w2sPos.y - BoxHeight / 12.5f + 2 - (BoxHeight / 100 * Player.Health), Player.w2sHead.x + (BoxWidth / 2) + 6, Player.w2sPos.y - 2), HealthColorBrush2);
                            }
                            else
                            {
                                _Device.FillRectangle(new RawRectangleF(Player.w2sHead.x - (BoxWidth / 2) - 8, Player.ScrenTop.y - BoxHeight / 12.5f, Player.w2sHead.x - (BoxWidth / 2) - 2, Player.w2sPos.y), HealthColorBrush1);
                                _Device.FillRectangle(new RawRectangleF(Player.w2sHead.x - (BoxWidth / 2) - 6, Player.w2sPos.y - BoxHeight / 12.5f + 2 - (BoxHeight / 100 * Player.Health), Player.w2sHead.x - (BoxWidth / 2) - 4, Player.w2sPos.y - 2), HealthColorBrush2);
                            }
                        }

                        if (MainForm.Nametags)
                        {
                            //Draw name
                            _Device.DrawText(MainForm.NametagsText, new TextFormat(_FontFactory, _FontFamily, FontSizeSmall),
                                             new RawRectangleF(Player.w2sHead.x - BoxWidth / 2, Player.ScrenTop.y, screenX, Player.ScrenTop.y - BoxHeight / 3),
                                             TextColorBrush, DrawTextOptions.None);
                        }

                        if (MainForm.Skeleton)
                        {
                            //Draw bones
                            /*Head-Neck*/
                            _Device.DrawLine(new RawVector2(Player.w2sHead.x, Player.w2sHead.y), new RawVector2(Player.w2sNeck.x, Player.w2sNeck.y), SkeletonColorBrush);
                            /*Neck-Chest*/
                            _Device.DrawLine(new RawVector2(Player.w2sNeck.x, Player.w2sNeck.y), new RawVector2(Player.w2sChest.x, Player.w2sChest.y), SkeletonColorBrush);
                            /*Chest-Stomach*/
                            _Device.DrawLine(new RawVector2(Player.w2sChest.x, Player.w2sChest.y), new RawVector2(Player.w2sStomach.x, Player.w2sStomach.y), SkeletonColorBrush);
                            /*Stomach-Pelvis*/
                            _Device.DrawLine(new RawVector2(Player.w2sStomach.x, Player.w2sStomach.y), new RawVector2(Player.w2sPelvis.x, Player.w2sPelvis.y), SkeletonColorBrush);
                            /*Pevlis-Feet*/
                            _Device.DrawLine(new RawVector2(Player.w2sPelvis.x, Player.w2sPelvis.y), new RawVector2(Player.w2sPos.x, Player.w2sPos.y), SkeletonColorBrush);
                            /*Chest-RIGHT_HAND*/
                            _Device.DrawLine(new RawVector2(Player.w2sChest.x, Player.w2sChest.y), new RawVector2(Player.w2sRHand.x, Player.w2sRHand.y), SkeletonColorBrush);
                        }

                        if (MainForm.Snaplines)
                        {
                            //Draw snapline
                            if (MainForm.Crosshair)
                            {
                                _Device.DrawLine(new RawVector2(screenX / 2, screenY / 2), new RawVector2(Player.w2sPos.x, Player.w2sPos.y), SnaplineColorBrush, 1);
                            }
                            else
                            {
                                _Device.DrawLine(new RawVector2(screenX / 2, screenY), new RawVector2(Player.w2sPos.x, Player.w2sPos.y), SnaplineColorBrush, 1);
                            }
                        }
                    }
                }

                // End Render of our ESP
                _Device.EndDraw();
            }
        }
Beispiel #16
0
        protected override void OnRender(WindowRenderTarget renderTarget)
        {
            RectF bounds = new RectF(new PointF(), renderTarget.Size);
            renderTarget.FillRect(_gridPatternBrush, bounds);

            RectF brushRect = new RectF(0, 0, 150, 150);
            RectF textRect = new RectF(0, 165, 150, 35);
            renderTarget.Transform = Matrix3x2.Translation(new SizeF(5.5f, 5.5f));
            renderTarget.FillRect(_yellowGreenBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("SolidColorBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(200.5f, 5.5f));
            renderTarget.FillRect(_linearGradientBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("LinearGradientBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(5.5f, 200.5f));
            renderTarget.FillEllipse(_radialGradientBrush, new Ellipse(brushRect));
            renderTarget.DrawEllipse(_blackBrush, 1, new Ellipse(brushRect));
            renderTarget.DrawText("RadialGradientBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);

            renderTarget.Transform = Matrix3x2.Translation(new SizeF(200.5f, 200.5f));
            renderTarget.FillRect(_bitmapBrush, brushRect);
            renderTarget.DrawRect(_blackBrush, 1, brushRect);
            renderTarget.DrawText("BitmapBrush", this._textFormat, textRect, this._blackBrush, DrawTextOptions.None, MeasuringMode.Natural);
        }
Beispiel #17
0
 private void DrawCircle(int X, int Y, int W, Color color)
 {
     solidColorBrush.Color = color;
     device.DrawEllipse(new Ellipse(new Vector2(X, Y), W, W), solidColorBrush);
 }
 public void DrawCircle(float x, float y, float radius, float stroke, int brush)
 {
     _device.DrawEllipse(new Ellipse(new SharpDX.Vector2(x, y), radius, radius), _brushContainer[brush], stroke);
 }
Beispiel #19
0
        public Cpuz()
        {
            InitializeComponent();
            //Make the window's border completely transparant

            #region D3D初始化
            // ANTI BATTLEYE SIG SCAN ;)
            this.Text = Guid.NewGuid().ToString().Replace("-", "");

            // TRANSPARENCY KEY
            this.BackColor = System.Drawing.Color.Black;

            // SETTINGS
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;

            // MAKE WINDOW TRANSPARENT
            Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT));

            // MAKE WINDOW SOLID
            Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA);

            var targetProperties = new HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top),
                PresentOptions = PresentOptions.Immediately
            };

            var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d3dFactory = new SharpDX.Direct2D1.Factory();

            var device = new WindowRenderTarget(d3dFactory, prop, targetProperties)
            {
                TextAntialiasMode = TextAntialiasMode.Cleartype,
                AntialiasMode     = AntialiasMode.Aliased
            };

            #endregion

            var       k         = KReader.readPuBase();
            JSON_DATA json_data = null;
            var       dxthread  = new Thread(() =>
            {
                var brushWhite   = new SolidColorBrush(device, RawColorFromColor(Color.White));
                var brushBlack   = new SolidColorBrush(device, RawColorFromColor(Color.Black));
                var brushGreen   = new SolidColorBrush(device, RawColorFromColor(Color.Green));
                var brushRed     = new SolidColorBrush(device, RawColorFromColor(Color.Red));
                var brushPurple  = new SolidColorBrush(device, RawColorFromColor(Color.Purple));
                var fontFactory  = new SharpDX.DirectWrite.Factory();
                var fontConsolas = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 15);
                var fontESP      = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 12);

                while (true)
                {
                    // attempt to download JSON data as a string
                    try
                    {
                        json_data = DoGame.getGameDate();

                        if (json_data != null && json_data.players.Count > 0)
                        {
                            mainFrom.STATE = true;
                            device.BeginDraw();
                            device.Clear(null);

                            #region RADAR

                            int radarSize       = 600;
                            Vector2 centerpoint = new Vector2(2356, 1210);

                            if (Setting.雷达)
                            {
                                Ellipse el3 = new Ellipse(new RawVector2(2356, 1210), 1, 1);
                                device.DrawEllipse(el3, brushRed);
                                device.FillEllipse(el3, brushRed);

                                // TODO: INTEGRATE INTO MINIMAP
                                //if (Setting.雷达)
                                //{
                                //    var radarOuterRectangle = new RawRectangleF(radarX, radarY, radarX + radarSize,
                                //        radarY + radarSize);
                                //    var radarRectangle = new RawRectangleF(radarX + radarBorder, radarY + radarBorder,
                                //        radarX + radarSize - radarBorder, radarY + radarSize - radarBorder);

                                //    var radarCenterRectangle = new RoundedRectangle()
                                //    {
                                //        RadiusX = 4,
                                //        RadiusY = 4,
                                //        Rect = new RawRectangleF(centerpoint.X, centerpoint.Y, centerpoint.X + 4,
                                //            centerpoint.Y + 4)
                                //    };

                                //    device.FillRectangle(radarRectangle, brushBlack);
                                //    device.DrawRectangle(radarRectangle, brushWhite);

                                //    device.FillRoundedRectangle(radarCenterRectangle, brushGreen);

                                //}
                            }

                            #endregion


                            var vecLocalLocation = new Model.Vector3
                            {
                                X = json_data.camera[1].X,
                                Y = json_data.camera[1].Y,
                                Z = json_data.camera[1].Z
                            };

                            var PlayerCameraManager = new PlayerCameraManager
                            {
                                CameraCache = new FCameraCacheEntry
                                {
                                    POV = new FMinimalViewInfo
                                    {
                                        Fov      = json_data.camera[2].X,
                                        Location = new Model.Vector3
                                        {
                                            X = json_data.camera[1].X,
                                            Y = json_data.camera[1].Y,
                                            Z = json_data.camera[1].Z
                                        },
                                        Rotation = new Model.FRotator
                                        {
                                            Pitch = json_data.camera[0].X,
                                            Yaw   = json_data.camera[0].Y,
                                            Roll  = json_data.camera[0].Z
                                        }
                                    }
                                }
                            };

                            #region 车

                            if (Setting.车辆显示)
                            {
                                foreach (var v in json_data.vehicles)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;
                                    if (lDeltaInMeters <= 400)
                                    {
                                        Vector2 screenlocation;
                                        if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                        {
                                            DrawText($"[{v.v}] {(int)lDeltaInMeters}m", (int)screenlocation.X,
                                                     (int)screenlocation.Y, v.v == "Deat" ? brushBlack : brushGreen,
                                                     fontFactory, fontESP, device);
                                        }
                                    }
                                }
                            }

                            #endregion

                            #region 物品

                            //todo:有BUG
                            if (Setting.物品显示)
                            {
                                foreach (var v in json_data.items)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;

                                    Vector2 screenlocation;
                                    if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                    {
                                        DrawText($"{v.n}", (int)screenlocation.X,
                                                 (int)screenlocation.Y, brushWhite, fontFactory, fontESP, device);
                                    }
                                }
                            }

                            #endregion

                            #region 人物

                            var playerList  = json_data.players.OrderBy(z => z.id).ToList();
                            var localPlayer = playerList[0];
                            foreach (var player in playerList)
                            {
                                if (player.health > 0 && player.isInactive > 0 && player.id != 0)
                                {
                                    var vecPlayerLocation = new Vector3 {
                                        X = player.rx, Y = player.ry, Z = player.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecPlayerLocation;
                                    //距离
                                    var lDeltaInMeters = vecRelativePos.Length / 100.0f;


                                    if (lDeltaInMeters >= 750)
                                    {
                                        continue;
                                    }
                                    #region 线条
                                    if (Setting.线条)
                                    {
                                        if (lDeltaInMeters > 3)
                                        {
                                            if (
                                                //超过200米不显示线
                                                lDeltaInMeters <= 200
                                                //超过40人不显示线
                                                && json_data.players.Count <= 40
                                                //队友不显示
                                                && player.t != localPlayer.t
                                                )
                                            {
                                                if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                                  out var screenlocation))
                                                {
                                                    device.DrawLine(new RawVector2(Setting.Screen.Width / 2f, Setting.Screen.Height),
                                                                    new RawVector2(screenlocation.X, screenlocation.Y), lDeltaInMeters <= 100 ? brushRed : brushWhite);
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region Distance ESP
                                    if (lDeltaInMeters > 3)
                                    {
                                        if (Setting.距离和血量)
                                        {
                                            if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                              out var screenlocation))
                                            {
                                                SolidColorBrush brush = brushRed;

                                                if (lDeltaInMeters >= 250)
                                                {
                                                    brush = brushPurple;
                                                }
                                                if (lDeltaInMeters >= 500)
                                                {
                                                    brush = brushGreen;
                                                }
                                                if (player.t == localPlayer.t)
                                                {
                                                    brush = brushGreen;
                                                }

                                                DrawText($"[{player.id}]{(int)player.health} {(int)lDeltaInMeters}m",
                                                         (int)screenlocation.X,
                                                         (int)screenlocation.Y,
                                                         brush,
                                                         fontFactory, fontESP, device);
                                            }
                                        }
                                    }

                                    #endregion

                                    #region Radar
                                    if (Setting.雷达)
                                    {
                                        var loclalLocation = new Vector3 {
                                            X = playerList[0].x, Y = playerList[0].y, Z = playerList[0].z
                                        };
                                        var currentActorLocation = new Vector3 {
                                            X = player.x, Y = player.y, Z = player.z
                                        };

                                        var relativePos = loclalLocation - currentActorLocation;

                                        if (relativePos.Length / 100.0f <= radarSize / 2 /*DISTANCE FROM CENTER TO EDGE*/)
                                        {
                                            Vector2 screenpos = centerpoint - relativePos.To2D() / 118f;

                                            Ellipse el22 = new Ellipse(new RawVector2(screenpos.X, screenpos.Y), 3, 3);
                                            device.DrawEllipse(el22, brushRed);
                                            device.FillEllipse(el22, brushRed);
                                        }
                                    }
                                    #endregion

                                    #region 骨骼

                                    if (lDeltaInMeters < 250 && lDeltaInMeters > 5)
                                    {
                                        DrawSkeleton(player.mesh, PlayerCameraManager, device, brushRed, fontESP);
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                            // DRAW END
                            device.EndDraw();
                        }
                        else
                        {
                            mainFrom.STATE = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.IO.File.WriteAllText("c:\\log\\bug_json.txt", JsonConvert.SerializeObject(json_data));
                    }
                    Thread.Sleep(10);
                }
            })
            {
                IsBackground = true
            };
            dxthread.Start();

            #region Web端
            var webThread = new Thread(() =>
            {
                while (true)
                {
                    using (var webClient = new WebClient())
                    {
                        if (Setting.Web端 && json_data.players.Count > 0 && !webClient.IsBusy)
                        {
                            try
                            {
                                // 指定 WebClient 編碼
                                webClient.Encoding = Encoding.UTF8;
                                // 指定 WebClient 的 Content-Type header
                                webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                                // 指定 WebClient 的 authorization header
                                //webClient.Headers.Add("authorization", "token {apitoken}");
                                // 執行 PUT 動作
                                var result = webClient.UploadString("http://127.0.0.1:3000/api/5", "PUT", JsonConvert.SerializeObject(json_data));
                            }
                            catch (Exception e)
                            {
                                continue;
                            }
                        }
                    }
                    Thread.Sleep(500);
                }
            });

            webThread.IsBackground = true;
            webThread.Start();
            #endregion


            var marg = new Win32.Margins {
                Left = 0, Top = 0, Right = this.Width, Bottom = this.Height
            };
            Win32.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
        }
Beispiel #20
0
        public void D3DRender(bool updated)
        {
#if (MARKERS)
            var span = Markers.EnterSpan($"{nameof(RC2)} render");
#endif

            Song song = Global.Instance.Song;

            if (resizeNeeded)
            {
                resizeNeeded = false;

                target.Resize(new Size2(Global.Instance.Width, Global.Instance.Height));

                if (song != null)
                {
                    song.DevDepReacquireAll(target);
                    song.ResetPoints();
                }
            }

            target.BeginDraw();
            target.Clear(SharpDX.Color.Black);

            if (initialized)
            {
                if (true) //Global.Instance.Updated)
                {
                    if (song != null)
                    {
                        if (!song.IsDevDepResourcesAcquired)
                        {
                            VizRes.DevDepAcquireAll(target);
                            song.IsDevDepResourcesAcquired = true;
                        }

                        if (song.PlayerMode == PlayerMode.playing)
                        {
                            if (song.Position < song.TrackPx)
                            {
                                song.Position = Math.Min(song.Position + 2, song.TrackPx - 1);
                            }
                            else
                            {
                                song.Position   = 0;
                                song.PlayerMode = PlayerMode.stopped;
                            }
                        }

                        var half = target.PixelSize.Width / 2;
                        if (song.Position < half)
                        {
                            song.LFT = 0;
                        }
                        else if (song.Position > song.TrackPx - half)
                        {
                            song.LFT = song.TrackPx - target.PixelSize.Width;
                        }
                        else
                        {
                            song.LFT = song.Position - half;
                        }

                        song.RIT = song.LFT + target.PixelSize.Width;

                        target.Transform = Matrix3x2.Translation(-song.LFT, 0);

                        bool moving = ((song.LFT != prevLFT) || (song.RIT != prevRIT));
                        if (moving)
                        {
                            prevLFT = song.LFT;
                            prevRIT = song.RIT;
                        }

                        DrawData dd = new DrawData()
                        {
                            target = target,
                            Song   = song,
                            Height = target.PixelSize.Height - Global.Slider_Height,
                            Width  = target.PixelSize.Width,
                            LFT    = prevLFT,
                            RIT    = prevRIT,
                            Offset = song.Position
                        };

                        if (moving)
                        {
                            foreach (var viz in song.Vizs)
                            {
                                viz.DrawMove(dd);
                            }
                        }

                        foreach (var viz in song.Vizs)
                        {
                            if (viz is Slider || viz is Rule || (viz.StartPoint.X < prevRIT && viz.EndPoint.X > prevLFT))
                            {
                                viz.Draw(dd);
                            }
                        }

                        foreach (Viz viz in song.Vizs)
                        {
                            if (viz.StartPoint.X < prevRIT && viz.EndPoint.X > prevLFT)
                            {
                                if ((viz.IsSelectable) && (song.Selected.Contains(viz)))
                                {
                                    viz.DrawSelect(dd, viz == song.Selected[0]);
                                }
                            }
                        }

                        if ((CurrOver != null) && (CurrOver.HasHilites))
                        {
                            CurrOver.DrawHilites(dd);
                        }

                        //if (song.Drag.DragMode == DragMode.Active)
                        //{
                        //    target.DrawRectangle(Pens.AliceBlue, Math.Min(dragBegin.X, dragEnd.X), Math.Min(dragBegin.Y, dragEnd.Y), Math.Abs(dragBegin.X - dragEnd.X), Math.Abs(dragBegin.Y - dragEnd.Y));
                        //}
                    }
                }
            }

            if (mouseOver)
            {
                using (var brush = new SolidColorBrush(target, Color.LightGoldenrodYellow))
                {
                    target.DrawEllipse(new Ellipse(new Vector2(mousex, mousey), 2, 2), brush);
                }
            }

            //end drawing
            target.EndDraw();

#if (MARKERS)
            span.Leave();
#endif

            fpsCounter.Update();

#if (MARKERS)
            span = Markers.EnterSpan($"{nameof(RC2)} progress");
#endif

            string text = $"FPS:{fpsCounter.FPS}:{Global.Instance.RealTime}  Updates:{updateds} W/H:{ClientSize.Width}/{ClientSize.Height} MO:{mouseOver}";
            tsLbl4Prog.Report(text);

            string time = string.Empty;
            if ((song != null) && (prevPosition != (song.Position / (Global.pxpersec / 10))))
            {
                prevPosition = song.Position / (Global.pxpersec / 10);
                time         = $"{(prevPosition / 600):00}:{(prevPosition / 10 % 60):00}.{(prevPosition % 10):0}";
                tsppTimeProg.Report(time);
            }

#if (MARKERS)
            span.Leave();
#endif
        }
 public void DrawCircle(int x, int y, int radius, int brush, float stroke)
 {
     device.DrawEllipse(new Ellipse(new Vector2(x, y), radius, radius), this.BrushContainer[brush], stroke);
 }
 public void DrawCircle(int x, int y, int radius, float stroke, int brush)
 {
     _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), _brushContainer[brush], stroke);
 }