Merge "fix: Operation parameters, SharedMemory struct"
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Overlay.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 EvasObject = ElmSharp.EvasObject;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Overlay map object.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class Overlay : MapObject, IDisposable
27     {
28         internal Interop.OverlayHandle handle;
29
30         /// <summary>
31         /// Creates a normal overlay map object.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         /// <param name="coordinates"></param>
35         /// <param name="objectToContain"></param>
36         /// <exception cref="ArgumentException">Thrown when the input coordinates or objectToContain are invalid.</exception>
37         public Overlay(Geocoordinates coordinates, EvasObject objectToContain)
38             : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal)
39         {
40         }
41
42         internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type)
43         {
44             var err = Interop.ErrorCode.InvalidParameter;
45             if (coordinates == null || objectToContain == null)
46             {
47                 err.ThrowIfFailed("given coordinates or parent evas object is null");
48             }
49             handle = new Interop.OverlayHandle(coordinates.handle, objectToContain, type);
50         }
51
52         /// <summary>
53         /// Gets or sets the visibility of an overlay map object.
54         /// </summary>
55         /// <since_tizen> 3 </since_tizen>
56         public override bool IsVisible
57         {
58             get { return handle.IsVisible; }
59             set { handle.IsVisible = value; }
60         }
61
62         /// <summary>
63         /// Gets or sets geographical coordinates for an overlay map object.
64         /// </summary>
65         /// <since_tizen> 3 </since_tizen>
66         public Geocoordinates Coordinates
67         {
68             get
69             {
70                 return new Geocoordinates(handle.Coordinates);
71             }
72             set
73             {
74                 // Overlay takes ownership of the native handle.
75                 handle.Coordinates = value.handle;
76                 value.handle.HasOwnership = false;
77             }
78         }
79
80         /// <summary>
81         /// Gets or sets minimum zoom level for an overlay map object.
82         /// </summary>
83         /// <since_tizen> 3 </since_tizen>
84         public int MinimumZoomLevel
85         {
86             get
87             {
88                 return handle.MinZoomLevel;
89             }
90             set
91             {
92                 handle.MinZoomLevel = value;
93             }
94         }
95
96         /// <summary>
97         /// Gets or sets maximum zoom lever for an overlay map object.
98         /// </summary>
99         /// <since_tizen> 3 </since_tizen>
100         public int MaximumZoomLevel
101         {
102             get
103             {
104                 return handle.MaxZoomLevel;
105             }
106             set
107             {
108                 handle.MaxZoomLevel = value;
109             }
110         }
111
112         // Overlay object does not support click events
113         internal override void HandleClickedEvent()
114         {
115             throw new NotSupportedException("Overlay object does not support click events");
116         }
117
118         internal override void InvalidateMapObject()
119         {
120             handle = null;
121         }
122
123         internal override Interop.ViewObjectHandle GetHandle()
124         {
125             return handle;
126         }
127
128         #region IDisposable Support
129         private bool _disposedValue = false;
130
131         /// <summary>
132         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
133         /// </summary>
134         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
135         protected virtual void Dispose(bool disposing)
136         {
137             if (!_disposedValue)
138             {
139                 handle.Dispose();
140                 _disposedValue = true;
141             }
142         }
143
144         /// <summary>
145         /// Releases all the resources used by this object.
146         /// </summary>
147         /// <since_tizen> 3 </since_tizen>
148         public void Dispose()
149         {
150             Dispose(true);
151             GC.SuppressFinalize(this);
152         }
153         #endregion
154     }
155
156     /// <summary>
157     /// The bubble overlay map object.
158     /// </summary>
159     /// <since_tizen> 3 </since_tizen>
160     public class BubbleOverlay : Overlay
161     {
162         /// <summary>
163         /// Creates a bubble overlay.
164         /// </summary>
165         /// <since_tizen> 3 </since_tizen>
166         /// <param name="coordinates">The geographical coordinates to be pointed.</param>
167         /// <param name="objectToContain">The EvasObject to be shown.</param>
168         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
169         /// <exception cref="ArgumentException">Thrown when the input coordinates or objectToContain are invalid.</exception>
170         public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain)
171             : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble)
172         {
173         }
174     }
175
176     /// <summary>
177     /// The box overlay map object.
178     /// </summary>
179     /// <since_tizen> 3 </since_tizen>
180     public class BoxOverlay : Overlay
181     {
182         /// <summary>
183         /// Creates a box overlay.
184         /// </summary>
185         /// <since_tizen> 3 </since_tizen>
186         /// <param name="coordinates">The geographical coordinates to be pointed.</param>
187         /// <param name="objectToContain">The EvasObject to be shown.</param>
188         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
189         /// <exception cref="ArgumentException">Thrown when the input coordinates or objectToContain are invalid</exception>
190         public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain)
191             : base(coordinates, objectToContain, Interop.ViewOverlayType.Box)
192         {
193         }
194     }
195 }