Exemplo n.º 1
0
        public override void Initialize(IWindow targetWindow)
        {
            // Set target window by calling the base method
            base.Initialize(targetWindow);

            // For demo, show how to use settings
            var current = Settings.Current;
            var type    = GetType();

            if (current.UpdateRate == 0)
            {
                current.UpdateRate = 1000 / 60;
            }

            current.Author      = GetAuthor(type);
            current.Description = GetDescription(type);
            current.Identifier  = GetIdentifier(type);
            current.Name        = GetName(type);
            current.Version     = GetVersion(type);

            // File is made from above info
            Settings.Save();
            Settings.Load();
            Console.Title = @"Overlay";

            OverlayWindow = new DirectXOverlayWindow(targetWindow.Handle, false);
            _watch        = Stopwatch.StartNew();


            _redOpacityBrush = OverlayWindow.Graphics.CreateBrush(Color.FromArgb(80, 255, 0, 0));
            _interiorBrush   = OverlayWindow.Graphics.CreateBrush(0x7FFFFF00);

            _hugeFont = OverlayWindow.Graphics.CreateFont("Arial", 50, true);

            _font       = OverlayWindow.Graphics.CreateFont("Arial", 32);
            _font_small = OverlayWindow.Graphics.CreateFont("Arial", 16);
            _black      = OverlayWindow.Graphics.CreateBrush(0x7F000000);
            _gray       = OverlayWindow.Graphics.CreateBrush(0x7FCCCCCC);
            _red        = OverlayWindow.Graphics.CreateBrush(0x7FFF0000);
            _green      = OverlayWindow.Graphics.CreateBrush(0x7F008000);
            _blue       = OverlayWindow.Graphics.CreateBrush(0x7F0000FF);

            aBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/a_btn.png");
            xBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/x_btn.png");
            yBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/y_btn.png");
            bBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/b_btn.png");
            backBtnImg = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/back_btn.png");
            lBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/lb_btn.png");
            ltBtnImg   = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/lt_btn.png");
            rBtnImg    = Direct2DRenderer.LoadFromFile(Direct2DRenderer._device, "Resources/rb_btn.png");

            //aBtnImg = Direct2DRenderer.LoadFromFile(Properties.Resources.a_btn.ToString());

            /*xBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.x_btn));
             * yBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.y_btn));
             * bBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.b_btn));
             * backBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.back_btn));
             * lBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.lb_btn));
             * ltBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.lt_btn));
             * rBtnImg = _graphics.CreateImage(f.pngToBytes(Properties.Resources.rb_btn));*/

            _rotation   = 0.0f;
            _displayFps = 0;
            _i          = 0;
            // Set up update interval and register events for the tick engine.

            _tickEngine.PreTick += OnPreTick;
            _tickEngine.Tick    += OnTick;
        }