|
using System;
using System.Globalization;
using System.Windows.Data;
namespace FsControls
{
public class HighlightDateConverter : IValueConverter
{
#region Properties
/// <summary>
/// The FsCalendarControl that owns this converter.
/// </summary>
public static FsCalendar Parent { get; set; }
#endregion
#region IValueConverter Members
/// <summary>
/// Converts from a Date Dictionary to a String.
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Exit if highlighting turned off
if (Parent.ShowDateHighlights == false) return null;
// Initialize
var dateDictionary = Parent.HighlightedDates;
var targetDate = (DateTime) value;
// Get tool tip for date passed in
string toolTip = null;
var dateIsHighlighted = dateDictionary.ContainsKey(targetDate);
if (dateIsHighlighted) toolTip = dateDictionary[targetDate];
// Set return value
return toolTip;
}
/// <summary>
/// Not used.
/// </summary>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.