/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using EvasObject = ElmSharp.EvasObject; namespace Tizen.Maps { /// /// Overlay map object. /// /// 3 public class Overlay : MapObject, IDisposable { internal Interop.OverlayHandle handle; /// /// Creates a normal overlay map object. /// /// 3 /// /// /// Thrown when the input coordinates or objectToContain are invalid. public Overlay(Geocoordinates coordinates, EvasObject objectToContain) : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal) { } internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type) { var err = Interop.ErrorCode.InvalidParameter; if (coordinates == null || objectToContain == null) { err.ThrowIfFailed("given coordinates or parent evas object is null"); } handle = new Interop.OverlayHandle(coordinates.handle, objectToContain, type); } /// /// Destroy the Overlay object. /// ~Overlay() { Dispose(false); } /// /// Gets or sets the visibility of an overlay map object. /// /// 3 public override bool IsVisible { get { return handle.IsVisible; } set { handle.IsVisible = value; } } /// /// Gets or sets geographical coordinates for an overlay map object. /// /// 3 public Geocoordinates Coordinates { get { return new Geocoordinates(handle.Coordinates); } set { // Overlay takes ownership of the native handle. handle.Coordinates = value.handle; value.handle.HasOwnership = false; } } /// /// Gets or sets minimum zoom level for an overlay map object. /// /// 3 public int MinimumZoomLevel { get { return handle.MinZoomLevel; } set { handle.MinZoomLevel = value; } } /// /// Gets or sets maximum zoom lever for an overlay map object. /// /// 3 public int MaximumZoomLevel { get { return handle.MaxZoomLevel; } set { handle.MaxZoomLevel = value; } } // Overlay object does not support click events internal override void HandleClickedEvent() { throw new NotSupportedException("Overlay object does not support click events"); } internal override void InvalidateMapObject() { handle = null; } internal override Interop.ViewObjectHandle GetHandle() { return handle; } #region IDisposable Support private bool _disposedValue = false; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed. /// 3 protected virtual void Dispose(bool disposing) { if (!_disposedValue) { handle?.Dispose(); _disposedValue = true; } } /// /// Releases all the resources used by this object. /// /// 3 public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion } /// /// The bubble overlay map object. /// /// 3 public class BubbleOverlay : Overlay { /// /// Creates a bubble overlay. /// /// 3 /// The geographical coordinates to be pointed. /// The EvasObject to be shown. /// Thrown when the required feature is not supported. /// Thrown when the input coordinates or objectToContain are invalid. public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble) { } } /// /// The box overlay map object. /// /// 3 public class BoxOverlay : Overlay { /// /// Creates a box overlay. /// /// 3 /// The geographical coordinates to be pointed. /// The EvasObject to be shown. /// Thrown when the required feature is not supported. /// Thrown when the input coordinates or objectToContain are invalid public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Box) { } } }