blob: c433fda57bbb9c6617d5ff3d946f5e38727fa7ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;
namespace MaterialDesignThemes.Wpf.Converters
{
public class ClockLineConverter : MarkupExtension, IValueConverter
{
public ClockDisplayMode DisplayMode { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var time = (DateTime) value;
return DisplayMode == ClockDisplayMode.Hours
? ((time.Hour > 13) ? time.Hour - 12 : time.Hour)*(360/12)
: (time.Minute == 0 ? 60 : time.Minute)*(360/60);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
|