private IntPtr HotKeyHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            if (msg == WM_HOTKEY)
            {
                var plant1 = new PVZ.Plant((int)NudPlantIndex1.Value);
                var plant2 = new PVZ.Plant((int)NudPlantIndex2.Value);
                switch (wParam.ToInt32())
                {
                case 100:
                    plant1.Row--;
                    break;

                case 101:
                    plant1.Row++;
                    break;

                case 102:
                    plant1.Column--;
                    break;

                case 103:
                    plant1.Column++;
                    break;

                case 104:
                    plant2.Row--;
                    break;

                case 105:
                    plant2.Row++;
                    break;

                case 106:
                    plant2.Column--;
                    break;

                case 107:
                    plant2.Column++;
                    break;
                }
                var pos = new System.Drawing.Point(plant1.Row, plant1.Column);
                PVZ.RCToXY(ref pos);
                plant1.X = pos.X;
                plant1.Y = pos.Y;
                pos      = new System.Drawing.Point(plant2.Row, plant2.Column);
                PVZ.RCToXY(ref pos);
                plant2.X = pos.X;
                plant2.Y = pos.Y;
                Refresh();
            }
            return(IntPtr.Zero);
        }
        private void Refresh()
        {
            var plant = new PVZ.Plant((int)NudPlantIndex1.Value);

            TBSelPlant1.Text       = plant.Type.GetDescription();
            TBSelPlantRow1.Text    = $"{plant.Row}行";
            TBSelPlantColumn1.Text = $"{plant.Column}列";
            plant                  = new PVZ.Plant((int)NudPlantIndex2.Value);
            TBSelPlant2.Text       = plant.Type.GetDescription();
            TBSelPlantRow2.Text    = $"{plant.Row}行";
            TBSelPlantColumn2.Text = $"{plant.Column}列";
        }
        private void KeyboardHook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            var plant1 = new PVZ.Plant((int)NudPlantIndex1.Value);
            var plant2 = new PVZ.Plant((int)NudPlantIndex2.Value);

            switch (e.KeyValue)
            {
            case (int)Keys.Up:
                plant1.Row--;
                break;

            case (int)Keys.Down:
                plant1.Row++;
                break;

            case (int)Keys.Left:
                plant1.Column--;
                break;

            case (int)Keys.Right:
                plant1.Column++;
                break;

            case (int)Keys.W:
                plant2.Row--;
                break;

            case (int)Keys.S:
                plant2.Row++;
                break;

            case (int)Keys.A:
                plant2.Column--;
                break;

            case (int)Keys.D:
                plant2.Column++;
                break;
            }
            var pos = new System.Drawing.Point(plant1.Row, plant1.Column);

            PVZ.RCToXY(ref pos);
            plant1.X = pos.X;
            plant1.Y = pos.Y;
            pos      = new System.Drawing.Point(plant2.Row, plant2.Column);
            PVZ.RCToXY(ref pos);
            plant2.X = pos.X;
            plant2.Y = pos.Y;
            Refresh();
        }