Ejemplo n.º 1
0
        public override void DestroyDevice()
        {
            foreach (string key in fonts.Keys)
            {
                GetFont(key).Dispose();
            }
            fonts.Clear();

            factory.Dispose();
            fontFactory.Dispose();
            device.Dispose();
            this.device = null;
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            foreach (var grad in verticalGradientCache.Values)
            {
                grad.Dispose();
            }
            verticalGradientCache.Clear();

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

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

            if (factory != null)
            {
                factory.Dispose();
                factory = null;
            }
        }
 public void DestroyDevice()
 {
     this.OnDestroyDevice();
     FactoryManager.FontFactory.Dispose();
     FactoryManager.Factory.Dispose();
     device.Dispose();
 }
Ejemplo n.º 4
0
 //清除内存
 public void Dispose()
 {
     target.Dispose();
     factory.Dispose();
     rBrush.Dispose();
     pBrush.Dispose();
 }
Ejemplo n.º 5
0
 //============================================================
 // <T>释放处理。</T>
 //============================================================
 public void Dispose()
 {
     // 释放目标
     _target.Dispose();
     // 释放工厂
     _factory.Dispose();
 }
Ejemplo n.º 6
0
 public override void Dispose()
 {
     if (Disposed)
     {
         return;
     }
     Program.MainLog.AddLong(0, MessageType.MSG, "Disposing D2D Renderer",
                             "Render Target: " + mainRenderTarget.NativePointer
                             + "\nFactory: " + factory.NativePointer);
     refTrack.Remove(this);
     Disposed = true;
     mainRenderTarget.Dispose();
     factoryAccesCount--;
     if (factoryAccesCount <= 0)
     {
         Program.MainLog.Add(MessageType.MSG, "Diposing Direct Write Factory {0}", writeFactory.NativePointer);
         writeFactory.Dispose();
         Program.MainLog.Add(MessageType.MSG, "Disposing D2D Factory");
         factory.Dispose();
     }
     foreach (var b in brushes)
     {
         b.Value.Dispose();
     }
     if (refTrack.Count == 0)
     {
         DisposeStatic();
     }
 }
Ejemplo n.º 7
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            target.Dispose();
            factory.Dispose();

            game.Closing();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// リソースの破棄
 /// </summary>
 public void Dispose()
 {
     if (render != null)
     {
         render.Dispose();
         render = null;
     }
 }
Ejemplo n.º 9
0
        private void UnloadGraphics()
        {
            windowRenderTarget?.Dispose();
            factory?.Dispose();

            windowRenderTarget = null;
            factory            = null;
        }
Ejemplo n.º 10
0
 private void CleanUpDeviceResourcesInternal()
 {
     if (_renderTarget != null)
     {
         OnCleanUpDeviceResources();
         _renderTarget.Dispose();
         _renderTarget = null;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     Do not call if you use OverlayWindow class
        /// </summary>
        public void Dispose()
        {
            DeleteLayoutContainer();

            _layoutContainer = null;

            _fontFactory.Dispose();
            _factory.Dispose();
            _device.Dispose();
        }
Ejemplo n.º 12
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     blue.Dispose();
     red.Dispose();
     brush.Dispose();
     sink.Dispose();
     path.Dispose();
     renderTarget.Dispose();
     factory.Dispose();
 }
Ejemplo n.º 13
0
 private void DisposeRenderObjects()
 {
     if (RenderObjectsCreated)
     {
         renderTarget.Dispose();
         renderTarget = null;
         OnDisposeRenderObjects();
         RenderObjectsCreated = false;
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// This is the GameWindow class's internal Dispose() method that actually disposes of the game window class.
        /// </summary>
        /// <param name="disposing">If this method is being called by this class's own code, then the value true should be passed into this parameter to indicate that this method was not called by the Garbage Collector.</param>
        protected override void Dispose(bool disposing)
        {
            if (!this.IsDisposed)
            {
                /*
                 * The following text is from MSDN  (http://msdn.microsoft.com/en-us/library/fs2xkftw%28VS.80%29.aspx)
                 *
                 *
                 * Dispose(bool disposing) executes in two distinct scenarios:
                 *
                 * If disposing equals true, the method has been called directly or indirectly by a user's code and managed and unmanaged resources can be disposed.
                 * If disposing equals false, the method has been called by the runtime from inside the finalizer and only unmanaged resources can be disposed.
                 *
                 * When an object is executing its finalization code, it should not reference other objects, because finalizers do not execute in any particular order.
                 * If an executing finalizer references another object that has already been finalized, the executing finalizer will fail.
                 */
                if (disposing)
                {
                    // Unregister events


                    // get rid of managed resources
                    if (m_RenderTarget != null)
                    {
                        m_RenderTarget.Dispose();
                    }

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

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

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

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


                // get rid of unmanaged resources
            }


            base.Dispose(disposing);
        }
Ejemplo n.º 15
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     redBrush.Dispose();
     //release resource
     redBrush.Dispose();
     whiteBrush.Dispose();
     gradient.Dispose();
     target.Dispose();
     factory.Dispose();
     factoryWrite.Dispose();
 }
Ejemplo n.º 16
0
 // Dispose of resources.
 public void Dispose()
 {
     _textRenderTarget.Dispose();
     _textSceneColorBrush.Dispose();
     _textFormatTitle.Dispose();
     _textFormatHorizontal.Dispose();
     _textFormatVertical.Dispose();
     _ambientLight.Dispose();
     _barOutlineLight.Dispose();
     _barLight.Dispose();
 }
Ejemplo n.º 17
0
 private void ClosedOverlay(object sender, FormClosingEventArgs e)
 {
     try
     {
         _running = false;
         _device.Flush();
         _device.EndDraw();
         _device.Dispose();
         _device = null;
     }
     catch { }
 }
Ejemplo n.º 18
0
 private void DisposeRenderTargets()
 {
     if (_compositeRenderTarget != null)
     {
         _compositeRenderTarget.Dispose();
     }
     _compositeRenderTarget = null;
     if (_windowRenderTarget != null)
     {
         _windowRenderTarget.Dispose();
     }
     _windowRenderTarget = null;
 }
Ejemplo n.º 19
0
 private void DestroyInstance()
 {
     try
     {
         _sharedBrush.Dispose();
         _fontFactory.Dispose();
         _factory.Dispose();
         _device.Dispose();
     }
     catch
     {
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Do not call if you use OverlayWindow class
        /// </summary>
        public void Dispose()
        {
            this.DeleteBrushContainer();
            this.DeleteFontContainer();
            this.DeleteLayoutContainer();

            this.BrushContainer  = null;
            this.FontContainer   = null;
            this.LayoutContainer = null;

            fontFactory.Dispose();
            factory.Dispose();
            device.Dispose();
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Do not call if you use OverlayWindow class
        /// </summary>
        public void Dispose()
        {
            DeleteBrushContainer();
            DeleteFontContainer();
            DeleteLayoutContainer();

            _brushContainer  = null;
            _fontContainer   = null;
            _layoutContainer = null;

            CurrentBitmap.Dispose();
            _fontFactory.Dispose();
            _factory.Dispose();
            _device.Dispose();
        }
Ejemplo n.º 22
0
        private void setupInstance(bool deleteOld = false)
        {
            if (deleteOld)
            {
                try
                {
                    _brush.Dispose();
                    _font.Dispose();

                    _fontFactory.Dispose();
                    _factory.Dispose();
                    _device.Dispose();
                }
                catch
                {
                }
            }

            _factory     = new Factory(SharpDX.Direct2D1.FactoryType.MultiThreaded, DebugLevel.None);
            _fontFactory = new FontFactory();

            RECT bounds = default(RECT);

            User32.GetWindowRect(TargetHandle, out bounds);

            _targetProperties = new HwndRenderTargetProperties()
            {
                Hwnd           = TargetHandle,
                PixelSize      = new Size2(Math.Abs(bounds.Right - bounds.Left), Math.Abs(bounds.Bottom - bounds.Top)),
                PresentOptions = VSync ? PresentOptions.None : PresentOptions.Immediately
            };

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

            _device = new WindowRenderTarget(_factory, renderTargetProperties, _targetProperties);

            _device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased;
            _device.AntialiasMode     = AntialiasMode.Aliased;

            _brush = new SolidColorBrush(_device, new RawColor4(0, 0, 0, 0));
        }
Ejemplo n.º 23
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            Graphics.Dispose();

            if (!Device.IsDisposed)
            {
                Device.Dispose();
            }
            if (!Factory.IsDisposed)
            {
                Factory.Dispose();
            }
        }
Ejemplo n.º 24
0
 public void Dispose()
 {
     _running = false;
     try
     {
         _d2dFactory.Dispose();
     }
     catch { }
     try
     {
         _thdMain.Abort();
         Thread.Sleep(100);
     }
     catch { }
     try
     {
         _renderTarget.Dispose();
     }
     catch { }
 }
Ejemplo n.º 25
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (!_brush.IsDisposed)
            {
                _brush.Dispose();
            }
            if (!_device.IsDisposed)
            {
                _device.Dispose();
            }
            if (!_factory.IsDisposed)
            {
                _factory.Dispose();
            }
        }
Ejemplo n.º 26
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.

                    if (hwndRenderTarget != null)
                    {
                        hwndRenderTarget.Dispose();
                        hwndRenderTarget = null;
                    }
                    if (_preBmp != null)
                    {
                        _preBmp.Dispose();
                        _preBmp = null;
                    }

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

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.

                // Note disposing has been done.
                disposed = true;
            }
        }
Ejemplo n.º 27
0
 public void Dispose()
 {
     _windowRenderTarget.Dispose();
     _currentGraph.Dispose();
 }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            mainForm = new RenderForm("Advanced Text rendering demo");

            d2dFactory = new D2DFactory();
            dwFactory  = new DWriteFactory(SharpDX.DirectWrite.FactoryType.Shared);

            textRenderer = new CustomColorRenderer();

            CreateResources();

            var bgcolor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);

            //This is the offset where we start our text layout
            Vector2 offset = new Vector2(202.0f, 250.0f);

            textFormat = new TextFormat(dwFactory, "Arial", FontWeight.Regular, FontStyle.Normal, 16.0f);
            textLayout = new TextLayout(dwFactory, introText, textFormat, 300.0f, 200.0f);

            //Apply various modifications to text
            textLayout.SetUnderline(true, new TextRange(0, 5));
            textLayout.SetDrawingEffect(greenBrush, new TextRange(10, 20));
            textLayout.SetFontSize(24.0f, new TextRange(6, 4));
            textLayout.SetFontFamilyName("Comic Sans MS", new TextRange(11, 7));

            //Measure full layout
            var textSize = textLayout.Metrics;

            fullTextBackground = new RectangleF(textSize.Left + offset.X, textSize.Top + offset.Y, textSize.Width, textSize.Height);

            //Measure text to apply background to
            var metrics = textLayout.HitTestTextRange(53, 4, 0.0f, 0.0f)[0];

            textRegionRect = new RectangleF(metrics.Left + offset.X, metrics.Top + offset.Y, metrics.Width, metrics.Height);

            //Assign render target and brush to our custom renderer
            textRenderer.AssignResources(renderTarget, defaultBrush);

            RenderLoop.Run(mainForm, () =>
            {
                renderTarget.BeginDraw();
                renderTarget.Clear(bgcolor);

                renderTarget.FillRectangle(fullTextBackground, backgroundBrush);

                renderTarget.FillRectangle(textRegionRect, redBrush);

                textLayout.Draw(textRenderer, offset.X, offset.Y);

                try
                {
                    renderTarget.EndDraw();
                }
                catch
                {
                    CreateResources();
                }
            });

            d2dFactory.Dispose();
            dwFactory.Dispose();
            renderTarget.Dispose();
        }
Ejemplo n.º 29
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();
        }