Files
win8phoneApp/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs
2013-10-15 12:17:51 +02:00

81 lines
2.7 KiB
C#

//-----------------------------------------------------------------------
// <copyright file="GoToMapButton.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>15.10.2013</date>
// <summary>Implements the go to map button class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8.Utility.Lui.Button
{
using System;
using System.Device.Location;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using CampusAppWP8.Resources;
using Microsoft.Phone.Tasks;
/// <summary> This class create an Button which open a Map. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
/// <seealso cref="T:System.Windows.Controls.Button"/>
public class GoToMapButton : System.Windows.Controls.Button
{
#region Members
/// <summary> Register the SearchTermProperty. </summary>
public static readonly DependencyProperty SearchTermProperty = DependencyProperty.Register("SearchTerm", typeof(object), typeof(GoToMapButton), new PropertyMetadata(false));
/// <summary> Icon of the Button. </summary>
private static BitmapImage icon = new BitmapImage(new Uri(Icons.Campus, UriKind.Relative));
#endregion
#region Constructors
/// <summary> Initializes a new instance of the <see cref="GoToMapButton" /> class. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
public GoToMapButton()
: base()
{
this.Content = new Image
{
Source = icon
};
}
#endregion
#region Proberties
/// <summary> Gets or sets the Url. </summary>
/// <value> The search term. </value>
public object SearchTerm
{
get { return (object)this.GetValue(SearchTermProperty); }
set { this.SetValue(SearchTermProperty, value); }
}
#endregion
#region Methods
/// <summary> Overrides the OnClick-Method from button. </summary>
/// <remarks> now method start the MapTask. </remarks>
/// <seealso cref="M:System.Windows.Controls.Button.OnClick()"/>
protected override void OnClick()
{
string urlString = Constants.PathCampusmap_Campusmap;
if (this.SearchTerm != null)
{
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);
}
#endregion
}
}