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 the view and link it to the instance of map service.
52 /// <since_tizen>3</since_tizen>
53 /// <param name="parent">An instance of <see cref="EvasObject"/> object which 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 native operation failed to allocate memory, connect to service</exception>
60 public MapView(EvasObject parent, MapService service) : base(parent)
62 handle = new Interop.ViewHandle(service.handle, this);
63 Log.Info(string.Format("MapView is created"));
68 // We need to keep Gesture Tap event enabled for object event to work
69 handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
70 SetObjectEventCallback();
74 /// Adds or removes event handlers to deliver scrolled gesture event.
76 /// <value>Event handlers to get scrolled gesture event</value>
77 /// <since_tizen>3</since_tizen>
78 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
79 public event EventHandler<MapGestureEventArgs> Scrolled
83 SetGestureEventCallback();
84 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, true);
85 _scrolledEventHandler += value;
86 Log.Info(string.Format("Scrolled event handler is added"));
90 _scrolledEventHandler -= value;
91 Log.Info(string.Format("Scrolled event handler is removed"));
92 if (_scrolledEventHandler == null)
94 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, false);
95 UnsetGestureEventCallback();
101 /// Adds or removes event handlers to deliver zoomed gesture event.
103 /// <value>Event handlers to get zoomed gesture event</value>
104 /// <since_tizen>3</since_tizen>
105 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
106 public event EventHandler<MapGestureEventArgs> TwoFingerZoomed
110 SetGestureEventCallback();
111 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, true);
112 _twoFingerZoomedEventHandler += value;
113 Log.Info(string.Format("TwoFingerZoomed event handler is added"));
117 _twoFingerZoomedEventHandler -= value;
118 Log.Info(string.Format("TwoFingerZoomed event handler is removed"));
119 if (_twoFingerZoomedEventHandler == null)
121 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, false);
122 UnsetGestureEventCallback();
128 /// Adds or removes event handlers to deliver clicked gesture event.
130 /// <value>Event handlers to get clicked gesture event</value>
131 /// <since_tizen>3</since_tizen>
132 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
133 public event EventHandler<MapGestureEventArgs> Clicked
137 SetGestureEventCallback();
138 //handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
139 _clickedEventHandler += value;
140 Log.Info(string.Format("Clicked event handler is added"));
144 _clickedEventHandler -= value;
145 Log.Info(string.Format("Clicked event handler is removed"));
146 if (_clickedEventHandler == null)
148 //handle.SetGestureEnabled(Interop.ViewGesture.Click, false);
149 UnsetGestureEventCallback();
155 /// Adds or removes event handlers to deliver double-clicked gesture event.
157 /// <value>Event handlers to get double-clicked gesture event</value>
158 /// <since_tizen>3</since_tizen>
159 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
160 public event EventHandler<MapGestureEventArgs> DoubleClicked
164 SetGestureEventCallback();
165 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, true);
166 _doubleClickedEventHandler += value;
167 Log.Info(string.Format("DoubleClicked event handler is removed"));
171 _doubleClickedEventHandler -= value;
172 Log.Info(string.Format("DoubleClicked event handler is removed"));
173 if (_doubleClickedEventHandler == null)
175 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, false);
176 UnsetGestureEventCallback();
182 /// Adds or removes event handlers to deliver clicked gesture event with two-fingers.
184 /// <value>Event handlers to get clicked gesture event</value>
185 /// <since_tizen>3</since_tizen>
186 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
187 public event EventHandler<MapGestureEventArgs> TwoFingerClicked
191 SetGestureEventCallback();
192 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, true);
193 _twoFingerClickedEventHandler += value;
194 Log.Info(string.Format("TwoFingerClicked event handler is added"));
198 _twoFingerClickedEventHandler -= value;
199 Log.Info(string.Format("TwoFingerClicked event handler is removed"));
200 if (_twoFingerClickedEventHandler == null)
202 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, false);
203 UnsetGestureEventCallback();
209 /// Adds or removes event handlers to deliver rotated gesture event.
211 /// <value>Event handlers to get rotated gesture event</value>
212 /// <since_tizen>3</since_tizen>
213 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
214 public event EventHandler<MapGestureEventArgs> TwoFingerRotated
218 SetGestureEventCallback();
219 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, true);
220 _twoFingerRotatedEventHandler += value;
221 Log.Info(string.Format("Rotated event handler is added"));
225 _twoFingerRotatedEventHandler -= value;
226 Log.Info(string.Format("Rotated event handler is removed"));
227 if (_twoFingerRotatedEventHandler == null)
229 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, false);
230 UnsetGestureEventCallback();
237 /// Adds or removes event handlers to deliver long-pressed gesture event.
239 /// <value>Event handlers to get long-pressed gesture event</value>
240 /// <since_tizen>3</since_tizen>
241 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
242 public event EventHandler<MapGestureEventArgs> LongPressed
246 SetGestureEventCallback();
247 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, true);
248 _longPressedEventHandler += value;
249 Log.Info(string.Format("LongPressed event handler is added"));
253 _longPressedEventHandler -= value;
254 Log.Info(string.Format("LongPressed event handler is removed"));
255 if (_longPressedEventHandler == null)
257 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, false);
258 UnsetGestureEventCallback();
264 /// Adds or removes event handlers to deliver a event representing the view is ready to be used.
266 /// <value>Event handlers to get view ready event</value>
267 /// <since_tizen>3</since_tizen>
268 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
269 public event EventHandler ViewReady
273 SetViewReadyEventCallback();
274 _viewReadyEventHandler += value;
275 Log.Info(string.Format("ViewReady event handler is added"));
279 _viewReadyEventHandler -= value;
280 Log.Info(string.Format("ViewReady event handler is removed"));
281 UnsetGestureEventCallback();
286 /// Gets or sets current zoom level.
288 /// <value>It is an integer value that representing current zoom level.</value>
289 /// <since_tizen>3</since_tizen>
290 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
291 /// <privilege>http://tizen.org/privilege/internet</privilege>
292 /// <privilege>http://tizen.org/privilege/network.get</privilege>
293 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
294 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
299 return handle.ZoomLevel;
303 Log.Info(string.Format("ZoomLevel is changed from {0} to {1}", handle.ZoomLevel, value));
304 handle.ZoomLevel = value;
309 /// Gets or sets minimum zoom level.
311 /// <value>It is an integer value that limits minimal zoom level within range of current map plug-in supported.</value>
312 /// <since_tizen>3</since_tizen>
313 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
314 /// <privilege>http://tizen.org/privilege/internet</privilege>
315 /// <privilege>http://tizen.org/privilege/network.get</privilege>
316 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
317 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
318 public int MinimumZoomLevel
322 return handle.MinimumZoomLevel;
326 Log.Info(string.Format("MinimumZoomLevel is changed from {0} to {1}", handle.MinimumZoomLevel, value));
327 handle.MinimumZoomLevel = value;
332 /// Gets or sets maximum zoom level.
334 /// <value>It is an integer value that limits maximum zoom level within range of current map plug-in supported.</value>
335 /// <since_tizen>3</since_tizen>
336 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
337 /// <privilege>http://tizen.org/privilege/internet</privilege>
338 /// <privilege>http://tizen.org/privilege/network.get</privilege>
339 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
340 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
341 public int MaximumZoomLevel
345 return handle.MaximumZoomLevel;
349 Log.Info(string.Format("MaximumZoomLevel is changed from {0} to {1}", handle.MaximumZoomLevel, value));
350 handle.MaximumZoomLevel = value;
355 /// Gets or sets orientation on the map view.
357 /// <value>It is an integer value from 0 to 360 that indicates orientation of the map view</value>
358 /// <since_tizen>3</since_tizen>
359 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
360 /// <privilege>http://tizen.org/privilege/internet</privilege>
361 /// <privilege>http://tizen.org/privilege/network.get</privilege>
362 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
363 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
364 public double Orientation
368 return handle.Orientation;
372 Log.Info(string.Format("Orientation is changed from {0} to {1}", handle.Orientation, value));
373 handle.Orientation = value;
378 /// Gets or sets theme type of the map view.
380 /// <since_tizen>3</since_tizen>
381 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
382 /// <privilege>http://tizen.org/privilege/internet</privilege>
383 /// <privilege>http://tizen.org/privilege/network.get</privilege>
384 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
385 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
386 public MapTypes MapType
390 return (MapTypes)handle.MapType;
394 Log.Info(string.Format("MapType is changed from {0} to {1}", handle.MapType, value));
395 handle.MapType = (Interop.ViewType)value;
400 /// Indicates whether the map should show the 3D buildings layer.
402 /// <since_tizen>3</since_tizen>
403 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
404 /// <privilege>http://tizen.org/privilege/internet</privilege>
405 /// <privilege>http://tizen.org/privilege/network.get</privilege>
406 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
407 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
408 public bool BuildingsEnabled
412 return handle.BuildingsEnabled;
416 Log.Info(string.Format("Showing the 3D buildings is {0}", (value ? "enabled" : "disabled")));
417 handle.BuildingsEnabled = value;
422 /// Indicates whether the map should show the traffic layer.
424 /// <since_tizen>3</since_tizen>
425 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
426 /// <privilege>http://tizen.org/privilege/internet</privilege>
427 /// <privilege>http://tizen.org/privilege/network.get</privilege>
428 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
429 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
430 public bool TrafficEnabled
434 return handle.TrafficEnabled;
438 Log.Info(string.Format("Showing the traffic is {0}", (value ? "enabled" : "disabled")));
439 handle.TrafficEnabled = value;
444 /// Indicates whether the map should show the public transit layer.
446 /// <since_tizen>3</since_tizen>
447 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
448 /// <privilege>http://tizen.org/privilege/internet</privilege>
449 /// <privilege>http://tizen.org/privilege/network.get</privilege>
450 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
451 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
452 public bool PublicTransitEnabled
456 return handle.PublicTransitEnabled;
460 Log.Info(string.Format("Showing the public transit is {0}", (value ? "enabled" : "disabled")));
461 handle.PublicTransitEnabled = value;
466 /// Indicates whether the scale-bar is enabled or not.
468 /// <since_tizen>3</since_tizen>
469 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
470 /// <privilege>http://tizen.org/privilege/internet</privilege>
471 /// <privilege>http://tizen.org/privilege/network.get</privilege>
472 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
473 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
474 public bool ScaleBarEnabled
478 return handle.ScaleBarEnabled;
482 Log.Info(string.Format("Showing the scale-bar is {0}", (value ? "enabled" : "disabled")));
483 handle.ScaleBarEnabled = value;
488 /// Sets language of map view.
490 /// <value>The display language in the map.
491 /// A language is specified as an ISO 3166 alpha-2 two letter country-code
492 /// followed by ISO 639-1 for the two-letter language code.
493 /// Each language tag is composed of one or more "subtags" separated by hyphens (-).
494 /// Each subtag is composed of basic Latin letters or digits only.
495 /// For example, "ko-KR" for Korean, "en-US" for American English.</value>
496 /// <since_tizen>3</since_tizen>
497 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
498 /// <privilege>http://tizen.org/privilege/internet</privilege>
499 /// <privilege>http://tizen.org/privilege/network.get</privilege>
500 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
501 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
502 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
503 public string Language
507 return handle.Language;
511 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
512 handle.Language = value;
517 /// Gets or sets geographical coordinates for map view's center.
519 /// <since_tizen>3</since_tizen>
520 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
521 /// <privilege>http://tizen.org/privilege/internet</privilege>
522 /// <privilege>http://tizen.org/privilege/network.get</privilege>
523 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
524 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
525 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
526 public Geocoordinates Center
530 return new Geocoordinates(handle.Center);
534 Log.Info(string.Format("Center is changed from {0} to {1}", handle.Center.ToString(), value.ToString()));
535 handle.Center = value.handle;
540 /// Gets a list of map object added to map view.
542 /// <since_tizen>3</since_tizen>
543 public IEnumerable<MapObject> Children
547 return _handleToObjectTable.Values;
552 /// Changes geographical coordinates to screen coordinates.
554 /// <since_tizen>3</since_tizen>
555 /// <param name="coordinates">Geographical coordinates</param>
556 /// <returns>Returns an instance of screen coordinates on the current screen</returns>
557 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
558 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
559 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
560 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
561 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
562 public Point GeolocationToScreen(Geocoordinates coordinates)
564 return handle.GeolocationToScreen(coordinates.handle);
568 /// Changes screen coordinates to geographical coordinates.
570 /// <since_tizen>3</since_tizen>
571 /// <param name="screenCoordinates">Screen coordinates</param>
572 /// <returns>Returns an instance of geographical coordinates object.</returns>
573 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
574 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
575 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
576 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
577 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
578 public Geocoordinates ScreenToGeolocation(Point screenCoordinates)
580 return new Geocoordinates(handle.ScreenToGeolocation(screenCoordinates));
584 /// Adds a map object to map view.
586 /// <since_tizen>3</since_tizen>
587 /// <param name="child">An instance of map object to be added</param>
588 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
589 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
590 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
591 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
592 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
593 public void Add(MapObject child)
595 Log.Info(string.Format("Add a object"));
596 var objectHandle = child.GetHandle();
597 if (!_handleToObjectTable.ContainsKey(objectHandle))
599 _handleToObjectTable[objectHandle] = child;
600 handle.AddObject(objectHandle);
602 // MapView take ownership of added map objects
603 objectHandle.HasOwnership = false;
608 /// Removes a map object from map view.
610 /// <since_tizen>3</since_tizen>
611 /// <param name="child">An instance of map object to be removed</param>
612 /// <remarks>Once removed, the child object will be become invalid</remarks>
613 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
614 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
615 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
616 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
617 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
618 public void Remove(MapObject child)
620 Log.Info(string.Format("Remove a object"));
621 var objectHandle = child.GetHandle();
622 if (_handleToObjectTable.Remove(objectHandle))
624 handle.RemoveObject(child.GetHandle());
626 // The object handle will be released automatically by the View, once RemoveObject call is successful
627 child.InvalidateMapObject();
632 /// Removes all map objects from map view.
634 /// <since_tizen>3</since_tizen>
635 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
636 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
637 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
638 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
639 public void RemoveAll()
641 Log.Info(string.Format("Remove all of objects"));
642 foreach (var child in _handleToObjectTable.Values)
644 child.InvalidateMapObject();
646 _handleToObjectTable.Clear();
647 handle.RemoveAllObjects();
651 /// Captures a snapshot of map view
653 /// <since_tizen>3</since_tizen>
654 /// <param name="type">Type of file format</param>
655 /// <param name="quality">A integer value which representing quality for encoding, from 1 to 100</param>
656 /// <param name="path">A string which representing The file path for snapshot</param>
657 /// <privilege>http://tizen.org/privilege/mapservice</privilege>
658 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
659 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
660 /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
661 /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
662 public void CaptureSnapshot(SnapshotType type, int quality, string path)
664 var err = Interop.ViewSnapshot.ViewCaptureSnapshot(handle, (Interop.ViewSnapshotFormatType)type, quality, path);
665 err.ThrowIfFailed("Failed to create snapshot for the view");
668 private void SetGestureEventCallback()
670 if (_gestureEventCallback == null)
672 _gestureEventCallback = (type, eventData, userData) =>
674 if (type != Interop.ViewEventType.Gesture) return;
675 var eventArg = new MapGestureEventArgs(eventData);
676 switch (eventArg.GestureType)
678 case GestureType.Scroll: _scrolledEventHandler?.Invoke(this, eventArg); break;
679 case GestureType.Zoom: _twoFingerZoomedEventHandler?.Invoke(this, eventArg); break;
680 case GestureType.Click: _clickedEventHandler?.Invoke(this, eventArg); break;
681 case GestureType.DoubleClick: _doubleClickedEventHandler?.Invoke(this, eventArg); break;
682 case GestureType.TwoFingerClick: _twoFingerClickedEventHandler?.Invoke(this, eventArg); break;
683 case GestureType.Rotation: _twoFingerRotatedEventHandler?.Invoke(this, eventArg); break;
684 case GestureType.LongPress: _longPressedEventHandler?.Invoke(this, eventArg); break;
687 handle.SetEventCb(Interop.ViewEventType.Gesture, _gestureEventCallback, IntPtr.Zero);
688 Log.Info(string.Format("Gesture event callback is set"));
692 private void UnsetGestureEventCallback()
694 if (_scrolledEventHandler != null || _twoFingerZoomedEventHandler != null
695 || _clickedEventHandler != null || _doubleClickedEventHandler != null
696 || _twoFingerClickedEventHandler != null || _twoFingerRotatedEventHandler != null
697 || _longPressedEventHandler != null)
702 handle.UnsetEventCb(Interop.ViewEventType.Gesture);
703 _gestureEventCallback = null;
704 Log.Info(string.Format("Gesture event callback is unset"));
707 private void SetObjectEventCallback()
709 if (_objectEventCallback == null)
711 _objectEventCallback = (type, eventData, userData) =>
713 if (type != Interop.ViewEventType.Object) return;
714 var eventArg = new Interop.ObjectEventDataHandle(eventData);
715 switch (eventArg.GestureType)
717 case Interop.ViewGesture.Click:
719 var mapObject = _handleToObjectTable[eventArg.ViewObject];
720 mapObject?.HandleClickedEvent();
725 handle.SetEventCb(Interop.ViewEventType.Object, _objectEventCallback, IntPtr.Zero);
726 Log.Info(string.Format("Object event callback is set"));
730 private void SetViewReadyEventCallback()
732 if (_viewReadyEventCallback == null)
734 _viewReadyEventCallback = (type, eventData, userData) =>
736 _viewReadyEventHandler?.Invoke(this, EventArgs.Empty);
738 handle.SetEventCb(Interop.ViewEventType.Ready, _viewReadyEventCallback, IntPtr.Zero);
739 Log.Info(string.Format("ViewReady event callback is set"));
743 private void UnsetViewReadyEventCallback()
745 if (_viewReadyEventHandler == null)
747 handle.UnsetEventCb(Interop.ViewEventType.Ready);
748 _viewReadyEventCallback = null;
749 Log.Info(string.Format("ViewReady event callback is unset"));
753 #region IDisposable Support
754 private bool _disposedValue = false;
756 protected virtual void Dispose(bool disposing)
765 _disposedValue = true;
770 /// Releases all resources used by this object.
772 /// <since_tizen>3</since_tizen>
773 public void Dispose()
776 GC.SuppressFinalize(this);