private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                const int MagicNumber = 123456789;
                int       unit        = Int32.Parse(tbUnit.Text);
                int       arg0        = MagicNumber;
                int       arg1        = MagicNumber;
                int       arg2        = MagicNumber;

                Int32.TryParse(tbArg0.Text, out arg0);
                Int32.TryParse(tbArg1.Text, out arg1);
                Int32.TryParse(tbArg2.Text, out arg2);

                AIBase.SCCommandID cid =
                    (AIBase.SCCommandID)Enum.Parse(
                        typeof(AIBase.SCCommandID),
                        cbCommand.SelectedItem.ToString());

                switch (cid)
                {
                case AIBase.SCCommandID.HoldPosition:
                    this.Command =
                        AIBase.SCCommand.NewHoldPosition(unit);
                    break;

                case AIBase.SCCommandID.RightClickPos:
                    if (arg1 == MagicNumber ||
                        arg2 == MagicNumber)
                    {
                        throw new InvalidOperationException("Arguments are invalid.");
                    }
                    this.Command =
                        AIBase.SCCommand.NewRightClickPos(unit, new BasicOM.Location(arg0, arg1));
                    break;

                default:
                    throw new InvalidOperationException("Invalid command id.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Invalid input. " + ex.Message,
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                const int MagicNumber = 123456789;
                int unit = Int32.Parse(tbUnit.Text);
                int arg0 = MagicNumber;
                int arg1 = MagicNumber;
                int arg2 = MagicNumber;

                Int32.TryParse(tbArg0.Text, out arg0);
                Int32.TryParse(tbArg1.Text, out arg1);
                Int32.TryParse(tbArg2.Text, out arg2);

                AIBase.SCCommandID cid =
                    (AIBase.SCCommandID) Enum.Parse(
                        typeof(AIBase.SCCommandID),
                        cbCommand.SelectedItem.ToString());

                switch (cid)
                {
                    case AIBase.SCCommandID.HoldPosition :
                        this.Command =
                            AIBase.SCCommand.NewHoldPosition(unit);
                        break;

                    case AIBase.SCCommandID.RightClickPos :
                        if (arg1 == MagicNumber ||
                            arg2 == MagicNumber)
                            throw new InvalidOperationException("Arguments are invalid.");
                        this.Command =
                            AIBase.SCCommand.NewRightClickPos(unit, new BasicOM.Location(arg0, arg1));
                        break;

                    default :
                        throw new InvalidOperationException("Invalid command id.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Invalid input. " + ex.Message,
                    "Error",
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Warning);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }