/// <summary>
        /// Initializes the message encodings dropdown.
        /// </summary>
        private void InitializeEncodings(EndpointDescriptionCollection endpoints, EndpointDescription endpoint)
        {
            // preserve the existing value.
            Encoding currentEncoding = Encoding.Default;

            if (EncodingCB.SelectedIndex != -1)
            {
                currentEncoding = (Encoding)EncodingCB.SelectedItem;
            }

            EncodingCB.Items.Clear();

            if (endpoint != null)
            {
                Protocol protocol = new Protocol(endpoint);
                String securityPolicy = SecurityPolicies.GetDisplayName(endpoint.SecurityPolicyUri);

                foreach (EndpointDescription endpointDescription in endpoints)
                {
                    if ((protocol.Matches(Utils.ParseUri(endpointDescription.EndpointUrl))) &&
                        (endpoint.SecurityMode == endpointDescription.SecurityMode) &&
                        (securityPolicy == SecurityPolicies.GetDisplayName(endpointDescription.SecurityPolicyUri)))
                    {
                        switch (endpointDescription.EncodingSupport)
                        {
                            case BinaryEncodingSupport.None:
                                {
                                    if (!EncodingCB.Items.Contains(Encoding.Xml))
                                    {
                                        EncodingCB.Items.Add(Encoding.Xml);
                                    }
                                    break;
                                }

                            case BinaryEncodingSupport.Required:
                                {
                                    if (!EncodingCB.Items.Contains(Encoding.Binary))
                                    {
                                        EncodingCB.Items.Add(Encoding.Binary);
                                    }
                                    break;
                                }

                            case BinaryEncodingSupport.Optional:
                                {
                                    if (!EncodingCB.Items.Contains(Encoding.Binary))
                                    {
                                        EncodingCB.Items.Add(Encoding.Binary);
                                    }
                                    if (!EncodingCB.Items.Contains(Encoding.Xml))
                                    {
                                        EncodingCB.Items.Add(Encoding.Xml);
                                    }
                                    break;
                                }
                        }
                    }
                }
            }

            // add at least one encoding.
            if (EncodingCB.Items.Count == 0)
            {
                EncodingCB.Items.Add(Encoding.Default);
            }

            // set the current value.
            int index = EncodingCB.Items.IndexOf(currentEncoding);

            if (index == -1)
            {
                index = 0;
            }

            EncodingCB.SelectedIndex = index;
        }