#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.3 KiB

using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Input;
using ICSharpCode.Core.Presentation;
namespace ICSharpCode.ShortcutsManagement.Converters
{
/// <summary>
/// Converts input gesture to string representation
/// </summary>
public class InputGestureConverter : IValueConverter
{
/// <summary>
/// Convert input gesture to string
/// </summary>
/// <param name="value">Input gesture</param>
/// <param name="targetType">Convertion target type (Only string is supported)</param>
/// <param name="parameter">Not used</param>
/// <param name="culture">Not used</param>
/// <returns>String representing <see cref="InputGesture" /></returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is KeyGesture && targetType == typeof(string)) {
var gestures = new InputGestureCollection(new[] {value});
return new InputGestureCollectionConverter().ConvertToInvariantString(gestures).Replace("+", " + ").Replace(",", ", ");
}
if(value is MouseGesture && targetType == typeof(string)) {
return new MouseGestureConverter().ConvertToInvariantString(value);
}
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}