fix some mapissue and extend functions

This commit is contained in:
stubbfel
2013-09-16 15:18:43 +02:00
parent 98213ff494
commit c01caf703a
14 changed files with 274 additions and 29 deletions

View File

@@ -164,7 +164,7 @@ namespace CampusAppWP8
if (Settings.AppSetting.GeoWatchEnable)
{
Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPosition));
Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPositionForce));
thread.Start();
}
}

View File

@@ -10,7 +10,8 @@ namespace CampusAppWP8.File.Places
{
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
/// <summary>Places file.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
@@ -23,6 +24,7 @@ using CampusAppWP8.Resources;
public PlacesFile()
: base(ModelType.File, Constants.FilePlace_AllPlaces)
{
this.OnFailedFile += new OnFailed(this.FallBackLoad);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
@@ -45,7 +47,17 @@ using CampusAppWP8.Resources;
return false;
}
/// <summary>
/// Method load OfflineMap as Fallback
/// </summary>
private void FallBackLoad()
{
SpsModel fallBackModel = XmlManager.DeserializationFileToModel<SpsModel>(Constants.FileMap_OfflineMap);
this.Model = fallBackModel;
this.SaveData();
}
#endregion
}
}

View File

@@ -8,9 +8,9 @@
namespace CampusAppWP8.Model.Campusmap
{
using System.Windows;
using CampusAppWP8.File.Places;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
/// <summary>
/// Class for the MapModel of the mainCampus of cottbus
@@ -22,6 +22,11 @@ namespace CampusAppWP8.Model.Campusmap
/// <summary>Variable for the identify of the campus.</summary>
private static readonly string Campus = ((int)CampusAppWP8.Model.Setting.UserProfilModel.Campus.CB_MAIN).ToString();
/// <summary>
/// Variable for the PlaceFile
/// </summary>
private PlacesFile file;
#endregion
#region Constructor
@@ -51,7 +56,21 @@ namespace CampusAppWP8.Model.Campusmap
/// <remarks>Stubbfel, 19.08.2013.</remarks>
protected override void LoadSpatials()
{
SpsModel model = XmlManager.DeserializationFileToModel<SpsModel>(Constants.FileMap_OfflineMap);
if (this.file == null)
{
this.file = new PlacesFile();
}
this.file.OnLoaded += new PlacesFile.OnIO(this.FileIsReady);
this.file.LoadData();
}
/// <summary>
/// Method is called if the PlaceFile is loaded
/// </summary>
private void FileIsReady()
{
SpsModel model = this.file.Model;
this.Spatial = new SpsModel();
foreach (PlaceModel place in model.Places)

View File

@@ -6,10 +6,12 @@
// <sience>24.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Campusmap
{
{
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;
@@ -30,6 +32,20 @@ namespace CampusAppWP8.Model.Campusmap
#endregion
#region Events
/// <summary>
/// Delegate for MapInfo
/// </summary>
/// <param name="places">list of places</param>
public delegate void MapInfos(List<PlaceModel> places);
/// <summary>
/// Event ShowMapInfo
/// </summary>
public event MapInfos ShowMapInfos = null;
#endregion
#region Property
/// <summary>
@@ -121,11 +137,12 @@ namespace CampusAppWP8.Model.Campusmap
/// <param name="x"> the x- coordinate.</param>
/// <param name="y"> the y-coordinate.</param>
/// <param name="type">The type.</param>
/// <param name="places">list of places</param>
/// <returns>image of the pin.</returns>
public Image AddPin(double x, double y, MapPinModel.PinType type)
public Image AddPin(double x, double y, MapPinModel.PinType type, List<PlaceModel> places = null)
{
Point position = new Point(x, y);
return this.AddPin(position, type);
return this.AddPin(position, type, places);
}
/// <summary>
@@ -136,11 +153,12 @@ namespace CampusAppWP8.Model.Campusmap
/// <param name="x"> the x-coordinate.</param>
/// <param name="y"> the y-coordinate.</param>
/// <param name="type">The type.</param>
/// <param name="places">list of places</param>
/// <returns>image of the pin.</returns>
public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type)
public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type, List<PlaceModel> places = null)
{
Point position = new Point(this.RefPoint.X + x, this.RefPoint.Y - y);
return this.AddPin(position, type);
return this.AddPin(position, type, places);
}
/// <summary>
@@ -150,22 +168,24 @@ namespace CampusAppWP8.Model.Campusmap
/// <remarks>Stubbfel, 27.08.2013.</remarks>
/// <param name="position">input point.</param>
/// <param name="type"> The type.</param>
/// <param name="places">list of places</param>
/// <returns>image of the pin.</returns>
public Image AddPinFromRefPoint(Point position, MapPinModel.PinType type)
public Image AddPinFromRefPoint(Point position, MapPinModel.PinType type, List<PlaceModel> places = null)
{
return this.AddPinFromRefPoint(position.X, position.Y, type);
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">list of places</param>
/// <returns>image of the pin.</returns>
public Image AddPin(Point position, MapPinModel.PinType type)
public Image AddPin(Point position, MapPinModel.PinType type, List<PlaceModel> places = null)
{
MapPinModel pin = this.CreatePin(type);
pin.Position = position;
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));
@@ -237,8 +257,10 @@ namespace CampusAppWP8.Model.Campusmap
/// <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)
private MapPinModel CreatePin(MapPinModel.PinType type, List<PlaceModel> places, Image pinImg)
{
MapPinModel pin;
switch (type)
@@ -248,6 +270,10 @@ namespace CampusAppWP8.Model.Campusmap
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;
default:
pin = new HiddenPinPlaceModel();
@@ -256,7 +282,7 @@ namespace CampusAppWP8.Model.Campusmap
return pin;
}
#endregion
#endregion

View File

@@ -8,6 +8,7 @@
namespace CampusAppWP8.Model.Campusmap
{
using System.Windows;
using System.Windows.Input;
/// <summary>
/// This Class manage the properties of a MapPin

View File

@@ -8,7 +8,8 @@
namespace CampusAppWP8.Model.Campusmap
{
using System.Windows;
using System.Collections.Generic;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
/// <summary>Search pin place model.</summary>
@@ -31,5 +32,33 @@ namespace CampusAppWP8.Model.Campusmap
}
#endregion
#region property
/// <summary>
/// Gets or sets Callback Function, to show place information of the Pin
/// </summary>
public MapModel.MapInfos CallBack { get; set; }
/// <summary>
/// Gets or sets place which are associative with this pin
/// </summary>
public List<PlaceModel> AssocPlaces { get; set; }
#endregion
#region Method
/// <summary>
/// Show Information of this pin places
/// </summary>
/// <param name="sender">sender of the Event</param>
/// <param name="e">MouseButtonEvent Arguments</param>
public void ShowInfo(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.CallBack(this.AssocPlaces);
}
#endregion
}
}

View File

@@ -207,6 +207,24 @@ namespace CampusAppWP8.Model.GeoDb
return true;
}
/// <summary>
/// Method gets the InformationValue of a certain InformationName
/// </summary>
/// <param name="key">string for InformationName</param>
/// <returns>value of the information</returns>
public string GetInformationsValue(string key)
{
foreach (PlaceInformation info in this.Informations)
{
if (info.InformationName.Equals(key))
{
return info.InformationValue;
}
}
return null;
}
#endregion
}
}

View File

@@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages.Campusmap
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
using Microsoft.Phone.Controls;
/// <summary>Class for the campusMap page.</summary>
@@ -45,6 +46,7 @@ namespace CampusAppWP8.Pages.Campusmap
this.InitializeComponent();
this.map = new CBMainMapModel();
this.MapCanvas.DataContext = this.map;
this.map.ShowMapInfos += new CBMainMapModel.MapInfos(this.ShowMapInfo);
}
#endregion
@@ -59,7 +61,7 @@ namespace CampusAppWP8.Pages.Campusmap
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.NavigationMode == NavigationMode.New)
if (this.map.Spatial != null && e.NavigationMode == NavigationMode.New)
{
MapCanvas.Children.Clear();
@@ -139,7 +141,9 @@ namespace CampusAppWP8.Pages.Campusmap
GeoCoordinate coor = place.GeoRefPoint;
if (coor != null)
{
this.AddPin(coor.Longitude, coor.Latitude, type, scroll);
List<PlaceModel> assocPlaces = new List<PlaceModel>();
assocPlaces.Add(place);
this.AddPin(coor.Longitude, coor.Latitude, type, scroll, assocPlaces);
}
}
}
@@ -150,10 +154,11 @@ namespace CampusAppWP8.Pages.Campusmap
/// <param name="y"> latitude parameter.</param>
/// <param name="type"> The type.</param>
/// <param name="scroll">(Optional) the scroll.</param>
private void AddPin(double x, double y, MapPinModel.PinType type, bool scroll = true)
/// <param name="assocPlaces">(Optional) List of places, whose are associative with the pin</param>
private void AddPin(double x, double y, MapPinModel.PinType type, bool scroll = true, List<PlaceModel> assocPlaces = null)
{
Point scrollPoint = this.map.GetScrollPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y)));
MapCanvas.Children.Add(this.map.AddPinFromRefPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y)), type));
MapCanvas.Children.Add(this.map.AddPinFromRefPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y)), type, assocPlaces));
MapScroller.UpdateLayout();
if (scroll)
@@ -191,14 +196,28 @@ namespace CampusAppWP8.Pages.Campusmap
/// <param name="scroll">(Optional) the scroll.</param>
private void ShowCurrentPosition(bool scroll = true)
{
Utilities.DetermineAndStoreCurrentPositionForce();
if (this.Dispatcher != null)
if (Settings.AppSetting.GeoWatchEnable)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetPinToCurrentPosition(scroll)));
Utilities.DetermineAndStoreCurrentPositionForce();
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetPinToCurrentPosition(scroll)));
}
else
{
this.SetPinToCurrentPosition(scroll);
}
}
else
{
this.SetPinToCurrentPosition(scroll);
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = Visibility.Collapsed));
}
else
{
this.ProgressBar.Visibility = Visibility.Collapsed;
}
}
}
@@ -209,7 +228,19 @@ namespace CampusAppWP8.Pages.Campusmap
{
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
this.SetPinToPosition(lat, log, MapPinModel.PinType.CurrentPosition, scroll);
if (lat.Equals("0") && log.Equals("0"))
{
if (Settings.AppSetting.GeoWatchEnable)
{
MessageBoxes.ShowMainModelInfoMessageBox(AppResources.MsgBox_NoLocation);
}
this.ProgressBar.Visibility = Visibility.Collapsed;
}
else
{
this.SetPinToPosition(lat, log, MapPinModel.PinType.CurrentPosition, scroll);
}
}
/// <summary>Sets pin to position.</summary>
@@ -231,6 +262,26 @@ namespace CampusAppWP8.Pages.Campusmap
ProgressBar.Visibility = Visibility.Collapsed;
}
/// <summary>
/// Method show same PlaceInformation
/// </summary>
/// <param name="places">List of places</param>
private void ShowMapInfo(List<PlaceModel> places)
{
string msgText = string.Empty;
foreach (PlaceModel place in places)
{
msgText += AppResources.PlaceLabel_Name + ": ";
msgText += place.GetInformationsValue(Constants.PisInformationName_Name);
msgText = StringManager.AddNewLine(msgText);
msgText += AppResources.PlaceLabel_ShortDesc + ": ";
msgText += place.GetInformationsValue(Constants.PisInformationName_ShortDesc);
msgText = StringManager.AddNewLine(msgText);
}
MessageBoxes.ShowMainModelInfoMessageBox(msgText);
}
#endregion
#endregion

View File

@@ -41,7 +41,7 @@
<ListBox.ItemTemplate>
<DataTemplate>
<lui:NavigateButton Url="{Binding Path=Constants.PathPlaceNews_ShowPadPage, Source={StaticResource Const}}" QuerryStringValue="{Binding PlaceId}" QuerryStringName="{Binding Path=Constants.ParamPlaceID, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
<TextBlock Text="{Binding Informations[0].InformationValue}"/>
<TextBlock Tag="{Binding PlaceId}" Loaded="TextBlock_Loaded"/>
</lui:NavigateButton>
</DataTemplate>
</ListBox.ItemTemplate>

View File

@@ -13,6 +13,7 @@ namespace CampusAppWP8.Pages.PlaceNews
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using CampusAppWP8.Api.GeoApi;
using CampusAppWP8.File.Places;
@@ -322,6 +323,29 @@ namespace CampusAppWP8.Pages.PlaceNews
#endregion
/// <summary>
/// Method set correct text of the TextBlock
/// </summary>
/// <param name="sender">sender of the event</param>
/// <param name="e">some args</param>
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
{
TextBlock txt = sender as TextBlock;
if (txt == null)
{
return;
}
string placeID = txt.Tag as string;
if (placeID == null)
{
return;
}
PlaceModel place = this.places.Model.GetPlaceById(placeID);
txt.Text = place.GetInformationsValue(Constants.PisInformationName_Name);
}
#endregion
}
}

View File

@@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages
using CampusAppWP8.Utility.Lui.MessageBoxes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.File.Places;
/// <summary>
/// Class for the StartPage
@@ -73,7 +74,8 @@ namespace CampusAppWP8.Pages
}
if (!Settings.AppSetting.InitApp)
{
{
this.initPlaceFile();
this.initCourseList = new CourseFeed();
this.initCourseList.OnLoaded += new CourseFeed.OnIO(this.StoreCourseFeed);
this.initCourseList.LoadData();
@@ -82,6 +84,12 @@ namespace CampusAppWP8.Pages
}
}
private void initPlaceFile()
{
PlacesFile file = new PlacesFile();
file.LoadData();
}
#endregion
#region Method

View File

@@ -654,6 +654,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Akutelle Position konnte nicht bestimmt werden. Bitte schalten Sie ggf. die Ortung ein. ähnelt.
/// </summary>
public static string MsgBox_NoLocation {
get {
return ResourceManager.GetString("MsgBox_NoLocation", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Es gibt keine Ergebnisse zur gestellten Anfrage ähnelt.
/// </summary>
@@ -663,6 +672,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Platzinfo ähnelt.
/// </summary>
public static string MsgBox_PlaceInfoHeader {
get {
return ResourceManager.GetString("MsgBox_PlaceInfoHeader", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die News ähnelt.
/// </summary>
@@ -771,6 +789,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Name ähnelt.
/// </summary>
public static string PlaceLabel_Name {
get {
return ResourceManager.GetString("PlaceLabel_Name", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Beschreibung ähnelt.
/// </summary>
public static string PlaceLabel_ShortDesc {
get {
return ResourceManager.GetString("PlaceLabel_ShortDesc", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Placenews ähnelt.
/// </summary>

View File

@@ -452,4 +452,16 @@
<data name="MsgBox_NoResult" xml:space="preserve">
<value>Es gibt keine Ergebnisse zur gestellten Anfrage</value>
</data>
<data name="MsgBox_NoLocation" xml:space="preserve">
<value>Akutelle Position konnte nicht bestimmt werden. Bitte schalten Sie ggf. die Ortung ein.</value>
</data>
<data name="MsgBox_PlaceInfoHeader" xml:space="preserve">
<value>Platzinfo</value>
</data>
<data name="PlaceLabel_Name" xml:space="preserve">
<value>Name</value>
</data>
<data name="PlaceLabel_ShortDesc" xml:space="preserve">
<value>Beschreibung</value>
</data>
</root>

View File

@@ -45,6 +45,15 @@ namespace CampusAppWP8.Utility.Lui.MessageBoxes
return MessageBox.Show(text, AppResources.MsgBox_InfoHeader, MessageBoxButton.OK);
}
/// <summary>Shows the place information message box.</summary>
/// <remarks>Stubbfel, 10.09.2013.</remarks>
/// <param name="text">custom text for the box.</param>
/// <returns>result of the UserInteraction</returns>
public static MessageBoxResult ShowPlaceInfoMessageBox(string text)
{
return MessageBox.Show(text, AppResources.MsgBox_PlaceInfoHeader, MessageBoxButton.OK);
}
#endregion
}
}