[NUI] Fixing the emtpy finalizers(CA1821)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / GraphicsTypeManager.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22
23     /// <summary>
24     /// GraphicsTypeManager class to manage various types.
25     /// </summary>
26     /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class GraphicsTypeManager
29     {
30
31         /// <summary>
32         /// Creates private GraphicsTypeManager object.
33         /// </summary>
34         private GraphicsTypeManager()
35         {
36             _typeConverter = new GraphicsTypeConverter();
37         }
38
39         /// <summary>
40         /// An unique Singleton Instance of GraphicsTypeManager
41         /// </summary>
42         /// <value>Singleton instance of GraphicsTypeManager</value>
43         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
44         [EditorBrowsable(EditorBrowsableState.Never)]
45         public static GraphicsTypeManager Instance
46         {
47             get
48             {
49                 if (_graphicsTypeManager == null)
50                 {
51                     _graphicsTypeManager = new GraphicsTypeManager();
52                 }
53
54                 return _graphicsTypeManager;
55             }
56
57         }
58
59         /// <summary>
60         /// Sets the custom GraphicsTypeConverter.
61         /// </summary>
62         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
63         [EditorBrowsable(EditorBrowsableState.Never)]
64         public void SetTypeConverter(GraphicsTypeConverter typeConverter)
65         {
66             _typeConverter = typeConverter;
67         }
68
69         /// <summary>
70         /// Converts script to px
71         /// </summary>
72         /// <returns>Pixel value that is converted from input string</returns>
73         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
74         [EditorBrowsable(EditorBrowsableState.Never)]
75         public float ConvertScriptToPixel(string scriptValue)
76         {
77             return _typeConverter.ConvertScriptToPixel(scriptValue);
78         }
79
80         /// <summary>
81         /// Converts other type to px
82         /// </summary>
83         /// <returns>Pixel value that is converted by the the display matric</returns>
84         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
85         [EditorBrowsable(EditorBrowsableState.Never)]
86         public virtual float ConvertToPixel(float value)
87         {
88             return _typeConverter.ConvertToPixel(value);
89         }
90
91         /// <summary>
92         /// Converts px to other type
93         /// </summary>
94         /// <returns>An converted value from pixel</returns>
95         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
96         [EditorBrowsable(EditorBrowsableState.Never)]
97         public virtual float ConvertFromPixel(float value)
98         {
99             return _typeConverter.ConvertFromPixel(value);
100         }
101
102         internal void RegisterCustomConverterForDynamicResourceBinding(global::System.Type type, Tizen.NUI.Binding.TypeConverter userConverter)
103         {
104             if (Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.ContainsKey(type) == false)
105             {
106                 Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Add(type, userConverter);
107             }
108             //NUILog.Error($"user custom converter ditionary count={Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Count}");
109         }
110
111         private volatile static GraphicsTypeManager _graphicsTypeManager;
112         private GraphicsTypeConverter _typeConverter;
113     }
114 }