markus / KCOM / Common / Converter / ConsolidationStringConverter.cs @ 787a4489
이력 | 보기 | 이력해설 | 다운로드 (5.6 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Globalization; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Windows; |
7 |
using System.Windows.Data; |
8 |
using Telerik.Windows.Controls.GridView; |
9 |
|
10 |
namespace KCOM.Common.Converter |
11 |
{ |
12 |
public class ConsolidationStringConverter : IValueConverter |
13 |
{ |
14 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
15 |
{ |
16 |
//if (value != null) |
17 |
//{ |
18 |
// if (value is ServiceInterface.MarkupInfoItem) |
19 |
// { |
20 |
// ServiceInterface.MarkupInfoItem instance = (value as ServiceInterface.MarkupInfoItem); |
21 |
|
22 |
// if (instance.Consolidate) |
23 |
// { |
24 |
// if (instance.PartConsolidate) |
25 |
// { |
26 |
// return "Team Consolidation"; |
27 |
|
28 |
// } |
29 |
// else |
30 |
// { |
31 |
// return "Consolidation"; |
32 |
// } |
33 |
// } |
34 |
// else |
35 |
// { |
36 |
// return ""; |
37 |
// } |
38 |
// } |
39 |
//} |
40 |
if (value != null) |
41 |
{ |
42 |
if (value is bool) |
43 |
{ |
44 |
if ((bool)value) |
45 |
return "Consolidated"; |
46 |
else |
47 |
return ""; |
48 |
} |
49 |
else if (value is Int32) |
50 |
{ |
51 |
return (int)value == 1 ? "Consolidated" : ""; |
52 |
} |
53 |
else |
54 |
{ |
55 |
throw new NotSupportedException("AvoidStringConverter bool만 가능합니다."); |
56 |
} |
57 |
} |
58 |
else |
59 |
{ |
60 |
throw new NotSupportedException("AvoidStringConverter ERROR"); |
61 |
} |
62 |
return ""; |
63 |
} |
64 |
|
65 |
|
66 |
|
67 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
68 |
{ |
69 |
throw new NotSupportedException(); |
70 |
} |
71 |
} |
72 |
|
73 |
public class GroupHeaderConverter : IValueConverter |
74 |
{ |
75 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
76 |
{ |
77 |
GroupViewModel groupViewModel = value as GroupViewModel; |
78 |
//string formattedValue = GetFormattedValue(groupViewModel); |
79 |
//int recordsCount = groupViewModel.Group.ItemCount; |
80 |
//return string.Format("{0} ({1} item{2})", formattedValue, |
81 |
// recordsCount, recordsCount == 1 ? string.Empty : "s"); |
82 |
|
83 |
|
84 |
if (groupViewModel.Header == "Consolidation") |
85 |
{ |
86 |
return "Originator's Consolidation"; |
87 |
} |
88 |
return groupViewModel.Header; |
89 |
|
90 |
} |
91 |
|
92 |
|
93 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
94 |
{ |
95 |
throw new NotImplementedException(); |
96 |
} |
97 |
} |
98 |
|
99 |
public class AvoidStringConverter : IValueConverter |
100 |
{ |
101 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
102 |
{ |
103 |
if (value != null) |
104 |
{ |
105 |
if (value is bool) |
106 |
{ |
107 |
if ((bool)value) |
108 |
return "[Avoid]"; |
109 |
else |
110 |
return ""; |
111 |
} |
112 |
else if(value is Int32) |
113 |
{ |
114 |
return (int)value == 1 ? "[Avoid]" : ""; |
115 |
} |
116 |
else |
117 |
{ |
118 |
throw new NotSupportedException("AvoidStringConverter bool만 가능합니다."); |
119 |
} |
120 |
} |
121 |
else |
122 |
{ |
123 |
return ""; |
124 |
} |
125 |
} |
126 |
|
127 |
|
128 |
|
129 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
130 |
{ |
131 |
throw new NotSupportedException(); |
132 |
} |
133 |
} |
134 |
|
135 |
public class TeamConsolidateStringConverter : IValueConverter |
136 |
{ |
137 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
138 |
{ |
139 |
if (value != null) |
140 |
{ |
141 |
if (value is bool) |
142 |
{ |
143 |
if ((bool)value) |
144 |
return "Team"; |
145 |
else |
146 |
return ""; |
147 |
} |
148 |
else if (value is Int32) |
149 |
{ |
150 |
return (int)value == 1 ? "[Team]" : ""; |
151 |
} |
152 |
else |
153 |
{ |
154 |
throw new NotSupportedException("AvoidStringConverter bool만 가능합니다."); |
155 |
} |
156 |
} |
157 |
else |
158 |
{ |
159 |
throw new NotSupportedException("AvoidStringConverter ERROR"); |
160 |
} |
161 |
} |
162 |
|
163 |
|
164 |
|
165 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
166 |
{ |
167 |
throw new NotSupportedException(); |
168 |
} |
169 |
} |
170 |
|
171 |
public class VisibilityConverter : IValueConverter |
172 |
{ |
173 |
public object Convert( |
174 |
object value, |
175 |
Type targetType, |
176 |
object parameter, |
177 |
CultureInfo culture) |
178 |
{ |
179 |
bool visibility = (bool)value; |
180 |
return visibility ? Visibility.Visible : Visibility.Collapsed; |
181 |
} |
182 |
|
183 |
public object ConvertBack( |
184 |
object value, |
185 |
Type targetType, |
186 |
object parameter, |
187 |
CultureInfo culture) |
188 |
{ |
189 |
Visibility visibility = (Visibility)value; |
190 |
return (visibility == Visibility.Visible); |
191 |
} |
192 |
} |
193 |
} |