/// <summary>
        ///  ConvertTo()
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns></returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException("destinationType");
            }

            if (destinationType == typeof(string))
            {
                if (value != null)
                {
                    AnyKeyGesture keyGesture = value as AnyKeyGesture;
                    if (keyGesture != null)
                    {
                        if (keyGesture.Key == Key.None)
                        {
                            return(string.Empty);
                        }

                        string strBinding = "";
                        string strKey     = (string)keyConverter.ConvertTo(context, culture, keyGesture.Key, destinationType) as string;
                        if (strKey != string.Empty)
                        {
                            strBinding += modifierKeysConverter.ConvertTo(context, culture, keyGesture.Modifiers, destinationType) as string;
                            if (strBinding != string.Empty)
                            {
                                strBinding += MODIFIERS_DELIMITER;
                            }
                            strBinding += strKey;

                            if (!string.IsNullOrEmpty(keyGesture.DisplayString))
                            {
                                strBinding += DISPLAYSTRING_SEPARATOR + keyGesture.DisplayString;
                            }
                        }
                        return(strBinding);
                    }
                }
                else
                {
                    return(string.Empty);
                }
            }
            throw GetConvertToException(value, destinationType);
        }
 ///<summary>
 /// TypeConverter method override.
 ///</summary>
 ///<param name="context">ITypeDescriptorContext</param>
 ///<param name="destinationType">Type to convert to</param>
 ///<returns>true if conversion	is possible</returns>
 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
 {
     // We can convert to an InstanceDescriptor or to a string.
     if (destinationType == typeof(string))
     {
         // When invoked by the serialization engine we can convert to string only for known type
         if (context != null && context.Instance != null)
         {
             AnyKeyGesture keyGesture = context.Instance as AnyKeyGesture;
             if (keyGesture != null)
             {
                 return(ModifierKeysConverter.IsDefinedModifierKeys(keyGesture.Modifiers) &&
                        IsDefinedKey(keyGesture.Key));
             }
         }
     }
     return(false);
 }
        /// <summary>
        ///  Decode the strings keyGestures and displayStrings, creating a sequence of KeyGestures. Add each
        ///  AnyKeyGesture to the given InputGestureCollection. The two input strings typically come from a resource
        ///  file.
        /// </summary>
        internal static void AddGesturesFromResourceStrings(string keyGestures, string displayStrings, InputGestureCollection gestures)
        {
            while (!string.IsNullOrEmpty(keyGestures))
            {
                string keyGestureToken;
                string keyDisplayString;

                // break apart first gesture from the rest
                int index = keyGestures.IndexOf(MULTIPLEGESTURE_DELIMITER, StringComparison.Ordinal);
                if (index >= 0)                     // multiple gestures exist
                {
                    keyGestureToken = keyGestures.Substring(0, index);
                    keyGestures     = keyGestures.Substring(index + 1);
                }
                else
                {
                    keyGestureToken = keyGestures;
                    keyGestures     = string.Empty;
                }

                // similarly, break apart first display string from the rest
                index = displayStrings.IndexOf(MULTIPLEGESTURE_DELIMITER, StringComparison.Ordinal);
                if (index >= 0)                     // multiple display strings exist
                {
                    keyDisplayString = displayStrings.Substring(0, index);
                    displayStrings   = displayStrings.Substring(index + 1);
                }
                else
                {
                    keyDisplayString = displayStrings;
                    displayStrings   = string.Empty;
                }

                AnyKeyGesture keyGesture = CreateFromResourceStrings(keyGestureToken, keyDisplayString);

                if (keyGesture != null)
                {
                    gestures.Add(keyGesture);
                }
            }
        }