2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
20 internal static partial class Interop
22 internal class AreaHandle : SafeMapsHandle
24 [DllImport(Libraries.MapService, EntryPoint = "maps_area_create_rectangle")]
25 internal static extern ErrorCode CreateRectangle(IntPtr /* maps_coordinates_h */ topLeft, IntPtr /* maps_coordinates_h */ bottomRight, out IntPtr /* maps_area_h */ area);
27 [DllImport(Libraries.MapService, EntryPoint = "maps_area_create_circle")]
28 internal static extern ErrorCode CreateCircle(IntPtr /* maps_coordinates_h */ center, double radius, out IntPtr /* maps_area_h */ area);
30 [DllImport(Libraries.MapService, EntryPoint = "maps_area_destroy")]
31 internal static extern ErrorCode Destroy(IntPtr /* maps_area_h */ area);
33 [DllImport(Libraries.MapService, EntryPoint = "maps_area_clone")]
34 internal static extern ErrorCode Clone(IntPtr /* maps_area_h */ origin, out IntPtr /* maps_area_h */ cloned);
36 internal AreaHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
40 internal AreaHandle(CoordinatesHandle topLeft, CoordinatesHandle bottomRight) : this(IntPtr.Zero, true)
42 IntPtr _topLeft = (topLeft != null ? topLeft : IntPtr.Zero);
43 IntPtr _bottomRight = (bottomRight != null ? bottomRight : IntPtr.Zero);
44 CreateRectangle(_topLeft, _bottomRight, out handle).ThrowIfFailed("Failed to create native handle");
47 internal AreaHandle(CoordinatesHandle center, double radius) : this(IntPtr.Zero, true)
49 IntPtr _center = (center != null ? center : IntPtr.Zero);
50 CreateCircle(_center, radius, out handle).ThrowIfFailed("Failed to create native handle");
53 internal static AreaHandle CloneFrom(IntPtr nativeHandle)
56 Clone(nativeHandle, out handle).ThrowIfFailed("Failed to clone native handle");
57 return new AreaHandle(handle, true);
60 internal static AreaHandle Create(IntPtr nativeHandle)
62 return new AreaHandle(nativeHandle, true);