@@ -186,4 +186,124 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
186
186
throw new NotImplementedException ( ) ;
187
187
}
188
188
}
189
+
190
+ sealed class ZoomToTextFormattingModeConverter : IMultiValueConverter
191
+ {
192
+ public static readonly ZoomToTextFormattingModeConverter Instance = new ZoomToTextFormattingModeConverter ( ) ;
193
+
194
+ public object Convert ( object [ ] value , Type targetType , object parameter , System . Globalization . CultureInfo culture )
195
+ {
196
+ var zoom = value [ 0 ] != null ? ( double ) value [ 0 ] : 1.0 ;
197
+ var antialiasing = value [ 1 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 1 ] : true ;
198
+ var hinting = value [ 2 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 2 ] : true ;
199
+
200
+ if ( antialiasing )
201
+ {
202
+ if ( hinting )
203
+ {
204
+ if ( zoom == 1.0 )
205
+ {
206
+ return TextFormattingMode . Display ;
207
+ }
208
+ else
209
+ {
210
+ return TextFormattingMode . Ideal ;
211
+ }
212
+ }
213
+ else
214
+ {
215
+ return TextFormattingMode . Ideal ;
216
+ }
217
+ }
218
+ else
219
+ {
220
+ return TextFormattingMode . Display ;
221
+ }
222
+ }
223
+
224
+ public object [ ] ConvertBack ( object value , Type [ ] targetType , object parameter , System . Globalization . CultureInfo culture )
225
+ {
226
+ throw new NotImplementedException ( ) ;
227
+ }
228
+ }
229
+
230
+ sealed class ZoomToTextRenderingModeConverter : IMultiValueConverter
231
+ {
232
+ public static readonly ZoomToTextRenderingModeConverter Instance = new ZoomToTextRenderingModeConverter ( ) ;
233
+
234
+ public object Convert ( object [ ] value , Type targetType , object parameter , System . Globalization . CultureInfo culture )
235
+ {
236
+ var zoom = value [ 0 ] != null ? ( double ) value [ 0 ] : 1.0 ;
237
+ var antialiasing = value [ 1 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 1 ] : true ;
238
+ var hinting = value [ 2 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 2 ] : true ;
239
+
240
+ if ( antialiasing )
241
+ {
242
+ if ( hinting )
243
+ {
244
+ if ( zoom == 1.0 )
245
+ {
246
+ return TextRenderingMode . ClearType ;
247
+ }
248
+ else
249
+ {
250
+ return TextRenderingMode . Grayscale ;
251
+ }
252
+ }
253
+ else
254
+ {
255
+ return TextRenderingMode . Grayscale ;
256
+ }
257
+ }
258
+ else
259
+ {
260
+ return TextRenderingMode . Aliased ;
261
+ }
262
+ }
263
+
264
+ public object [ ] ConvertBack ( object value , Type [ ] targetType , object parameter , System . Globalization . CultureInfo culture )
265
+ {
266
+ throw new NotImplementedException ( ) ;
267
+ }
268
+ }
269
+
270
+ sealed class ZoomToTextHintingModeConverter : IMultiValueConverter
271
+ {
272
+ public static readonly ZoomToTextHintingModeConverter Instance = new ZoomToTextHintingModeConverter ( ) ;
273
+
274
+ public object Convert ( object [ ] value , Type targetType , object parameter , System . Globalization . CultureInfo culture )
275
+ {
276
+ var zoom = value [ 0 ] != null ? ( double ) value [ 0 ] : 1.0 ;
277
+ var antialiasing = value [ 1 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 1 ] : true ;
278
+ var hinting = value [ 2 ] != DependencyProperty . UnsetValue ? ( bool ) value [ 2 ] : true ;
279
+
280
+ if ( antialiasing )
281
+ {
282
+ if ( hinting )
283
+ {
284
+ if ( zoom == 1.0 )
285
+ {
286
+ return TextHintingMode . Fixed ;
287
+ }
288
+ else
289
+ {
290
+ return TextHintingMode . Fixed ;
291
+ }
292
+ }
293
+ else
294
+ {
295
+ return TextHintingMode . Animated ;
296
+ }
297
+ }
298
+ else
299
+ {
300
+ return TextHintingMode . Fixed ;
301
+ }
302
+ }
303
+
304
+ public object [ ] ConvertBack ( object value , Type [ ] targetType , object parameter , System . Globalization . CultureInfo culture )
305
+ {
306
+ throw new NotImplementedException ( ) ;
307
+ }
308
+ }
189
309
}
0 commit comments