Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Converters/BackgroundToForegroundConverter.cs @ 13780

Last change on this file since 13780 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 681 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Data;
6using System.Globalization;
7using System.Windows.Media;
8
9namespace 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.