|
1 | | -/* |
2 | | - * ThreadPilot - Advanced Windows Process and Power Plan Manager |
3 | | - * Copyright (C) 2025 Prime Build |
4 | | - * |
5 | | - * This program is free software: you can redistribute it and/or modify |
6 | | - * it under the terms of the GNU Affero General Public License as published by |
7 | | - * the Free Software Foundation, version 3 only. |
8 | | - * |
9 | | - * This program is distributed in the hope that it will be useful, |
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | - * GNU Affero General Public License for more details. |
13 | | - * |
14 | | - * You should have received a copy of the GNU Affero General Public License |
15 | | - * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | | - */ |
17 | | -namespace ThreadPilot |
18 | | -{ |
19 | | - using System; |
20 | | - using System.Globalization; |
21 | | - using System.Windows; |
22 | | - using System.Windows.Data; |
23 | | - using System.Windows.Media; |
24 | | - |
25 | | - public class BoolToColorConverter : IValueConverter |
26 | | - { |
27 | | - public static readonly BoolToColorConverter Instance = new(); |
28 | | - |
29 | | - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
30 | | - { |
31 | | - if (value is bool boolValue) |
32 | | - { |
33 | | - return boolValue |
34 | | - ? ResolveBrush("TextFillColorPrimaryBrush", System.Windows.Media.Brushes.Black) |
35 | | - : ResolveBrush("TextFillColorSecondaryBrush", System.Windows.Media.Brushes.Gray); |
36 | | - } |
37 | | - |
38 | | - return ResolveBrush("TextFillColorSecondaryBrush", System.Windows.Media.Brushes.Gray); |
39 | | - } |
40 | | - |
41 | | - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
42 | | - { |
43 | | - throw new NotImplementedException(); |
44 | | - } |
45 | | - |
46 | | - private static System.Windows.Media.Brush ResolveBrush(string key, System.Windows.Media.Brush fallback) |
47 | | - { |
48 | | - if (System.Windows.Application.Current?.TryFindResource(key) is System.Windows.Media.Brush brush) |
49 | | - { |
50 | | - return brush; |
51 | | - } |
52 | | - |
53 | | - return fallback; |
54 | | - } |
55 | | - } |
56 | | -} |
57 | | - |
| 1 | +namespace ThreadPilot |
| 2 | +{ |
| 3 | + using System; |
| 4 | + using System.Globalization; |
| 5 | + using System.Windows; |
| 6 | + using System.Windows.Data; |
| 7 | + using System.Windows.Media; |
| 8 | + |
| 9 | + public class BoolToColorConverter : IValueConverter |
| 10 | + { |
| 11 | + public static readonly BoolToColorConverter Instance = new(); |
| 12 | + |
| 13 | + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
| 14 | + { |
| 15 | + if (value is bool boolValue) |
| 16 | + { |
| 17 | + return boolValue |
| 18 | + ? ResolveBrush("TextFillColorPrimaryBrush", System.Windows.Media.Brushes.Black) |
| 19 | + : ResolveBrush("TextFillColorSecondaryBrush", System.Windows.Media.Brushes.Gray); |
| 20 | + } |
| 21 | + |
| 22 | + return ResolveBrush("TextFillColorSecondaryBrush", System.Windows.Media.Brushes.Gray); |
| 23 | + } |
| 24 | + |
| 25 | + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
| 26 | + { |
| 27 | + throw new NotImplementedException(); |
| 28 | + } |
| 29 | + |
| 30 | + private static System.Windows.Media.Brush ResolveBrush(string key, System.Windows.Media.Brush fallback) |
| 31 | + { |
| 32 | + if (System.Windows.Application.Current?.TryFindResource(key) is System.Windows.Media.Brush brush) |
| 33 | + { |
| 34 | + return brush; |
| 35 | + } |
| 36 | + |
| 37 | + return fallback; |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | + |
0 commit comments