BoolToKeyVisualStateConverter.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Collections.Generic; 7 using System.Linq; 8 using System.Text; 9 using System.Threading.Tasks; 10 using Microsoft.PowerToys.Settings.UI.Controls; 11 using Microsoft.UI.Xaml.Data; 12 13 namespace Microsoft.PowerToys.Settings.UI.Converters 14 { 15 public partial class BoolToKeyVisualStateConverter : IValueConverter 16 { 17 public object Convert(object value, Type targetType, object parameter, string language) 18 { 19 if (value is bool b && parameter is string param) 20 { 21 if (b && param == "Warning") 22 { 23 return State.Warning; 24 } 25 else if (b && param == "Error") 26 { 27 return State.Error; 28 } 29 else 30 { 31 return State.Normal; 32 } 33 } 34 else 35 { 36 return State.Normal; 37 } 38 } 39 40 public object ConvertBack(object value, Type targetType, object parameter, string language) 41 { 42 throw new NotImplementedException(); 43 } 44 } 45 }