diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 55c47531..65a2fc88 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -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(); } } diff --git a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs index 5a3e57f1..df16df60 100644 --- a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs +++ b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs @@ -10,7 +10,8 @@ namespace CampusAppWP8.File.Places { using CampusAppWP8.Model; using CampusAppWP8.Model.GeoDb; -using CampusAppWP8.Resources; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; /// Places file. /// Stubbfel, 09.09.2013. @@ -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; } - + + /// + /// Method load OfflineMap as Fallback + /// + private void FallBackLoad() + { + SpsModel fallBackModel = XmlManager.DeserializationFileToModel(Constants.FileMap_OfflineMap); + this.Model = fallBackModel; + this.SaveData(); + } + #endregion } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs index f955f2dc..10f39661 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs @@ -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; /// /// Class for the MapModel of the mainCampus of cottbus @@ -22,6 +22,11 @@ namespace CampusAppWP8.Model.Campusmap /// Variable for the identify of the campus. private static readonly string Campus = ((int)CampusAppWP8.Model.Setting.UserProfilModel.Campus.CB_MAIN).ToString(); + /// + /// Variable for the PlaceFile + /// + private PlacesFile file; + #endregion #region Constructor @@ -51,7 +56,21 @@ namespace CampusAppWP8.Model.Campusmap /// Stubbfel, 19.08.2013. protected override void LoadSpatials() { - SpsModel model = XmlManager.DeserializationFileToModel(Constants.FileMap_OfflineMap); + if (this.file == null) + { + this.file = new PlacesFile(); + } + + this.file.OnLoaded += new PlacesFile.OnIO(this.FileIsReady); + this.file.LoadData(); + } + + /// + /// Method is called if the PlaceFile is loaded + /// + private void FileIsReady() + { + SpsModel model = this.file.Model; this.Spatial = new SpsModel(); foreach (PlaceModel place in model.Places) diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs index 421d4fc8..40c97791 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs @@ -6,10 +6,12 @@ // 24.06.2013 //---------------------------------------------------------------------- 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 + + /// + /// Delegate for MapInfo + /// + /// list of places + public delegate void MapInfos(List places); + + /// + /// Event ShowMapInfo + /// + public event MapInfos ShowMapInfos = null; + + #endregion #region Property /// @@ -121,11 +137,12 @@ namespace CampusAppWP8.Model.Campusmap /// the x- coordinate. /// the y-coordinate. /// The type. + /// list of places /// image of the pin. - public Image AddPin(double x, double y, MapPinModel.PinType type) + public Image AddPin(double x, double y, MapPinModel.PinType type, List places = null) { Point position = new Point(x, y); - return this.AddPin(position, type); + return this.AddPin(position, type, places); } /// @@ -136,11 +153,12 @@ namespace CampusAppWP8.Model.Campusmap /// the x-coordinate. /// the y-coordinate. /// The type. + /// list of places /// image of the pin. - public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type) + public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type, List 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); } /// @@ -150,22 +168,24 @@ namespace CampusAppWP8.Model.Campusmap /// Stubbfel, 27.08.2013. /// input point. /// The type. + /// list of places /// image of the pin. - public Image AddPinFromRefPoint(Point position, MapPinModel.PinType type) + public Image AddPinFromRefPoint(Point position, MapPinModel.PinType type, List places = null) { - return this.AddPinFromRefPoint(position.X, position.Y, type); + return this.AddPinFromRefPoint(position.X, position.Y, type, places); } /// Method create in image, which can show at a certain position. /// Stubbfel, 27.08.2013. /// input point. /// The type. + /// list of places /// image of the pin. - public Image AddPin(Point position, MapPinModel.PinType type) + public Image AddPin(Point position, MapPinModel.PinType type, List 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 /// Creates a pin. /// Stubbfel, 27.08.2013. /// The type. + /// list of places + /// image of the pin /// The new pin. - private MapPinModel CreatePin(MapPinModel.PinType type) + private MapPinModel CreatePin(MapPinModel.PinType type, List 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 diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs index 37b1bc7a..44cc5451 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs @@ -8,6 +8,7 @@ namespace CampusAppWP8.Model.Campusmap { using System.Windows; + using System.Windows.Input; /// /// This Class manage the properties of a MapPin diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs index 78edcb0e..15b62fc3 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs @@ -8,7 +8,8 @@ namespace CampusAppWP8.Model.Campusmap { - using System.Windows; + using System.Collections.Generic; + using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Resources; /// Search pin place model. @@ -31,5 +32,33 @@ namespace CampusAppWP8.Model.Campusmap } #endregion + + #region property + + /// + /// Gets or sets Callback Function, to show place information of the Pin + /// + public MapModel.MapInfos CallBack { get; set; } + + /// + /// Gets or sets place which are associative with this pin + /// + public List AssocPlaces { get; set; } + + #endregion + + #region Method + + /// + /// Show Information of this pin places + /// + /// sender of the Event + /// MouseButtonEvent Arguments + public void ShowInfo(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + this.CallBack(this.AssocPlaces); + } + + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs index 2758cfcc..758b2ef1 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs @@ -207,6 +207,24 @@ namespace CampusAppWP8.Model.GeoDb return true; } + /// + /// Method gets the InformationValue of a certain InformationName + /// + /// string for InformationName + /// value of the information + public string GetInformationsValue(string key) + { + foreach (PlaceInformation info in this.Informations) + { + if (info.InformationName.Equals(key)) + { + return info.InformationValue; + } + } + + return null; + } + #endregion } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 87c8ed5e..6062f5e8 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -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; /// Class for the campusMap page. @@ -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 assocPlaces = new List(); + assocPlaces.Add(place); + this.AddPin(coor.Longitude, coor.Latitude, type, scroll, assocPlaces); } } } @@ -150,10 +154,11 @@ namespace CampusAppWP8.Pages.Campusmap /// latitude parameter. /// The type. /// (Optional) the scroll. - private void AddPin(double x, double y, MapPinModel.PinType type, bool scroll = true) + /// (Optional) List of places, whose are associative with the pin + private void AddPin(double x, double y, MapPinModel.PinType type, bool scroll = true, List 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 /// (Optional) the scroll. 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(Constants.GeoWatch_CurrentPosition_Lat); string log = App.LoadFromAppState(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); + } } /// Sets pin to position. @@ -231,6 +262,26 @@ namespace CampusAppWP8.Pages.Campusmap ProgressBar.Visibility = Visibility.Collapsed; } + /// + /// Method show same PlaceInformation + /// + /// List of places + private void ShowMapInfo(List 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 diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml index 52cbd5de..cf5ae132 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml @@ -41,7 +41,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs index b8c4ef91..f0e1e317 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs @@ -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 + /// + /// Method set correct text of the TextBlock + /// + /// sender of the event + /// some args + 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 } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index 459a5316..3bd7cdc6 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; + using CampusAppWP8.File.Places; /// /// 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 diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 8acbfeac..1840f04c 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -654,6 +654,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Akutelle Position konnte nicht bestimmt werden. Bitte schalten Sie ggf. die Ortung ein. ähnelt. + /// + public static string MsgBox_NoLocation { + get { + return ResourceManager.GetString("MsgBox_NoLocation", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Es gibt keine Ergebnisse zur gestellten Anfrage ähnelt. /// @@ -663,6 +672,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Platzinfo ähnelt. + /// + public static string MsgBox_PlaceInfoHeader { + get { + return ResourceManager.GetString("MsgBox_PlaceInfoHeader", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die News ähnelt. /// @@ -771,6 +789,24 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Name ähnelt. + /// + public static string PlaceLabel_Name { + get { + return ResourceManager.GetString("PlaceLabel_Name", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Beschreibung ähnelt. + /// + public static string PlaceLabel_ShortDesc { + get { + return ResourceManager.GetString("PlaceLabel_ShortDesc", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Placenews ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 133f3b14..3fd4d90c 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -452,4 +452,16 @@ Es gibt keine Ergebnisse zur gestellten Anfrage + + Akutelle Position konnte nicht bestimmt werden. Bitte schalten Sie ggf. die Ortung ein. + + + Platzinfo + + + Name + + + Beschreibung + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs index 45d20f39..a095990b 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs @@ -45,6 +45,15 @@ namespace CampusAppWP8.Utility.Lui.MessageBoxes return MessageBox.Show(text, AppResources.MsgBox_InfoHeader, MessageBoxButton.OK); } + /// Shows the place information message box. + /// Stubbfel, 10.09.2013. + /// custom text for the box. + /// result of the UserInteraction + public static MessageBoxResult ShowPlaceInfoMessageBox(string text) + { + return MessageBox.Show(text, AppResources.MsgBox_PlaceInfoHeader, MessageBoxButton.OK); + } + #endregion } }