[MediaContent] Fix description of Delete method (#866)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Xaml / src / public / XamlBinding / VectorTypeConverter.cs
1 using System;
2 using System.Linq;
3 using System.Reflection;
4 using System.Globalization;
5
6 using Tizen.NUI;
7 using System.ComponentModel;
8
9 namespace Tizen.NUI.XamlBinding
10 {
11     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
12     [EditorBrowsable(EditorBrowsableState.Never)]
13     public class Vector2TypeConverter : TypeConverter
14     {
15         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
16         [EditorBrowsable(EditorBrowsableState.Never)]
17         public override object ConvertFromInvariantString(string value)
18         {
19             if (value != null)
20             {
21                 string[] parts = value.Split(',');
22                 if (parts.Length == 2 )
23                 {
24                     return new Vector2(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
25                                        Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
26                 }
27             }
28
29             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector2)}");
30         }
31     }
32
33     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
34     [EditorBrowsable(EditorBrowsableState.Never)]
35     public class Vector3TypeConverter : TypeConverter
36     {
37         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public override object ConvertFromInvariantString(string value)
40         {
41             if (value != null)
42             {
43                 string[] parts = value.Split(',');
44                 if (parts.Length == 3 )
45                 {
46                     return new Vector3(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
47                                        Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
48                                        Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
49                 }
50             }
51
52             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector3)}");
53         }
54     }
55
56     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
57     [EditorBrowsable(EditorBrowsableState.Never)]
58     public class Vector4TypeConverter : TypeConverter
59     {
60         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         public override object ConvertFromInvariantString(string value)
63         {
64             if (value != null)
65             {
66                 string[] parts = value.Split(',');
67                 if (parts.Length == 4 )
68                 {
69                     return new Vector4(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
70                                        Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
71                                        Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture),
72                                        Single.Parse(parts[3].Trim(), CultureInfo.InvariantCulture));
73                 }
74             }
75
76             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector4)}");
77         }
78     }
79
80     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
81     [EditorBrowsable(EditorBrowsableState.Never)]
82     public class RelativeVector2TypeConverter : TypeConverter
83     {
84         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
85         [EditorBrowsable(EditorBrowsableState.Never)]
86         public override object ConvertFromInvariantString(string value)
87         {
88             if (value != null)
89             {
90                 string[] parts = value.Split(',');
91                 if (parts.Length == 2 )
92                 {
93                     return new RelativeVector2(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
94                                                Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
95                 }
96             }
97
98             throw new InvalidOperationException("Cannot convert \"{value}\" into {typeof(RelativeVector2)}");
99         }
100     }
101
102     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
103     [EditorBrowsable(EditorBrowsableState.Never)]
104     public class RelativeVector3TypeConverter : TypeConverter
105     {
106         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public override object ConvertFromInvariantString(string value)
109         {
110             if (value != null)
111             {
112                 string[] parts = value.Split(',');
113                 if (parts.Length == 3 )
114                 {
115                     return new RelativeVector3(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
116                                                Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
117                                                Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
118                 }
119             }
120
121             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector3)}");
122         }
123     }
124
125     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
126     [EditorBrowsable(EditorBrowsableState.Never)]
127     public class RelativeVector4TypeConverter : TypeConverter
128     {
129         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
130         [EditorBrowsable(EditorBrowsableState.Never)]
131         public override object ConvertFromInvariantString(string value)
132         {
133             if (value != null)
134             {
135                 string[] parts = value.Split(',');
136                 if (parts.Length == 4 )
137                 {
138                     return new RelativeVector4(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
139                                                Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
140                                                Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture),
141                                                Single.Parse(parts[3].Trim(), CultureInfo.InvariantCulture));
142                 }
143             }
144
145             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector4)}");
146         }
147     }
148 }