diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 5494815e..3b770275 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -112,12 +112,15 @@ + + + @@ -131,6 +134,9 @@ + + RoomListPage.xaml + Exams.xaml @@ -143,6 +149,11 @@ ShowPad.xaml + + True + True + Constants.resx + @@ -262,11 +273,6 @@ True AppResources.resx - - True - True - Constants.resx - @@ -294,6 +300,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -519,8 +529,8 @@ PublicResXFileCodeGenerator - Constants.Designer.cs Designer + Constants1.Designer.cs Designer diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs index 220d403f..95552f47 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CBMainMapModel.cs @@ -2,7 +2,7 @@ // // Company copyright tag. // -// fiedlchr +// stubbfel // 13.08.2013 //----------------------------------------------------------------------------- namespace CampusAppWP8.Model.Campusmap @@ -15,7 +15,7 @@ namespace CampusAppWP8.Model.Campusmap /// /// Class for the MapModel of the mainCampus of cottbus /// - public class CBMainMapModel : MapModel + public class CBMainMapModel : CampusMapModel { #region Member @@ -46,6 +46,7 @@ namespace CampusAppWP8.Model.Campusmap this.ScaleY = 197648.8919266073; this.GeoOffsetX = 14.327159; this.GeoOffsetY = 51.766548; + this.CampusId = CBMainMapModel.Campus; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CampusMapModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CampusMapModel.cs new file mode 100644 index 00000000..812a8d78 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CampusMapModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8.Model.Campusmap +{ + public class CampusMapModel : MapModel + { + public string CampusId { get; protected set; } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingLayerModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingLayerModel.cs new file mode 100644 index 00000000..32307073 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingLayerModel.cs @@ -0,0 +1,57 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.09.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Model.GeoDb +{ + using System.Collections.Generic; + using CampusAppWP8.Resources; + + /// + /// Class is model for buildings of a campus + /// + public class CampusBuildingLayerModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// id of the layer + /// list of place which can be room of the layer + public CampusBuildingLayerModel(string layerId, List places) + { + this.LayerId = layerId; + this.Rooms = new SpsModel(); + + foreach (PlaceModel place in places) + { + string placeLayerId = place.GetInformationsValue(Constants.PisInformationName_Layer); + if (placeLayerId != null && placeLayerId.Equals(layerId)) + { + this.Rooms.Places.Add(place); + } + } + } + + #endregion + + #region property + + /// + /// Gets or sets Rooms + /// + public SpsModel Rooms { get; set; } + + /// + /// Gets or sets LayerId + /// + public string LayerId { get; set; } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingModel.cs new file mode 100644 index 00000000..fc31223a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/CampusBuildingModel.cs @@ -0,0 +1,96 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.09.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Model.GeoDb +{ + using System.Collections.Generic; + using CampusAppWP8.Resources; + + /// + /// Class is model for buildings of a campus + /// + public class CampusBuildingModel + { + #region constructor + + /// + /// Initializes a new instance of the class. + /// + /// id of the building + /// list of place which can be room of the buildings + public CampusBuildingModel(string buildingId, List places) + { + this.Layers = new Dictionary(); + + foreach (PlaceModel place in places) + { + if (place.ParentId.Equals(buildingId)) + { + string placeLayerId = place.GetInformationsValue(Constants.PisInformationName_Layer); + if (placeLayerId == null) + { + continue; + } + + if (this.Layers.ContainsKey(placeLayerId)) + { + this.Layers[placeLayerId].Rooms.Places.Add(place); + } + else + { + this.Layers.Add(placeLayerId, new CampusBuildingLayerModel(placeLayerId, new List() { place })); + } + } + else if (place.PlaceId.Equals(buildingId)) + { + this.Building = place; + } + } + } + + #endregion + + #region Property + + /// + /// Gets the Layer of the building + /// + public Dictionary Layers { get; private set; } + + /// + /// Gets or sets the Building PlaceModel + /// + public PlaceModel Building { get; set; } + + #endregion + + #region method + + /// + /// Method gets a place by their placeID + /// + /// the placeId of the place + /// The place by identifier. + public PlaceModel GetPlaceById(string placeID) + { + PlaceModel result = null; + foreach (CampusBuildingLayerModel layer in this.Layers.Values) + { + result = layer.Rooms.GetPlaceById(placeID); + if (result != null) + { + break; + } + } + + return result; + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs index 799b0757..3d2ecfe4 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs @@ -87,6 +87,11 @@ namespace CampusAppWP8.Model.GeoDb [XmlElement("placeService")] public ObservableCollection Services { get; set; } + /// + /// Gets or sets a string, which is the caption of the place (e.g. for contents of UIElements) + /// + public string Caption { get; set; } + #endregion #region Method diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 74fadd03..5f3fe554 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -11,10 +11,11 @@ namespace CampusAppWP8.Pages.Campusmap using System.Collections.Generic; using System.Device.Location; using System.Globalization; + using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading; using System.Windows; - using System.Windows.Navigation; + using System.Windows.Navigation; using CampusAppWP8.Model.Campusmap; using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Resources; @@ -35,7 +36,7 @@ namespace CampusAppWP8.Pages.Campusmap private readonly ProximityDevice device = ProximityDevice.GetDefault(); /// Variable for the map model. - private MapModel map; + private CampusMapModel campusMap; /// /// List of information names @@ -56,9 +57,9 @@ namespace CampusAppWP8.Pages.Campusmap public CampusMapPage() { this.InitializeComponent(); - this.map = new CBMainMapModel(); - this.MapCanvas.DataContext = this.map; - this.map.ShowMapInfos += new CBMainMapModel.MapInfos(this.ShowMapInfo); + this.campusMap = new CBMainMapModel(); + this.MapCanvas.DataContext = this.campusMap; + this.campusMap.ShowMapInfos += new CBMainMapModel.MapInfos(this.ShowMapInfo); ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem; ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem; @@ -86,7 +87,7 @@ namespace CampusAppWP8.Pages.Campusmap protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (this.map.Spatial == null) + if (this.campusMap.Spatial == null) { return; } @@ -134,7 +135,7 @@ namespace CampusAppWP8.Pages.Campusmap /// list of placeId /// type of pin /// (optional) if its true, clear canvas before adding - private void AddPinsByPids(List pidList, MapPinModel.PinType pinType, bool clearCanvas = true) + private void AddPinsByPids(List pidList, MapPinModel.PinType pinType, bool clearCanvas = true) { // clear canvas if (clearCanvas) @@ -153,13 +154,13 @@ namespace CampusAppWP8.Pages.Campusmap foreach (string pid in pidList) { - tmpPlace = this.map.Spatial.GetPlaceById(pid); + tmpPlace = this.campusMap.Spatial.GetPlaceById(pid); if (tmpPlace != null) { placeList.Add(tmpPlace); } } - + // add pins to map if (placeList.Count > 0) { @@ -236,8 +237,8 @@ namespace CampusAppWP8.Pages.Campusmap if (this.Dispatcher != null) { this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail))); - } - else + } + else { MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail); } @@ -246,8 +247,8 @@ namespace CampusAppWP8.Pages.Campusmap if (this.Dispatcher != null) { this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = Visibility.Collapsed)); - } - else + } + else { this.ProgressBar.Visibility = Visibility.Collapsed; } @@ -276,6 +277,12 @@ namespace CampusAppWP8.Pages.Campusmap /// The found places. private List SearchPlaces(string query) { + // if query is an id + if (Wp8StringManager.IsDigitsOnly(query)) + { + return new List() { this.campusMap.Spatial.GetPlaceById(query) }; + } + if (this.informationsNames == null) { this.informationsNames = new List(); @@ -284,7 +291,7 @@ namespace CampusAppWP8.Pages.Campusmap this.informationsNames.Add(Constants.PisInformationName_ShortName); } - return this.map.Spatial.GetPlacesByInformation(query, true, this.informationsNames); + return this.campusMap.Spatial.GetPlacesByInformation(query, true, this.informationsNames); } /// Adds the pins. @@ -315,8 +322,8 @@ namespace CampusAppWP8.Pages.Campusmap /// (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, assocPlaces)); + Point scrollPoint = this.campusMap.GetScrollPoint(this.campusMap.ConverToPixelPoint(this.campusMap.ConverToMapPoint(x, y))); + MapCanvas.Children.Add(this.campusMap.AddPinFromRefPoint(this.campusMap.ConverToPixelPoint(this.campusMap.ConverToMapPoint(x, y)), type, assocPlaces)); MapScroller.UpdateLayout(); if (scroll) @@ -432,12 +439,56 @@ namespace CampusAppWP8.Pages.Campusmap msgText += AppResources.PlaceLabel_Name + ": "; msgText += place.GetInformationsValue(Constants.PisInformationName_Name); msgText = Wp8StringManager.AddNewLine(msgText); - msgText += AppResources.PlaceLabel_ShortDesc + ": "; - msgText += place.GetInformationsValue(Constants.PisInformationName_ShortDesc); - msgText = Wp8StringManager.AddNewLine(msgText); + + string shortDesc = place.GetInformationsValue(Constants.PisInformationName_ShortDesc); + if (shortDesc == null) + { + shortDesc = place.GetInformationsValue(Constants.PisInformationName_Typ); + } + + if (shortDesc != null) + { + msgText += AppResources.PlaceLabel_ShortDesc + ": "; + msgText += shortDesc; + msgText = Wp8StringManager.AddNewLine(msgText); + } } MessageBoxes.ShowMainModelInfoMessageBox(msgText); + + foreach (PlaceModel place in places) + { + + if (place.ParentId.Equals(this.campusMap.CampusId) && this.HasRooms(place.PlaceId)) + { + MessageBoxResult msgResult = MessageBoxes.ShowPlaceInfoOkCancelMessageBox("Für " + place.GetInformationsValue((Constants.PisInformationName_Name)) + " gibt es eine Raumübersicht. Soll diese angezeigt werden"); + if (msgResult.Equals(MessageBoxResult.OK)) + { + string urlString = Constants.PathCampusmap_RoomListPage; + urlString += "?" + Constants.ParamBuildingId+ "=" + place.PlaceId; + Uri url = new Uri(urlString as string, UriKind.Relative); + this.NavigationService.Navigate(url); + return; + } + } + } + } + + /// + /// Method check if a certain place has some rooms + /// + /// the place id + /// true, if the place has got rooms, otherwise false + private bool HasRooms(string placeId) + { + foreach (PlaceModel place in this.campusMap.Spatial.Places) + { + if (place.ParentId.Equals(placeId)) + { + return true; + } + } + return false; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml new file mode 100644 index 00000000..be326965 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs new file mode 100644 index 00000000..dc0cac40 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs @@ -0,0 +1,162 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.09.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Pages.Campusmap +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Windows.Navigation; + using CampusAppWP8.File.Places; + using CampusAppWP8.Model.GeoDb; + using CampusAppWP8.Resources; + using Microsoft.Phone.Controls; + using CampusAppWP8.Utility.Lui.MessageBoxes; + + /// + /// Class of the RoomListPage + /// + public partial class RoomListPage : PhoneApplicationPage + { + #region Members + /// + /// Variable of placeFile + /// + private PlacesFile placeFile; + + /// + /// Variable of building which is shown in the list + /// + private CampusBuildingModel building; + + #endregion + + #region Constructor + + /// Initializes a new instance of the class. + /// Stubbfel, 19.08.2013. + public RoomListPage() + { + this.InitializeComponent(); + } + + #endregion + + #region Method + + #region protected + + /// Methods overrides the OnNavigatedTo-Method. + /// Stubbfel, 19.08.2013. + /// some NavigationEventArgs. + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + if (this.placeFile == null) + { + this.placeFile = new PlacesFile(); + this.placeFile.OnLoaded += new PlacesFile.OnIO(this.PlacesFileIsReady); + this.placeFile.OnFailedLoad += new PlacesFile.OnFailed(this.PlacesFileIsFail); + this.placeFile.LoadData(); + } + } + + #endregion + + #region private + /// + /// Callback of the PlaceFile, if load failed + /// + private void PlacesFileIsFail() + { + MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoad); + } + + /// + /// Callback of the PlaceFile, if load was successful + /// + private void PlacesFileIsReady() + { + if (this.placeFile.Model != null) + { + this.SetupPivot(); + } + } + + /// + /// Method setup the PivotElement + /// + private void SetupPivot() + { + if (NavigationContext.QueryString.ContainsKey(Constants.ParamBuildingId)) + { + this.building = new CampusBuildingModel(NavigationContext.QueryString[Constants.ParamBuildingId], this.placeFile.Model.Places.ToList()); + + if (this.building != null && this.building.Layers != null && this.building.Layers.Count > 0) + { + this.SetCaptionsToRooms(); + this.RoomPivot.ItemsSource = this.GetSortedLayers(this.building); + } + else + { + MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoad); + } + } + else + { + MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoad); + } + + } + + /// + /// Method sorts the Layers + /// + /// building of the layers + /// sorted Dictionary + private Dictionary GetSortedLayers(CampusBuildingModel build) + { + Dictionary result = new Dictionary(); + foreach (CampusBuildingLayerModel layer in build.Layers.Values) + { + var sortRom = from place in layer.Rooms.Places + orderby place.GetInformationsValue(Constants.PisInformationName_Typ), place.GetInformationsValue(Constants.PisInformationName_Name) + select place; + result.Add(layer.LayerId, new CampusBuildingLayerModel(layer.LayerId, sortRom.ToList())); + } + + return result; + } + + /// + /// Method set all rooms a formatted string , which will be show as buttonContent + /// + private void SetCaptionsToRooms() + { + string name; + string type; + foreach (CampusBuildingLayerModel layer in this.building.Layers.Values) + { + foreach (PlaceModel place in layer.Rooms.Places) + { + name = place.GetInformationsValue(Constants.PisInformationName_Name); + type = place.GetInformationsValue(Constants.PisInformationName_Typ); + if (name != null && type != null) + { + place.Caption = name + " (" + type + ")"; + } + } + } + } + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs index 6ad59c34..e4a529f5 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs @@ -418,7 +418,6 @@ namespace CampusAppWP8.Pages.PlaceNews txt.Text = place.GetInformationsValue(Constants.PisInformationName_Name); } - /// Handler, called when the ndef. /// Stubbfel, 22.08.2013. /// The sender. diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 09dd5d5f..c2faecea 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -525,4 +525,13 @@ NDEF + + BuildingId + + + /Pages/Campusmap/RoomListPage.xaml + + + Ebene + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs similarity index 98% rename from CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs rename to CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4595325a..678ece02 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -573,6 +573,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die BuildingId ähnelt. + /// + public static string ParamBuildingId { + get { + return ResourceManager.GetString("ParamBuildingId", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt. /// @@ -699,6 +708,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Campusmap/RoomListPage.xaml ähnelt. + /// + public static string PathCampusmap_RoomListPage { + get { + return ResourceManager.GetString("PathCampusmap_RoomListPage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Departments/DepartmentFavoritePage.xaml ähnelt. /// @@ -942,6 +960,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Ebene ähnelt. + /// + public static string PisInformationName_Layer { + get { + return ResourceManager.GetString("PisInformationName_Layer", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Name ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs index a095990b..af439b41 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs @@ -54,6 +54,15 @@ namespace CampusAppWP8.Utility.Lui.MessageBoxes return MessageBox.Show(text, AppResources.MsgBox_PlaceInfoHeader, MessageBoxButton.OK); } + /// Shows the place information message box (OKCancel-Box). + /// Stubbfel, 10.09.2013. + /// custom text for the box. + /// result of the UserInteraction + public static MessageBoxResult ShowPlaceInfoOkCancelMessageBox(string text) + { + return MessageBox.Show(text, AppResources.MsgBox_PlaceInfoHeader, MessageBoxButton.OKCancel); + } + #endregion } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index 75be2464..c373f1ff 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -127,7 +127,7 @@ namespace CampusAppWP8.Utility } else { - retValue.AddRange(GetChild(child as DependencyObject, elemName)); + retValue.AddRange(Utilities.GetChild(child as DependencyObject, elemName)); } }