[NUI]Refactor Components (#1152)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Attributes / ImageControlStyle.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 using System.Collections.Generic;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// ImageControlStyle is a class which saves Button's ux data.
26     /// </summary>
27     /// <since_tizen> 6 </since_tizen>
28     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class ImageControlStyle : ControlStyle
31     {
32         /// <summary>
33         /// Creates a new instance of a ImageControlStyle.
34         /// </summary>
35         /// <since_tizen> 6 </since_tizen>
36         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
37         [EditorBrowsable(EditorBrowsableState.Never)]
38         public ImageControlStyle() : base()
39         {
40             InitSubStyle();
41         }
42         /// <summary>
43         /// Creates a new instance of a ImageControlStyle with style.
44         /// </summary>
45         /// <param name="style">Create ImageControlStyle by style customized by user.</param>
46         /// <since_tizen> 6 </since_tizen>
47         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
48         [EditorBrowsable(EditorBrowsableState.Never)]
49         public ImageControlStyle(ImageControlStyle style) : base(style)
50         {
51             if(style == null)
52             {
53                 return;
54             }
55
56             InitSubStyle();
57
58             Image.CopyFrom(style.Image);
59         }
60
61         /// <summary>
62         /// Image's Style.
63         /// </summary>
64         /// <since_tizen> 6 </since_tizen>
65         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public ImageViewStyle Image
68         {
69             get;
70             set;
71         }
72
73         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
74         [EditorBrowsable(EditorBrowsableState.Never)]
75         public override void CopyFrom(BindableObject bindableObject)
76         {
77             base.CopyFrom(bindableObject);
78
79             ImageControlStyle imageControlStyle = bindableObject as ImageControlStyle;
80
81             if (null != imageControlStyle)
82             {
83                 if (null != imageControlStyle.Image)
84                 {
85                     Image.CopyFrom(imageControlStyle.Image);
86                 }
87             }
88         }
89
90         private void InitSubStyle()
91         {
92             Image = new ImageViewStyle();
93             Image.PropertyChanged += SubStyleCalledEvent;
94         }
95
96         private void SubStyleCalledEvent(object sender, global::System.EventArgs e)
97         {
98             OnPropertyChanged();
99         }
100     }
101 }