204 lines
8.6 KiB
C#
204 lines
8.6 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="MapModel.cs" company="BTU/IIT">
|
|
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
|
// </copyright>
|
|
// <author>Stubbfel</author>
|
|
// <date>14.10.2013</date>
|
|
// <summary>Implements the map model class</summary>
|
|
//-----------------------------------------------------------------------
|
|
namespace CampusAppWP8.Model.Campusmap.Map
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media.Imaging;
|
|
using CampusAppWP8.Model.GeoDb;
|
|
using CampusAppWP8.Model.Campusmap.Pin;
|
|
using CampusAppWPortalLib8.Model.Utility;
|
|
using CampusAppWPortalLib8.Model.Campusmap.Pin;
|
|
|
|
/// <summary> This Class manage the properties of a Map. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
public class MapWp8Model : CampusAppWPortalLib8.Model.Campusmap.Map.MapModel<SpsWp8Model,PlaceWp8Model>
|
|
{
|
|
#region Constructors
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="MapWp8Model" /> class. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
public MapWp8Model()
|
|
{
|
|
this.IsReady = false;
|
|
}
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="MapWp8Model" /> class. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="placeList"> list of places. </param>
|
|
public MapWp8Model(List<PlaceWp8Model> placeList)
|
|
{
|
|
this.IsReady = false;
|
|
this.LoadSpatials(placeList);
|
|
this.IsReady = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
/// <summary> Delegate for MapInfo. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="places"> list of places. </param>
|
|
public delegate void MapInfos(List<PlaceWp8Model> places);
|
|
|
|
/// <summary> Event ShowMapInfo. </summary>
|
|
public event MapInfos ShowMapInfos = null;
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
#region public
|
|
|
|
/// <summary> Method create in image, which can show at a certain position. </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="x"> the x- coordinate. </param>
|
|
/// <param name="y"> the y-coordinate. </param>
|
|
/// <param name="type"> The type. </param>
|
|
/// <param name="places"> (Optional) list of places. </param>
|
|
/// <returns> image of the pin. </returns>
|
|
public Image AddPin(double x, double y, MapPinModel.PinType type, List<PlaceWp8Model> places = null)
|
|
{
|
|
MapPoint position = new MapPoint(x, y);
|
|
return this.AddPin(position, type, places);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method create in image, which can show at a certain position depend of the
|
|
/// <see cref="RefPoint" />
|
|
/// </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="x"> the x-coordinate. </param>
|
|
/// <param name="y"> the y-coordinate. </param>
|
|
/// <param name="type"> The type. </param>
|
|
/// <param name="places"> (Optional) list of places. </param>
|
|
/// <returns> image of the pin. </returns>
|
|
public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type, List<PlaceWp8Model> places = null)
|
|
{
|
|
MapPoint position = new MapPoint(this.RefPoint.X + x, this.RefPoint.Y - y);
|
|
return this.AddPin(position, type, places);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method create in image, which can show at a certain position depend of the
|
|
/// <see cref="RefPoint" />
|
|
/// </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="position"> input point. </param>
|
|
/// <param name="type"> The type. </param>
|
|
/// <param name="places"> (Optional) list of places. </param>
|
|
/// <returns> image of the pin. </returns>
|
|
public Image AddPinFromRefPoint(MapPoint position, MapPinModel.PinType type, List<PlaceWp8Model> places = null)
|
|
{
|
|
return this.AddPinFromRefPoint(position.X, position.Y, type, places);
|
|
}
|
|
|
|
/// <summary> Method create in image, which can show at a certain position. </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="position"> input point. </param>
|
|
/// <param name="type"> The type. </param>
|
|
/// <param name="places"> (Optional) list of places. </param>
|
|
/// <returns> image of the pin. </returns>
|
|
public Image AddPin(MapPoint position, MapPinModel.PinType type, List<PlaceWp8Model> places = null)
|
|
{
|
|
Image pinImg = new Image();
|
|
MapPinModel pin = this.CreatePin(type, places, pinImg);
|
|
pin.Position = position;
|
|
if (pin.ImageSource != null)
|
|
{
|
|
pinImg.Source = new BitmapImage(new Uri(pin.ImageSource, UriKind.Relative));
|
|
pinImg.Width = pin.ImageWidth;
|
|
pinImg.Height = pin.ImageHeight;
|
|
}
|
|
|
|
Canvas.SetTop(pinImg, pin.Position.Y);
|
|
Canvas.SetLeft(pinImg, pin.Position.X);
|
|
Canvas.SetZIndex(pinImg, pin.ZIndex);
|
|
return pinImg;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region private
|
|
|
|
/// <summary> Creates a pin. </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="type"> The type. </param>
|
|
/// <param name="places"> list of places. </param>
|
|
/// <param name="pinImg"> image of the pin. </param>
|
|
/// <returns> The new pin. </returns>
|
|
private MapPinModel CreatePin(MapPinModel.PinType type, List<PlaceWp8Model> places, Image pinImg)
|
|
{
|
|
MapPinModel pin;
|
|
switch (type)
|
|
{
|
|
case MapPinModel.PinType.CurrentPosition:
|
|
pin = new CurrentPositionPinModel();
|
|
break;
|
|
case MapPinModel.PinType.SearchPlace:
|
|
pin = new SearchPlacePinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((SearchPlacePinModel)pin).ShowInfo);
|
|
|
|
((SearchPlacePinModel)pin).AssocPlaces = places;
|
|
((SearchPlacePinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
case MapPinModel.PinType.InfoPlace:
|
|
pin = new InfoPlacePinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((InfoPlacePinModel)pin).ShowInfo);
|
|
|
|
((InfoPlacePinModel)pin).AssocPlaces = places;
|
|
((InfoPlacePinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
case MapPinModel.PinType.InfoLabPlace:
|
|
pin = new InfoLabPlacePinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((InfoLabPlacePinModel)pin).ShowInfo);
|
|
|
|
((InfoLabPlacePinModel)pin).AssocPlaces = places;
|
|
((InfoLabPlacePinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
case MapPinModel.PinType.InfoAccesPlace:
|
|
pin = new InfoPlaceAccessPinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((InfoPlaceAccessPinModel)pin).ShowInfo);
|
|
|
|
((InfoPlaceAccessPinModel)pin).AssocPlaces = places;
|
|
((InfoPlaceAccessPinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
case MapPinModel.PinType.InfoRedPlace:
|
|
pin = new InfoPlaceRedPinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((InfoPlaceRedPinModel)pin).ShowInfo);
|
|
|
|
((InfoPlaceRedPinModel)pin).AssocPlaces = places;
|
|
((InfoPlaceRedPinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
case MapPinModel.PinType.InfoWcPlace:
|
|
pin = new InfoPlaceWCPinModel();
|
|
pinImg.MouseLeftButtonDown += new MouseButtonEventHandler(((InfoPlaceWCPinModel)pin).ShowInfo);
|
|
|
|
((InfoPlaceWCPinModel)pin).AssocPlaces = places;
|
|
((InfoPlaceWCPinModel)pin).CallBack = this.ShowMapInfos;
|
|
break;
|
|
default:
|
|
pin = new HiddenPinPlaceModel();
|
|
break;
|
|
}
|
|
|
|
pinImg.Tag = pin.Tag;
|
|
return pin;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|