-
Notifications
You must be signed in to change notification settings - Fork 1
/
PresetTDPConverter.cs
35 lines (29 loc) · 1.09 KB
/
PresetTDPConverter.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 System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Data;
namespace PocketTDPControl
{
public class PresetTDPConverter : IMultiValueConverter
{
private ObservableCollection<int> presetTDP;
private int selectedPresetTDPIndex;
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
this.presetTDP = values[0] as ObservableCollection<int>;
if (values[1] != null)
this.selectedPresetTDPIndex = (int)values[1];
else
{
this.selectedPresetTDPIndex = 0;
}
return (double)presetTDP[selectedPresetTDPIndex];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
var presetTDPValue = (double)value;
this.presetTDP[this.selectedPresetTDPIndex] = (int)Math.Round(presetTDPValue, 0);
return new object[] {this.presetTDP, this.selectedPresetTDPIndex};
}
}
}