EnumToModuleListSortOptionConverter.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 Microsoft.PowerToys.Settings.UI.Controls; 7 using Microsoft.PowerToys.Settings.UI.Library; 8 using Microsoft.UI.Xaml.Data; 9 10 namespace Microsoft.PowerToys.Settings.UI.Converters 11 { 12 public partial class EnumToModuleListSortOptionConverter : IValueConverter 13 { 14 public object Convert(object value, Type targetType, object parameter, string language) 15 { 16 if (value is DashboardSortOrder sortOrder) 17 { 18 return sortOrder switch 19 { 20 DashboardSortOrder.Alphabetical => ModuleListSortOption.Alphabetical, 21 DashboardSortOrder.ByStatus => ModuleListSortOption.ByStatus, 22 _ => ModuleListSortOption.Alphabetical, 23 }; 24 } 25 26 return ModuleListSortOption.Alphabetical; 27 } 28 29 public object ConvertBack(object value, Type targetType, object parameter, string language) 30 { 31 if (value is ModuleListSortOption sortOption) 32 { 33 return sortOption switch 34 { 35 ModuleListSortOption.Alphabetical => DashboardSortOrder.Alphabetical, 36 ModuleListSortOption.ByStatus => DashboardSortOrder.ByStatus, 37 _ => DashboardSortOrder.Alphabetical, 38 }; 39 } 40 41 return DashboardSortOrder.Alphabetical; 42 } 43 } 44 }