//-------------------------------------------------------------------------
        // Handles the event when a method in-parameter is selected.
        // 
        //-------------------------------------------------------------------------
        private void InParameterBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            
            for(int i = 0; i < InParameterBox.Items.Count; i++)
            {
                try
                {
                    if(InParameterBox.SelectedIndices.Contains(i) && !InParameterArray[i].GetOkClicked())
                    {
                    
                        InParameterArray[i].Visible = true;
                        InParameterArray[i].ChangeText(
                            "Assign a value to the " + InParameterArray[i].GetParameterName()
                            + " parameter. The parameter is of type: " +
                            InParameterArray[i].GetParameterType() + ".");
				
                    }
                }
                catch (System.NullReferenceException nullError)
                {
                    // Catches the case if the window was closed.
                    InParameterArray[i] = new InParameterWindow(this);
                    InParameterArray[i].SetParameterName((InParameterBox.Items[i].ToString().Split(" ".ToCharArray()))[0]);
                    InParameterArray[i].Visible = true;
                    InParameterArray[i].ChangeText(
                        "Assign a value to the " + InParameterArray[i].GetParameterName()
                        + " parameter. The parameter is of type: " +
                        InParameterArray[i].GetParameterType() + ".");
                }
                
                
                if(!InParameterBox.SelectedIndices.Contains(i))
                {
                    try
                    {
                        InParameterArray[i].Visible = false;
                        InParameterArray[i].SetOkClicked(false);
                    }
                    catch (System.NullReferenceException nullError)
                    {
                        // Catches the case if the window was closed.
                        InParameterArray[i] = new InParameterWindow(this);
                        InParameterArray[i].SetParameterName((InParameterBox.Items[i].ToString().Split(" ".ToCharArray()))[0]);
                        InParameterArray[i].Visible = false;
                        InParameterArray[i].SetOkClicked(false);
                    }
                }
            }

            this.GenerateMethodCode();
        }
        //-------------------------------------------------------------------------
        // Handles the event when the method is changed on the method tab.
        //
        //-------------------------------------------------------------------------
        private void MethodList_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            try
            {
                this.CodeText_m.Text = "";
                this.InParameterBox.Items.Clear();
                this.KeyValueBox.Items.Clear();

                AddInParams();

                if(InParameterBox.Items.Count > 0) 
                {
                    // Create a new InParameterArray for all the items in the list. 
                    if(InParameterBox.Items.Count < MAXINPARAMS)
                    {
                        System.Array.Clear(this.InParameterArray, 0, InParameterArray.Length);
                        this.InParameterArray = new InParameterWindow[InParameterBox.Items.Count];

                        for(int i = 0; i < InParameterBox.Items.Count; i++)
                        {
                            InParameterArray[i] = new InParameterWindow(this);
                            InParameterArray[i].SetParameterName((InParameterBox.Items[i].ToString().Split(" ".ToCharArray()))[0]);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Method has too many in-Parameters.  Choose a different method.");
                    }
                }

            
                if(this.IsStaticMethodSelected())
                {
                    GenerateMethodCode();
                }
                else
                {
                    this.KeyValueLabel.Visible = true;
                    this.KeyValueBox.Visible = true;
                    System.Threading.ThreadPool.
                        QueueUserWorkItem(
                        new System.Threading.WaitCallback(
                        this.AddKeyValues_m));
                }
            }
            catch (ManagementException mErr)
            {
                if(mErr.Message.Equals("Not found "))
                    MessageBox.Show("Error creating code: WMI class not found.");
                else
                    MessageBox.Show("Error creating code: " + mErr.Message.ToString());
            }
            
        }