Пример #1
0
        private void ctlButton_Click(object sender, EventArgs e)
        {
            var btn    = sender as Button;
            var result = CarCtl.TurnFunc(btn.Tag.ToString());

            this.lblPostResultInfo.Text = "请求成功 - " + result;
        }
Пример #2
0
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            var result = CarCtl.SetSpeed((255 - this.trackBar1.Value).ToString(),
                                         (100 + this.trackBar1.Value).ToString());

            this.lblPostResultInfo.Text = "请求成功 - " + result;
        }
Пример #3
0
        private void setSpeedButton_Click(object sender, EventArgs e)
        {
            var btn    = sender as Button;
            var result = CarCtl.SetSpeed(btn.Tag.ToString(), btn.Tag.ToString());

            this.lblPostResultInfo.Text = "请求成功 - " + result;
        }
Пример #4
0
        public static int KeyBoardHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                KeyBoardHookStruct kbh = (KeyBoardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyBoardHookStruct));
                Keys k = (Keys)Enum.Parse(typeof(Keys), kbh.vkCode.ToString());
                switch (k)
                {
                case Keys.Left:
                    if (kbh.flags == 1)
                    {
                        // 这里写按下后做什么事
                        if (CarCtl.CurrentStatus != CarCtl.CarStatus.Up)
                        {
                            CarCtl.TurnFunc("t_left");
                            CarCtl.CurrentStatus = CarCtl.CarStatus.Up;
                        }
                    }
                    else if (kbh.flags == 129)
                    {
                        //放开后做什么事
                        CarCtl.TurnFunc("t_stop");
                        CarCtl.CurrentStatus = CarCtl.CarStatus.Stop;
                    }
                    return(1);

                case Keys.Up:
                    if (kbh.flags == 1)
                    {
                        // 这里写按下后做什么事
                        if (CarCtl.CurrentStatus != CarCtl.CarStatus.Up)
                        {
                            CarCtl.TurnFunc("t_up");
                            CarCtl.CurrentStatus = CarCtl.CarStatus.Up;
                        }
                    }
                    else if (kbh.flags == 129)
                    {
                        //放开后做什么事
                        CarCtl.TurnFunc("t_stop");
                        CarCtl.CurrentStatus = CarCtl.CarStatus.Stop;
                    }
                    return(1);

                case Keys.Right:
                    if (kbh.flags == 1)
                    {
                        if (CarCtl.CurrentStatus != CarCtl.CarStatus.Up)
                        {
                            CarCtl.TurnFunc("t_right");
                            CarCtl.CurrentStatus = CarCtl.CarStatus.Up;
                        }
                    }
                    else if (kbh.flags == 129)
                    {
                        //放开后做什么事
                        CarCtl.TurnFunc("t_stop");
                        CarCtl.CurrentStatus = CarCtl.CarStatus.Stop;
                    }
                    return(1);

                case Keys.Down:
                    if (kbh.flags == 1)
                    {
                        if (CarCtl.CurrentStatus != CarCtl.CarStatus.Up)
                        {
                            CarCtl.TurnFunc("t_down");
                            CarCtl.CurrentStatus = CarCtl.CarStatus.Up;
                        }
                    }
                    else if (kbh.flags == 129)
                    {
                        //放开后做什么事
                        CarCtl.TurnFunc("t_stop");
                        CarCtl.CurrentStatus = CarCtl.CarStatus.Stop;
                    }
                    return(1);

                default:
                    break;
                }
            }
            return(CallNextHookEx(hHook, nCode, wParam, lParam));
        }