public static string GetInstructionText(Collection <Instruction> ic, int insIndex, bool deepCheck)
        {
            if (insIndex == -1)
            {
                return("?");
            }

            // check dead loop
            string opText;

            if (ic[insIndex].Operand is Instruction)
            {
                if (deepCheck)
                {
                    Instruction op = (Instruction)ic[insIndex].Operand;
                    opText = GetInstructionText(ic, ic.IndexOf(op), false);
                }
                else
                {
                    opText = insIndex.ToString();
                }
            }
            else
            {
                opText = InsUtils.GetOperandText(ic, insIndex);
            }
            return(String.Format("{0} -> {1} {2}", insIndex, ic[insIndex].OpCode.Name, opText));
        }
        private void cboOpCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnSelectMethod.Enabled = false;

            if (cboOpCode.SelectedItem == null)
            {
                DisableOperand();
                return;
            }

            OpCode op = (OpCode)cboOpCode.SelectedItem;

            lblOpCodeInfo.Text = String.Format("FlowControl: {0}\nOpCodeType: {1}\nOperandType: {2}", op.FlowControl.ToString(), op.OpCodeType.ToString(), op.OperandType.ToString());
            Collection <Instruction> ic = _method.Body.Instructions;

            switch (op.OperandType)
            {
            case OperandType.InlineBrTarget:
            case OperandType.ShortInlineBrTarget:
                InitInstructions(cboOperand);
                break;

            case OperandType.InlineString:
                cboOperand.Enabled = true;
                cboOperand.Items.Clear();
                cboOperand.DropDownStyle = ComboBoxStyle.DropDown;
                if (_ins.Operand != null)
                {
                    cboOperand.Items.Add(_ins.Operand);
                    cboOperand.SelectedIndex = 0;
                }
                break;

            case OperandType.InlineNone:
                DisableOperand();
                break;

            case OperandType.InlineI:
            case OperandType.InlineI8:
            case OperandType.ShortInlineI:
            case OperandType.InlineR:
            case OperandType.ShortInlineR:
                cboOperand.Enabled = true;
                cboOperand.Items.Clear();
                cboOperand.DropDownStyle = ComboBoxStyle.DropDown;
                cboOperand.Items.Add(InsUtils.GetOperandText(ic, _insIndex));
                cboOperand.SelectedIndex = 0;
                break;

            case OperandType.InlineSwitch:
                cboOperand.Enabled = true;
                cboOperand.Items.Clear();
                cboOperand.DropDownStyle = ComboBoxStyle.DropDown;
                cboOperand.Items.Add(InsUtils.GetOperandText(ic, _insIndex));
                cboOperand.SelectedIndex = 0;
                Instruction[] switchIns = _ins.Operand as Instruction[];
                cboOperand.Items.Add("----------------------------------------");
                for (int i = 0; i < switchIns.Length; i++)
                {
                    cboOperand.Items.Add(
                        String.Format("{0} (0x{0:x}): {1}", i, InsUtils.GetInstructionText(ic, ic.IndexOf(switchIns[i])))
                        );
                }
                break;

            case OperandType.InlineField:
                if (_ins.Operand == null || _method.DeclaringType.Fields.Contains(_ins.Operand as FieldDefinition))
                {
                    InitFields(cboOperand);
                }
                else
                {
                    cboOperand.Enabled = true;
                    cboOperand.Items.Clear();
                    cboOperand.DropDownStyle = ComboBoxStyle.DropDownList;
                    cboOperand.Items.Add(InsUtils.GetOperandText(ic, _insIndex));
                    cboOperand.SelectedIndex = 0;
                }
                break;

            case OperandType.InlineVar:
            case OperandType.ShortInlineVar:
                InitVars(cboOperand);
                break;

            case OperandType.ShortInlineArg:
            case OperandType.InlineArg:
                InitParams(cboOperand);
                break;

            case OperandType.InlineMethod:
                InitMethods(cboOperand);
                btnSelectMethod.Enabled = true;
                break;

            case OperandType.InlineType:
                cboOperand.Enabled = true;
                cboOperand.Items.Clear();
                cboOperand.DropDownStyle = ComboBoxStyle.DropDown;
                if (_ins.Operand != null)
                {
                    cboOperand.Items.Add(_ins.Operand);
                    cboOperand.SelectedIndex = 0;
                }
                ClassEditHelper.InitDropdownTypes(cboOperand, _method.Module);
                break;

            default:
                cboOperand.Enabled = true;
                cboOperand.Items.Clear();
                cboOperand.DropDownStyle = ComboBoxStyle.DropDownList;
                if (_ins.Operand != null)
                {
                    cboOperand.Items.Add(_ins.Operand);
                    cboOperand.SelectedIndex = 0;
                }
                break;
            }
        }