Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Interop / Interop.View.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 System.Runtime.InteropServices;
19 using ElmSharp;
20
21 internal static partial class Interop
22 {
23     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_type")]
24     internal static extern ErrorCode GetType(this MarkerHandle /* maps_view_object_h */ marker, out ViewMarkerType /* maps_view_marker_type_e */ type);
25
26     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_coordinates")]
27     internal static extern ErrorCode GetCoordinates(this MarkerHandle /* maps_view_object_h */ marker, out IntPtr /* maps_coordinates_h */ coordinates);
28
29     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_coordinates")]
30     internal static extern ErrorCode SetCoordinates(this MarkerHandle /* maps_view_object_h */ marker, CoordinatesHandle /* maps_coordinates_h */ coordinates);
31
32     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_image_file")]
33     internal static extern ErrorCode GetImageFile(this MarkerHandle /* maps_view_object_h */ marker, out string filePath);
34
35     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_image_file")]
36     internal static extern ErrorCode SetImageFile(this MarkerHandle /* maps_view_object_h */ marker, string filePath);
37
38     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_z_order")]
39     internal static extern ErrorCode GetZOrder(this MarkerHandle /* maps_view_object_h */ marker, out int zOrder);
40
41     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_z_order")]
42     internal static extern ErrorCode SetZOrder(this MarkerHandle /* maps_view_object_h */ marker, int zOrder);
43
44     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_size")]
45     internal static extern ErrorCode GetSize(this MarkerHandle /* maps_view_object_h */ marker, out int width, out int height);
46
47     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_resize")]
48     internal static extern ErrorCode Resize(this MarkerHandle /* maps_view_object_h */ marker, int width, int height);
49
50     internal static ErrorCode GetSize(this MarkerHandle /* maps_view_object_h */ marker, out Size size)
51     {
52         size = new Size(0, 0);
53         return GetSize(marker, out size.Width, out size.Height);
54     }
55
56     internal static ErrorCode SetSize(this MarkerHandle /* maps_view_object_h */ marker, Size size)
57     {
58         return Resize(marker, size.Width, size.Height);
59     }
60
61     internal class MarkerHandle : ViewObjectHandle
62     {
63         [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_marker")]
64         internal static extern ErrorCode CreateMarker(CoordinatesHandle /* maps_coordinates_h */ coordinates, string imageFilePath, ViewMarkerType /* maps_view_marker_type_e */ type, out IntPtr /* maps_view_object_h */ marker);
65
66         internal ViewMarkerType Type
67         {
68             get { return NativeGet<ViewMarkerType>(this.GetType); }
69         }
70
71         internal string ImageFile
72         {
73             get { return NativeGet(this.GetImageFile); }
74             set { NativeSet(this.SetImageFile, value); }
75         }
76
77         internal int ZOrder
78         {
79             get { return NativeGet<int>(this.GetZOrder); }
80             set { NativeSet(this.SetZOrder, value); }
81         }
82
83         internal Size MarkerSize
84         {
85             get { return NativeGet<Size>(this.GetSize); }
86             set { NativeSet(this.SetSize, value); }
87         }
88
89         internal CoordinatesHandle Coordinates
90         {
91             get { return NativeGet(this.GetCoordinates, CoordinatesHandle.Create); }
92             set { NativeSet(this.SetCoordinates, value); }
93         }
94
95         internal MarkerHandle(CoordinatesHandle coordinates, string imagePath, ViewMarkerType type) : base(IntPtr.Zero, true)
96         {
97             var clonedCoordinatesHandle = CoordinatesHandle.CloneFrom(coordinates);
98             CreateMarker(clonedCoordinatesHandle, imagePath, type, out handle).ThrowIfFailed("Failed to create native handle for marker");
99             clonedCoordinatesHandle.HasOwnership = false;
100         }
101     }
102 }