[NUI] Adjust directory (#903)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / XamlBinding / SizeTypeConverter.cs
1 using System;
2 using System.Linq;
3 using System.Reflection;
4 using System.Globalization;
5
6 using Tizen.NUI;
7 using Tizen.NUI.Xaml;
8 using System.ComponentModel;
9
10 namespace Tizen.NUI.Binding
11 {
12     /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
13     [EditorBrowsable(EditorBrowsableState.Never)]
14     [ProvideCompiledAttribute("Tizen.NUI.Xaml.Core.XamlC.Size2DTypeConverter")]
15     public class SizeTypeConverter : TypeConverter
16     {
17         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
18         [EditorBrowsable(EditorBrowsableState.Never)]
19         public override object ConvertFromInvariantString(string value)
20         {
21             if (value != null)
22             {
23                 string[] parts = value.Split(',');
24                 if (parts.Length == 3)
25                 {
26                     int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
27                     int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
28                     int z = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[2].Trim());
29                     return new Size(x, y, z);
30                 }
31             }
32
33             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Size)}");
34         }
35     }
36
37     /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
38     [EditorBrowsable(EditorBrowsableState.Never)]
39     [ProvideCompiledAttribute("Tizen.NUI.Xaml.Core.XamlC.Size2DTypeConverter")]
40     public class Size2DTypeConverter : TypeConverter
41     {
42         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         public override object ConvertFromInvariantString(string value)
45         {
46             if (value != null)
47             {
48                 string[] parts = value.Split(',');
49                 if (parts.Length == 2)
50                 {
51                     int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
52                     int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
53                     return new Size2D(x, y);
54                 }
55             }
56
57             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Size2D)}");
58         }
59     }
60 }