Friday, February 1, 2013

windows8 develop metro sample code-1 dragft

1.get user current location language:

string region = ResourceManager.Current.DefaultContext.HomeRegion

2.multi language support:

http://blogs.msdn.com/b/windowsappdev_cn/archive/2012/10/09/visual-studio-2012-windows.aspx

3.windows8 official develop blog:

http://blogs.msdn.com/b/windowsappdev_cn/

4。bing map api

4.1 get input location from bingmap to map location:

var point = new Microsoft.Maps.Point(e.getX(), e.getY());
var loc = e.target.tryPixelToLocation(point);



4.2 hide or show all Pins in bing map:

map.entities.setOptions({visible:false});
map.entities.setOptions({visible:true});

4.3 add click event:

// Add handler for the map click event - add a pin to the click location.
Microsoft.Maps.Events.addHandler(map, 'click', addPin);

function addPin(e) {
if (e.targetType == "map") {

// Return the location where the map was clicked and create the pin.
var point = new Microsoft.Maps.Point(e.getX(), e.getY());
var loc = e.target.tryPixelToLocation(point);
var pin = new Microsoft.Maps.Pushpin(loc);

// Add the pushpin
map.entities.push(pin);


}
}



4.4 add pushpin:

gpsLayer.push(new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(item.latitude, item.longitude),
{
icon:"1.png",
width: 32, height: 32,
text:"1243"
}));



5.jquery error

SCRIPT7002: XMLHttpRequest: 网络错误 0x2efd, 由于出现错误 00002efd 而导致此项操作无法完成。
文件: default.html



解决:URL Not Found


add class:

WinJS.Utilities.addClass(document.getElementById("cmdShare"), "hide-ctl");

remove class:

WinJS.Utilities.removeClass(document.getElementById("cmdShare"), "hide-ctl");





 


6.Listview liststyle:


image


code:

data-win-options="{ layout:{type: WinJS.UI.ListLayout} }"



default:


image


code:

data-win-options="{ layout:{type: WinJS.UI.GridLayout} }"


my listview code css:
#listLabelView {
width: calc(100%-20px);
margin: 0 20px 0 0;
height: 400px;
border: 1px solid #222222;
background-color: #ffffff;
}

.mediumListIconTextItem {
height: 70px;
padding: 5px;
overflow: hidden;
display: -ms-grid;
width: 292px;
}

.mediumListIconTextItem img.mediumListIconTextItem-Image {
width: 60px;
height: 60px;
margin: 5px;
-ms-grid-column: 1;
}

.mediumListIconTextItem .mediumListIconTextItem-Detail {
margin: 5px;
-ms-grid-column: 2;
}

.groupHeader {
width: 200px;
overflow: hidden;
height: 40px;
margin: 0 10px;
}

#listLabelView .win-container:hover {
background-color: #b200ff;
}

html code:

<div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template" style="display: none;">
<div class="mediumListIconTextItem" onclick="mapContext.onUrlListItemClick(event)">
<img class="mediumListIconTextItem-Image" data-win-bind="src: icon" width="32" height="32"/>
<div class="mediumListIconTextItem-Detail">
<h4 data-win-bind="innerText: url"></h4>
</div>
</div>
</div>
<div id="groupTemplate" data-win-control="WinJS.Binding.Template">
<div class="groupHeader">
<h2 data-win-bind="innerText: type"></h2>
</div>
</div>
<!-- Declarative placeholder used for the listview control -->
<div id="listLabelView" class="win-selectionstylefilled" data-win-control="WinJS.UI.ListView" data-win-options="{itemDataSource:GameManager.game.labelsList.dataSource, itemTemplate:select('#mediumListIconTextTemplate'), layout:{type: WinJS.UI.ListLayout} }" style="width: 100%; height: 100%;">
</div>



javascript code:

var mapContext = function () {

// Called when the page loads.
function onLoad() {
"use strict";

listLabelView.addEventListener("selectionchanged", onSelectionChanged);
}

function onSelectionChanged(event) {
// ListView.selection,in pc is right mouse key.
}

function onUrlListItemClick(event) {
}

// Return the public functionality.
return {
onLoad: onLoad,
onSelectionChanged: onSelectionChanged,
onUrlListItemClick: onUrlListItemClick
};
}();



6. publish


6.1 error

错误    1    未能对“\AppPackages\pkmap_1.0.0.0_ARM_Test\pkmap_1.0.0.0_ARM.appx”签名。SignTool Error: An unexpected internal error has occurred.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\AppxPackage\Microsoft.AppXPackage.Targets 1139 9 pkmap



fixed:


login the same account in local machine,the account is same as publish account.


if already has the account in the local machine,may skip it .


error2:

Cross-package validation error: A single app can't include both architecture-neutral and architecture-specific packages



fixed:


remove other .appxupload file  except pkmap_1.0.0.4_AnyCPU.appxupload

No comments: