Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows.Data;
|
---|
6 | using System.Globalization;
|
---|
7 | using System.Windows.Media;
|
---|
8 |
|
---|
9 | namespace Microsoft.Research.DynamicDataDisplay.Converters
|
---|
10 | {
|
---|
11 | public class BackgroundToForegroundConverter : GenericValueConverter<SolidColorBrush>
|
---|
12 | {
|
---|
13 | public override object ConvertCore(SolidColorBrush value, Type targetType, object parameter, CultureInfo culture)
|
---|
14 | {
|
---|
15 | SolidColorBrush back = value;
|
---|
16 | Color diff = back.Color - Colors.Black;
|
---|
17 | int summ = diff.R + diff.G + diff.B;
|
---|
18 |
|
---|
19 | int border = 3 * 255 / 2;
|
---|
20 |
|
---|
21 | return summ > border ? Brushes.Black : Brushes.White;
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.