diff --git a/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/current_position_159.png b/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/current_position_159.png new file mode 100644 index 00000000..47ed68d2 Binary files /dev/null and b/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/current_position_159.png differ diff --git a/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/search_place_159.png b/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/search_place_159.png new file mode 100644 index 00000000..2b8797ca Binary files /dev/null and b/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/search_place_159.png differ diff --git a/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/current_position_159.png b/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/current_position_159.png new file mode 100644 index 00000000..47ed68d2 Binary files /dev/null and b/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/current_position_159.png differ diff --git a/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/search_place_159.png b/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/search_place_159.png new file mode 100644 index 00000000..2b8797ca Binary files /dev/null and b/CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/search_place_159.png differ diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index b86cead6..b2d262b0 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -105,6 +105,9 @@ + + + @@ -391,15 +394,18 @@ + + + @@ -422,6 +428,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/CurrentPositionPinModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CurrentPositionPinModel.cs new file mode 100644 index 00000000..8bb3347d --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/CurrentPositionPinModel.cs @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 27.08.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Model.Campusmap +{ + using System.Windows; + using CampusAppWP8.Resources; + + /// Current position pin model. + /// Stubbfel, 27.08.2013. + public class CurrentPositionPinModel : MapPinModel + { + /// Initializes a new instance of the CurrentPositionPinModel class. + /// Stubbfel, 27.08.2013. + public CurrentPositionPinModel() + { + this.ImageSource = Icons.CurrentPosition; + this.ImageWidth = 60; + this.ImageHeight = 60; + this.PinImageOffsetX = -25; + this.PinImageOffsetY = -34; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/HiddenPinPlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/HiddenPinPlaceModel.cs new file mode 100644 index 00000000..e684b3d9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/HiddenPinPlaceModel.cs @@ -0,0 +1,15 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 13.08.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Model.Campusmap +{ + /// Hidden pin place model. + /// Stubbfel, 27.08.2013. + public class HiddenPinPlaceModel : MapPinModel + { + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs index 38e1ef38..49a5009d 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs @@ -114,60 +114,73 @@ namespace CampusAppWP8.Model.Campusmap return new Point(x, y); } - /// - /// Method create in image, which can show at a certain position - /// - /// the x- coordinate - /// the y-coordinate - /// image of the pin - public Image AddPin(double x, double y) + /// Method create in image, which can show at a certain position. + /// Stubbfel, 27.08.2013. + /// the x- coordinate. + /// the y-coordinate. + /// The type. + /// image of the pin. + public Image AddPin(double x, double y, MapPinModel.PinType type) { Point position = new Point(x, y); - return this.AddPin(position); + return this.AddPin(position, type); } /// - /// Method create in image, which can show at a certain position depend of the + /// Method create in image, which can show at a certain position depend of the + /// /// - /// the x-coordinate - /// the y-coordinate - /// image of the pin - public Image AddPinFromRefPoint(double x, double y) + /// Stubbfel, 27.08.2013. + /// the x-coordinate. + /// the y-coordinate. + /// The type. + /// image of the pin. + public Image AddPinFromRefPoint(double x, double y, MapPinModel.PinType type) { Point position = new Point(this.RefPoint.X + x, this.RefPoint.Y - y); - return this.AddPin(position); + return this.AddPin(position, type); } /// - /// Method create in image, which can show at a certain position depend of the + /// Method create in image, which can show at a certain position depend of the + /// /// - /// input point - /// image of the pin - public Image AddPinFromRefPoint(Point position) + /// Stubbfel, 27.08.2013. + /// input point. + /// The type. + /// image of the pin. + public Image AddPinFromRefPoint(Point position, MapPinModel.PinType type) { - return this.AddPinFromRefPoint(position.X, position.Y); + return this.AddPinFromRefPoint(position.X, position.Y, type); } - /// - /// Method create in image, which can show at a certain position - /// - /// input point - /// image of the pin - public Image AddPin(Point position) + /// Method create in image, which can show at a certain position. + /// Stubbfel, 27.08.2013. + /// input point. + /// The type. + /// image of the pin. + public Image AddPin(Point position, MapPinModel.PinType type) { - MapPinModel pin = new MapPinModel() { Position = position }; - Image pinImg = new Image() { Source = new BitmapImage(new Uri(pin.ImageSource, UriKind.Relative)), Width = pin.ImageWidth }; + MapPinModel pin = this.CreatePin(type); + pin.Position = position; + Image pinImg = new Image(); + 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); return pinImg; } - /// - /// Convert a coordinates to coordinates which address pixels - /// - /// the x-coordinate - /// the y-coordinate - /// Point in pixel-size + /// Convert a coordinates to coordinates which address pixels. + /// Stubbfel, 27.08.2013. + /// the x-coordinate. + /// the y-coordinate. + /// Point in pixel-size. public Point ConverToPixelPoint(double x, double y) { Point p = new Point { X = this.ScaleX * x, Y = this.ScaleY * y }; @@ -210,6 +223,29 @@ namespace CampusAppWP8.Model.Campusmap protected virtual void LoadSpatials() { } + + /// Creates a pin. + /// Stubbfel, 27.08.2013. + /// The type. + /// The new pin. + private MapPinModel CreatePin(MapPinModel.PinType type) + { + MapPinModel pin; + switch (type) + { + case MapPinModel.PinType.CurrentPosition: + pin = new CurrentPositionPinModel(); + break; + case MapPinModel.PinType.SearchPlace: + pin = new SearchPlacePinModel(); + break; + default: + pin = new HiddenPinPlaceModel(); + break; + } + + return pin; + } #endregion } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs index a46cacaa..37b1bc7a 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/MapPinModel.cs @@ -8,12 +8,11 @@ namespace CampusAppWP8.Model.Campusmap { using System.Windows; - using CampusAppWP8.Resources; /// /// This Class manage the properties of a MapPin /// - public class MapPinModel + public abstract class MapPinModel { #region Member @@ -30,15 +29,26 @@ namespace CampusAppWP8.Model.Campusmap /// public MapPinModel() { - this.ImageSource = Icons.Search; - this.ImageWidth = 60; - this.ImageHeight = 60; - this.PinImageOffsetX = -25; - this.PinImageOffsetY = -27; } #endregion + #region enums + /// Values that represent PinType. + /// Stubbfel, 27.08.2013. + public enum PinType + { + /// An enum constant representing the hidden option. + Hidden = 0, + + /// An enum constant representing the search place option. + SearchPlace = 1, + + /// An enum constant representing the current position option. + CurrentPosition = 2 + } + #endregion + #region Property /// diff --git a/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs b/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs new file mode 100644 index 00000000..4cba699a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Campusmap/SearchPlacePinModel.cs @@ -0,0 +1,31 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 27.08.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Model.Campusmap +{ + using System.Windows; + using CampusAppWP8.Resources; + + /// Search pin place model. + /// Stubbfel, 27.08.2013. + public class SearchPlacePinModel : MapPinModel + { + /// + /// Initializes a new instance of the class. + /// + /// Stubbfel, 27.08.2013. + public SearchPlacePinModel() + { + this.ImageSource = Icons.SearchPlace; + this.ImageWidth = 60; + this.ImageHeight = 60; + this.PinImageOffsetX = -25; + this.PinImageOffsetY = -27; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index deaa55c5..c7c77f94 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -46,15 +46,19 @@ namespace CampusAppWP8.Pages.Campusmap { MapCanvas.Children.Clear(); - string alias = "campus"; bool scroll = true; + string alias = "campus"; if (NavigationContext.QueryString.ContainsKey(Constants.ParamModelMap_SearchTermAlias)) { alias = NavigationContext.QueryString[Constants.ParamModelMap_SearchTermAlias]; + this.AddPins(this.SearchPlaces(alias), MapPinModel.PinType.SearchPlace); scroll = false; } + else + { + this.AddPins(this.SearchPlaces(alias), MapPinModel.PinType.Hidden); + } - this.AddPins(this.SearchPlaces(alias)); this.ShowCurrentPositionDispatcher(scroll); } } @@ -82,7 +86,7 @@ namespace CampusAppWP8.Pages.Campusmap } MapCanvas.Children.Clear(); - this.AddPins(this.SearchPlaces(query)); + this.AddPins(this.SearchPlaces(query), MapPinModel.PinType.SearchPlace); } /// Searches for the first places. @@ -97,15 +101,16 @@ namespace CampusAppWP8.Pages.Campusmap /// Adds the pins. /// Stubbfel, 19.08.2013. /// The places. + /// The type. /// (Optional) the scroll. - private void AddPins(List places, bool scroll = true) + private void AddPins(List places, MapPinModel.PinType type, bool scroll = true) { foreach (PlaceModel place in places) { GeoCoordinate coor = place.GeoRefPoint; if (coor != null) { - this.AddPin(coor.Longitude, coor.Latitude, scroll); + this.AddPin(coor.Longitude, coor.Latitude, type, scroll); } } } @@ -114,11 +119,12 @@ namespace CampusAppWP8.Pages.Campusmap /// Stubbfel, 19.08.2013. /// longitude parameter. /// latitude parameter. + /// The type. /// (Optional) the scroll. - private void AddPin(double x, double y, bool scroll = true) + private void AddPin(double x, double y, MapPinModel.PinType type, bool scroll = true) { 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)))); + MapCanvas.Children.Add(this.map.AddPinFromRefPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y)), type)); MapScroller.UpdateLayout(); if (scroll) @@ -174,15 +180,16 @@ namespace CampusAppWP8.Pages.Campusmap { string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat); string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long); - this.SetPinToPosition(lat, log, scroll); + this.SetPinToPosition(lat, log, MapPinModel.PinType.CurrentPosition, scroll); } /// Sets pin to position. /// Stubbfel, 27.08.2013. /// The latitude. /// The longitude. + /// The type. /// (Optional) the scroll. - private void SetPinToPosition(string latitude, string longitude, bool scroll = true) + private void SetPinToPosition(string latitude, string longitude, MapPinModel.PinType type, bool scroll = true) { double x; double y; @@ -191,7 +198,7 @@ namespace CampusAppWP8.Pages.Campusmap return; } - this.AddPin(x, y, scroll); + this.AddPin(x, y, type, scroll); ProgressBar.Visibility = Visibility.Collapsed; } } diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs index 7d6a9c8a..4d91d96d 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs @@ -66,6 +66,17 @@ namespace CampusAppWP8.Resources } } + /// + /// Gets the uri string of the CurrentPosition icon. + /// + public static string CurrentPosition + { + get + { + return Themerize("current_position_159.png"); + } + } + /// /// Gets the uri string of the Delete icon. /// @@ -264,6 +275,17 @@ namespace CampusAppWP8.Resources } } + /// + /// Gets the uri string of the SearchPlace icon. + /// + public static string SearchPlace + { + get + { + return Themerize("search_place_159.png"); + } + } + /// /// Gets the uri string of the StudentCouncil icon. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx index f981d217..7cd96949 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx @@ -129,6 +129,9 @@ info_159.png + + current_position_159.png + delete_159.png @@ -183,6 +186,9 @@ search_159.png + + search_place_159.png + student_council_159.png diff --git a/CampusAppWP8/CampusAppWP8/Settings.StyleCop b/CampusAppWP8/CampusAppWP8/Settings.StyleCop index 1b4199b4..ea0eb655 100644 --- a/CampusAppWP8/CampusAppWP8/Settings.StyleCop +++ b/CampusAppWP8/CampusAppWP8/Settings.StyleCop @@ -1,6 +1,7 @@ + enum Stubbfel diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs index 19521cc9..7247612e 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs @@ -78,6 +78,7 @@ namespace CampusAppWP8.Utility.Lui.Button { urlString += "?" + Constants.ParamModelMap_SearchTermAlias + "=" + this.SearchTerm; } + Uri url = new Uri(urlString as string, UriKind.Relative); Page page = App.RootFrame.Content as Page; page.NavigationService.Navigate(url);