/* * 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 ElmSharp; namespace Tizen.Maps { /// /// The marker map object. /// /// 3 public class Marker : MapObject, IDisposable { internal Interop.MarkerHandle handle; internal Marker(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type) { var err = Interop.ErrorCode.InvalidParameter; if (coordinates == null || imagePath == null) { err.ThrowIfFailed("given coordinates or imagePath is null"); } handle = new Interop.MarkerHandle(coordinates.handle, imagePath, type); } /// /// Gets or sets the clicked event handlers. /// /// 3 public event EventHandler Clicked; /// /// Gets or sets the marker's visibility. /// /// 3 public override bool IsVisible { get { return handle.IsVisible; } set { handle.IsVisible = value; } } /// /// Gets or sets the geographical coordinates for this marker. /// /// 3 public Geocoordinates Coordinates { get { return new Geocoordinates(handle.Coordinates); } set { handle.Coordinates = value.handle; // Marker takes ownership of the native handle. value.handle.HasOwnership = false; } } /// /// Gets or sets a string representing the image file path for this marker. /// /// 3 public string ImagePath { get { return handle.ImageFile; } set { handle.ImageFile = value; } } /// /// Gets or sets the screen size for this marker. /// /// 3 public Size MarkerSize { get { return handle.MarkerSize; } set { handle.MarkerSize = value; } } /// /// Gets or sets the z-order for this marker. /// /// 3 /// The integer value is 0 by default, and must be in the range of -100 to 100. public int ZOrder { get { return handle.ZOrder; } set { handle.ZOrder = value; } } /// /// Changes the marker size. /// /// 3 /// New size. public void Resize(Size newSize) { MarkerSize = newSize; } /// /// Changes the marker coordinates. /// /// 3 /// New position for the marker. public void Move(Geocoordinates newPosition) { Coordinates = newPosition; } internal override void HandleClickedEvent() { Clicked?.Invoke(this, EventArgs.Empty); } 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. /// /// 3 /// If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed. 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 } /// /// Pin type the marker map object. /// /// 3 public class Pin : Marker { private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png"; /// /// Creates a pin type marker. /// /// 3 /// Marker coordinates. /// Thrown when input coordinates are invalid. public Pin(Geocoordinates coordinates) : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin) { } /// /// Creates a pin type marker. /// /// 3 /// Marker coordinates. /// Image file path for the Marker. /// /// http://tizen.org/privilege/mediastorage is needed if the file path is relevant to media storage. /// http://tizen.org/privilege/externalstorage is needed if the file path is relevant to external storage. /// /// Thrown when the required feature is not supported. /// Thrown when application does not have some privilege to access this method. /// Thrown when the input coordinates or imagePath is invalid. public Pin(Geocoordinates coordinates, string imagePath) : base(coordinates, imagePath, Interop.ViewMarkerType.Pin) { } } /// /// Sticker type marker map object. /// /// 3 public class Sticker : Marker { private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png"; /// /// Creates a sticker type marker. /// /// 3 /// Marker coordinates. /// Thrown when input coordinates are invalid. public Sticker(Geocoordinates coordinates) : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker) { } /// /// Creates a sticker type marker. /// /// 3 /// Marker coordinates. /// Image file path for Marker. /// /// http://tizen.org/privilege/mediastorage is needed if the input or output path are relevant to media storage. /// http://tizen.org/privilege/externalstorage is needed if the input or output path are relevant to external storage. /// /// Thrown when the required feature is not supported. /// Thrown when application does not have some privilege to access this method. /// Thrown when the input coordinates or imagePath is invalid. public Sticker(Geocoordinates coordinates, string imagePath) : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker) { } } }