-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathConverters.cs
157 lines (147 loc) · 5.47 KB
/
Converters.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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
namespace FSClient {
public class ConfStateConverter : IValueConverter{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture){
if (value == null)
return "";
ConferenceUser.USER_STATE state = (ConferenceUser.USER_STATE)value;
return StateConvert(state);
}
public static String StateConvert(ConferenceUser.USER_STATE state){
String ret = "";
if (ConferenceUser.StateTest(state,ConferenceUser.USER_STATE.DEAF))
ret += "D ";
if (ConferenceUser.StateTest(state, ConferenceUser.USER_STATE.FLOOR))
ret += "F ";
if (ConferenceUser.StateTest(state, ConferenceUser.USER_STATE.MUTE))
ret += "M ";
if (ConferenceUser.StateTest(state, ConferenceUser.USER_STATE.TALK))
ret += "T ";
return ret;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){
throw new NotImplementedException();
}
}
public class StateConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return Colors.White.ToString();
String ret = Colors.White.ToString();
Call.CALL_STATE state = (Call.CALL_STATE)value;
switch (state) {
case Call.CALL_STATE.Answered:
ret = "#FF4EFF00";
break;
case Call.CALL_STATE.Busy:
ret = "#FFFFAF00";
break;
case Call.CALL_STATE.Ended:
ret = "#FFAFAFAF";
break;
case Call.CALL_STATE.Failed:
ret = "#FF000000";
break;
case Call.CALL_STATE.Hold:
ret = "#FFF1FF00";
break;
case Call.CALL_STATE.Missed:
ret = "#FFFF0000";
break;
case Call.CALL_STATE.Hold_Ringing:
case Call.CALL_STATE.Ringing:
ret = "#FF00B3FF";
break;
}
return ret;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class AccountDefaultConverter : IValueConverter {
public static SolidColorBrush default_account_color;
public static SolidColorBrush normal_account_color;
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return normal_account_color;
bool is_default = (bool)value;
return is_default ? default_account_color : normal_account_color;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class EnglishDirectionConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return "";
return EnglishDirectionConverter.Convert((bool)value);
}
public static String Convert(bool is_outgoing) {
return is_outgoing ? "Outgoing" : "Incoming";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class DirectionConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return "";
bool is_outgoing = (bool)value;
return is_outgoing ? "<-" : "->";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class DurationTimeConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return "";
return Convert((TimeSpan)value);
}
public static string Convert(TimeSpan duration) {
return duration.Minutes + ":" + duration.Seconds.ToString("00");
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class ShortDateTimeConverter : IValueConverter {
public static string Convert(DateTime time) {
if (time == DateTime.MinValue)
return "";
return time.ToString("ddd, dd MMM yyyy HH:mm:ss tt");
}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return "";
return Convert((DateTime)value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
public class BoolToVisibilityConverter : IValueConverter {
public static Visibility Convert(bool value) {
return value ? Visibility.Visible : Visibility.Hidden;
}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
if (value == null)
return "";
return Convert((bool)value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
}