~ubuntu-branches/ubuntu/karmic/moon/karmic

« back to all changes in this revision

Viewing changes to class/Microsoft.SilverlightControls/Controls/Src/Common/TextDecorationCollectionConverter.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
Import upstream version 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright © Microsoft Corporation. 
 
2
// This source is subject to the Microsoft Source License for Silverlight Controls (March 2008 Release).
 
3
// Please see http://go.microsoft.com/fwlink/?LinkID=111693 for details.
 
4
// All other rights reserved. 
 
5
 
 
6
using System;
 
7
using System.ComponentModel; 
 
8
using System.Collections.Generic; 
 
9
using System.Windows.Controls;
 
10
 
 
11
namespace System.Windows
 
12
{
 
13
    /// <summary> 
 
14
    /// Converts instances of the String type to TextDecorationCollection
 
15
    /// instances.
 
16
    /// </summary> 
 
17
    public sealed partial class TextDecorationCollectionConverter : TypeConverter 
 
18
    {
 
19
        /// <summary> 
 
20
        /// TextDecorationCollection known values.
 
21
        /// </summary>
 
22
        private static Dictionary<string, TextDecorationCollection> KnownValues = 
 
23
            new Dictionary<string, TextDecorationCollection>(2, StringComparer.OrdinalIgnoreCase)
 
24
            {
 
25
                { string.Empty, null }, 
 
26
                { "Underline", TextDecorations.Underline } 
 
27
            };
 
28
 
 
29
        /// <summary>
 
30
        /// Initializes a new instance of the TextDecorationCollectionConverter
 
31
        /// class. 
 
32
        /// </summary>
 
33
        public TextDecorationCollectionConverter()
 
34
        { 
 
35
        } 
 
36
 
 
37
        /// <summary> 
 
38
        /// Returns a value that indicates whether this converter can convert an
 
39
        /// object of the given type to an instance of TextDecorationCollection.
 
40
        /// </summary> 
 
41
        /// <param name="sourceType">
 
42
        /// The type of the source that is being evaluated for conversion.
 
43
        /// </param> 
 
44
        /// <returns> 
 
45
        /// true if the converter can convert the provided type to an instance
 
46
        /// of TextDecorationCollection; otherwise, false. 
 
47
        /// </returns>
 
48
#if NET_2_1
 
49
        override
 
50
#endif
 
51
        public bool CanConvertFrom(Type sourceType)
 
52
        { 
 
53
            return TypeConverters.CanConvertFrom<TextDecorationCollection>(sourceType);
 
54
        }
 
55
 
 
56
        /// <summary> 
 
57
        /// Attempts to convert a specified object to an instance of
 
58
        /// TextDecorationCollection. 
 
59
        /// </summary>
 
60
        /// <param name="value">The object being converted.</param>
 
61
        /// <returns> 
 
62
        /// The instance of TextDecorationCollection created from the converted
 
63
        /// object.
 
64
        /// </returns> 
 
65
#if NET_2_1
 
66
        override
 
67
#endif
 
68
        public object ConvertFrom(object value) 
 
69
        {
 
70
            return TypeConverters.ConvertFrom<TextDecorationCollection>(this, value); 
 
71
        }
 
72
 
 
73
        /// <summary> 
 
74
        /// Attempts to convert a specified String to an instance of
 
75
        /// TextDecorationCollection.
 
76
        /// </summary> 
 
77
        /// <param name="text"> 
 
78
        /// The String to be converted into the TextDecorationCollection object.
 
79
        /// </param> 
 
80
        /// <returns>
 
81
        /// The instance of TextDecorationCollection created from the converted
 
82
        /// text. 
 
83
        /// </returns>
 
84
#if NET_2_1
 
85
        override
 
86
#endif
 
87
        public object ConvertFromString(string text)
 
88
        { 
 
89
            if (text == null) 
 
90
            {
 
91
                return null; 
 
92
            }
 
93
            return TypeConverters.ConvertFromString(text, KnownValues);
 
94
        } 
 
95
    }
 
96
}