53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using Flexitime.Objects;
|
|
|
|
namespace FlexitimeTaskbarUtility.Converters
|
|
{
|
|
public class UserStatusToImageSourceConverter:IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value.GetType() != typeof(UserState))
|
|
{
|
|
throw new ArgumentException(nameof(value));
|
|
}
|
|
|
|
var userState = (UserState) value;
|
|
string basePath = string.Intern("pack://application:,,,/FlexitimeTaskbarUtility;component/Images/");
|
|
string imageName;
|
|
switch (userState)
|
|
{
|
|
case UserState.Unknown:
|
|
imageName = "Clock_LoggedOut.ico";
|
|
break;
|
|
case UserState.In:
|
|
imageName = "Clock_In.ico";
|
|
break;
|
|
case UserState.Out:
|
|
imageName = "Clock_Out.ico";
|
|
break;
|
|
case UserState.OutOfOffice:
|
|
imageName = "Clock_OutOfOffice.ico";
|
|
break;
|
|
case UserState.Remote:
|
|
imageName = "Clock_Remote.ico";
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
|
|
ImageSource ret = new BitmapImage(new Uri($"{basePath}{imageName}"));
|
|
return ret;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|