Modify documentation of APIs
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Marker.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 ElmSharp;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Marker map object
24     /// </summary>
25     public class Marker : MapObject, IDisposable
26     {
27         internal Interop.MarkerHandle handle;
28
29         internal Marker(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type)
30         {
31             var err = Interop.ErrorCode.InvalidParameter;
32             if (coordinates == null || imagePath == null)
33             {
34                 err.ThrowIfFailed("given coordinates or imagePath is null");
35             }
36             handle = new Interop.MarkerHandle(coordinates.handle, imagePath, type);
37         }
38
39         /// <summary>
40         /// Gets or sets clicked event handlers.
41         /// </summary>
42         public event EventHandler Clicked;
43
44         /// <summary>
45         /// Gets or sets marker's visibility.
46         /// </summary>
47         public override bool IsVisible
48         {
49             get
50             {
51                 return handle.IsVisible;
52             }
53             set
54             {
55                 handle.IsVisible = value;
56             }
57         }
58
59         /// <summary>
60         /// Gets or sets geographical coordinates for this marker.
61         /// </summary>
62         public Geocoordinates Coordinates
63         {
64             get
65             {
66                 return new Geocoordinates(handle.Coordinates);
67             }
68             set
69             {
70                 handle.Coordinates = value.handle;
71
72                 // Marker takes ownership of the native handle.
73                 value.handle.HasOwnership = false;
74             }
75         }
76
77         /// <summary>
78         /// Gets or sets a string representing image file path for this marker.
79         /// </summary>
80         public string ImagePath
81         {
82             get
83             {
84                 return handle.ImageFile;
85             }
86             set
87             {
88                 handle.ImageFile = value;
89             }
90         }
91
92         /// <summary>
93         /// Gets or sets screen size for this marker.
94         /// </summary>
95         public Size MarkerSize
96         {
97             get
98             {
99                 return handle.MarkerSize;
100             }
101             set
102             {
103                 handle.MarkerSize = value;
104             }
105         }
106
107         /// <summary>
108         /// Gets or sets z-order for this marker.
109         /// </summary>
110         /// <value>The integer value is 0 in default, and must be in range of from -100 to 100.</value>
111         public int ZOrder
112         {
113             get
114             {
115                 return handle.ZOrder;
116             }
117             set
118             {
119                 handle.ZOrder = value;
120             }
121         }
122
123         /// <summary>
124         /// Changes marker size.
125         /// </summary>
126         /// <param name="newSize">New size</param>
127         public void Resize(Size newSize)
128         {
129             MarkerSize = newSize;
130         }
131
132         /// <summary>
133         /// Changes marker coordinates.
134         /// </summary>
135         /// <param name="newPosition">New position for marker</param>
136         public void Move(Geocoordinates newPosition)
137         {
138             Coordinates = newPosition;
139         }
140
141         internal override void HandleClickedEvent()
142         {
143             Clicked?.Invoke(this, EventArgs.Empty);
144         }
145
146         internal override void InvalidateMapObject()
147         {
148             handle = null;
149         }
150
151         internal override Interop.ViewObjectHandle GetHandle()
152         {
153             return handle;
154         }
155
156         #region IDisposable Support
157         private bool _disposedValue = false;
158
159         protected virtual void Dispose(bool disposing)
160         {
161             if (!_disposedValue)
162             {
163                 handle.Dispose();
164                 _disposedValue = true;
165             }
166         }
167
168         /// <summary>
169         /// Releases all resources used by this object.
170         /// </summary>
171         public void Dispose()
172         {
173             Dispose(true);
174             GC.SuppressFinalize(this);
175         }
176
177
178         #endregion
179     }
180
181     /// <summary>
182     /// Pin type marker map object
183     /// </summary>
184     public class Pin : Marker
185     {
186         private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png";
187
188         /// <summary>
189         /// Creates a Pin type marker.
190         /// </summary>
191         /// <param name="coordinates">Marker coordinates</param>
192         /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
193         public Pin(Geocoordinates coordinates)
194             : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin)
195         {
196         }
197
198         /// <summary>
199         /// Creates a Pin type marker.
200         /// </summary>
201         /// <param name="coordinates">Marker coordinates</param>
202         /// <param name="imagePath">Image file path for Marker</param>
203         /// <remark>
204         /// http://tizen.org/privilege/mediastorage is needed if the file path are relevant to media storage.
205         /// http://tizen.org/privilege/externalstorage is needed if the file path are relevant to external storage.
206         /// </remark>
207         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
208         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
209         /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
210         public Pin(Geocoordinates coordinates, string imagePath)
211             : base(coordinates, imagePath, Interop.ViewMarkerType.Pin)
212         {
213         }
214     }
215
216     /// <summary>
217     /// Sticker type marker map object
218     /// </summary>
219     public class Sticker : Marker
220     {
221         private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png";
222
223         /// <summary>
224         /// Creates a Sticker type marker.
225         /// </summary>
226         /// <param name="coordinates">Marker coordinates</param>
227         /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
228         public Sticker(Geocoordinates coordinates)
229             : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker)
230         {
231         }
232
233         /// <summary>
234         /// Creates a Sticker type marker.
235         /// </summary>
236         /// <param name="coordinates">Marker coordinates</param>
237         /// <param name="imagePath">Image file path for Marker</param>
238         /// <remark>
239         /// http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
240         /// http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
241         /// </remark>
242         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
243         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
244         /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
245         public Sticker(Geocoordinates coordinates, string imagePath)
246             : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker)
247         {
248         }
249     }
250 }