Skip to content

Instantly share code, notes, and snippets.

View anuith's full-sized avatar
💭
Hello World

Thiwakorn anuith

💭
Hello World
View GitHub Profile
@anuith
anuith / shareWeather.html
Created December 19, 2012 08:21
HTML page for shareWeather page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>shareWeather</title>
<!-- WinJS references -->
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
@anuith
anuith / shareWeather.css
Created December 19, 2012 08:20
CSS style for shareWeather page
.shareWeather section[role=main] {
margin-left: 120px;
margin-right: 120px;
display: -ms-grid;
-ms-grid-columns: 4fr 40px 3fr;
-ms-grid-rows: 1fr auto 60px;
}
.shareWeather #photoPlaceholder {
-ms-grid-column: 1;
@anuith
anuith / ThailandWeather.json
Created December 18, 2012 03:16
Sample weather data from wunderground API
{
"response": {
"version": "0.1"
,"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"
,"features": {
"geolookup": 1
}
, "results": [
{
"name": "Aranyaprathet",
@anuith
anuith / PrettyDate.js
Created July 22, 2012 15:42
Javascript Pretty Date formatter
/*
Pretty Date script modified from John Resig here http://ejohn.org/blog/javascript-pretty-date
*/
function relativeDateTime (tdate) {
var system_date;
if (typeof (tdate) === "number") {
tdate = new Date(tdate).toString();
}
if (navigator.userAgent.match(/MSIE\s([^;]*)/)) {
@anuith
anuith / gist:2991191
Created June 25, 2012 20:57
Windows Phone Hackathon : Bing Map Sample V2 - Code - ListBox SelectionChanged
private void ListBox_Places_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listbox = sender as ListBox;
if(listbox.SelectedIndex < 0) return;
// ดึงค่า item ที่ถูกเลือก มาจาก listbox
Place item = listbox.SelectedItem as Place;
// เลื่อน pivot ให้กลับไปยังหน้า map
PivotRoot.SelectedIndex = 0;
@anuith
anuith / gist:2991098
Created June 25, 2012 20:43
Windows Phone Hackathon : Bing Map Sample V2 - Code - Application Bar Events
private void ApplicationBarButton_FindMe_Click(object sender, System.EventArgs e)
{
PivotRoot.SelectedIndex = 0;
FindMe();
}
private void ApplicationBarButton_Direction_Click(object sender, EventArgs e)
{
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
@anuith
anuith / gist:2991087
Created June 25, 2012 20:41
Windows Phone Hackathon : Bing Map Sample V2 - Code - Watcher PositionChanged
private void watcher_PositionChanged(
object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => LocationChanged(e));
}
private void LocationChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
{
GeoCoordinate location = e.Position.Location;
PushPin_Me.Location = location;
@anuith
anuith / gist:2991076
Created June 25, 2012 20:40
Windows Phone Hackathon : Bing Map Sample V2 - Code - Watcher StatusChanged
private void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => LocationStatusChanged(e));
}
private void LocationStatusChanged(GeoPositionStatusChangedEventArgs e)
{
ApplicationBarIconButton ApplicationBarButton_FindMe =
ApplicationBar.Buttons[1] as ApplicationBarIconButton;
switch (e.Status)
@anuith
anuith / gist:2991006
Created June 25, 2012 20:25
Windows Phone Hackathon : Bing Map Sample V2 - Code - ClearMap
private void ClearMap()
{
Map_Main.SetView(defaultLocation, defaultZoomLevel);
Map_Main.Mode = new RoadMode();
PushPin_Me.Location = defaultLocation;
PushPin_Me.Visibility = System.Windows.Visibility.Collapsed;
PushPin_Dest.Visibility = System.Windows.Visibility.Collapsed;
}
@anuith
anuith / gist:2990995
Created June 25, 2012 20:21
Windows Phone Hackathon : Bing Map Sample V2 - Code - FindMe
private void FindMe()
{
// Reinitialize the GeoCoordinateWatcher
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 100;//distance in metres
// Add event handlers for StatusChanged and PositionChanged events
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);