-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVpnLifecycleToBoolConverter.cs
35 lines (31 loc) · 1.19 KB
/
VpnLifecycleToBoolConverter.cs
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
32
33
34
35
using System;
using Coder.Desktop.App.Models;
using DependencyPropertyGenerator;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
namespace Coder.Desktop.App.Converters;
[DependencyProperty<bool>("Unknown", DefaultValue = false)]
[DependencyProperty<bool>("Starting", DefaultValue = false)]
[DependencyProperty<bool>("Started", DefaultValue = false)]
[DependencyProperty<bool>("Stopping", DefaultValue = false)]
[DependencyProperty<bool>("Stopped", DefaultValue = false)]
public partial class VpnLifecycleToBoolConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is not VpnLifecycle lifecycle) return Stopped;
return lifecycle switch
{
VpnLifecycle.Unknown => Unknown,
VpnLifecycle.Starting => Starting,
VpnLifecycle.Started => Started,
VpnLifecycle.Stopping => Stopping,
VpnLifecycle.Stopped => Stopped,
_ => Visibility.Collapsed,
};
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}