| | | 1 | | using System; |
| | | 2 | | using System.Globalization; |
| | | 3 | | using System.Windows; |
| | | 4 | | using System.Windows.Data; |
| | | 5 | | |
| | | 6 | | namespace SwitchBlade.Core |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Converts boolean inputs to Visibility. |
| | | 10 | | /// Expects values[0]: bool IsShortcutVisible |
| | | 11 | | /// Expects values[1]: bool EnableNumberShortcuts |
| | | 12 | | /// Returns Visible if both are true, otherwise Collapsed. |
| | | 13 | | /// </summary> |
| | | 14 | | public class ShortcutVisibilityConverter : IMultiValueConverter |
| | | 15 | | { |
| | | 16 | | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
| | 6 | 17 | | { |
| | 6 | 18 | | if (values.Length < 2) |
| | 1 | 19 | | return Visibility.Collapsed; |
| | | 20 | | |
| | | 21 | | // Check if shortcuts are globally enabled |
| | 5 | 22 | | if (values[1] is not bool enableShortcuts || !enableShortcuts) |
| | 2 | 23 | | return Visibility.Collapsed; |
| | | 24 | | |
| | | 25 | | // Check if the individual item has a visible shortcut |
| | 3 | 26 | | if (values[0] is bool isVisible && isVisible) |
| | 1 | 27 | | return Visibility.Visible; |
| | | 28 | | |
| | 2 | 29 | | return Visibility.Collapsed; |
| | 6 | 30 | | } |
| | | 31 | | |
| | | 32 | | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
| | 1 | 33 | | { |
| | 1 | 34 | | throw new NotImplementedException(); |
| | | 35 | | } |
| | | 36 | | } |
| | | 37 | | } |