OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.ComponentModel; | |
5 using System.Globalization; | |
6 | |
7 namespace Microsoft.VisualStudio.Project | |
8 { | |
9 public class OutputTypeConverter : EnumConverter | |
10 { | |
11 public OutputTypeConverter() | |
12 : base(typeof(OutputType)) | |
13 { | |
14 | |
15 } | |
16 | |
17 public override bool CanConvertFrom(ITypeDescriptorContext conte
xt, Type sourceType) | |
18 { | |
19 if(sourceType == typeof(string)) return true; | |
20 | |
21 return base.CanConvertFrom(context, sourceType); | |
22 } | |
23 | |
24 public override object ConvertFrom(ITypeDescriptorContext contex
t, CultureInfo culture, object value) | |
25 { | |
26 string str = value as string; | |
27 | |
28 if(str != null) | |
29 { | |
30 if(str == SR.GetString(SR.Exe, culture)) return
OutputType.Exe; | |
31 if(str == SR.GetString(SR.Library, culture)) ret
urn OutputType.Library; | |
32 if(str == SR.GetString(SR.WinExe, culture)) retu
rn OutputType.WinExe; | |
33 } | |
34 | |
35 return base.ConvertFrom(context, culture, value); | |
36 } | |
37 | |
38 public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType) | |
39 { | |
40 if(destinationType == typeof(string)) | |
41 { | |
42 string result = null; | |
43 // In some cases if multiple nodes are selected
the windows form engine | |
44 // calls us with a null value if the selected no
de's property values are not equal | |
45 if(value != null) | |
46 { | |
47 result = SR.GetString(((OutputType)value
).ToString(), culture); | |
48 } | |
49 else | |
50 { | |
51 result = SR.GetString(OutputType.Library
.ToString(), culture); | |
52 } | |
53 | |
54 if(result != null) return result; | |
55 } | |
56 | |
57 return base.ConvertTo(context, culture, value, destinati
onType); | |
58 } | |
59 | |
60 public override bool GetStandardValuesSupported(System.Component
Model.ITypeDescriptorContext context) | |
61 { | |
62 return true; | |
63 } | |
64 | |
65 public override System.ComponentModel.TypeConverter.StandardValu
esCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext cont
ext) | |
66 { | |
67 return new StandardValuesCollection(new OutputType[] { O
utputType.Exe, OutputType.Library, OutputType.WinExe }); | |
68 } | |
69 } | |
70 | |
71 public class DebugModeConverter : EnumConverter | |
72 { | |
73 | |
74 public DebugModeConverter() | |
75 : base(typeof(DebugMode)) | |
76 { | |
77 | |
78 } | |
79 public override bool CanConvertFrom(ITypeDescriptorContext conte
xt, Type sourceType) | |
80 { | |
81 if(sourceType == typeof(string)) return true; | |
82 | |
83 return base.CanConvertFrom(context, sourceType); | |
84 } | |
85 | |
86 public override object ConvertFrom(ITypeDescriptorContext contex
t, CultureInfo culture, object value) | |
87 { | |
88 string str = value as string; | |
89 | |
90 if(str != null) | |
91 { | |
92 if(str == SR.GetString(SR.Program, culture)) ret
urn DebugMode.Program; | |
93 | |
94 if(str == SR.GetString(SR.Project, culture)) ret
urn DebugMode.Project; | |
95 | |
96 if(str == SR.GetString(SR.URL, culture)) return
DebugMode.URL; | |
97 } | |
98 | |
99 return base.ConvertFrom(context, culture, value); | |
100 } | |
101 | |
102 public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType) | |
103 { | |
104 if(destinationType == typeof(string)) | |
105 { | |
106 string result = null; | |
107 // In some cases if multiple nodes are selected
the windows form engine | |
108 // calls us with a null value if the selected no
de's property values are not equal | |
109 if(value != null) | |
110 { | |
111 result = SR.GetString(((DebugMode)value)
.ToString(), culture); | |
112 } | |
113 else | |
114 { | |
115 result = SR.GetString(DebugMode.Program.
ToString(), culture); | |
116 } | |
117 | |
118 if(result != null) return result; | |
119 } | |
120 | |
121 return base.ConvertTo(context, culture, value, destinati
onType); | |
122 } | |
123 | |
124 public override bool GetStandardValuesSupported(System.Component
Model.ITypeDescriptorContext context) | |
125 { | |
126 return true; | |
127 } | |
128 | |
129 public override System.ComponentModel.TypeConverter.StandardValu
esCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext cont
ext) | |
130 { | |
131 return new StandardValuesCollection(new DebugMode[] { De
bugMode.Program, DebugMode.Project, DebugMode.URL }); | |
132 } | |
133 } | |
134 | |
135 public class BuildActionConverter : EnumConverter | |
136 { | |
137 | |
138 public BuildActionConverter() | |
139 : base(typeof(BuildAction)) | |
140 { | |
141 | |
142 } | |
143 | |
144 public override bool CanConvertFrom(ITypeDescriptorContext conte
xt, Type sourceType) | |
145 { | |
146 if(sourceType == typeof(string)) return true; | |
147 | |
148 return base.CanConvertFrom(context, sourceType); | |
149 } | |
150 | |
151 public override object ConvertFrom(ITypeDescriptorContext contex
t, CultureInfo culture, object value) | |
152 { | |
153 string str = value as string; | |
154 | |
155 if(str != null) | |
156 { | |
157 if(str == SR.GetString(SR.Compile, culture)) ret
urn BuildAction.Compile; | |
158 | |
159 if(str == SR.GetString(SR.Content, culture)) ret
urn BuildAction.Content; | |
160 | |
161 if(str == SR.GetString(SR.EmbeddedResource, cult
ure)) return BuildAction.EmbeddedResource; | |
162 | |
163 if(str == SR.GetString(SR.None, culture)) return
BuildAction.None; | |
164 } | |
165 | |
166 return base.ConvertFrom(context, culture, value); | |
167 } | |
168 | |
169 public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType) | |
170 { | |
171 if(destinationType == typeof(string)) | |
172 { | |
173 string result = null; | |
174 | |
175 // In some cases if multiple nodes are selected
the windows form engine | |
176 // calls us with a null value if the selected no
de's property values are not equal | |
177 // Example of windows form engine passing us nul
l: File set to Compile, Another file set to None, bot nodes are selected, and th
e build action combo is clicked. | |
178 if(value != null) | |
179 { | |
180 result = SR.GetString(((BuildAction)valu
e).ToString(), culture); | |
181 } | |
182 else | |
183 { | |
184 result = SR.GetString(BuildAction.None.T
oString(), culture); | |
185 } | |
186 | |
187 if(result != null) return result; | |
188 } | |
189 | |
190 return base.ConvertTo(context, culture, value, destinati
onType); | |
191 } | |
192 | |
193 public override bool GetStandardValuesSupported(System.Component
Model.ITypeDescriptorContext context) | |
194 { | |
195 return true; | |
196 } | |
197 | |
198 public override System.ComponentModel.TypeConverter.StandardValu
esCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext cont
ext) | |
199 { | |
200 return new StandardValuesCollection(new BuildAction[] {
BuildAction.Compile, BuildAction.Content, BuildAction.EmbeddedResource, BuildAct
ion.None }); | |
201 } | |
202 } | |
203 | |
204 | |
205 | |
206 public class PlatformTypeConverter : EnumConverter | |
207 { | |
208 | |
209 public PlatformTypeConverter() | |
210 : base(typeof(PlatformType)) | |
211 { | |
212 } | |
213 | |
214 public override bool CanConvertFrom(ITypeDescriptorContext conte
xt, Type sourceType) | |
215 { | |
216 if(sourceType == typeof(string)) return true; | |
217 | |
218 return base.CanConvertFrom(context, sourceType); | |
219 } | |
220 | |
221 public override object ConvertFrom(ITypeDescriptorContext contex
t, CultureInfo culture, object value) | |
222 { | |
223 string str = value as string; | |
224 | |
225 if(str != null) | |
226 { | |
227 if(str == SR.GetString(SR.v1, culture)) return P
latformType.v1; | |
228 | |
229 if(str == SR.GetString(SR.v11, culture)) return
PlatformType.v11; | |
230 | |
231 if(str == SR.GetString(SR.v2, culture)) return P
latformType.v2; | |
232 | |
233 if(str == SR.GetString(SR.cli1, culture)) return
PlatformType.cli1; | |
234 } | |
235 | |
236 return base.ConvertFrom(context, culture, value); | |
237 } | |
238 | |
239 public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType) | |
240 { | |
241 if(destinationType == typeof(string)) | |
242 { | |
243 string result = null; | |
244 // In some cases if multiple nodes are selected
the windows form engine | |
245 // calls us with a null value if the selected no
de's property values are not equal | |
246 if(value != null) | |
247 { | |
248 result = SR.GetString(((PlatformType)val
ue).ToString(), culture); | |
249 } | |
250 else | |
251 { | |
252 result = SR.GetString(PlatformType.notSp
ecified.ToString(), culture); | |
253 } | |
254 | |
255 if(result != null) return result; | |
256 } | |
257 | |
258 return base.ConvertTo(context, culture, value, destinati
onType); | |
259 } | |
260 | |
261 public override bool GetStandardValuesSupported(System.Component
Model.ITypeDescriptorContext context) | |
262 { | |
263 return true; | |
264 } | |
265 | |
266 public override System.ComponentModel.TypeConverter.StandardValu
esCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext cont
ext) | |
267 { | |
268 return new StandardValuesCollection(new PlatformType[] {
PlatformType.v1, PlatformType.v11, PlatformType.v2, PlatformType.cli1 }); | |
269 } | |
270 } | |
271 } | |
OLD | NEW |