Merge "[Usb] Fix crashes while disposing"
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / MoreOptionItem.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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;
18 using System.Collections.Generic;
19 using System.Text;
20
21 namespace ElmSharp.Wearable
22 {
23     /// <summary>
24     /// The MoreOptionItem is a item of MoreOption widget.
25     /// </summary>
26     public class MoreOptionItem
27     {
28         const string MainTextPartName = "selector,main_text";
29         const string SubTextPartName = "selector,sub_text";
30         const string IconPartName = "item,icon";
31
32         string _mainText;
33         string _subText;
34         Image _icon;
35         IntPtr _handle;
36
37         /// <summary>
38         /// Sets or gets the more option item handle.
39         /// </summary>
40         public IntPtr Handle
41         {
42             get
43             {
44                 return _handle;
45             }
46             set
47             {
48                 if (_handle == value) return;
49                 _handle = value;
50                 if (_mainText != null)
51                     Interop.Eext.eext_more_option_item_part_text_set(Handle, MainTextPartName, _mainText);
52                 if (_subText != null)
53                     Interop.Eext.eext_more_option_item_part_text_set(Handle, SubTextPartName, _subText);
54                 if (_icon != null)
55                     Interop.Eext.eext_more_option_item_part_content_set(Handle, IconPartName, _icon);
56             }
57         }
58
59         /// <summary>
60         /// Creates and initializes a new instance of MoreOptionItem class.
61         /// </summary>
62         public MoreOptionItem()
63         {
64             _icon = null;
65         }
66
67         /// <summary>
68         /// Sets or gets the main text of a more option object.
69         /// </summary>
70         public string MainText
71         {
72             set
73             {
74                 if (_mainText == value) return;
75                 _mainText = value;
76                 if (Handle != IntPtr.Zero)
77                 {
78                     Interop.Eext.eext_more_option_item_part_text_set(Handle, MainTextPartName, _mainText);
79                 }
80             }
81
82             get
83             {
84                 return _mainText;
85             }
86         }
87
88         /// <summary>
89         /// Sets or gets the sub text of a more option object.
90         /// </summary>
91         public string SubText
92         {
93             set
94             {
95                 if (_subText == value) return;
96                 _subText = value;
97                 if (Handle != IntPtr.Zero)
98                 {
99                     Interop.Eext.eext_more_option_item_part_text_set(Handle, SubTextPartName, _subText);
100                 }
101             }
102
103             get
104             {
105                 return _subText;
106             }
107         }
108
109         /// <summary>
110         /// Sets or gets the icon image
111         /// </summary>
112         public Image Icon
113         {
114             set
115             {
116                 if (_icon == value) return;
117                 _icon = value;
118                 if (Handle != IntPtr.Zero)
119                 {
120                     Interop.Eext.eext_more_option_item_part_content_set(Handle, IconPartName, _icon);
121                 }
122             }
123             get
124             {
125                 return _icon;
126             }
127         }
128     }
129 }