Initial Commit

This commit is contained in:
2024-02-23 00:46:06 -05:00
commit 2bbedc0178
470 changed files with 46035 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public class BackgroundToForegroundConverter : GenericValueConverter<SolidColorBrush>
{
public override object ConvertCore(SolidColorBrush value, Type targetType, object parameter, CultureInfo culture)
{
SolidColorBrush back = value;
Color diff = back.Color - Colors.Black;
int summ = diff.R + diff.G + diff.B;
int border = 3 * 255 / 2;
return summ > border ? Brushes.Black : Brushes.White;
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public sealed class BrushHSBConverter : IValueConverter
{
private double lightnessDelta = 1.0;
public double LightnessDelta
{
get { return lightnessDelta; }
set { lightnessDelta = value; }
}
private double saturationDelta = 1.0;
public double SaturationDelta
{
get { return saturationDelta; }
set { saturationDelta = value; }
}
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
SolidColorBrush brush = value as SolidColorBrush;
if (brush != null)
{
SolidColorBrush result = brush.ChangeLightness(lightnessDelta).ChangeSaturation(saturationDelta);
return result;
}
else { return value; }
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public abstract class FourValuesMultiConverter<T1, T2, T3, T4> : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values != null && values.Length == 4)
{
if (values[0] is T1 && values[1] is T2 && values[2] is T3 && values[3] is T4)
{
T1 param1 = (T1)values[0];
T2 param2 = (T2)values[1];
T3 param3 = (T3)values[2];
T4 param4 = (T4)values[3];
var result = ConvertCore(param1, param2, param3, param4, targetType, parameter, culture);
return result;
}
}
return DependencyProperty.UnsetValue;
}
protected abstract object ConvertCore(T1 value1, T2 value2, T3 value3, T4 value4, Type targetType, object parameter, System.Globalization.CultureInfo culture);
public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
#endregion
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public class GenericValueConverter<T> : IValueConverter
{
public GenericValueConverter() { }
private Func<T, object> conversion;
public GenericValueConverter(Func<T, object> conversion)
{
if (conversion == null)
throw new ArgumentNullException("conversion");
this.conversion = conversion;
}
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is T)
{
T genericValue = (T)value;
object result = ConvertCore(genericValue, targetType, parameter, culture);
return result;
}
return null;
}
public virtual object ConvertCore(T value, Type targetType, object parameter, CultureInfo culture)
{
if (conversion != null)
{
return conversion(value);
}
throw new NotImplementedException();
}
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
#endregion
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public abstract class ThreeValuesMultiConverter<T1, T2, T3> : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values != null && values.Length == 3)
{
if (values[0] is T1 && values[1] is T2 && values[2] is T3)
{
T1 param1 = (T1)values[0];
T2 param2 = (T2)values[1];
T3 param3 = (T3)values[2];
var result = ConvertCore(param1, param2, param3, targetType, parameter, culture);
return result;
}
}
return null;
}
protected abstract object ConvertCore(T1 value1, T2 value2, T3 value3, Type targetType, object parameter, System.Globalization.CultureInfo culture);
public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
#endregion
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
namespace Microsoft.Research.DynamicDataDisplay.Converters
{
public abstract class TwoValuesMultiConverter<T1, T2> : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values != null && values.Length == 2)
{
if (values[0] is T1 && values[1] is T2)
{
T1 param1 = (T1)values[0];
T2 param2 = (T2)values[1];
var result = ConvertCore(param1, param2, targetType, parameter, culture);
return result;
}
}
return DependencyProperty.UnsetValue;
}
protected abstract object ConvertCore(T1 value1, T2 value2, Type targetType, object parameter, System.Globalization.CultureInfo culture);
public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
#endregion
}
}