add testmap
This commit is contained in:
BIN
CampusAppWP8/CampusAppWP8/Assets/campusmap.png
Normal file
BIN
CampusAppWP8/CampusAppWP8/Assets/campusmap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -358,6 +358,7 @@
|
||||
<Content Include="Assets\ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\campusmap.png" />
|
||||
<Content Include="Assets\Icons\DarkTheme\add_159.png" />
|
||||
<Content Include="Assets\Icons\DarkTheme\btulogo_159.png" />
|
||||
<Content Include="Assets\Icons\DarkTheme\campus_159.png" />
|
||||
|
||||
@@ -70,6 +70,11 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
/// </summary>
|
||||
public double Scale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Scale (to pixel) of the map
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reference point
|
||||
/// </summary>
|
||||
@@ -159,7 +164,8 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
/// <returns>Point in pixel-size</returns>
|
||||
public Point ConverToPixelPoint(double x, double y)
|
||||
{
|
||||
return new Point { X = this.Scale * x, Y = this.Scale * y };
|
||||
Point p = new Point { X = this.Scale * x, Y = (this.Scale * y) / this.Ratio};
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,6 +178,27 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
return this.ConverToPixelPoint(point.X, point.Y);
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// Convert a coordinates to coordinates which address pixels
|
||||
/// </summary>
|
||||
/// <param name="x">the x-coordinate</param>
|
||||
/// <param name="y">the y-coordinate</param>
|
||||
/// <returns>Point in pixel-size</returns>
|
||||
public Point ConverToMapPoint(double x, double y)
|
||||
{
|
||||
return new Point { X = x - this.GeoOffsetX, Y = (y - this.GeoOffsetY)};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a coordinates to coordinates which address pixels
|
||||
/// </summary>
|
||||
/// <param name="point">not scaled point</param>
|
||||
/// <returns>Point in pixel-size</returns>
|
||||
public Point ConverToMapPoint(Point point)
|
||||
{
|
||||
return this.ConverToMapPoint(point.X, point.Y);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.Campusmap
|
||||
{
|
||||
using CampusAppWP8.Resources;
|
||||
using System.Windows;
|
||||
|
||||
/// <summary>
|
||||
@@ -22,13 +23,14 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
private Point position;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MapPinModel" /> class.
|
||||
/// </summary>
|
||||
public MapPinModel()
|
||||
{
|
||||
this.ImageSource = "/Assets/icons/search_159_light.png";
|
||||
this.ImageSource = Icons.Search;
|
||||
this.ImageWidth = 60;
|
||||
this.ImageHeight = 60;
|
||||
this.PinImageOffsetX = -24;
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Name="XPoint" Grid.Column="0" Text="0" />
|
||||
<TextBox Name="YPoint" Grid.Column="1" Text="0"/>
|
||||
<TextBox Name="XPoint" Grid.Column="0" Text="14,322364" />
|
||||
<TextBox Name="YPoint" Grid.Column="1" Text="51,765760725"/>
|
||||
<Button Grid.Column="2" Click="Button_Click">
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Search, Source={StaticResource ThemelizedIcons}}" Width="60"/>
|
||||
</Button>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
public CampusMapPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.map = new MapModel() { ImageSource = "/Assets/testmap.png", ImageWidth = 2000, ImageHeight = 2000, MapImageOffsetX = -228, MapImageOffsetY = -300, RefPoint = new Point(1000, 1000), Scale = 20};
|
||||
this.map = new MapModel() { ImageSource = "/Assets/campusmap.png", ImageWidth = 2000, ImageHeight = 1425, MapImageOffsetX = -228, MapImageOffsetY = -300, RefPoint = new Point(625, 900), Scale = 127118.6440677966, Ratio = 0.7125, GeoOffsetX = 14.32141, GeoOffsetY = 51.76599 };
|
||||
this.MapCanvas.DataContext = map;
|
||||
|
||||
}
|
||||
@@ -32,8 +32,8 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MapCanvas.Children.Clear();
|
||||
Point scrollPoint = map.GetScrollPoint(map.ConverToPixelPoint(double.Parse(XPoint.Text), double.Parse(YPoint.Text)));
|
||||
MapCanvas.Children.Add(map.AddPinFromRefPoint(map.ConverToPixelPoint(double.Parse(XPoint.Text), double.Parse(YPoint.Text))));
|
||||
Point scrollPoint = map.GetScrollPoint(map.ConverToPixelPoint(map.ConverToMapPoint(double.Parse(XPoint.Text), double.Parse(YPoint.Text))));
|
||||
MapCanvas.Children.Add(map.AddPinFromRefPoint(map.ConverToPixelPoint(map.ConverToMapPoint(double.Parse(XPoint.Text), double.Parse(YPoint.Text)))));
|
||||
|
||||
MapScroller.ScrollToVerticalOffset(scrollPoint.Y);
|
||||
MapScroller.ScrollToHorizontalOffset(scrollPoint.X);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<Capability Name="ID_CAP_PHONEDIALER" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="pages/StartPage.xaml" />
|
||||
<DefaultTask Name="_default" NavigationPage="pages/Campusmap/CampusMapPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">
|
||||
|
||||
Reference in New Issue
Block a user