MonitorSelectionItem.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 #nullable enable 6 7 using System.ComponentModel; 8 using System.Runtime.CompilerServices; 9 using Microsoft.PowerToys.Settings.UI.Library; 10 11 namespace Microsoft.PowerToys.Settings.UI.ViewModels 12 { 13 /// <summary> 14 /// ViewModel for monitor selection in profile editor 15 /// </summary> 16 public class MonitorSelectionItem : INotifyPropertyChanged 17 { 18 private bool _isSelected; 19 private int _brightness = 100; 20 private int _contrast = 50; 21 private int _volume = 50; 22 private int _colorTemperature = 6500; 23 private bool _includeBrightness; 24 private bool _includeContrast; 25 private bool _includeVolume; 26 private bool _includeColorTemperature; 27 28 public required MonitorInfo Monitor { get; set; } 29 30 public bool SuppressAutoSelection { get; set; } 31 32 public bool IsSelected 33 { 34 get => _isSelected; 35 set 36 { 37 if (_isSelected != value) 38 { 39 _isSelected = value; 40 OnPropertyChanged(); 41 } 42 } 43 } 44 45 public int Brightness 46 { 47 get => _brightness; 48 set 49 { 50 if (_brightness != value) 51 { 52 _brightness = value; 53 OnPropertyChanged(); 54 if (!SuppressAutoSelection) 55 { 56 IncludeBrightness = true; 57 } 58 } 59 } 60 } 61 62 public int Contrast 63 { 64 get => _contrast; 65 set 66 { 67 if (_contrast != value) 68 { 69 _contrast = value; 70 OnPropertyChanged(); 71 if (!SuppressAutoSelection) 72 { 73 IncludeContrast = true; 74 } 75 } 76 } 77 } 78 79 public int Volume 80 { 81 get => _volume; 82 set 83 { 84 if (_volume != value) 85 { 86 _volume = value; 87 OnPropertyChanged(); 88 if (!SuppressAutoSelection) 89 { 90 IncludeVolume = true; 91 } 92 } 93 } 94 } 95 96 public int ColorTemperature 97 { 98 get => _colorTemperature; 99 set 100 { 101 if (_colorTemperature != value) 102 { 103 _colorTemperature = value; 104 OnPropertyChanged(); 105 if (!SuppressAutoSelection) 106 { 107 IncludeColorTemperature = true; 108 } 109 } 110 } 111 } 112 113 public bool SupportsContrast => Monitor?.SupportsContrast ?? false; 114 115 public bool SupportsVolume => Monitor?.SupportsVolume ?? false; 116 117 public bool SupportsColorTemperature => Monitor?.SupportsColorTemperature ?? false; 118 119 public bool IncludeBrightness 120 { 121 get => _includeBrightness; 122 set 123 { 124 if (_includeBrightness != value) 125 { 126 _includeBrightness = value; 127 OnPropertyChanged(); 128 } 129 } 130 } 131 132 public bool IncludeContrast 133 { 134 get => _includeContrast; 135 set 136 { 137 if (_includeContrast != value) 138 { 139 _includeContrast = value; 140 OnPropertyChanged(); 141 } 142 } 143 } 144 145 public bool IncludeVolume 146 { 147 get => _includeVolume; 148 set 149 { 150 if (_includeVolume != value) 151 { 152 _includeVolume = value; 153 OnPropertyChanged(); 154 } 155 } 156 } 157 158 public bool IncludeColorTemperature 159 { 160 get => _includeColorTemperature; 161 set 162 { 163 if (_includeColorTemperature != value) 164 { 165 _includeColorTemperature = value; 166 OnPropertyChanged(); 167 } 168 } 169 } 170 171 public event PropertyChangedEventHandler? PropertyChanged; 172 173 protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) 174 { 175 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 176 } 177 } 178 }