3
3
// See the LICENSE file in the project root for more information.
4
4
5
5
using System ;
6
+ using System . Drawing ;
6
7
using System . Runtime . CompilerServices ;
7
8
using Microsoft . PowerToys . Settings . UI . Lib . Helpers ;
8
9
using Microsoft . PowerToys . Settings . UI . Lib . ViewModels . Commands ;
@@ -401,6 +402,7 @@ public string ZoneHighlightColor
401
402
402
403
set
403
404
{
405
+ value = ToRGBHex ( value ) ;
404
406
if ( ! value . Equals ( _zoneHighlightColor ) )
405
407
{
406
408
_zoneHighlightColor = value ;
@@ -419,6 +421,7 @@ public string ZoneBorderColor
419
421
420
422
set
421
423
{
424
+ value = ToRGBHex ( value ) ;
422
425
if ( ! value . Equals ( _zoneBorderColor , StringComparison . OrdinalIgnoreCase ) )
423
426
{
424
427
_zoneBorderColor = value ;
@@ -437,6 +440,7 @@ public string ZoneInActiveColor
437
440
438
441
set
439
442
{
443
+ value = ToRGBHex ( value ) ;
440
444
if ( ! value . Equals ( _zoneInActiveColor ) )
441
445
{
442
446
_zoneInActiveColor = value ;
@@ -524,5 +528,19 @@ public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
524
528
SendConfigMSG ( ipcMessage . ToJsonString ( ) ) ;
525
529
}
526
530
}
531
+
532
+ private string ToRGBHex ( string color )
533
+ {
534
+ try
535
+ {
536
+ int argb = int . Parse ( color . Replace ( "#" , string . Empty ) , System . Globalization . NumberStyles . HexNumber ) ;
537
+ Color clr = Color . FromArgb ( argb ) ;
538
+ return "#" + clr . R . ToString ( "X2" ) + clr . G . ToString ( "X2" ) + clr . B . ToString ( "X2" ) ;
539
+ }
540
+ catch ( Exception )
541
+ {
542
+ return "#FFFFFF" ;
543
+ }
544
+ }
527
545
}
528
546
}
0 commit comments