add mapmodel
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalizedStrings.cs" />
|
||||
<Compile Include="Model\Campusmap\MapModel.cs" />
|
||||
<Compile Include="Model\Departments\ChairModel.cs" />
|
||||
<Compile Include="Model\Departments\DepartmentModel.cs" />
|
||||
<Compile Include="Model\Departments\DepartmentViewModel.cs" />
|
||||
|
||||
62
CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs
Normal file
62
CampusAppWP8/CampusAppWP8/Model/Campusmap/MapModel.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="LectureActivity.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>20.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.Campusmap
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
|
||||
public class MapModel
|
||||
{
|
||||
|
||||
public MapModel()
|
||||
{
|
||||
}
|
||||
|
||||
public string ImageSource { get; set; }
|
||||
public double ImageWidth { get; set; }
|
||||
public double ImageHeight { get; set; }
|
||||
|
||||
public double MapOffsetX { get; set; }
|
||||
public double MapOffsetY { get; set; }
|
||||
|
||||
public Point RefPoint { get; set; }
|
||||
|
||||
public Point GetMapPoint(double x, double y)
|
||||
{
|
||||
x += this.MapOffsetX;
|
||||
y += this.MapOffsetY;
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public Point GetMapPoint(Point point)
|
||||
{
|
||||
|
||||
return this.GetMapPoint(point.X, point.Y);
|
||||
}
|
||||
|
||||
public Point GetMapFromRefPoint(Point point)
|
||||
{
|
||||
|
||||
return this.GetMapFromRefPoint(point.X, point.Y);
|
||||
}
|
||||
|
||||
public Point GetMapFromRefPoint(double x, double y)
|
||||
{
|
||||
x += this.RefPoint.X;
|
||||
x += this.MapOffsetX;
|
||||
y += this.RefPoint.Y;
|
||||
y += this.MapOffsetY;
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,23 +39,25 @@
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0" />
|
||||
<Image Grid.Column="1" Source="/Assets/icons/search_159_dark.png" Width="60" />
|
||||
<Button Grid.Column="1" Click="Button_Click">
|
||||
<Image Source="/Assets/icons/search_159_dark.png" Width="60"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<!--<Controls:Map Grid.Row="1" ZoomLevel="17" CartographicMode="Hybrid">
|
||||
<Controls:Map.Center>
|
||||
<Location:GeoCoordinate Altitude="NaN" Course="NaN" HorizontalAccuracy="NaN" Longitude="14.3242" Latitude="51.7662" Speed="NaN" VerticalAccuracy="NaN"/>
|
||||
</Controls:Map.Center>
|
||||
</Controls:Map> -->
|
||||
<ScrollViewer Name="test" Grid.Row="1" HorizontalScrollBarVisibility="Auto" RenderTransformOrigin="0,0">
|
||||
<Canvas Width="2000" Height="2000" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer Name="MapScroller" Grid.Row="1" HorizontalScrollBarVisibility="Auto" RenderTransformOrigin="0,0">
|
||||
<Canvas Name="MapCanvas" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="{Binding ImageHeight}" Width="{Binding ImageWidth}">
|
||||
<Canvas.Background>
|
||||
<ImageBrush Stretch="Fill" ImageSource="/Assets/testmap.png">
|
||||
<ImageBrush Stretch="Fill" ImageSource="{Binding ImageSource}">
|
||||
|
||||
</ImageBrush>
|
||||
</Canvas.Background>
|
||||
|
||||
|
||||
<Image Name="bla" Source="/Assets/icons/search_159_light.png" Width="60" Canvas.ZIndex="1" Canvas.Top="800" Canvas.Left="800"/>
|
||||
|
||||
|
||||
<Image Name="bla" Source="/Assets/icons/search_159_light.png" Width="60" Canvas.ZIndex="1" Canvas.Top="976" Canvas.Left="976"/>
|
||||
</Canvas>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
@@ -8,20 +8,39 @@ using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System.Windows.Media;
|
||||
using CampusAppWP8.Model.Campusmap;
|
||||
|
||||
namespace CampusAppWP8.Pages.Campusmap
|
||||
{
|
||||
public partial class CampusMapPage : PhoneApplicationPage
|
||||
{
|
||||
private MapModel map;
|
||||
public CampusMapPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
test.SetValue(H, 800);
|
||||
|
||||
this.map = new MapModel() { ImageSource = "/Assets/testmap.png", ImageWidth = 2000, ImageHeight = 2000, MapOffsetX = -228, MapOffsetY = -300, RefPoint = new Point(1000, 1000) };
|
||||
this.MapCanvas.DataContext = map;
|
||||
}
|
||||
|
||||
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
|
||||
{
|
||||
//test.ScrollToVerticalOffset(800);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Methods overrides the OnNavigatedTo-Method
|
||||
/// </summary>
|
||||
/// <param name="e">some NavigationEventArgs</param>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point scrollPoint = map.GetMapFromRefPoint(0,0);
|
||||
MapScroller.ScrollToVerticalOffset(scrollPoint.Y);
|
||||
MapScroller.ScrollToHorizontalOffset(scrollPoint.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user