Beispiel #1
0
 public Mouse(DirectInput input, IntPtr wndHandle)
 {
     mMouse = new SlimDX.DirectInput.Mouse(input);
     mMouse.SetCooperativeLevel(wndHandle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
     mMouse.Acquire();
     State = mMouse.GetCurrentState();
 }
Beispiel #2
0
 public Mouse(DirectInput input, IntPtr wndHandle)
 {
     mMouse = new SlimDX.DirectInput.Mouse(input);
     mMouse.SetCooperativeLevel(wndHandle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
     mMouse.Acquire();
     State = mMouse.GetCurrentState();
 }
 public override void Dispose()
 {
     if (mouse != null)
     {
         mouse.Unacquire();
     }
     mouse       = null;
     directInput = null;
 }
 public SlimDXMouse(Window window)
 {
     positionTranslater = new CursorPositionTranslater(window);
     mouseCounter       = new MouseDeviceCounter();
     directInput        = new DInput.DirectInput();
     mouse = new DInput.Mouse(directInput);
     mouse.Properties.AxisMode = DInput.DeviceAxisMode.Absolute;
     mouse.Acquire();
     currentState = new DInput.MouseState();
 }
Beispiel #5
0
        public Mouse(IntPtr windowHandle)
        {
            this.windowHandle = windowHandle;

            var dinput = new DirectInput();

            this.mouse = new DIMouse(dinput);
            var cooperativeLevel = CooperativeLevel.Foreground;
            cooperativeLevel |= exclusive? CooperativeLevel.Exclusive : CooperativeLevel.Nonexclusive;
            this.mouse.SetCooperativeLevel(windowHandle, cooperativeLevel);
            this.mouse.Acquire();
        }
Beispiel #6
0
        public void TestMouse()
        {
            var mouse = new TWMouse();
            var dev   = new SlimDX.DirectInput.DirectInput();
            var m     = new SlimDX.DirectInput.Mouse(dev);

            m.Acquire();

            Application.Idle += delegate
            {
                for (int i = 0; i < 100; i++)
                {
                    var state = m.GetCurrentState();
                    mouse.UpdateMouseState(state);
                    if (state.X != 0)
                    {
                        Console.WriteLine(mouse.RelativeX);
                    }
                    if (mouse.RightMouseJustReleased)
                    {
                        break;
                    }
                    Application.DoEvents();
                }

                mouse.CursorEnabled = true;

                for (int i = 0; i < 100; i++)
                {
                    var state = m.GetCurrentState();
                    mouse.UpdateMouseState(state);
                    if (state.X != 0)
                    {
                        Console.WriteLine(mouse.RelativeX);
                    }
                    if (mouse.RightMouseJustReleased)
                    {
                        break;
                    }
                    Application.DoEvents();
                }

                mouse.CursorEnabled = false;

                for (int i = 0; i < 100; i++)
                {
                    var state = m.GetCurrentState();
                    mouse.UpdateMouseState(state);
                    if (state.X != 0)
                    {
                        Console.WriteLine(mouse.RelativeX);
                    }
                    if (mouse.RightMouseJustReleased)
                    {
                        break;
                    }
                    Application.DoEvents();
                }

                Application.Exit();
            };
            Application.Run();

            m.Dispose();
            dev.Dispose();
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
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();
            }
        }
Beispiel #10
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();
            }
        }