200b84c8d7a8a692f96751909bb3fdd7bf9aad20
[platform/core/csapi/maps.git] / Tizen.Maps / Tizen.Maps / MapObject.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
20 namespace Tizen.Maps
21 {
22     public class MapObject
23     {
24         internal Interop.ViewObjectHandle handle;
25         private static Dictionary<IntPtr, MapObject> s_HandleToItemTable = new Dictionary<IntPtr, MapObject>();
26
27         internal MapObject(Interop.ViewObjectHandle nativeHandle)
28         {
29             handle = nativeHandle;
30         }
31
32
33         /// <summary>
34         /// Clicked event
35         /// </summary>
36         public event EventHandler Clicked;
37
38         /// <summary>
39         /// Map Object's visibility
40         /// </summary>
41         public bool IsVisible
42         {
43             get
44             {
45                 bool value;
46                 Interop.ViewObject.GetVisible(handle, out value);
47                 return value;
48             }
49             set
50             {
51                 Interop.ViewObject.SetVisible(handle, value);
52             }
53         }
54
55         internal void AddToMapObjectTable()
56         {
57             s_HandleToItemTable[handle] = this;
58         }
59
60         internal void RemoveFromMapObjectTable()
61         {
62             s_HandleToItemTable.Remove(handle);
63         }
64
65         internal static MapObject GetItemByHandle(IntPtr handle)
66         {
67             MapObject value;
68             s_HandleToItemTable.TryGetValue(handle, out value);
69             return value;
70         }
71
72         internal void HandleClickedEvent()
73         {
74             Clicked?.Invoke(this, EventArgs.Empty);
75         }
76     }
77 }