Files
win8phoneApp/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs
2013-09-26 15:39:37 +02:00

221 lines
6.2 KiB
C#

//-----------------------------------------------------------------------
// <copyright file="MapPinModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>24.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Campusmap
{
using System.Windows;
using System.Windows.Input;
using CampusAppWP8.Resources;
/// <summary>
/// This Class manage the properties of a MapPin
/// </summary>
public abstract class MapPinModel
{
#region Member
/// <summary>
/// String for info pins
/// </summary>
private static string infoPlacePinString = MapPinModel.PinTypeToString(PinType.InfoPlace);
/// <summary>
/// String for hidden pins
/// </summary>
private static string hiddenPlacePinString = MapPinModel.PinTypeToString(PinType.Hidden);
/// <summary>
/// String for search pins
/// </summary>
private static string searchPlacePinString = MapPinModel.PinTypeToString(PinType.SearchPlace);
/// <summary>
/// String for current position pins
/// </summary>
private static string currendPositionPlacePinString = MapPinModel.PinTypeToString(PinType.CurrentPosition);
/// <summary>
/// Variable of the actual position of the pin
/// </summary>
private Point position;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="MapPinModel" /> class.
/// </summary>
public MapPinModel()
{
}
#endregion
#region enums
/// <summary>Values that represent PinType.</summary>
/// <remarks>Stubbfel, 27.08.2013.</remarks>
public enum PinType
{
/// <summary>An enum constant representing the hidden option.</summary>
Hidden = 0,
/// <summary>An enum constant representing the search place option.</summary>
SearchPlace = 1,
/// <summary>An enum constant representing the current position option.</summary>
CurrentPosition = 2,
/// <summary>An enum constant representing the info place option.</summary>
InfoPlace = 3
}
#endregion
#region Property
/// <summary>
/// Gets the string of current position pins
/// </summary>
public static string CurrendPositionPlacePinString
{
get { return MapPinModel.currendPositionPlacePinString; }
}
/// <summary>
/// Gets the string of search pins
/// </summary>
public static string SearchPlacePinString
{
get { return MapPinModel.searchPlacePinString; }
}
/// <summary>
/// Gets the string of hidden pins
/// </summary>
public static string HiddenPlacePinString
{
get { return MapPinModel.hiddenPlacePinString; }
}
/// <summary>
/// Gets the string of info pins
/// </summary>
public static string InfoPlacePinString
{
get { return MapPinModel.infoPlacePinString; }
}
/// <summary>
/// Gets or sets the ImageSource of the pin
/// </summary>
public string ImageSource { get; set; }
/// <summary>
/// Gets or sets the ImageWidth of the pin
/// </summary>
public double ImageWidth { get; set; }
/// <summary>
/// Gets or sets the ImageHeight of the pin
/// </summary>
public double ImageHeight { get; set; }
/// <summary>
/// Gets or sets the ZIndex of the pin
/// </summary>
public int ZIndex { get; set; }
/// <summary>
/// Gets or sets the ImageOffsetX of the pin
/// </summary>
public double PinImageOffsetX { get; set; }
/// <summary>
/// Gets or sets the ImageOffsetY of the pin
/// </summary>
public double PinImageOffsetY { get; set; }
/// <summary>
/// Gets or sets position of the pin
/// </summary>
public Point Position
{
get
{
return this.position;
}
set
{
// null assert
if (value == null)
{
return;
}
if (this.position == null)
{
this.position = value;
return;
}
// check the x-value
if (value.X + this.PinImageOffsetX != this.position.X)
{
this.position.X = value.X + this.PinImageOffsetX;
}
// check the y-value
if (value.Y + this.PinImageOffsetY != this.position.Y)
{
this.position.Y = value.Y + this.PinImageOffsetY;
}
}
}
/// <summary>
/// Gets or sets the tag of the pin
/// </summary>
public object Tag { get; set; }
#endregion
#region Method
/// <summary>
/// Method convert PinType to a string
/// </summary>
/// <param name="type">type of the Pin</param>
/// <returns>PinType as string</returns>
public static string PinTypeToString(PinType type)
{
string result = null;
switch (type)
{
case PinType.CurrentPosition:
result = Constants.PinType_CurrentPosition;
break;
case PinType.Hidden:
result = Constants.PinType_Hidden;
break;
case PinType.InfoPlace:
result = Constants.PinType_Info;
break;
case PinType.SearchPlace:
result = Constants.PinType_Search;
break;
default:
result = string.Empty;
break;
}
return result;
}
#endregion
}
}