Files
win8phoneApp/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/GoToMapButton.cs
2013-08-27 14:11:22 +02:00

89 lines
2.5 KiB
C#

//-----------------------------------------------------------------------
// <copyright file="GoToMapButton.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>08.07.2013</sience>
//----------------------------------------------------------------------
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>
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>
public GoToMapButton()
: base()
{
this.Content = new Image
{
Source = icon
};
}
#endregion
#region Proberties
/// <summary>
/// Gets or sets the Url
/// </summary>
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>
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
}
}