Fix warnings that there is an unused value
[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     public class Overlay : MapObject, IDisposable
26     {
27         internal Interop.OverlayHandle handle;
28
29         /// <summary>
30         /// Creates normal overlay map object
31         /// </summary>
32         /// <param name="coordinates"></param>
33         /// <param name="objectToContain"></param>
34         public Overlay(Geocoordinates coordinates, EvasObject objectToContain) : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal)
35         {
36         }
37
38         internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type)
39         {
40             var err = Interop.ErrorCode.InvalidParameter;
41             if (coordinates == null || objectToContain == null)
42             {
43                 err.ThrowIfFailed("given coordinates or parent evas object is null");
44             }
45             handle = new Interop.OverlayHandle(coordinates.handle, objectToContain, Interop.ViewOverlayType.Normal);
46         }
47
48         public override bool IsVisible
49         {
50             get { return handle.IsVisible; }
51             set { handle.IsVisible = value; }
52         }
53
54         /// <summary>
55         /// Geographical coordinates for overlay
56         /// </summary>
57         public Geocoordinates Coordinates
58         {
59             get
60             {
61                 return new Geocoordinates(handle.Coordinates);
62             }
63             set
64             {
65                 // Overlay takes ownership of the native handle.
66                 handle.Coordinates = value.handle;
67                 value.handle.HasOwnership = false;
68             }
69         }
70
71         /// <summary>
72         /// Minimum zoom level for overlay
73         /// </summary>
74         public int MinimumZoomLevel
75         {
76             get
77             {
78                 return handle.MinZoomLevel;
79             }
80             set
81             {
82                 handle.MinZoomLevel = value;
83             }
84         }
85
86         /// <summary>
87         /// Maximum zoom lever for overlay
88         /// </summary>
89         public int MaximumZoomLevel
90         {
91             get
92             {
93                 return handle.MaxZoomLevel;
94             }
95             set
96             {
97                 handle.MaxZoomLevel = value;
98             }
99         }
100
101         // Overlay object does not support click events
102         internal override void HandleClickedEvent()
103         {
104             throw new NotSupportedException("Overlay object does not support click events");
105         }
106
107         internal override void InvalidateMapObject()
108         {
109             handle = null;
110         }
111
112         internal override Interop.ViewObjectHandle GetHandle()
113         {
114             return handle;
115         }
116
117         #region IDisposable Support
118         private bool _disposedValue = false;
119
120         protected virtual void Dispose(bool disposing)
121         {
122             if (!_disposedValue)
123             {
124                 handle.Dispose();
125                 _disposedValue = true;
126             }
127         }
128
129         public void Dispose()
130         {
131             Dispose(true);
132             GC.SuppressFinalize(this);
133         }
134         #endregion
135     }
136
137     /// <summary>
138     /// Bubble overlay map object
139     /// </summary>
140     public class BubbleOverlay : Overlay
141     {
142         public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble)
143         {
144         }
145     }
146
147     /// <summary>
148     /// Box Overlay map object
149     /// </summary>
150     public class BoxOverlay : Overlay
151     {
152         /// <summary>
153         /// Creates Box overlay
154         /// </summary>
155         public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Box)
156         {
157         }
158     }
159 }