/// <inheritdoc /> public override bool CanConvertToString(object value, IValueSerializerContext context) { var result = false; var gesture = value as MouseWheelGesture; if (gesture != null) { if (ModifierKeysConverter.IsDefinedModifierKeys(gesture.Modifiers) && gesture.MouseAction == MouseAction.WheelClick && MouseWheelDirectionExt.IsDefined(gesture.Direction)) { result = true; } } return(result); }
/// <inheritdoc /> 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 var gesture = context?.Instance as MouseWheelGesture; if (gesture != null) { if (System.Windows.Input.ModifierKeysConverter.IsDefinedModifierKeys(gesture.Modifiers) && gesture.MouseAction == MouseAction.WheelClick && MouseWheelDirectionExt.IsDefined(gesture.Direction)) { return(true); } } } return(base.CanConvertTo(context, destinationType)); }