blob: 3be7a881874cdc899142b71f300d6f31420f3ac7 (
plain)
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
57
58
59
60
61
62
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Tango.PPC.UI.Converters
{
public class ProgressLengthSpoolConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
try
{
if (values.Count() == 2)
{
double length = System.Convert.ToDouble(values[0]);
bool forOneSpool = System.Convert.ToBoolean(values[1]);
var totalBy4Spools = (double)length*4;// spools ;
if (forOneSpool)
{
return (double)totalBy4Spools / 4;
}
return totalBy4Spools;
}
if (values.Count() == 3)
{
double length = System.Convert.ToDouble(values[0]);
bool forOneSpool = System.Convert.ToBoolean(values[1]);
double currentProgresslength = System.Convert.ToDouble(values[2]) ;
var totalBy4Spools = (double)length * 4;
var currentProgressBy4Spools = (double)currentProgresslength * 4 ;
int coeff = (int)currentProgressBy4Spools / (int)totalBy4Spools;
var progressCurrent = coeff == 0 ? currentProgressBy4Spools : currentProgressBy4Spools % (coeff * totalBy4Spools);//show for progress
if (forOneSpool)
{
return (double)progressCurrent / 4;
}
return progressCurrent;
}
return "-";
}
catch
{
return "-";
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
|