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.
19 using Layout = ElmSharp.Layout;
20 using EvasObject = ElmSharp.EvasObject;
21 using System.Collections.Generic;
26 /// Map View class to show a map on the screen.
28 /// <since_tizen> 3 </since_tizen>
29 public class MapView : Layout, IDisposable
31 internal Interop.ViewHandle handle;
32 private MapService _service;
34 private Dictionary<IntPtr, MapObject> _handleToObjectTable = new Dictionary<IntPtr, MapObject>();
36 private Interop.ViewOnEventCallback _gestureEventCallback;
37 private Interop.ViewOnEventCallback _objectEventCallback;
38 private Interop.ViewOnEventCallback _viewReadyEventCallback;
40 private event EventHandler<MapGestureEventArgs> _scrolledEventHandler;
41 private event EventHandler<MapGestureEventArgs> _twoFingerZoomedEventHandler;
42 private event EventHandler<MapGestureEventArgs> _clickedEventHandler;
43 private event EventHandler<MapGestureEventArgs> _doubleClickedEventHandler;
44 private event EventHandler<MapGestureEventArgs> _twoFingerClickedEventHandler;
45 private event EventHandler<MapGestureEventArgs> _twoFingerRotatedEventHandler;
46 private event EventHandler<MapGestureEventArgs> _longPressedEventHandler;
47 private event EventHandler _viewReadyEventHandler;
50 /// Creates a view and links it to the instance of a map service.
52 /// <since_tizen> 3 </since_tizen>
53 /// <param name="parent">An instance of <see cref="EvasObject"/> object for which a map view will be drawn.</param>
54 /// <param name="service">An instance of <see cref="MapService"/> object.</param>
55 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
56 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
57 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
58 /// <exception cref="System.ArgumentException">Thrown when parameters are invalid.</exception>
59 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory, and connect to the service.</exception>
60 public MapView(EvasObject parent, MapService service) : base(parent)
62 handle = new Interop.ViewHandle(service.handle, this);
63 service.handle.HasOwnership = false;
64 Log.Info(string.Format("MapView is created"));
69 // We need to keep Gesture Tap event enabled for object event to work
70 handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
71 SetObjectEventCallback();
75 /// Destroy the MapView object.
83 /// Adds or removes event handlers to deliver a scrolled gesture event.
85 /// <value>Event handlers to get a scrolled gesture event.</value>
86 /// <since_tizen> 3 </since_tizen>
87 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
88 public event EventHandler<MapGestureEventArgs> Scrolled
92 SetGestureEventCallback();
93 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, true);
94 _scrolledEventHandler += value;
95 Log.Info(string.Format("Scrolled event handler is added"));
99 _scrolledEventHandler -= value;
100 Log.Info(string.Format("Scrolled event handler is removed"));
101 if (_scrolledEventHandler == null)
103 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, false);
104 UnsetGestureEventCallback();
110 /// Adds or removes event handlers to deliver a zoomed gesture event.
112 /// <value>Event handlers to get a zoomed gesture event.</value>
113 /// <since_tizen> 3 </since_tizen>
114 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
115 public event EventHandler<MapGestureEventArgs> TwoFingerZoomed
119 SetGestureEventCallback();
120 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, true);
121 _twoFingerZoomedEventHandler += value;
122 Log.Info(string.Format("TwoFingerZoomed event handler is added"));
126 _twoFingerZoomedEventHandler -= value;
127 Log.Info(string.Format("TwoFingerZoomed event handler is removed"));
128 if (_twoFingerZoomedEventHandler == null)
130 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, false);
131 UnsetGestureEventCallback();
137 /// Adds or removes event handlers to deliver a clicked gesture event.
139 /// <value>Event handlers to get a clicked gesture event.</value>
140 /// <since_tizen> 3 </since_tizen>
141 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
142 public event EventHandler<MapGestureEventArgs> Clicked
146 SetGestureEventCallback();
147 //handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
148 _clickedEventHandler += value;
149 Log.Info(string.Format("Clicked event handler is added"));
153 _clickedEventHandler -= value;
154 Log.Info(string.Format("Clicked event handler is removed"));
155 if (_clickedEventHandler == null)
157 //handle.SetGestureEnabled(Interop.ViewGesture.Click, false);
158 UnsetGestureEventCallback();
164 /// Adds or removes event handlers to deliver a double-clicked gesture event.
166 /// <value>Event handlers to get a double-clicked gesture event.</value>
167 /// <since_tizen> 3 </since_tizen>
168 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
169 public event EventHandler<MapGestureEventArgs> DoubleClicked
173 SetGestureEventCallback();
174 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, true);
175 _doubleClickedEventHandler += value;
176 Log.Info(string.Format("DoubleClicked event handler is removed"));
180 _doubleClickedEventHandler -= value;
181 Log.Info(string.Format("DoubleClicked event handler is removed"));
182 if (_doubleClickedEventHandler == null)
184 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, false);
185 UnsetGestureEventCallback();
191 /// Adds or removes event handlers to deliver a clicked gesture event with two-fingers.
193 /// <value>Event handlers to get a clicked gesture event.</value>
194 /// <since_tizen> 3 </since_tizen>
195 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
196 public event EventHandler<MapGestureEventArgs> TwoFingerClicked
200 SetGestureEventCallback();
201 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, true);
202 _twoFingerClickedEventHandler += value;
203 Log.Info(string.Format("TwoFingerClicked event handler is added"));
207 _twoFingerClickedEventHandler -= value;
208 Log.Info(string.Format("TwoFingerClicked event handler is removed"));
209 if (_twoFingerClickedEventHandler == null)
211 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, false);
212 UnsetGestureEventCallback();
218 /// Adds or removes event handlers to deliver a rotated gesture event.
220 /// <value>Event handlers to get a rotated gesture event.</value>
221 /// <since_tizen> 3 </since_tizen>
222 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
223 public event EventHandler<MapGestureEventArgs> TwoFingerRotated
227 SetGestureEventCallback();
228 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, true);
229 _twoFingerRotatedEventHandler += value;
230 Log.Info(string.Format("Rotated event handler is added"));
234 _twoFingerRotatedEventHandler -= value;
235 Log.Info(string.Format("Rotated event handler is removed"));
236 if (_twoFingerRotatedEventHandler == null)
238 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, false);
239 UnsetGestureEventCallback();
246 /// Adds or removes event handlers to deliver a long-pressed gesture event.
248 /// <value>Event handlers to get a long-pressed gesture event.</value>
249 /// <since_tizen> 3 </since_tizen>
250 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
251 public event EventHandler<MapGestureEventArgs> LongPressed
255 SetGestureEventCallback();
256 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, true);
257 _longPressedEventHandler += value;
258 Log.Info(string.Format("LongPressed event handler is added"));
262 _longPressedEventHandler -= value;
263 Log.Info(string.Format("LongPressed event handler is removed"));
264 if (_longPressedEventHandler == null)
266 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, false);
267 UnsetGestureEventCallback();
273 /// Adds or removes event handlers to deliver an event representing a view ready to be used.
275 /// <value>Event handlers to get a view ready event.</value>
276 /// <since_tizen> 3 </since_tizen>
277 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
278 public event EventHandler ViewReady
282 SetViewReadyEventCallback();
283 _viewReadyEventHandler += value;
284 Log.Info(string.Format("ViewReady event handler is added"));
288 _viewReadyEventHandler -= value;
289 Log.Info(string.Format("ViewReady event handler is removed"));
290 UnsetGestureEventCallback();
295 /// Gets or sets the current zoom level.
297 /// <value>It is an integer value representing the current zoom level.</value>
298 /// <since_tizen> 3 </since_tizen>
299 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
300 /// <privilege>http://tizen.org/privilege/internet</privilege>
301 /// <privilege>http://tizen.org/privilege/network.get</privilege>
302 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
303 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
308 return handle.ZoomLevel;
312 Log.Info(string.Format("ZoomLevel is changed from {0} to {1}", handle.ZoomLevel, value));
313 handle.ZoomLevel = value;
318 /// Gets or sets the minimum zoom level.
320 /// <value>It is an integer value that limits minimal zoom level within a range of the current map plug-in support.</value>
321 /// <since_tizen> 3 </since_tizen>
322 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
323 /// <privilege>http://tizen.org/privilege/internet</privilege>
324 /// <privilege>http://tizen.org/privilege/network.get</privilege>
325 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
326 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
327 public int MinimumZoomLevel
331 return handle.MinimumZoomLevel;
335 Log.Info(string.Format("MinimumZoomLevel is changed from {0} to {1}", handle.MinimumZoomLevel, value));
336 handle.MinimumZoomLevel = value;
341 /// Gets or sets the maximum zoom level.
343 /// <value>It is an integer value that limits maximum zoom level within a range of the current map plug-in support.</value>
344 /// <since_tizen> 3 </since_tizen>
345 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
346 /// <privilege>http://tizen.org/privilege/internet</privilege>
347 /// <privilege>http://tizen.org/privilege/network.get</privilege>
348 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
349 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
350 public int MaximumZoomLevel
354 return handle.MaximumZoomLevel;
358 Log.Info(string.Format("MaximumZoomLevel is changed from {0} to {1}", handle.MaximumZoomLevel, value));
359 handle.MaximumZoomLevel = value;
364 /// Gets or sets the orientation on the map view.
366 /// <value>It is an integer value from 0 to 360 that indicates the orientation of the map view.</value>
367 /// <since_tizen> 3 </since_tizen>
368 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
369 /// <privilege>http://tizen.org/privilege/internet</privilege>
370 /// <privilege>http://tizen.org/privilege/network.get</privilege>
371 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
372 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
373 public double Orientation
377 return handle.Orientation;
381 Log.Info(string.Format("Orientation is changed from {0} to {1}", handle.Orientation, value));
382 handle.Orientation = value;
387 /// Gets or sets theme type of the map view.
389 /// <since_tizen> 3 </since_tizen>
390 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
391 /// <privilege>http://tizen.org/privilege/internet</privilege>
392 /// <privilege>http://tizen.org/privilege/network.get</privilege>
393 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
394 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
395 public MapTypes MapType
399 return (MapTypes)handle.MapType;
403 Log.Info(string.Format("MapType is changed from {0} to {1}", handle.MapType, value));
404 handle.MapType = (Interop.ViewType)value;
409 /// Indicates whether the map should show the 3D buildings layer.
411 /// <since_tizen> 3 </since_tizen>
412 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
413 /// <privilege>http://tizen.org/privilege/internet</privilege>
414 /// <privilege>http://tizen.org/privilege/network.get</privilege>
415 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
416 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
417 public bool BuildingsEnabled
421 return handle.BuildingsEnabled;
425 Log.Info(string.Format("Showing the 3D buildings is {0}", (value ? "enabled" : "disabled")));
426 handle.BuildingsEnabled = value;
431 /// Indicates whether the map should show the traffic layer.
433 /// <since_tizen> 3 </since_tizen>
434 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
435 /// <privilege>http://tizen.org/privilege/internet</privilege>
436 /// <privilege>http://tizen.org/privilege/network.get</privilege>
437 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
438 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
439 public bool TrafficEnabled
443 return handle.TrafficEnabled;
447 Log.Info(string.Format("Showing the traffic is {0}", (value ? "enabled" : "disabled")));
448 handle.TrafficEnabled = value;
453 /// Indicates whether the map should show the public transit layer.
455 /// <since_tizen> 3 </since_tizen>
456 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
457 /// <privilege>http://tizen.org/privilege/internet</privilege>
458 /// <privilege>http://tizen.org/privilege/network.get</privilege>
459 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
460 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
461 public bool PublicTransitEnabled
465 return handle.PublicTransitEnabled;
469 Log.Info(string.Format("Showing the public transit is {0}", (value ? "enabled" : "disabled")));
470 handle.PublicTransitEnabled = value;
475 /// Indicates whether the scale-bar is enabled or not.
477 /// <since_tizen> 4 </since_tizen>
478 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
479 /// <privilege>http://tizen.org/privilege/internet</privilege>
480 /// <privilege>http://tizen.org/privilege/network.get</privilege>
481 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
482 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
483 public bool ScaleBarEnabled
487 return handle.ScaleBarEnabled;
491 Log.Info(string.Format("Showing the scale-bar is {0}", (value ? "enabled" : "disabled")));
492 handle.ScaleBarEnabled = value;
497 /// Sets language of map view.
499 /// <value>The display language in the map.
500 /// A language is specified as an ISO 3166 alpha-2 two letter country-code
501 /// followed by ISO 639-1 for the two-letter language code.
502 /// Each language tag is composed of one or more "subtags" separated by hyphens (-).
503 /// Each subtag is composed of basic Latin letters or digits only.
504 /// For example, "ko-KR" for Korean, "en-US" for American English.</value>
505 /// <since_tizen> 3 </since_tizen>
506 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
507 /// <privilege>http://tizen.org/privilege/internet</privilege>
508 /// <privilege>http://tizen.org/privilege/network.get</privilege>
509 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
510 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
511 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
512 public string Language
516 return handle.Language;
520 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
521 handle.Language = value;
526 /// Gets or sets geographical coordinates for map view's center.
528 /// <since_tizen> 3 </since_tizen>
529 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
530 /// <privilege>http://tizen.org/privilege/internet</privilege>
531 /// <privilege>http://tizen.org/privilege/network.get</privilege>
532 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
533 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
534 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
535 public Geocoordinates Center
539 return new Geocoordinates(handle.Center);
543 Log.Info(string.Format("Center is changed from {0} to {1}", handle.Center.ToString(), value.ToString()));
544 handle.Center = value.handle;
549 /// Gets a list of the map object added to map view.
551 /// <since_tizen> 3 </since_tizen>
552 public new IEnumerable<MapObject> Children
556 return _handleToObjectTable.Values;
561 /// Changes the geographical coordinates to screen coordinates.
563 /// <since_tizen> 3 </since_tizen>
564 /// <param name="coordinates">Geographical coordinates.</param>
565 /// <returns>Returns an instance of the screen coordinates on the current screen.</returns>
566 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
567 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
568 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
569 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
570 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory and connect to the service.</exception>
571 public Point GeolocationToScreen(Geocoordinates coordinates)
573 return handle.GeolocationToScreen(coordinates.handle);
577 /// Changes the screen coordinates to geographical coordinates.
579 /// <since_tizen> 3 </since_tizen>
580 /// <param name="screenCoordinates">Screen coordinates.</param>
581 /// <returns>Returns an instance of the geographical coordinates object.</returns>
582 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
583 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
584 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
585 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
586 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory and connect to the service.</exception>
587 public Geocoordinates ScreenToGeolocation(Point screenCoordinates)
589 return new Geocoordinates(handle.ScreenToGeolocation(screenCoordinates));
593 /// Adds a map object to map view.
595 /// <since_tizen> 3 </since_tizen>
596 /// <param name="child">An instance of the map object to be added.</param>
597 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
598 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
599 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
600 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
601 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory and connect to the service.</exception>
602 public void Add(MapObject child)
604 Log.Info(string.Format("Add a object"));
605 var objectHandle = child.GetHandle();
606 if (!_handleToObjectTable.ContainsKey(objectHandle))
608 _handleToObjectTable[objectHandle] = child;
609 handle.AddObject(objectHandle);
611 // MapView take ownership of added map objects
612 objectHandle.HasOwnership = false;
617 /// Removes a map object from the map view.
619 /// <since_tizen> 3 </since_tizen>
620 /// <param name="child">An instance of the map object to be removed.</param>
621 /// <remarks>Once removed, the child object will be become invalid.</remarks>
622 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
623 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
624 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
625 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
626 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory and connect to the service.</exception>
627 public void Remove(MapObject child)
629 Log.Info(string.Format("Remove a object"));
630 var objectHandle = child.GetHandle();
631 if (_handleToObjectTable.Remove(objectHandle))
633 handle.RemoveObject(child.GetHandle());
635 // The object handle will be released automatically by the View, once RemoveObject call is successful
636 child.InvalidateMapObject();
641 /// Removes all map objects from the map view.
643 /// <since_tizen> 3 </since_tizen>
644 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
645 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
646 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
647 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory and connect to the service.</exception>
648 public void RemoveAll()
650 Log.Info(string.Format("Remove all of objects"));
651 foreach (var child in _handleToObjectTable.Values)
653 child.InvalidateMapObject();
655 _handleToObjectTable.Clear();
656 handle.RemoveAllObjects();
660 /// Captures a snapshot of the map view.
662 /// <since_tizen> 3 </since_tizen>
663 /// <param name="type">Type of file format.</param>
664 /// <param name="quality">An integer value representing the quality for encoding from 1 to 100.</param>
665 /// <param name="path">A string representing the file path for a snapshot.</param>
666 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
667 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
668 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
669 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
670 /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory and connect to the service.</exception>
671 public void CaptureSnapshot(SnapshotType type, int quality, string path)
673 var err = Interop.ViewSnapshot.ViewCaptureSnapshot(handle, (Interop.ViewSnapshotFormatType)type, quality, path);
674 err.ThrowIfFailed("Failed to create snapshot for the view");
677 private void SetGestureEventCallback()
679 if (_gestureEventCallback == null)
681 _gestureEventCallback = (type, eventData, userData) =>
683 if (type != Interop.ViewEventType.Gesture) return;
684 var eventArg = new MapGestureEventArgs(eventData);
685 switch (eventArg.GestureType)
687 case GestureType.Scroll: _scrolledEventHandler?.Invoke(this, eventArg); break;
688 case GestureType.Zoom: _twoFingerZoomedEventHandler?.Invoke(this, eventArg); break;
689 case GestureType.Click: _clickedEventHandler?.Invoke(this, eventArg); break;
690 case GestureType.DoubleClick: _doubleClickedEventHandler?.Invoke(this, eventArg); break;
691 case GestureType.TwoFingerClick: _twoFingerClickedEventHandler?.Invoke(this, eventArg); break;
692 case GestureType.Rotation: _twoFingerRotatedEventHandler?.Invoke(this, eventArg); break;
693 case GestureType.LongPress: _longPressedEventHandler?.Invoke(this, eventArg); break;
696 handle.SetEventCb(Interop.ViewEventType.Gesture, _gestureEventCallback, IntPtr.Zero);
697 Log.Info(string.Format("Gesture event callback is set"));
701 private void UnsetGestureEventCallback()
703 if (_scrolledEventHandler != null || _twoFingerZoomedEventHandler != null
704 || _clickedEventHandler != null || _doubleClickedEventHandler != null
705 || _twoFingerClickedEventHandler != null || _twoFingerRotatedEventHandler != null
706 || _longPressedEventHandler != null)
711 handle.UnsetEventCb(Interop.ViewEventType.Gesture);
712 _gestureEventCallback = null;
713 Log.Info(string.Format("Gesture event callback is unset"));
716 private void SetObjectEventCallback()
718 if (_objectEventCallback == null)
720 _objectEventCallback = (type, eventData, userData) =>
722 if (type != Interop.ViewEventType.Object) return;
723 var eventArg = new Interop.ObjectEventDataHandle(eventData);
724 switch (eventArg.GestureType)
726 case Interop.ViewGesture.Click:
728 var mapObject = _handleToObjectTable[eventArg.ViewObject];
729 mapObject?.HandleClickedEvent();
734 handle.SetEventCb(Interop.ViewEventType.Object, _objectEventCallback, IntPtr.Zero);
735 Log.Info(string.Format("Object event callback is set"));
739 private void SetViewReadyEventCallback()
741 if (_viewReadyEventCallback == null)
743 _viewReadyEventCallback = (type, eventData, userData) =>
745 _viewReadyEventHandler?.Invoke(this, EventArgs.Empty);
747 handle.SetEventCb(Interop.ViewEventType.Ready, _viewReadyEventCallback, IntPtr.Zero);
748 Log.Info(string.Format("ViewReady event callback is set"));
752 private void UnsetViewReadyEventCallback()
754 if (_viewReadyEventHandler == null)
756 handle.UnsetEventCb(Interop.ViewEventType.Ready);
757 _viewReadyEventCallback = null;
758 Log.Info(string.Format("ViewReady event callback is unset"));
762 #region IDisposable Support
763 private bool _disposedValue = false;
766 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
768 /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
769 /// <since_tizen> 3 </since_tizen>
770 protected virtual void Dispose(bool disposing)
776 _handleToObjectTable?.Clear();
779 _service.handle.HasOwnership = true;
780 _disposedValue = true;
785 /// Releases all the resources used by this object.
787 /// <since_tizen> 3 </since_tizen>
788 public void Dispose()
791 GC.SuppressFinalize(this);