PowerToys/Wox/Converters/OpacityModeConverter.cs

40 lines
1.4 KiB
C#
Raw Normal View History

2014-03-26 17:34:19 +08:00
using System;
using System.Globalization;
using Wox.Core.UserSettings;
2014-03-26 17:34:19 +08:00
namespace Wox.Converters
2014-03-26 17:34:19 +08:00
{
public class OpacityModeConverter : ConvertorBase<OpacityModeConverter>
2014-03-26 17:34:19 +08:00
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
2014-03-26 17:34:19 +08:00
{
if (!(value is OpacityMode)) return value.ToString();
var mode = (OpacityMode) value;
switch (mode)
{
case OpacityMode.Normal:
return "Normal Window";
case OpacityMode.LayeredWindow:
{
if (Environment.OSVersion.Version.Major < 5)
return "Layered Window (not supported by your Windows)";
if (Environment.OSVersion.Version.Major == 5)
return "Layered Window (not recommended on your Windows)";
return "Layered Window";
}
case OpacityMode.DWM:
{
if (Environment.OSVersion.Version.Major < 6)
return "DWM-Enabled Window (not supported by your Windows)";
return "DWM-Enabled Window";
}
}
return value.ToString();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}