public void Draw(D2DDevice device)
        {
            _geometry.Fill(BackgroundBrush);

            device.DrawText(Header, X + 5, Y + 5, Font, HeaderSize, ForegroundBrush);
            device.DrawText(Body, X + 5, Y + HeaderSize * 2 + 5, Font, BodySize, ForegroundBrush);
        }
Exemple #2
0
        public void Dispose()
        {
            _hWnd = IntPtr.Zero;

            if (D2DDeviceContext != null)
            {
                D2DDeviceContext.Dispose();
                D2DDeviceContext = null;
            }

            if (D2DDevice != null)
            {
                D2DDevice.Dispose();
                D2DDevice = null;
            }

            if (SwapChain != null)
            {
                SwapChain.Dispose();
                SwapChain = null;
            }
            if (Context != null)
            {
                Context.Dispose();
                Context = null;
            }
            if (Device != null)
            {
                Device.Dispose();
                Device = null;
            }
        }
Exemple #3
0
        private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device)
        {
            if (!_initializeGraphicObjects)
            {
                return;
            }

            if (!device.IsInitialized)
            {
                return;
            }
            if (device.IsDrawing)
            {
                return;
            }

            // colors automatically normalize values to fit. you can use 1.0f but also 255.0f.
            _blackBrush  = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF);
            _redBrush    = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF);
            _greenBrush  = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF);
            _blueBrush   = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF);
            _yellowBrush = device.CreateSolidColorBrush(0xFF, 0xFF, 0x0, 0xFF);
            _gradient    = new D2DLinearGradientBrush(device, new D2DColor(0, 0, 80), new D2DColor(0x88, 0, 125), new D2DColor(0, 0, 225));

            _initializeGraphicObjects = false;
        }
Exemple #4
0
        private void SetupInstance()
        {
            _window = new OverlayWindow(new OverlayOptions()
            {
                BypassTopmost = false,
                Height        = (int)(Main.ScreenSize.Height),
                Width         = (int)(Main.ScreenSize.Width),
                WindowTitle   = "Overlay",
                X             = 0,
                Y             = 0,
            });

            _device = new D2DDevice(new DeviceOptions()
            {
                AntiAliasing  = true,
                Hwnd          = _window.WindowHandle,
                MeasureFps    = true,
                MultiThreaded = false,
                VSync         = false
            });

            _frameTimer = new FrameTimer(_device, 0);

            _initializeGraphicObjects = true;

            _frameTimer.OnFrameStarting += _frameTimer_OnFrameStarting;
            _frameTimer.OnFrame         += _frameTimer_OnFrame;

            _frameTimer.Start();
        }
        public static void Main(string[] args)
        {
            OverlayWindow window = new OverlayWindow(new OverlayCreationOptions()
            {
                BypassTopmost = false,
                Height        = 1080,
                Width         = 1920,
                WindowTitle   = "test",
                X             = 0,
                Y             = 0
            });

            while (!window.IsInitialized)
            {
            }

            D2DDevice device = new D2DDevice(new DeviceOptions()
            {
                AntiAliasing = true,
                Hwnd         = window.WindowHandle,
                MeasureFps   = false,
                VSync        = false
            });

            var red = device.CreateSolidColorBrush(1.0f, 0.0f, 0.0f);

            device.BeginScene();
            device.ClearScene();

            device.DrawLine(100, 100, 800, 800, 1.0f, red);

            device.EndScene();

            Console.ReadLine();
        }
Exemple #6
0
        public void Dispose()
        {
            _hWnd = IntPtr.Zero;

            if (D2DDeviceContext != null)
            {
                D2DDeviceContext.Dispose();
                D2DDeviceContext = null;
            }

            if (D2DDevice != null)
            {
                D2DDevice.Dispose();
                D2DDevice = null;
            }

            if (DXGIDevice != null)
            {
                DXGIDevice.Dispose();
                DXGIDevice = null;
            }

            if (Context != null)
            {
                Context.Dispose();
                Context = null;
            }
            if (Device != null)
            {
                Device.Dispose();
                Device = null;
            }
        }
Exemple #7
0
        private static Geometry CreateSkeleton(D2DDevice device)
        {
            var geometry = device.CreateGeometry();

            geometry.BeginFigure(new Graphics.Primitives.Point(170, 270));

            geometry.AddPoint(new Graphics.Primitives.Point(200, 200));
            geometry.AddPoint(new Graphics.Primitives.Point(200, 300));
            geometry.AddPoint(new Graphics.Primitives.Point(150, 350));

            geometry.EndFigure(false);

            geometry.BeginFigure(new Graphics.Primitives.Point(200, 200));

            geometry.AddPoint(new Graphics.Primitives.Point(230, 270));

            geometry.EndFigure(false);

            geometry.BeginFigure(new Graphics.Primitives.Point(200, 300));

            geometry.AddPoint(new Graphics.Primitives.Point(250, 350));

            geometry.EndFigure(false);

            geometry.Close();

            return(geometry);
        }
Exemple #8
0
        private static Geometry CreateRadarBackground(D2DDevice device, Rectangle bounds, float size)
        {
            var geometry = device.CreateGeometry();

            float width = bounds.Right - bounds.Left;

            int steps = (int)(width / size);

            for (int i = 0; i < steps + 1; i++)
            {
                float curHeight = bounds.Top + (i * size);
                float curWidth  = bounds.Left + (i * size);

                geometry.BeginFigure(new Point(bounds.Left, curHeight));
                geometry.AddPoint(new Point(bounds.Right, curHeight));
                geometry.EndFigure(false);

                geometry.BeginFigure(new Point(curWidth, bounds.Top));
                geometry.AddPoint(new Point(curWidth, bounds.Bottom));
                geometry.EndFigure(false);
            }

            geometry.Close();

            return(geometry);
        }
        private void SetupInstance()
        {
            _window = new OverlayWindow(new OverlayOptions()
            {
                BypassTopmost = false,
                Height        = 600,
                Width         = 800,
                WindowTitle   = "GameOverlayExample",
                X             = 0,
                Y             = 0
            });

            _device = new D2DDevice(new DeviceOptions()
            {
                AntiAliasing  = true,
                Hwnd          = _window.WindowHandle,
                MeasureFps    = true,
                MultiThreaded = false,
                VSync         = false
            });

            _frameTimer = new FrameTimer(_device, 0);

            _window.OnWindowBoundsChanged += _window_OnWindowBoundsChanged;

            _initializeGraphicObjects = true;

            _frameTimer.OnFrameStarting += _frameTimer_OnFrameStarting;
            _frameTimer.OnFrame         += _frameTimer_OnFrame;

            _frameTimer.Start();
        }
 public OverlayNotification(D2DDevice device, ID2DBrush background, ID2DBrush foreground, D2DFont font)
 {
     _device         = device;
     BackgroundBrush = background;
     ForegroundBrush = foreground;
     Font            = font;
 }
Exemple #11
0
        private static void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            _notification.Setup(100, 100, 310, 94);

            device.ClearScene();

            device.DrawShape(_notification);
        }
        // public Vector2[] points = new Vector2[Constants.Llegbones.Length + Constants.Rlegbones.Length + Constants.Spinebones.Length + Constants.Larmbones.Length + Constants.Rarmbones.Length];


        private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            if (!device.IsDrawing)
            {
                _initializeGraphicObjects = true;
                return;
            }

            device.ClearScene(_backgroundColor);
            //device.DrawTextWithBackground("FPS: " + device.FramesPerSecond, 0, 0, _font, _redBrush, _blackBrush);
            //device.DrawTextWithBackground(text, 0, 20, _font, _redBrush, _blackBrush);
            if (OtherCheatsRealisation.IsWallHackEspEnabled())
            {
                ESPRectangle[] Rects = OtherCheatsRealisation.Rects;

                Vector3 tempVector3 = new Vector3(), tempVector3_2 = new Vector3();

                for (int i = 0; i < Rects.Length; i++)
                {
                    if (Rects[i].topPosX != 0 && Rects[i].topPosY != 0)
                    {
                        device.DrawCircle(Rects[i].topPosX, Rects[i].topPosY, 5 * (1000 / Rects[i].lenToPlayer), 3, Rects[i].IsEnemy ? _redBrush : _greenBrush);
                    }

                    if (Rects[i].downPosX != 0 && Rects[i].downPosY != 0)
                    {
                        float   cof = (200 / Rects[i].lenToPlayer);
                        float[] newPos;
                        newPos = Сentering(Rects[i].downPosX, Rects[i].downPosY, 100 * cof, 20 * cof, device, _blackBrush);
                        device.FillRectangle(newPos[0] + 1, newPos[1] + 1, newPos[0] + (Rects[i].hp * 100 - 1) * cof, newPos[1] + (20 - 1) * cof, device.CreateSolidColorBrush(1 - Rects[i].hp, Rects[i].hp, 0));
                    }
                    //device.DrawTextWithBackground(q, Rects[i].downPosX, Rects[i].downPosY, _font, 14, _blueBrush, _greenBrush);
                }
            }
            if (aimCheats.IsNoRecoilSaveEnabled())
            {
                device.FillCircle(aimCheats.RecoilCrossX, aimCheats.RecoilCrossY, 4, _redBrush);
            }
            if (aimCheats.IsAimEnabled())
            {
                device.DrawCircle(Constants.screenWidth / 2, Constants.screenHeight / 2, aimCheats.AIM_RADIUS, 2, _blueBrush);
            }
            //DrawTSkeleton(device);
            //DrawSkeletonT(device);
            //DrawCTSkeleton(device);
            // DrawTSkeleton(device);
            //DrawSkeletonT(device);
            // DrawSkeletonCT(device);

            /*for (int i = 0; i < points.Length; i++)
             *  device.DrawTextWithBackground(i.ToString(), points[i].X, points[i].Y, _font, _redBrush, _blackBrush);*/

            /*for (int i = 0; i+1 < bones_points.Length; i += 2)
             * {
             *  device.DrawLine(bones_points[i].X, bones_points[i].Y, bones_points[i+1].X, bones_points[i+1].Y, 1, _redBrush);
             * }*/
            //DrawText(device);
        }
Exemple #13
0
        static void Main(string[] args)
        {
            _window = new OverlayWindow(new OverlayOptions()
            {
                BypassTopmost = false,
                Height        = 600,
                Width         = 800,
                WindowTitle   = "GameOverlayExample",
                X             = 0,
                Y             = 0
            });

            _device = new D2DDevice(new DeviceOptions()
            {
                AntiAliasing  = true,
                Hwnd          = _window.WindowHandle,
                MeasureFps    = true,
                MultiThreaded = false,
                VSync         = false
            });

            _image = _device.LoadImage(@"C:\Users\Michel\Desktop\NotificationBackOrange.png");

            _backgroundBrush = _device.CreateSolidColorBrush(0xF1, 0x9A, 0x4C, 255);

            _foregroundBrush = _device.CreateSolidColorBrush(0, 0, 0, 255);

            _font = _device.CreateFont(new FontOptions()
            {
                Bold           = false,
                FontFamilyName = "Arial",
                FontSize       = 14,
                Italic         = false,
                WordWrapping   = false
            });

            _notification = new OverlayNotification(_device, _backgroundBrush, _foregroundBrush, _font)
            {
                Body       = "You earned an achievement!",
                BodySize   = 14,
                Header     = "Achievement",
                HeaderSize = 18
            };

            _frameTimer = new FrameTimer(_device, 0);

            _window.OnWindowBoundsChanged += _window_OnWindowBoundsChanged;

            _frameTimer.OnFrame += _frameTimer_OnFrame;

            _frameTimer.Start();

            Console.WriteLine("Press enter to exit");

            Console.ReadLine();
        }
Exemple #14
0
        public void DestroyInstance()
        {
            _frameTimer.Stop();

            _frameTimer.Dispose();
            _device.Dispose();
            _window.Dispose();
            _device     = null;
            _frameTimer = null;
        }
        private float[] Сentering(float x, float y, float w, float h, D2DDevice device, ID2DBrush brush)
        {
            float newX = x - w / 2;
            float newY = y - h / 2;

            device.FillRectangle(newX, newY, newX + w, newY + h, brush);
            float[] newLeftRight = new float[2];
            newLeftRight[0] = newX;
            newLeftRight[1] = newY;
            return(newLeftRight);
        }
Exemple #16
0
        protected override void CreateHandle()
        {
            base.CreateHandle();

            this.DoubleBuffered = false;

            if (this.device == null)
            {
                this.device = D2DDevice.FromHwnd(this.Handle);
            }

            this.graphics = new D2DGraphics(this.device);
        }
        private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            // the render loop will call device.BeginScene() and device.EndScene() for us

            if (!device.IsDrawing)
            {
                _initializeGraphicObjects = true;
                return;
            }

            // clear the scene / fill it with our background

            device.ClearScene(_backgroundColor);

            // text

            // the background is dynamically adjusted to the text's size
            device.DrawTextWithBackground("FPS: " + device.FramesPerSecond, 10, 10, _font, _redBrush, _blackBrush);

            // primitives

            device.DrawCircle(100, 100, 50, 2.0f, _redBrush);
            device.DrawDashedCircle(250, 100, 50, 2.0f, _greenBrush);

            // Rectangle.Create offers a method to create rectangles with x, y, width, heigth
            device.DrawRectangle(Rectangle.Create(350, 50, 100, 100), 2.0f, _blueBrush);
            device.DrawRoundedRectangle(RoundedRectangle.Create(500, 50, 100, 100, 6.0f), 2.0f, _redBrush);

            device.DrawTriangle(650, 150, 750, 150, 700, 50, _greenBrush, 2.0f);

            // lines

            device.DrawLine(50, 175, 750, 175, 2.0f, _blueBrush);
            device.DrawDashedLine(50, 200, 750, 200, 2.0f, _redBrush);

            // outlines & filled

            device.OutlineCircle(100, 275, 50, 4.0f, _redBrush, _blackBrush);
            device.FillCircle(250, 275, 50, _greenBrush);

            device.OutlineRectangle(Rectangle.Create(350, 225, 100, 100), 4.0f, _blueBrush, _blackBrush);

            _gradient.SetRange(500, 225, 600, 325);
            device.FillRoundedRectangle(RoundedRectangle.Create(500, 225, 100, 100, 6.0f), _gradient);

            device.FillTriangle(650, 325, 750, 325, 700, 225, _greenBrush);

            // images

            device.DrawImage(_image, 310, 375);
        }
Exemple #18
0
        private static void Main(string[] args)
        {
            Console.WindowHeight = Console.LargestWindowHeight / 2;
            Console.WindowWidth  = Console.LargestWindowWidth / 2;

            OverlayCreationOptions overlayOptions = new OverlayCreationOptions()
            {
                BypassTopmost = true,
                Height        = 600,
                Width         = 600,
                WindowTitle   = HelperMethods.GenerateRandomString(5, 11),
                X             = Console.WindowLeft,
                Y             = Console.WindowTop
            };

            StickyOverlayWindow overlay = new StickyOverlayWindow(Process.GetCurrentProcess().MainWindowHandle, overlayOptions);

            DeviceOptions rendererOptions = new DeviceOptions()
            {
                AntiAliasing = true,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = false
            };

            gfx = new D2DDevice(rendererOptions);

            font            = gfx.CreateFont("Arial", 22);
            red             = gfx.CreateSolidColorBrush(255, 0, 0, 255);
            black           = gfx.CreateSolidColorBrush(0, 0, 0, 255);
            green           = gfx.CreateSolidColorBrush(0, 255.0f, 0, 255.0f);
            backgroundBrush = gfx.CreateSolidColorBrush(0xCC, 0xCC, 0xCC, 80);

            skeleton = CreateSkeleton(gfx);
            radar    = CreateRadarBackground(gfx, new Rectangle(100, 100, 400, 400), 10.0f);

            overlay.OnWindowBoundsChanged += Overlay_OnWindowBoundsChanged;

            FrameTimer timer = new FrameTimer(0, gfx);

            timer.FrameStarting += Timer_OnFrameStart;

            timer.Start();

            Console.ReadLine();

            timer.Stop();

            gfx.Dispose();
            overlay.Dispose();
        }
Exemple #19
0
        private static void DrawRadarBackground(D2DDevice device, Rectangle bounds, float size)
        {
            float width = bounds.Right - bounds.Left;

            int steps = (int)(width / size);

            for (int i = 0; i < steps + 1; i++)
            {
                float curHeight = bounds.Top + (i * size);
                float curWidth  = bounds.Left + (i * size);
                device.DrawLine(new Line(bounds.Left, curHeight, bounds.Right, curHeight), 1.0f, green);
                device.DrawLine(new Line(curWidth, bounds.Top, curWidth, bounds.Bottom), 1.0f, green);
            }
        }
        private void SetupInstance()
        {
            _window = new OverlayWindow(new OverlayOptions()
            {
                BypassTopmost = false,
                Height        = Constants.screenHeight,
                Width         = Constants.screenWidth,
                WindowTitle   = "Overlay",
                X             = 0,
                Y             = 0
            });

            _device = new D2DDevice(new DeviceOptions()
            {
                AntiAliasing  = true,
                Hwnd          = _window.WindowHandle,
                MeasureFps    = true,
                MultiThreaded = false,
                VSync         = true
            });

            /*for (int i = 0; i < pointsT.Length; i++)
             * {
             *  pointsT[i] = new Vector2();
             * }*/
            for (int i = 0; i < pointsCT.Length; i++)
            {
                pointsCT[i] = new Vector2();
            }
            for (int i = 0; i < points.Length; i++)
            {
                points[i] = new Vector2();
            }
            for (int i = 0; i < bones_points.Length; i++)
            {
                bones_points[i] = new Vector2();
            }

            _frameTimer = new FrameTimer(_device, 0);

            _window.OnWindowBoundsChanged += _window_OnWindowBoundsChanged;

            _initializeGraphicObjects = true;

            _frameTimer.OnFrameStarting += _frameTimer_OnFrameStarting;
            _frameTimer.OnFrame         += _frameTimer_OnFrame;

            _frameTimer.Start();
        }
        public static void Main(string[] args)
        {
            IntPtr handle = /*new IntPtr(0x30F98);//*/ Process.GetCurrentProcess().MainWindowHandle;

            StickyOverlayWindow window = new StickyOverlayWindow(handle);

            window.OnWindowBoundsChanged += Window_OnWindowBoundsChanged;

            device = new D2DDevice(window.WindowHandle, false, true, true);

            D2DSolidColorBrush red   = device.CreateSolidColorBrush(255, 0, 0);
            D2DSolidColorBrush green = device.CreateSolidColorBrush(0, 255, 0);
            D2DSolidColorBrush blue  = device.CreateSolidColorBrush(0, 0, 255);
            D2DSolidColorBrush black = device.CreateSolidColorBrush(0, 0, 0);

            while (true)
            {
                //RECT windowRect = new RECT();
                //RECT clientRect = new RECT();
                RECT fixedRect = new RECT();

                //User32.GetWindowRect(handle, out windowRect);
                //User32.GetClientRect(handle, out clientRect);
                HelperMethods.GetWindowClientRect(handle, out fixedRect);

                //Console.WriteLine("WindowRect: " + windowRect.Output());
                //Console.WriteLine("ClientRect: " + clientRect.Output());
                //Console.WriteLine("FixedRect: " + fixedRect.Output());

                //Console.WriteLine();

                //Console.WriteLine("WindowRect: " + windowRect.ToBounds());
                //Console.WriteLine("ClientRect: " + clientRect.ToBounds());
                //Console.WriteLine("FixedRect: " + fixedRect.ToBounds());

                using (var scene = device.UseScene())
                {
                    //device.FillRectangle(0, 0, fixedRect.Right - fixedRect.Left, fixedRect.Bottom - fixedRect.Top, red);

                    //device.DrawRectangle(0, 0, windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top, 16.0f, red);
                    //device.DrawRectangle(0, 0, clientRect.Right - clientRect.Left, clientRect.Bottom - clientRect.Top, 12.0f, green);
                    //device.DrawRectangle(0, 0, fixedRect.Right - fixedRect.Left, fixedRect.Bottom - fixedRect.Top, 6.0f, blue);
                }


                Console.ReadLine();
            }
        }
Exemple #22
0
        private static void Timer_OnFrameStart(FrameTimer timer, D2DDevice device)
        {
            device.BeginScene();
            device.ClearScene();

            device.DrawTextWithBackground(device.FPS.ToString(), new Point(10, 20), font, red, backgroundBrush);

            DrawRadarBackground(device, new Rectangle(100, 100, 400, 400), 10.0f);

            //for (int i = 0; i < 100; i++)
            //{
            //    DrawRadarBackground(device, new Rectangle(100, 100, 400, 400), 10.0f);
            //}

            device.EndScene();
        }
Exemple #23
0
        public void DestroyInstance()
        {
            _frameTimer.Stop();

            //Begin and clear scene to stop last draw sticking on screen
            _device.BeginScene();
            _device.ClearScene();

            _frameTimer.Dispose();
            _device.Dispose();
            _window.Dispose();

            _window     = null;
            _device     = null;
            _frameTimer = null;
        }
Exemple #24
0
        private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device)
        {
            if (!_initializeGraphicObjects)
            {
                return;
            }

            if (!device.IsInitialized)
            {
                return;
            }
            if (device.IsDrawing)
            {
                return;
            }
            _initializeGraphicObjects = false;
        }
Exemple #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Geometry"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <exception cref="ArgumentNullException">device</exception>
        /// <exception cref="InvalidOperationException">The render target needs to be initialized first</exception>
        public Geometry(D2DDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (!device.IsInitialized)
            {
                throw new InvalidOperationException("The render target needs to be initialized first");
            }

            _device = device;

            _geometry = new PathGeometry(device.GetFactory());

            _sink       = _geometry.Open();
            _isSinkOpen = true;
        }
Exemple #26
0
        private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            // the render loop will call device.BeginScene() and device.EndScene() for us
            if (!device.IsDrawing)
            {
                _initializeGraphicObjects = true;
                return;
            }
            device.ClearScene();

            if (Config.focused)
            {
                if (vars.drawFOV == 1)
                {
                    device.DrawCircle(vars.ScreenWidth / 2 + 1, vars.ScreenHeight / 2 + 1, Config.FOV, 1, _blueBrush);  //Draw FOV circle
                }
                //Crosshair aimPunch
                Point centralPoint = new Point(vars.recoilX + 1, vars.recoilY + 1);
                device.DrawCrosshair(CrosshairStyle.Plus, centralPoint, 7, 1f, _greenBrush);

                for (int i = 0; i < Config.numberOfPlayers; i++)
                {
                    if (Lists.team[i] == 2)
                    {
                        _emptyBrush = _redBrush;
                    }
                    else
                    {
                        _emptyBrush = _greenBrush;
                    };

                    if (Lists.dormant[i] == 1)
                    {
                        _emptyBrush = _yellowBrush;
                    }

                    if (Lists.health[i] > 0 && vars.localClass.LocalPlayer != Lists.entityID[i] && Lists.entityID[i] != Lists.observer[i] && Lists.selectedBoneX[i] != 0)
                    {
                        device.OutlineCircle(Lists.selectedBoneX[i], Lists.selectedBoneY[i], Lists.distance[i] + 0.1f, 2.0f, _emptyBrush, _blackBrush);
                    }
                }
            }
        }
        private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device)
        {
            if (!_initializeGraphicObjects)
            {
                return;
            }

            if (!device.IsInitialized)
            {
                return;
            }
            if (device.IsDrawing)
            {
                return;
            }

            _backgroundColor = new D2DColor(0x24, 0x29, 0x2E, 0xFF);

            _font = _device.CreateFont(new FontOptions()
            {
                Bold           = false,
                FontFamilyName = "Arial",
                FontSize       = 16,
                Italic         = false,
                WordWrapping   = true
            });

            // colors automatically normalize values to fit. you can use 1.0f but also 255.0f.
            _blackBrush = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF);

            _redBrush   = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF);
            _greenBrush = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF);
            _blueBrush  = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF);

            _gradient = new D2DLinearGradientBrush(device, new D2DColor(0, 0, 80), new D2DColor(0x88, 0, 125), new D2DColor(0, 0, 225));

            // loads an image from resource bytes (.png in this case)
            _image = device.LoadImage(Properties.Resources.placeholder_image_bytes);

            _initializeGraphicObjects = false;
        }
Exemple #28
0
        protected override void CreateHandle()
        {
            base.CreateHandle();

            this.DoubleBuffered = false;

            if (this.device == null)
            {
                this.device = D2DDevice.FromHwnd(this.Handle);
            }

            this.graphics    = new D2DGraphics(this.device);
            this.timer.Tick += (ss, ee) =>
            {
                if (!SceneAnimation || SceneChanged)
                {
                    OnFrame();
                    Invalidate(); SceneChanged = false;
                }
            };
        }
Exemple #29
0
        public void Dispose()
        {
            foreach (KeyValuePair <string, D2D1.Brush> p in Brushes)
            {
                p.Value.Dispose();
            }
            DashStyle.Dispose();

            D2DTarget.Dispose();
            D2DDevice.Dispose();
            D2DContext.Dispose();
            D2DFactory.Dispose();

            BlackTextureView.Dispose();
            WhiteTextureView.Dispose();
            AnisotropicSampler.Dispose();

            blendStateOpaque.Dispose();
            blendStateTransparent.Dispose();

            rasterizerStateSolidCullBack.Dispose();
            rasterizerStateWireframeCullBack.Dispose();
            rasterizerStateSolidNoCull.Dispose();
            rasterizerStateWireframeNoCull.Dispose();
            depthStencilStateDefault.Dispose();
            depthStencilStateNoDepth.Dispose();

            foreach (Camera c in Cameras)
            {
                c.Dispose();
            }
            constantBuffer.Dispose();

            swapChain.Dispose();
            Device.Dispose();
            Context.Dispose();
        }
        private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device)
        {
            if (!_initializeGraphicObjects)
            {
                return;
            }

            if (!device.IsInitialized)
            {
                return;
            }
            if (device.IsDrawing)
            {
                return;
            }

            _backgroundColor = new D2DColor(0, 0, 0, 0);

            _font = _device.CreateFont(new FontOptions()
            {
                Bold           = false,
                FontFamilyName = "Times New Roman",
                FontSize       = 10,
                Italic         = false,
                WordWrapping   = true
            });

            // colors automatically normalize values to fit. you can use 1.0f but also 255.0f.
            _blackBrush = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF);

            _redBrush   = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF);
            _greenBrush = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF);
            _blueBrush  = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF);

            _initializeGraphicObjects = false;
        }