Exemple #1
0
 public Keyboard()
 {
     var directInput = new DirectInput();
     mKeyboard = new SlimDX.DirectInput.Keyboard(directInput);
     mKeyboard.Acquire();
     mState = new KeyboardState();
 }
Exemple #2
0
        public void TestKeyboard()
        {
            var keyboard = new SlimDXTWKeyboard();
            var dev      = new SlimDX.DirectInput.DirectInput();
            var kb       = new SlimDX.DirectInput.Keyboard(dev);

            kb.Acquire();

            Application.Idle += delegate
            {
                while (true)
                {
                    keyboard.UpdateKeyboardState(kb.GetCurrentState());
                    if (keyboard.IsKeyReleased(SlimDX.DirectInput.Key.Escape))
                    {
                        break;
                    }
                    Application.DoEvents();
                }
                Application.Exit();
            };
            Application.Run();

            kb.Dispose();
            dev.Dispose();
        }
 public Keyboard(System.Windows.Forms.Form host)
 {
     directInput = new DirectInput();
     keyboard    = new SlimDX.DirectInput.Keyboard(directInput);
     keyboard.SetCooperativeLevel(host, CooperativeLevel.Nonexclusive | CooperativeLevel.Background);
     keyboard.Acquire();
 }
Exemple #4
0
        /// <summary>
        /// Найти все устройства типа джойстик
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            try
            {
                _quitThread = false;
                // create a device from this controller.
                _device = new SlimDX.DirectInput.Keyboard(_directInput);

                _device.SetCooperativeLevel(IntPtr.Zero, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);

                _thread = new Thread(GetDeviceData);
                _device.SetNotification(_event);

                // Finally, acquire the device.
                _buttons = new KeyboardButtonState[_device.GetObjects(ObjectDeviceType.Button).Count];
                for (var i = 0; i < _buttons.Length; i++)
                {
                    _buttons[i] = new KeyboardButtonState();
                }

                _device.Acquire();

                _thread.Start();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>Disposes resources.</summary>
        public override void Dispose()
        {
            if(_keyboard != null)
            {
                try { _keyboard.Unacquire(); }
                catch { }

                try { _keyboard.Dispose(); }
                catch { _keyboard = null; }
            }

            if(_joystick != null)
            {
                try { _joystick.Unacquire(); }
                catch { }

                try { _joystick.Dispose(); }
                catch { }
            }

            if(_directInput != null)
            {
                try { _directInput.Dispose(); }
                catch { }
                _directInput = null;
            }
        }
 private void CreateNativeKeyboard()
 {
     nativeState    = new DInput.KeyboardState();
     directInput    = new DInput.DirectInput();
     nativeKeyboard = new DInput.Keyboard(directInput);
     nativeKeyboard.SetCooperativeLevel(windowHandle,
                                        DInput.CooperativeLevel.Nonexclusive | DInput.CooperativeLevel.Background);
     nativeKeyboard.Acquire();
 }
 public override void Dispose()
 {
     if (nativeKeyboard != null)
     {
         nativeKeyboard.Unacquire();
         nativeKeyboard = null;
     }
     directInput = null;
     IsAvailable = false;
 }
Exemple #8
0
        private void Window_Main_Load(object sender, EventArgs e)
        {
            if (!SupportedProcessVersion())
            {
                this.Text = "You are running a not supported D3Client(" + GetFileVersion().ToString() +
                            ") Supported Version is " + SupportedVersion;

                return;
            }

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill1, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill2, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill3, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill4, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillLmb, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillRmb, new object[] { true });

            A_WPFOverlay.Overlay o = new A_WPFOverlay.Overlay();
            o.Show();

            directInput = new DirectInput();
            keyboard    = new SlimDX.DirectInput.Keyboard(directInput);
            keyboard.Acquire();


            Point d3helpermainwindowpos = Properties.Settings.Default.D3Helper_MainForm_StartPosition;
            var   screens = Screen.AllScreens.OrderByDescending(x => x.Bounds.X);

            if (d3helpermainwindowpos.X >= screens.Last().Bounds.Left&& d3helpermainwindowpos.X <= screens.First().Bounds.Right&& d3helpermainwindowpos.Y <= screens.First().Bounds.Bottom&& d3helpermainwindowpos.Y >= screens.First().Bounds.Top)
            {
                this.Top  = Properties.Settings.Default.D3Helper_MainForm_StartPosition.Y;
                this.Left = Properties.Settings.Default.D3Helper_MainForm_StartPosition.X;
            }
            else
            {
                this.Top  = 0;
                this.Left = 0;
            }



            this.btn_donate.Image = new Bitmap(Properties.Resources.paypal_donate_button11, new Size(this.btn_donate.Width, this.btn_donate.Height));

            this.btn_info.Image     = new Bitmap(Properties.Resources._480px_Info_icon_002_svg, new Size(this.btn_info.Width, this.btn_info.Height));
            this.btn_settings.Image = new Bitmap(Properties.Resources.pignon, new Size(this.btn_settings.Width, this.btn_settings.Height));


            this.bt_update.Visible = false;

            this.Text = "D3Helper - V" + A_Tools.Version.AppVersion.version;


            DateTime latestOnlineVersion = A_Tools.Version.AppVersion.LatestOnlineVersion;
            DateTime currentVersion      = A_Tools.Version.AppVersion.get_CurrentVersionDate();

            if (latestOnlineVersion > currentVersion)
            {
                this.lb_versionlb.Text = "New Version Available!" + System.Environment.NewLine + latestOnlineVersion.ToString("yy.MM.d.H");
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = "New Version Available!"));
                this.bt_update.Visible = true;
            }
            else
            {
                this.lb_versionlb.Text = "";
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = ""));
            }
        }
Exemple #9
0
        public void TestLineManager3D()
        {
            var keyboard = new SlimDXTWKeyboard();
            var dev      = new SlimDX.DirectInput.DirectInput();
            var kb       = new SlimDX.DirectInput.Keyboard(dev);

            kb.Acquire();

            var mouse = new TWMouse();
            var m     = new SlimDX.DirectInput.Mouse(dev);

            m.Acquire();



            var game = new DX11Form();

            game.InitDirectX();
            var device = game.Device;

            var rasterizerState = RasterizerState.FromDescription(device, new RasterizerStateDescription()
            {
                CullMode = CullMode.None,
                FillMode = FillMode.Solid
            });

            device.ImmediateContext.Rasterizer.State = rasterizerState;


            var cam = new SpectaterCamera();

            var lineManager = new LineManager3D(device);

            game.GameLoopEvent += delegate
            {
                mouse.UpdateMouseState(m.GetCurrentState());
                keyboard.UpdateKeyboardState(kb.GetCurrentState());
                cam.Update(0.001f, keyboard, mouse);

                for (int num = 0; num < 200; num++)
                {
                    lineManager.AddLine(
                        new Vector3(-12.0f + num / 4.0f, 13.0f, 0),
                        new Vector3(-17.0f + num / 4.0f, -13.0f, 0),
                        new Color4((byte)(255 - num) / 255f, 14 / 255f, (byte)num / 255f));
                } // for

                lineManager.DrawGroundShadows = true;
                lineManager.AddCenteredBox(new Vector3(4, 4, 4), 2, new Color4(1, 0, 0));

                lineManager.WorldMatrix =
                    Matrix.Translation(MathHelper.Up * 30);

                for (int num = 0; num < 200; num++)
                {
                    lineManager.AddLine(
                        new Vector3(-12.0f + num / 4.0f, 13.0f, 0),
                        new Vector3(-17.0f + num / 4.0f, -13.0f, 0),
                        new Color4((byte)(255 - num) / 255f, 14 / 255f, (byte)num / 255f));
                } // for



                lineManager.Render(cam);
                if (keyboard.IsKeyDown(Key.Escape))
                {
                    game.Exit();
                }
            };

            game.Run();

            rasterizerState.Dispose();
            kb.Dispose();
            m.Dispose();
            dev.Dispose();
        }
Exemple #10
0
        public void TestDirectX11SpecaterCamera()
        {
            var keyboard = new SlimDXTWKeyboard();
            var dev      = new SlimDX.DirectInput.DirectInput();
            var kb       = new SlimDX.DirectInput.Keyboard(dev);

            kb.Acquire();

            var mouse = new TWMouse();
            var m     = new SlimDX.DirectInput.Mouse(dev);

            m.Acquire();



            var game = new DX11Form();

            game.InitDirectX();
            var device    = game.Device;
            var bytecode  = ShaderBytecode.CompileFromFile("../../Common.Core/Shaders/MiniTri.fx", "fx_5_0", ShaderFlags.None, EffectFlags.None);
            var effect    = new Effect(device, bytecode);
            var technique = effect.GetTechniqueByName("RenderTransform");
            var pass      = technique.GetPassByIndex(0);
            var layout    = new InputLayout(device, pass.Description.Signature,
                                            new[] {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0)
            });

            var vertexStride = (16 + 16 + 8);
            var stream       = new DataStream(3 * vertexStride, true, true);

            stream.WriteRange(new[] {
                new VertexCustom(new Vector4(-1.0f, 0, 0, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector2(0.5f, 0)),
                new VertexCustom(new Vector4(0f, 1f, 0, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), new Vector2(0f, 1f)),
                new VertexCustom(new Vector4(1f, 0f, 0, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), new Vector2(1f, 1f))
            });
            stream.Position = 0;



            var vertices = new SlimDX.Direct3D11.Buffer(device, stream, new BufferDescription()
            {
                BindFlags      = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags    = ResourceOptionFlags.None,
                SizeInBytes    = 3 * vertexStride,
                Usage          = ResourceUsage.Default
            });

            stream.Dispose();

            //var world = Matrix.Translation(MathHelper.Forward);

            /*var viewProjection = Matrix.LookAtRH(Vector3.UnitZ * 5, -Vector3.UnitZ, MathHelper.Up)
             * Matrix.PerspectiveFovRH(MathHelper.PiOver4, 4f / 3f, 0.1f, 1000f);*/


            var diffuseShaderVariable = effect.GetVariableByName("txDiffuse").AsResource();
            var worldParam            = effect.GetVariableByName("world").AsMatrix();
            //worldParam.AsMatrix().SetMatrix(world);


            var viewProjParam = effect.GetVariableBySemantic("viewprojection").AsMatrix();

            /*viewProjParam.SetMatrix(
             *  viewProjection);*/

            //worldParam.SetMatrix(Matrix.Identity);
            //effect.GetVariableBySemantic("viewprojection").AsMatrix().SetMatrix(Matrix.Identity);

            var texturePath = Wallpaper001_png;

            var diffuseTexture = Texture2D.FromFile(device, texturePath);

            var diffuseTextureRv = new ShaderResourceView(device, diffuseTexture);


            diffuseShaderVariable.SetResource(diffuseTextureRv);


            var rasterizerState = RasterizerState.FromDescription(device, new RasterizerStateDescription()
            {
                CullMode = CullMode.None,
                FillMode = FillMode.Solid
            });

            device.ImmediateContext.Rasterizer.State = rasterizerState;


            var cam = new SpectaterCamera();

            game.GameLoopEvent += delegate
            {
                mouse.UpdateMouseState(m.GetCurrentState());
                keyboard.UpdateKeyboardState(kb.GetCurrentState());
                cam.Update(0.001f, keyboard, mouse);

                device.ImmediateContext.InputAssembler.InputLayout       = layout;
                device.ImmediateContext.InputAssembler.PrimitiveTopology =
                    PrimitiveTopology.TriangleList;
                device.ImmediateContext.InputAssembler.SetVertexBuffers(0,
                                                                        new VertexBufferBinding
                                                                            (vertices,
                                                                            vertexStride, 0));

                for (int i = 0; i < technique.Description.PassCount; ++i)
                {
                    pass.Apply(device.ImmediateContext);
                    device.ImmediateContext.Draw(3, 0);
                }

                viewProjParam.SetMatrix(cam.ViewProjection);
                worldParam.SetMatrix(Matrix.Identity);
                if (keyboard.IsKeyDown(Key.Escape))
                {
                    game.Exit();
                }
            };

            game.Run();

            bytecode.Dispose();
            effect.Dispose();
            layout.Dispose();
            vertices.Dispose();
            diffuseTexture.Dispose();
            diffuseTextureRv.Dispose();
            rasterizerState.Dispose();
            kb.Dispose();
            m.Dispose();
            dev.Dispose();
        }
Exemple #11
0
        private void Window_Main_Load(object sender, EventArgs e)
        {
            if (!SupportedProcessVersion())
            {
                this.Text = "You are running a not supported D3Client(" + GetFileVersion() +
                            ") Supported Version is " + SupportedVersion;

                return;
            }

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_Skill1, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_Skill2, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_Skill3, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_Skill4, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_SkillLmb, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
    null, bt_SkillRmb, new object[] { true });

            A_WPFOverlay.Overlay o = new A_WPFOverlay.Overlay();
            o.Show();

            directInput = new DirectInput();
            keyboard = new SlimDX.DirectInput.Keyboard(directInput);
            keyboard.Acquire();
           
           
            Point d3helpermainwindowpos = Properties.Settings.Default.D3Helper_MainForm_StartPosition;
            var screens = Screen.AllScreens.OrderByDescending(x => x.Bounds.X);

            if (d3helpermainwindowpos.X >= screens.Last().Bounds.Left && d3helpermainwindowpos.X <= screens.First().Bounds.Right && d3helpermainwindowpos.Y <= screens.First().Bounds.Bottom && d3helpermainwindowpos.Y >= screens.First().Bounds.Top)
            {
                this.Top = Properties.Settings.Default.D3Helper_MainForm_StartPosition.Y;
                this.Left = Properties.Settings.Default.D3Helper_MainForm_StartPosition.X;
            }
            else
            {
                this.Top = 0;
                this.Left = 0;
            }




            this.btn_donate.Image = new Bitmap(Properties.Resources.paypal_donate_button11, new Size(this.btn_donate.Width, this.btn_donate.Height));
            
            this.btn_info.Image = new Bitmap(Properties.Resources._480px_Info_icon_002_svg, new Size(this.btn_info.Width, this.btn_info.Height));
            this.btn_settings.Image = new Bitmap(Properties.Resources.pignon, new Size(this.btn_settings.Width, this.btn_settings.Height));
            

            this.bt_update.Visible = false;

            this.Text = "D3Helper - V" + A_Tools.Version.AppVersion.version;
            

            DateTime latestOnlineVersion = A_Tools.Version.AppVersion.LatestOnlineVersion;
            DateTime currentVersion = A_Tools.Version.AppVersion.get_CurrentVersionDate();

            if (latestOnlineVersion > currentVersion)
            {
                this.lb_versionlb.Text = "New Version Available!" + System.Environment.NewLine + latestOnlineVersion.ToString("yy.MM.d.H");
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = "New Version Available!"));
                this.bt_update.Visible = true;
            }
            else
            {
                this.lb_versionlb.Text = "";
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = ""));
            }


        }
Exemple #12
0
        private void Window_Main_Load(object sender, EventArgs e)
        {
            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill1, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill2, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill3, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill4, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillLmb, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillRmb, new object[] { true });


            directInput = new DirectInput();
            keyboard    = new SlimDX.DirectInput.Keyboard(directInput);
            keyboard.Acquire();

            mouse = new SlimDX.DirectInput.Mouse(directInput);
            mouse.Acquire();


            Point d3helpermainwindowpos = Properties.Settings.Default.D3Helper_MainForm_StartPosition;
            var   screens = Screen.AllScreens.OrderByDescending(x => x.Bounds.X);

            if (d3helpermainwindowpos.X >= screens.Last().Bounds.Left&& d3helpermainwindowpos.X <= screens.First().Bounds.Right&& d3helpermainwindowpos.Y <= screens.First().Bounds.Bottom&& d3helpermainwindowpos.Y >= screens.First().Bounds.Top)
            {
                this.Top  = Properties.Settings.Default.D3Helper_MainForm_StartPosition.Y;
                this.Left = Properties.Settings.Default.D3Helper_MainForm_StartPosition.X;
            }
            else
            {
                this.Top  = 0;
                this.Left = 0;
            }


            //this.btn_donate.Image = new Bitmap(Properties.Resources.paypal_donate_button11, new Size(this.btn_donate.Width, this.btn_donate.Height));

            this.btn_info.Image     = new Bitmap(Properties.Resources._480px_Info_icon_002_svg, new Size(this.btn_info.Width, this.btn_info.Height));
            this.btn_settings.Image = new Bitmap(Properties.Resources.pignon, new Size(this.btn_settings.Width, this.btn_settings.Height));



            DateTime latestOnlineVersion = A_Tools.Version.AppVersion.LatestOnlineVersion;
            DateTime currentVersion      = A_Tools.Version.AppVersion.get_CurrentVersionDate();

            if (latestOnlineVersion > currentVersion)
            {
                this.lb_versionlb.Text = "New Version Available!" + System.Environment.NewLine + latestOnlineVersion.ToString("yy.MM.d.H");
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = "New Version Available!"));
                this.bt_update.Visible = true;
            }
            else
            {
                this.lb_versionlb.Text = "";
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = ""));
            }

            this.Text = "D3Helper - V" + A_Tools.Version.AppVersion.version;



            //create thread waiting for d3 start!
            Thread t = new Thread(delegate()
            {
                //wait till d3 is running
                while (!isDiabloRunning())
                {
                    try
                    {
                        Thread.Sleep(1000);
                    }
                    catch { }
                }

                if (SupportedProcessVersion())
                {
                    //-- Initialize Collector and Handler Thread
                    if (!Program.SingleThreaded)
                    {
                        A_Initialize.Th_ICollector.New_ICollector();
                    }
                    A_Initialize.Th_Handler.New_Handler();
                    //
                    if (A_Tools.Version.AppVersion.isOutdated()) // !!!!! REENABLE THIS!!!!!!
                    {
                        Window_Outdated WO = new Window_Outdated();
                        WO.ShowDialog();
                    }

                    System.Timers.Timer UpdateUI = new System.Timers.Timer(1000);
                    UpdateUI.Elapsed            += RefreshUI;
                    UpdateUI.Start();

                    Load_CustomFonts();
                }
                else
                {
                    this.Text = "You are running a not supported D3Client(" + GetFileVersion() +
                                ") Supported Version is " + SupportedVersion;
                }
            });

            t.SetApartmentState(ApartmentState.STA); //must be STA Thread to access GUI
            t.Start();



            //overlay
            if (SupportedProcessVersion())
            {
                A_WPFOverlay.Overlay o = new A_WPFOverlay.Overlay();
                o.Show();
            }
        }
Exemple #13
0
        private void Window_Main_Load(object sender, EventArgs e)
        {
            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill1, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill2, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill3, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_Skill4, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillLmb, new object[] { true });

            typeof(Button).InvokeMember("DoubleBuffered",
                                        BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                        null, bt_SkillRmb, new object[] { true });


            directInput = new DirectInput();
            keyboard    = new SlimDX.DirectInput.Keyboard(directInput);
            keyboard.Acquire();

            mouse = new SlimDX.DirectInput.Mouse(directInput);
            mouse.Acquire();


            Point d3helpermainwindowpos = Properties.Settings.Default.D3Helper_MainForm_StartPosition;
            var   screens = Screen.AllScreens.OrderByDescending(x => x.Bounds.X);

            if (d3helpermainwindowpos.X >= screens.Last().Bounds.Left&& d3helpermainwindowpos.X <= screens.First().Bounds.Right&& d3helpermainwindowpos.Y <= screens.First().Bounds.Bottom&& d3helpermainwindowpos.Y >= screens.First().Bounds.Top)
            {
                this.Top  = Properties.Settings.Default.D3Helper_MainForm_StartPosition.Y;
                this.Left = Properties.Settings.Default.D3Helper_MainForm_StartPosition.X;
            }
            else
            {
                this.Top  = 0;
                this.Left = 0;
            }


            //this.btn_donate.Image = new Bitmap(Properties.Resources.paypal_donate_button11, new Size(this.btn_donate.Width, this.btn_donate.Height));

            this.btn_info.Image     = new Bitmap(Properties.Resources._480px_Info_icon_002_svg, new Size(this.btn_info.Width, this.btn_info.Height));
            this.btn_settings.Image = new Bitmap(Properties.Resources.pignon, new Size(this.btn_settings.Width, this.btn_settings.Height));



            DateTime latestOnlineVersion = A_Tools.Version.AppVersion.LatestOnlineVersion;
            DateTime currentVersion      = A_Tools.Version.AppVersion.get_CurrentVersionDate();

            if (latestOnlineVersion > currentVersion)
            {
                this.lb_versionlb.Text = "New Version Available!" + System.Environment.NewLine + latestOnlineVersion.ToString("yy.MM.d.H");
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = "New Version Available!"));
                this.bt_update.Visible = true;
            }
            else
            {
                this.lb_versionlb.Text = "";
                //this.lb_versionlb.Invoke((MethodInvoker)(() => this.lb_versionlb.Text = ""));
            }

            this.Text = "D3Helper - V" + A_Tools.Version.AppVersion.version;



            //Use SimpleCast!
            T_SimpleCast.StartSimpleCastThread();

            //fill combobox for simple cast
            loadSimeCastListToCombobox();



            //create thread waiting for d3 start!
            Thread t = new Thread(delegate()
            {
                //wait till d3 is running
                while (!isDiabloRunning())
                {
                    try
                    {
                        Thread.Sleep(1000);
                    }
                    catch { }
                }

                if (SupportedProcessVersion())
                {
                    //-- Initialize Collector and Handler Thread
                    //if (!Program.SingleThreaded)
                    A_Initialize.Th_ICollector.New_ICollector();
                    A_Initialize.Th_Handler.New_Handler();


                    System.Timers.Timer UpdateUI = new System.Timers.Timer(1000);
                    UpdateUI.Elapsed            += RefreshUI;
                    UpdateUI.Start();

                    Load_CustomFonts();
                }
                else
                {
                    this.Text = "You are running a not supported D3Client(" + GetFileVersion() +
                                ") Supported Version is " + SupportedVersion;
                }
            });

            t.SetApartmentState(ApartmentState.STA); //must be STA Thread to access GUI
            t.Start();



            //overlay
            if (SupportedProcessVersion())
            {
                A_WPFOverlay.Overlay o = new A_WPFOverlay.Overlay();
                o.Show();
            }

            Me.Threads.AntiIdleThread = new Thread(() =>
            {
                AntiIdle antiIdle = new AntiIdle();
            });
            if (Properties.Settings.Default.AntiIdleBool)
            {
                Me.Threads.AntiIdleThread.Start();
            }

            try
            {
                if (Me.Threads.RosBotUpgradeKadalaThread.ThreadState == System.Threading.ThreadState.Unstarted)
                {
                    Me.Threads.RosBotUpgradeKadalaThread = new Thread(() =>
                    {
                        RosBotUpgradeKadala rosBotUpgradeKadala = new RosBotUpgradeKadala();
                    });
                    if (Properties.Settings.Default.RosBotUpgradeKadalaBool)
                    {
                        Me.Threads.RosBotUpgradeKadalaThread.Start();
                    }
                }
            }
            catch
            {
                Me.Threads.RosBotUpgradeKadalaThread = new Thread(() =>
                {
                    RosBotUpgradeKadala rosBotUpgradeKadala = new RosBotUpgradeKadala();
                });
                if (Properties.Settings.Default.RosBotUpgradeKadalaBool)
                {
                    Me.Threads.RosBotUpgradeKadalaThread.Start();
                }
            }

            Me.Threads.HomingPadsThread = new Thread(() =>
            {
                HomingPadsHandler homingPadsHandler = new HomingPadsHandler();
            });
            // Probably best to not start this thread unless user has it turned on in settings
            // Will require a restart of D3helper any time it's turned on/off though
            if (Properties.Settings.Default.HomingPadsBool)
            {
                Me.Threads.HomingPadsThread.Start();
            }
        }
        /// <summary>Initialises the keyboard.</summary>
        /// <param name="control">The control to associate with DirectInput.</param>
        private void InitialiseKeyboard(WF.Control control)
        {
            // From idlibc.c
            _keyToScanCode = new int[256];
            _keyToScanCode[(int) DI.Key.Escape] = 0x01;
            _keyToScanCode[(int) DI.Key.Space] = 0x39;
            _keyToScanCode[(int) DI.Key.Backspace] = 0x0e;
            _keyToScanCode[(int) DI.Key.Tab] = 0x0f;
            _keyToScanCode[(int) DI.Key.LeftControl] = 0x1d;
            _keyToScanCode[(int) DI.Key.LeftShift] = 0x2a;
            _keyToScanCode[(int) DI.Key.CapsLock] = 0x3a;
            _keyToScanCode[(int) DI.Key.F1] = 0x3b;
            _keyToScanCode[(int) DI.Key.F2] = 0x3c;
            _keyToScanCode[(int) DI.Key.F3] = 0x3d;
            _keyToScanCode[(int) DI.Key.F4] = 0x3e;
            _keyToScanCode[(int) DI.Key.F5] = 0x3f;
            _keyToScanCode[(int) DI.Key.F6] = 0x40;
            _keyToScanCode[(int) DI.Key.F7] = 0x41;
            _keyToScanCode[(int) DI.Key.F8] = 0x42;
            _keyToScanCode[(int) DI.Key.F9] = 0x43;
            _keyToScanCode[(int) DI.Key.F10] = 0x44;
            _keyToScanCode[(int) DI.Key.F11] = 0x57;
            _keyToScanCode[(int) DI.Key.F12] = 0x58;
            _keyToScanCode[(int) DI.Key.ScrollLock] = 0x46;
            _keyToScanCode[(int) DI.Key.Return] = 0x1c;
            _keyToScanCode[(int) DI.Key.RightShift] = 0x36;
            _keyToScanCode[(int) DI.Key.PrintScreen] = 0x37;
            _keyToScanCode[(int) DI.Key.LeftAlt] = 0x38;
            _keyToScanCode[(int) DI.Key.Home] = 0x47;
            _keyToScanCode[(int) DI.Key.PageUp] = 0x49;
            _keyToScanCode[(int) DI.Key.End] = 0x4f;
            _keyToScanCode[(int) DI.Key.PageDown] = 0x51;
            _keyToScanCode[(int) DI.Key.Insert] = 0x52;
            _keyToScanCode[(int) DI.Key.Delete] = 0x53;
            _keyToScanCode[(int) DI.Key.NumberLock] = 0x45;
            _keyToScanCode[(int) DI.Key.UpArrow] = 0x48;
            _keyToScanCode[(int) DI.Key.DownArrow] = 0x50;
            _keyToScanCode[(int) DI.Key.LeftArrow] = 0x4b;
            _keyToScanCode[(int) DI.Key.RightArrow] = 0x4d;
            _keyToScanCode[(int) DI.Key.D1] = 0x02;
            _keyToScanCode[(int) DI.Key.D2] = 0x03;
            _keyToScanCode[(int) DI.Key.D3] = 0x04;
            _keyToScanCode[(int) DI.Key.D4] = 0x05;
            _keyToScanCode[(int) DI.Key.D5] = 0x06;
            _keyToScanCode[(int) DI.Key.D6] = 0x07;
            _keyToScanCode[(int) DI.Key.D7] = 0x08;
            _keyToScanCode[(int) DI.Key.D8] = 0x09;
            _keyToScanCode[(int) DI.Key.D9] = 0x0a;
            _keyToScanCode[(int) DI.Key.D0] = 0x0b;
            _keyToScanCode[(int) DI.Key.Minus] = 0x0c;
            _keyToScanCode[(int) DI.Key.Equals] = 0x0d;
            _keyToScanCode[(int) DI.Key.Q] = 0x10;
            _keyToScanCode[(int) DI.Key.W] = 0x11;
            _keyToScanCode[(int) DI.Key.E] = 0x12;
            _keyToScanCode[(int) DI.Key.R] = 0x13;
            _keyToScanCode[(int) DI.Key.T] = 0x14;
            _keyToScanCode[(int) DI.Key.Y] = 0x15;
            _keyToScanCode[(int) DI.Key.U] = 0x16;
            _keyToScanCode[(int) DI.Key.I] = 0x17;
            _keyToScanCode[(int) DI.Key.O] = 0x18;
            _keyToScanCode[(int) DI.Key.P] = 0x19;
            _keyToScanCode[(int) DI.Key.LeftBracket] = 0x1a;
            _keyToScanCode[(int) DI.Key.RightBracket] = 0x1b;
            //_keyToScanCode[(int) DI.Key.OemPipe] = 0x1c; // TODO
            _keyToScanCode[(int) DI.Key.A] = 0x1e;
            _keyToScanCode[(int) DI.Key.S] = 0x1f;
            _keyToScanCode[(int) DI.Key.D] = 0x20;
            _keyToScanCode[(int) DI.Key.F] = 0x21;
            _keyToScanCode[(int) DI.Key.G] = 0x22;
            _keyToScanCode[(int) DI.Key.H] = 0x23;
            _keyToScanCode[(int) DI.Key.J] = 0x24;
            _keyToScanCode[(int) DI.Key.K] = 0x25;
            _keyToScanCode[(int) DI.Key.L] = 0x26;
            _keyToScanCode[(int) DI.Key.Semicolon] = 0x27;
            //_keyToScanCode[(int) DI.Key.OemQuotes] = 0x28; // TODO
            _keyToScanCode[(int) DI.Key.Z] = 0x2c;
            _keyToScanCode[(int) DI.Key.X] = 0x2d;
            _keyToScanCode[(int) DI.Key.C] = 0x2e;
            _keyToScanCode[(int) DI.Key.V] = 0x2f;
            _keyToScanCode[(int) DI.Key.B] = 0x30;
            _keyToScanCode[(int) DI.Key.N] = 0x31;
            _keyToScanCode[(int) DI.Key.M] = 0x32;
            _keyToScanCode[(int) DI.Key.Comma] = 0x33;
            _keyToScanCode[(int) DI.Key.Period] = 0x34;
            // see idlibc.chartable for other keys

            _keyboard = new DI.Keyboard(_directInput);
            _keyboard.SetCooperativeLevel(control, DI.CooperativeLevel.Nonexclusive | DI.CooperativeLevel.Background);
            _keyboard.Acquire();

            _keyboardState = _keyboard.GetCurrentState();
        }