Repository navigation
Expand file tree
/
Copy pathIPScannerHostChangeToStringConverter.cs
More file actions
56 lines (52 loc) · 2.07 KB
/
Copy pathIPScannerHostChangeToStringConverter.cs
File metadata and controls
56 lines (52 loc) · 2.07 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Globalization;
using System.Windows.Data;
using NETworkManager.Localization.Resources;
using NETworkManager.Models.Network;
namespace NETworkManager.Converters;
/// <summary>
/// Convert the <see cref="IPScannerHostChange" /> of a host (since the previous scan) to a translated
/// <see cref="string" /> (e.g. "New").
/// </summary>
public sealed class IPScannerHostChangeToStringConverter : IValueConverter
{
/// <summary>
/// Convert the <see cref="IPScannerHostChange" /> of a host to a translated <see cref="string" />.
/// </summary>
/// <param name="value">Change of the host as <see cref="IPScannerHostChange" />.</param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns>Translated change, empty if there is none.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is IPScannerHostChange change ? ToLocalizedString(change) : string.Empty;
}
/// <summary>
/// Gets the translated change of a host.
/// </summary>
/// <param name="change">Change of the host.</param>
/// <returns>Translated change, empty for <see cref="IPScannerHostChange.None" />.</returns>
public static string ToLocalizedString(IPScannerHostChange change)
{
return change switch
{
IPScannerHostChange.New => Strings.HostChange_New,
IPScannerHostChange.Gone => Strings.HostChange_Gone,
IPScannerHostChange.MACChanged => Strings.HostChange_MACChanged,
_ => string.Empty
};
}
/// <summary>
/// !!! Method not implemented !!!
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}