first
2
AppxBlockMap.xml
Normal file
25
AppxManifest.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
|
||||
<Identity Name="Microsoft.InkPad" Version="1.0.0.5" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" ProcessorArchitecture="neutral" />
|
||||
<Properties>
|
||||
<DisplayName>InkPad</DisplayName>
|
||||
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
|
||||
<Description>InkPad - A sample of modern inking</Description>
|
||||
<Logo>images\inkPad_56x-store.png</Logo>
|
||||
</Properties>
|
||||
<Resources>
|
||||
<Resource Language="en-us" />
|
||||
</Resources>
|
||||
<Prerequisites>
|
||||
<OSMinVersion>6.2</OSMinVersion>
|
||||
<OSMaxVersionTested>6.2</OSMaxVersionTested>
|
||||
</Prerequisites>
|
||||
<Applications>
|
||||
<Application Id="Microsoft.SDKSamples.InkPad" StartPage="default.html">
|
||||
<VisualElements DisplayName="InkPad" Logo="images\inkpad-tile.png" SmallLogo="images\inkPad-time_30x30.png" Description="SDK Sample" ForegroundText="dark" BackgroundColor="#b2815a" ToastCapable="false">
|
||||
<DefaultTile ShortName="InkPad" ShowName="false" />
|
||||
<SplashScreen BackgroundColor="white" Image="images\inkPad_splash.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
</Package>
|
||||
BIN
AppxSignature.p7x
Normal file
1296
animations.js
Normal file
1347
binding.js
Normal file
5603
controls.js
vendored
Normal file
2109
css/Ui-light.css
Normal file
195
css/program.css
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
|
||||
|
||||
*
|
||||
{
|
||||
overflow: hidden;
|
||||
-ms-scroll-rails: none;
|
||||
-ms-content-zooming: none;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (-ms-view-state: full-screen)
|
||||
{
|
||||
#canvasGroup
|
||||
{
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
@media screen and (-ms-view-state: fill)
|
||||
{
|
||||
#HighlightColors
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#HighlightWidth
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#bottomAppBar hr
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#canvasGroup
|
||||
{
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
@media screen and (-ms-view-state: snapped)
|
||||
{
|
||||
/* Docked */
|
||||
#ModeErase
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#ModeSelect
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#InkColors
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#InkWidth
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#HighlightColors
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#HighlightWidth
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#More
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
button.color
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#bottomAppBar hr
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#canvasGroup
|
||||
{
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
@media screen and (-ms-view-state: device-portrait)
|
||||
{
|
||||
#HighlightColors
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#HighlightWidth
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#bottomAppBar hr
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
#canvasGroup
|
||||
{
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
/* ISSUE: Perhaps we can have a border on color buttons when in high contrast? */
|
||||
@media screen and (-ms-high-contrast)
|
||||
{
|
||||
button.color, canvas.surface
|
||||
{
|
||||
-ms-high-contrast-adjust: none;
|
||||
}
|
||||
}
|
||||
|
||||
#statusMessage
|
||||
{
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
color: black;
|
||||
font-size: 18pt;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
#canvasGroup
|
||||
{
|
||||
overflow: scroll;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
canvas.surface
|
||||
{
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#HighlightCanvas
|
||||
{
|
||||
background-color: White;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#InkCanvas
|
||||
{
|
||||
background-color: rgba(0, 0, 0, 0.075);
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
#SelectCanvas
|
||||
{
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
cursor: "url(images/erase.cur)";
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.color-choice
|
||||
{
|
||||
float: left;
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 10px;
|
||||
width: 73px;
|
||||
height: 48px;
|
||||
border: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
#RecoFlyout
|
||||
{
|
||||
color: black;
|
||||
/* display: block; */
|
||||
}
|
||||
|
||||
171
default.html
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>InkPad</title>
|
||||
<meta content="IE=10" http-equiv="X-UA-Compatible"/>
|
||||
<!-- Include AppBar component -->
|
||||
<link href="css/ui-light.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="base.js" type="text/javascript"></script>
|
||||
<script src="ui.js" type="text/javascript"></script>
|
||||
<script src="binding.js" type="text/javascript"></script>
|
||||
<script src="controls.js" type="text/javascript"></script>
|
||||
<script src="animations.js" type="text/javascript"></script>
|
||||
<script src="wwaapp.js" type="text/javascript"></script>
|
||||
|
||||
<link href="css/program.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="program.js" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
// Stock appbar initialization
|
||||
document.addEventListener("DOMContentLoaded", function() {WinJS.UI.processAll();}, false);
|
||||
|
||||
// Helper function to toggle the flyout
|
||||
function toggleFlyout(flyoutElement, buttonElement)
|
||||
{
|
||||
var flyout = WinJS.UI.getControl(flyoutElement);
|
||||
if (flyout && flyout.element.style.visibility !== "visible")
|
||||
{
|
||||
flyout.show(buttonElement, "top");
|
||||
}
|
||||
// else it will light-dismiss
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body role="application">
|
||||
<div id="rootGrid">
|
||||
<div id="content" aria-labelledby="featureLabel" role="main">
|
||||
<!-- These 3 canvases are displayed directly on top of each other. -->
|
||||
|
||||
<div id="canvasGroup" aria-label="Ink canvas" role="img" >
|
||||
<canvas id="HighlightCanvas" class="surface"></canvas>
|
||||
<canvas id="InkCanvas" class="surface"></canvas>
|
||||
<canvas id="SelectCanvas" class="surface"></canvas>
|
||||
</div>
|
||||
|
||||
<!-- The statusMessage item displays status and error messages, and also the recognition results. -->
|
||||
|
||||
<div id="statusMessage" aria-label="Recognition results" aria-live="polite" role="region"></div>
|
||||
|
||||
<!-- The Reco Flyout contains 5 submit buttons laid out vertically.
|
||||
At the time the form is displayed, we set the values of the buttons to the recognition alternates
|
||||
for a specific word. All 5 buttons execute the same function, recoClipboard(), which
|
||||
copies that value into the clipboard. -->
|
||||
|
||||
<div id="RecoFlyout" class="win-menu" aria-label="Reco options" data-win-control="WinJS.UI.Flyout" role="dialog">
|
||||
<h4>Copy to clipboard:</h4>
|
||||
<button id="Reco0" role="menuitem"></button>
|
||||
<button id="Reco1" role="menuitem"></button>
|
||||
<button id="Reco2" role="menuitem"></button>
|
||||
<button id="Reco3" role="menuitem"></button>
|
||||
<button id="Reco4" role="menuitem"></button>
|
||||
</div>
|
||||
|
||||
<!-- This toolbar is displayed across the bottom of the screen.
|
||||
The bottons are shown as cirles with icons in the middle. The color buttons have IDs
|
||||
which are the names of colors; the ID of each one is fed directly into the strokeStyle
|
||||
of the corresponding canvas. -->
|
||||
|
||||
<div id="bottomAppBar" aria-label="Command Bar" data-win-control="WinJS.UI.AppBar" data-win-options="{position:'bottom',transient:true,autoHide:0,lightDismiss:true}">
|
||||
<div class="win-right">
|
||||
<button id="Reco" class="win-command" >
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/Reco.png')"></span>
|
||||
<span class="win-label">Recognize</span>
|
||||
</button>
|
||||
|
||||
<button id="Find" class="win-command" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/Find.png')"></span>
|
||||
<span class="win-label">Find</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="FindFlyout" class="win-menu" aria-label="Find" data-win-control="WinJS.UI.Flyout">
|
||||
<h3>Find:</h3>
|
||||
<input id="FindString" aria-label="Search string" maxlength="100" size="40" type="text" value=""/>
|
||||
<br />
|
||||
<button id="FindButton">Find</button>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<button id="ModeErase" class="win-command" >
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/Eraser.png')"></span>
|
||||
<span class="win-label">Erase</span>
|
||||
</button>
|
||||
<button id="ModeSelect" class="win-command" >
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/Lasso.png')"></span>
|
||||
<span class="win-label">Select</span>
|
||||
</button>
|
||||
|
||||
<hr />
|
||||
|
||||
<button id="InkColors" class="win-command" aria-haspopup="true" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/InkColors.png')"></span>
|
||||
<span class="win-label">Color</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="InkColorFlyout" class="win-menu" aria-label="Ink Colors" data-win-control="WinJS.UI.Flyout">
|
||||
<div id="Black" class="color-choice" style="background-color: Black;"></div>
|
||||
<div id="Blue" class="color-choice" style="background-color: Blue;" ></div>
|
||||
<div id="Red" class="color-choice" style="background-color: Red;" ></div>
|
||||
<div id="Green" class="color-choice" style="background-color: Green;"></div>
|
||||
</div>
|
||||
|
||||
<button id="InkWidth" class="win-command" aria-haspopup="true" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/InkWidth.png')"></span>
|
||||
<span class="win-label">Width</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="InkWidthFlyout" class="win-menu" aria-label="Ink Widths" data-win-control="WinJS.UI.Flyout">
|
||||
<button id="IW2" role="menuitem" value="2" >Smallest</button>
|
||||
<button id="IW4" role="menuitem" value="4" >Small</button>
|
||||
<button id="IW6" role="menuitem" value="6" >Medium</button>
|
||||
<button id="IW8" role="menuitem" value="8" >Large</button>
|
||||
<button id="IW10" role="menuitem" value="10">Largest</button>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<button id="HighlightColors" class="win-command" aria-haspopup="true" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/HighlightColors.png')"></span>
|
||||
<span class="win-label">Highlight Color</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="HighlightColorFlyout" class="win-menu" aria-label="Highlighter Colors" data-win-control="WinJS.UI.Flyout">
|
||||
<div id="Yellow" class="color-choice" style="background-color: Yellow;"></div>
|
||||
<div id="Aqua" class="color-choice" style="background-color: Aqua;" ></div>
|
||||
<div id="Lime" class="color-choice" style="background-color: Lime;" ></div>
|
||||
</div>
|
||||
|
||||
<button id="HighlightWidth" class="win-command" aria-haspopup="true" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/HighlightWidth.png')"></span>
|
||||
<span class="win-label">Highlight Width</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="HighlightWidthFlyout" class="win-menu" aria-label="Highlighter Widths" data-win-control="WinJS.UI.Flyout">
|
||||
<button id="HW10" role="menuitem" value="10">Small</button>
|
||||
<button id="HW20" role="menuitem" value="20">Medium</button>
|
||||
<button id="HW30" role="menuitem" value="30">Large</button>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<button id="More" class="win-command" aria-haspopup="true" onclick="toggleFlyout(this.nextElementSibling, this);">
|
||||
<span class="win-spritestates win-commandicon win-large" style="background-image:url('images/More.png')"></span>
|
||||
<span class="win-label">More</span>
|
||||
</button>
|
||||
<!-- The onclick above expects this to immediately follow the button -->
|
||||
<div id="MoreFlyout" class="win-menu" aria-label="More Commands" data-win-control="WinJS.UI.Flyout">
|
||||
<button id="CopySelected" role="menuitem">Copy</button>
|
||||
<button id="Paste" role="menuitem">Paste</button>
|
||||
<button id="Load" role="menuitem">Load</button>
|
||||
<button id="Save" role="menuitem">Save</button>
|
||||
<button id="Clear" role="menuitem">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
images/Erase.cur
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
images/Eraser.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
images/Find.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
images/HighlightColors.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
images/HighlightWidth.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
images/InkColors.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
images/InkWidth.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
images/Lasso.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
images/More.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
images/Reco.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
images/Select.png
Normal file
|
After Width: | Height: | Size: 125 B |
BIN
images/Trash.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
images/Width10.png
Normal file
|
After Width: | Height: | Size: 815 B |
BIN
images/Width2.png
Normal file
|
After Width: | Height: | Size: 423 B |
BIN
images/Width20.png
Normal file
|
After Width: | Height: | Size: 760 B |
BIN
images/Width30.png
Normal file
|
After Width: | Height: | Size: 1,018 B |
BIN
images/Width4.png
Normal file
|
After Width: | Height: | Size: 360 B |
BIN
images/Width6.png
Normal file
|
After Width: | Height: | Size: 440 B |
BIN
images/Width8.png
Normal file
|
After Width: | Height: | Size: 478 B |
BIN
images/inkPad-time_30x30.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
images/inkPad_56x-store.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
images/inkPad_splash.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
images/inkpad-tile.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
1798
program.js
Normal file
BIN
resources.pri
Normal file
716
wwaapp.js
Normal file
|
|
@ -0,0 +1,716 @@
|
|||
/// <loc filename="metadata\wwaapp_loc_oam.xml" format="messagebundle" />
|
||||
/// <reference path='base.js' />
|
||||
/// <reference path='wwaapp.js' />
|
||||
/// <reference winrt='true' />
|
||||
|
||||
/*
|
||||
© Microsoft. All rights reserved.
|
||||
|
||||
This library is supported for use in Windows Tailored Apps only.
|
||||
|
||||
Build: 6.2.8054.0
|
||||
Version: 0.5
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function (global, WinJS, undefined) {
|
||||
var checkpointET = "checkpoint",
|
||||
unloadET = "unload",
|
||||
mainwindowactivatedET = "mainwindowactivated",
|
||||
activatedET = "activated",
|
||||
loadedET = "loaded",
|
||||
readyET = "ready",
|
||||
errorET = "error";
|
||||
|
||||
var pendingDrain;
|
||||
|
||||
function dispatchEvent(eventRecord) {
|
||||
var promise = WinJS.Promise.as();
|
||||
eventRecord.setPromise = function (p) {
|
||||
promise = promise.then(function() { return p; });
|
||||
};
|
||||
eventRecord.detail = eventRecord.detail || {};
|
||||
if (typeof(eventRecord.detail) === "object") {
|
||||
eventRecord.detail.setPromise = eventRecord.setPromise;
|
||||
}
|
||||
|
||||
try {
|
||||
if (listeners._listeners) {
|
||||
l = listeners._listeners[eventRecord.type];
|
||||
if (l) {
|
||||
l.forEach(function dispatchOne(e) { e.listener(eventRecord); });
|
||||
}
|
||||
}
|
||||
|
||||
// Fire built in listeners last, for checkpoint this is important
|
||||
// as it lets our built in serialization see any mutations to
|
||||
// app.sessionState
|
||||
//
|
||||
var l = builtInListeners[eventRecord.type];
|
||||
if (l) {
|
||||
l.forEach(function dispatchOne(e) { e(eventRecord); });
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
queueEvent({type:errorET, detail:err});
|
||||
}
|
||||
|
||||
return promise.then(function() {
|
||||
if (eventRecord._deferral) {
|
||||
eventRecord._deferral.complete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function drainQueue(queue) {
|
||||
pendingDrain = true;
|
||||
if (queue.length === 0) {
|
||||
if (eventQueue.length > 0) {
|
||||
return drainQueue(copyAndClearQueue());
|
||||
}
|
||||
pendingDrain = false;
|
||||
return WinJS.Promise.as(queue);
|
||||
}
|
||||
function drainNext() {
|
||||
return drainQueue(queue.slice(1));
|
||||
}
|
||||
function drainError(err) {
|
||||
queueEvent({type:errorET, detail:err});
|
||||
return drainNext();
|
||||
}
|
||||
return dispatchEvent(queue[0]).
|
||||
then(drainNext, drainError);
|
||||
}
|
||||
|
||||
function queueEvent(eventRecord) {
|
||||
/// <summary locid="1">
|
||||
/// Queue an event to be processed by the WinJS.Application
|
||||
/// </summary>
|
||||
/// <param name="eventRecord" type="object" locid="2">
|
||||
/// The event record is expected to have a type property which will be
|
||||
/// used as the event name when dispatching on the WinJS.Application
|
||||
/// event queue. The entire object will be provided to event listeners
|
||||
/// in the detail property of the event.
|
||||
/// </param>
|
||||
eventQueue.push(eventRecord);
|
||||
if (running && !pendingDrain) {
|
||||
drainQueue(copyAndClearQueue());
|
||||
}
|
||||
}
|
||||
|
||||
function copyAndClearQueue() {
|
||||
var queue = eventQueue;
|
||||
eventQueue = [];
|
||||
return queue;
|
||||
}
|
||||
|
||||
var ListenerType = WinJS.Class.mix(WinJS.Class.define(null), WinJS.Utilities.eventMixin);
|
||||
var listeners = new ListenerType();
|
||||
var builtInListeners = {
|
||||
mainwindowactivated: [
|
||||
function (e) {
|
||||
queueEvent({type: activatedET, detail: e});
|
||||
}
|
||||
],
|
||||
activated: [
|
||||
function () {
|
||||
queueEvent({ type: readyET });
|
||||
}
|
||||
],
|
||||
checkpoint: [
|
||||
function(e) {
|
||||
// comes from state.js
|
||||
WinJS.Application._oncheckpoint(e);
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var eventQueue = [ ];
|
||||
var running = false;
|
||||
|
||||
// loaded == DOMContentLoaded
|
||||
// mainwindowactivated == after WinRT Activated
|
||||
// ready == after all of the above
|
||||
//
|
||||
var useWinRT = false;
|
||||
if (window.Windows && Windows.UI) {
|
||||
useWinRT = true;
|
||||
var wui = Windows.UI.WebUI.WebUIApplication;
|
||||
wui.addEventListener("activated", function (e) {
|
||||
WinJS.Application._loadState(e).then(function () {
|
||||
queueEvent({type: mainwindowactivatedET, detail: e});
|
||||
});
|
||||
});
|
||||
|
||||
function suspendingHandler(e) {
|
||||
WinJS.Application.queueEvent({type:checkpointET, _deferral: e.suspendingOperation.getDeferral() });
|
||||
}
|
||||
wui.addEventListener("suspending", suspendingHandler, false);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (e) {
|
||||
queueEvent({ type: loadedET });
|
||||
if (!useWinRT) {
|
||||
var activatedArgs = {
|
||||
arguments: "",
|
||||
kind: "Windows.Launch",
|
||||
previousExecutionState: 0 //Windows.ApplicationModel.Activation.ApplicationExecutionState.NotRunning
|
||||
// UNDONE: tileId: e.tileId,
|
||||
// UNDONE: splashScreen: e.splashScreen,
|
||||
};
|
||||
WinJS.Application._loadState(activatedArgs).then(function () {
|
||||
queueEvent({ type: mainwindowactivatedET, detail:activatedArgs});
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
|
||||
window.addEventListener("beforeunload", function (e) {
|
||||
queueEvent({type:checkpointET});
|
||||
queueEvent({type:unloadET});
|
||||
}, false);
|
||||
|
||||
WinJS.Namespace.defineWithParent(WinJS, "Application", {
|
||||
stop: function() {
|
||||
/// <summary locid="3">
|
||||
/// Stop application event processing and reset the WinJS.Application
|
||||
/// to its initial state
|
||||
/// </summary>
|
||||
listeners = new ListenerType();
|
||||
running = false;
|
||||
sawActivated = false;
|
||||
sawLoaded = false;
|
||||
queuedReady = false;
|
||||
copyAndClearQueue();
|
||||
},
|
||||
|
||||
addEventListener: function (eventType, listener, capture) {
|
||||
/// <summary locid="4">
|
||||
/// Adds an event listener to the control.
|
||||
/// </summary>
|
||||
/// <param name="eventType" locid="5">
|
||||
/// The type (name) of the event.
|
||||
/// </param>
|
||||
/// <param name="listener" locid="6">
|
||||
/// The listener to invoke when the event gets raised.
|
||||
/// </param>
|
||||
/// <param name="capture" locid="7">
|
||||
/// Specifies whether or not to initiate capture.
|
||||
/// </param>
|
||||
listeners.addEventListener(eventType, listener, capture);
|
||||
},
|
||||
removeEventListener: function (eventType, listener, capture) {
|
||||
/// <summary locid="8">
|
||||
/// Removes an event listener from the control.
|
||||
/// </summary>
|
||||
/// <param name="eventType" locid="5">
|
||||
/// The type (name) of the event.
|
||||
/// </param>
|
||||
/// <param name="listener" locid="9">
|
||||
/// The listener to remove from the invoke list.
|
||||
/// </param>
|
||||
/// <param name="capture" locid="7">
|
||||
/// Specifies whether or not to initiate capture.
|
||||
/// </param>
|
||||
listeners.removeEventListener(eventType, listener, capture);
|
||||
},
|
||||
|
||||
checkpoint: function() {
|
||||
/// <summary locid="10">
|
||||
/// Queue a checkpoint event
|
||||
/// </summary>
|
||||
queueEvent({type:checkpointET});
|
||||
},
|
||||
|
||||
start: function () {
|
||||
/// <summary locid="11">
|
||||
/// Start processing items in the WinJS.Application event queue
|
||||
/// </summary>
|
||||
var queue = copyAndClearQueue();
|
||||
running = true;
|
||||
drainQueue(queue);
|
||||
},
|
||||
|
||||
queueEvent : queueEvent
|
||||
});
|
||||
|
||||
Object.defineProperties(WinJS.Application, WinJS.Utilities.createEventProperties(checkpointET, unloadET, mainwindowactivatedET, activatedET, loadedET, readyET));
|
||||
})(this, WinJS);
|
||||
|
||||
|
||||
|
||||
(function (WinJS, undefined) {
|
||||
var navigatedEventName = "navigated";
|
||||
var navigatingEventName = "navigating";
|
||||
var beforenavigateEventName = "beforenavigate";
|
||||
var ListenerType = WinJS.Class.mix(WinJS.Class.define(null), WinJS.Utilities.eventMixin);
|
||||
var listeners = new ListenerType();
|
||||
var history = {
|
||||
backStack: [],
|
||||
current: {location:"", initialPlaceholder: true},
|
||||
forwardStack: []
|
||||
};
|
||||
|
||||
var raiseBeforeNavigate = function (proposed) {
|
||||
return WinJS.Promise.as().
|
||||
then(function () {
|
||||
var promise = WinJS.Promise.as();
|
||||
var defaultPrevented = listeners.dispatchEvent(beforenavigateEventName, {
|
||||
setPromise: function(p) { promise = p; },
|
||||
location: proposed.location,
|
||||
state: proposed.state
|
||||
});
|
||||
return promise.then(function beforeNavComplete() {
|
||||
return defaultPrevented;
|
||||
});
|
||||
});
|
||||
};
|
||||
var raiseNavigating = function (delta) {
|
||||
return WinJS.Promise.as().
|
||||
then(function () {
|
||||
var promise = WinJS.Promise.as();
|
||||
listeners.dispatchEvent(navigatingEventName, {
|
||||
setPromise: function(p) { promise = p; },
|
||||
location: history.current.location,
|
||||
state: history.current.state,
|
||||
delta: delta
|
||||
});
|
||||
return promise;
|
||||
});
|
||||
};
|
||||
var raiseNavigated = function(value, err) {
|
||||
var promise = WinJS.Promise.as();
|
||||
var detail = {
|
||||
value: value,
|
||||
location: history.current.location,
|
||||
state: history.current.state,
|
||||
setPromise: function(p) { promise = p; }
|
||||
};
|
||||
if (!value && err) {
|
||||
detail.error = err;
|
||||
}
|
||||
listeners.dispatchEvent(navigatedEventName, detail);
|
||||
return promise;
|
||||
};
|
||||
|
||||
var go = function (distance, fromStack, toStack, delta) {
|
||||
distance = Math.min(distance, fromStack.length);
|
||||
if (distance > 0) {
|
||||
return raiseBeforeNavigate(fromStack[fromStack.length-distance]).
|
||||
then(function goBeforeCompleted(cancel) {
|
||||
if (!cancel) {
|
||||
toStack.push(history.current);
|
||||
while (distance-1 != 0) {
|
||||
distance--;
|
||||
toStack.push(fromStack.pop());
|
||||
}
|
||||
history.current = fromStack.pop();
|
||||
return raiseNavigating(delta).then(
|
||||
raiseNavigated,
|
||||
function (err) {
|
||||
raiseNavigated(undefined, err || true);
|
||||
throw err;
|
||||
}).then(function() { return true; });
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return WinJS.Promise.wrap(false);
|
||||
}
|
||||
|
||||
WinJS.Namespace.defineWithParent(WinJS, "Navigation", {
|
||||
/// <field name="state" type="Boolean" locid="12">
|
||||
/// True if we can navigate forwards
|
||||
/// </field>
|
||||
canGoForward: {
|
||||
get: function () {
|
||||
return history.forwardStack.length > 0;
|
||||
}
|
||||
},
|
||||
/// <field name="state" type="Boolean" locid="13">
|
||||
/// True if we can navigate backwards
|
||||
/// </field>
|
||||
canGoBack: {
|
||||
get: function () {
|
||||
return history.backStack.length > 0;
|
||||
}
|
||||
},
|
||||
/// <field name="state" locid="14">
|
||||
/// Current location
|
||||
/// </field>
|
||||
location: {
|
||||
get: function () {
|
||||
return history.current.location;
|
||||
}
|
||||
},
|
||||
/// <field name="state" locid="15">
|
||||
/// Navigation state
|
||||
/// </field>
|
||||
state: {
|
||||
get: function () {
|
||||
return history.current.state;
|
||||
},
|
||||
set: function (value) {
|
||||
history.current.state = value;
|
||||
}
|
||||
},
|
||||
/// <field name="history" locid="16">
|
||||
/// Navigation history
|
||||
/// </field>
|
||||
history: {
|
||||
get: function() {
|
||||
return history;
|
||||
},
|
||||
set: function(value) {
|
||||
var s = history = value;
|
||||
|
||||
// ensure the require fields are present
|
||||
//
|
||||
s.backStack = s.backStack || [];
|
||||
s.forwardStack = s.forwardStack || [];
|
||||
s.current = s.current || {location:"", initialPlaceholder:true};
|
||||
s.current.location = s.current.location || "";
|
||||
}
|
||||
},
|
||||
forward: function(distance) {
|
||||
/// <summary locid="17">
|
||||
/// Navigate forwards
|
||||
/// </summary>
|
||||
/// <param name="distance" type="Number" optional="true" locid="18">
|
||||
/// The number of entries forward to go
|
||||
/// </param>
|
||||
/// <returns type="Promise" locid="19">
|
||||
/// Promise which is completed with a Boolean value indicating whether or not
|
||||
/// the navigation was successful
|
||||
/// </returns>
|
||||
distance = distance || 1;
|
||||
return go(distance, history.forwardStack, history.backStack, distance);
|
||||
},
|
||||
back: function(distance) {
|
||||
/// <summary locid="20">
|
||||
/// Navigate backwards
|
||||
/// </summary>
|
||||
/// <param name="distance" type="Number" optional="true" locid="21">
|
||||
/// The number of entries back into the history to go
|
||||
/// </param>
|
||||
/// <returns type="Promise" locid="19">
|
||||
/// Promise which is completed with a Boolean value indicating whether or not
|
||||
/// the navigation was successful
|
||||
/// </returns>
|
||||
distance = distance || 1;
|
||||
return go(distance, history.backStack, history.forwardStack, -distance);
|
||||
},
|
||||
navigate: function (location, initialState) {
|
||||
/// <summary locid="22">
|
||||
/// Navigate to a location
|
||||
/// </summary>
|
||||
/// <param name="location" locid="23">
|
||||
/// The location to navigate to. Generally the location is a string, but
|
||||
/// it may be anything.
|
||||
/// </param>
|
||||
/// <param name="initialState" locid="24">
|
||||
/// Navigation state which may be accessed through WinJS.Navigation.state
|
||||
/// </param>
|
||||
/// <returns type="Promise" locid="19">
|
||||
/// Promise which is completed with a Boolean value indicating whether or not
|
||||
/// the navigation was successful
|
||||
/// </returns>
|
||||
var proposed = { location:location, state: initialState };
|
||||
return raiseBeforeNavigate(proposed).
|
||||
then(function navBeforeCompleted(cancel) {
|
||||
if (!cancel) {
|
||||
if (!history.current.initialPlaceholder) {
|
||||
history.backStack.push(history.current);
|
||||
}
|
||||
history.forwardStack = [];
|
||||
history.current = proposed;
|
||||
|
||||
// error or no, we go from navigating -> navigated
|
||||
// cancelation should be handled with "beforenavigate"
|
||||
//
|
||||
return raiseNavigating().then(
|
||||
raiseNavigated,
|
||||
function (err) {
|
||||
raiseNavigated(undefined, err || true);
|
||||
throw err;
|
||||
}).then(function () { return true; });
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
addEventListener: function (eventType, listener, capture) {
|
||||
/// <summary>
|
||||
/// Adds an event listener to the control.
|
||||
/// </summary>
|
||||
/// <param name='eventType'>
|
||||
/// The type (name) of the event.
|
||||
/// </param>
|
||||
/// <param name='listener'>
|
||||
/// The listener to invoke when the event gets raised.
|
||||
/// </param>
|
||||
/// <param name='capture'>
|
||||
/// Specifies whether or not to initiate capture.
|
||||
/// </param>
|
||||
listeners.addEventListener(eventType, listener, capture);
|
||||
},
|
||||
removeEventListener: function (eventType, listener, capture) {
|
||||
/// <summary>
|
||||
/// Removes an event listener from the control.
|
||||
/// </summary>
|
||||
/// <param name='eventType'>
|
||||
/// The type (name) of the event.
|
||||
/// </param>
|
||||
/// <param name='listener'>
|
||||
/// The listener to remove from the invoke list.
|
||||
/// </param>
|
||||
/// <param name='capture'>
|
||||
/// Specifies whether or not to initiate capture.
|
||||
/// </param>
|
||||
listeners.removeEventListener(eventType, listener, capture);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperties(WinJS.Navigation, WinJS.Utilities.createEventProperties(navigatedEventName, navigatingEventName, beforenavigateEventName));
|
||||
})(WinJS);
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
function initWithWinRT() {
|
||||
var sto = Windows.Storage;
|
||||
var local, temp, roaming;
|
||||
|
||||
var IOHelper = WinJS.Class.define(
|
||||
function (folder) {
|
||||
this.folder = folder;
|
||||
this._path = folder.path;
|
||||
}, {
|
||||
exists: function (fileName) {
|
||||
/// <summary locid="25">
|
||||
/// Determines if the specified file exists in the container
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="26">
|
||||
/// The file which may exist within this folder
|
||||
/// </param>
|
||||
/// <returns locid="27">
|
||||
/// Promise with either true (file exists) or false.
|
||||
/// </returns>
|
||||
return this.folder.getFileAsync(fileName).
|
||||
then(
|
||||
function () { return true; },
|
||||
function () { return false; }
|
||||
);
|
||||
},
|
||||
remove: function (fileName) {
|
||||
/// <summary locid="28">
|
||||
/// Delets a file in the container
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="29">
|
||||
/// The file to be deleted
|
||||
/// </param>
|
||||
/// <returns locid="30">
|
||||
/// Promise which is fulfilled when the file has been deleted
|
||||
/// </returns>
|
||||
var that = this;
|
||||
return that.folder.getFileAsync(fileName).
|
||||
then(
|
||||
function (fileItem) {
|
||||
return fileItem.deleteAsync();
|
||||
},
|
||||
function() { return false; }
|
||||
);
|
||||
},
|
||||
writeText: function (fileName, str) {
|
||||
/// <summary locid="31">
|
||||
/// Writes a file to the container with the specified text
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="32">
|
||||
/// The file to write to
|
||||
/// </param>
|
||||
/// <param name="str" type="String" locid="33">
|
||||
/// Content to be written to the file
|
||||
/// </param>
|
||||
/// <returns locid="34">
|
||||
/// Promise with the count of characters written
|
||||
/// </returns>
|
||||
var that = this;
|
||||
return that.folder.createFileAsync(fileName, sto.CreationCollisionOption.replaceExisting).
|
||||
then(function (fileItem) {
|
||||
return fileItem.openAsync(sto.FileAccessMode.readWrite);
|
||||
}).then(function (randomAccessStream) {
|
||||
var outputStream = randomAccessStream.getOutputStreamAt(0);
|
||||
|
||||
var writer = new Windows.Storage.Streams.DataWriter(outputStream);
|
||||
var count = writer.writeString(str);
|
||||
return writer.storeAsync().then(function() {
|
||||
return outputStream.flushAsync().then(function() {
|
||||
return count;
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
readText: function (fileName, def) {
|
||||
/// <summary locid="35">
|
||||
/// Reads the contents of a file from the container, if the file
|
||||
/// doesn't exist, def is returned.
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="36">
|
||||
/// The file to read from
|
||||
/// </param>
|
||||
/// <param name="def" type="String" locid="37">
|
||||
/// Default value to be returned if the file failed to open
|
||||
/// </param>
|
||||
/// <returns locid="38">
|
||||
/// Promise containing the contents of the file, or def.
|
||||
/// </returns>
|
||||
var that = this;
|
||||
function onerror() { return def; }
|
||||
|
||||
return that.folder.getFileAsync(fileName).
|
||||
then(function (fileItem) {
|
||||
return fileItem.openAsync(sto.FileAccessMode.read).
|
||||
then(function (randomAccessStream) {
|
||||
var reader = new Windows.Storage.Streams.DataReader(randomAccessStream.getInputStreamAt(0));
|
||||
var size = randomAccessStream.size;
|
||||
return reader.loadAsync(size).then(function () {
|
||||
var fileContents = reader.readString(size);
|
||||
return (fileContents);
|
||||
}, onerror);
|
||||
}, onerror);
|
||||
}, onerror);
|
||||
}
|
||||
});
|
||||
|
||||
WinJS.Namespace.define("WinJS.Application", {
|
||||
local: { get: function() {
|
||||
if (!local) {
|
||||
local = new IOHelper(sto.ApplicationData.current.localFolder);
|
||||
}
|
||||
return local;
|
||||
}},
|
||||
temp: { get: function() {
|
||||
if (!temp) {
|
||||
temp = new IOHelper(sto.ApplicationData.current.temporaryFolder);
|
||||
}
|
||||
return temp;
|
||||
}},
|
||||
roaming: { get: function() {
|
||||
if (!roaming) {
|
||||
roaming = new IOHelper(sto.ApplicationData.current.roamingFolder);
|
||||
}
|
||||
return roaming;
|
||||
}}
|
||||
});
|
||||
};
|
||||
|
||||
function initWithStub() {
|
||||
var InMemoryHelper = WinJS.Class.define(
|
||||
function () {
|
||||
this.storage = {};
|
||||
}, {
|
||||
exists: function (fileName) {
|
||||
/// <summary locid="25">
|
||||
/// Determines if the specified file exists in the container
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="39">
|
||||
/// The filename which may exist within this folder
|
||||
/// </param>
|
||||
/// <returns locid="27">
|
||||
/// Promise with either true (file exists) or false.
|
||||
/// </returns>
|
||||
// force conversion to boolean
|
||||
//
|
||||
return WinJS.Promise.as(this.storage[fileName] !== undefined);
|
||||
},
|
||||
remove: function (fileName) {
|
||||
/// <summary>
|
||||
/// Delets a file in the container
|
||||
/// </summary>
|
||||
/// <param name='fileName' type='String'>
|
||||
/// The file to be deleted
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Promise which is fulfilled when the file has been deleted
|
||||
/// </returns>
|
||||
delete this.storage[fileName];
|
||||
return WinJS.Promise.as();
|
||||
},
|
||||
writeText: function (fileName, str) {
|
||||
/// <summary locid="31">
|
||||
/// Writes a file to the container with the specified text
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="40">
|
||||
/// The filename to write to
|
||||
/// </param>
|
||||
/// <param name="str" type="String" locid="33">
|
||||
/// Content to be written to the file
|
||||
/// </param>
|
||||
/// <returns locid="34">
|
||||
/// Promise with the count of characters written
|
||||
/// </returns>
|
||||
this.storage[fileName] = str;
|
||||
return WinJS.Promise.as(str.length);
|
||||
},
|
||||
readText: function (fileName, def) {
|
||||
/// <summary locid="35">
|
||||
/// Reads the contents of a file from the container, if the file
|
||||
/// doesn't exist, def is returned.
|
||||
/// </summary>
|
||||
/// <param name="fileName" type="String" locid="41">
|
||||
/// The filename to read from
|
||||
/// </param>
|
||||
/// <param name="def" type="String" locid="37">
|
||||
/// Default value to be returned if the file failed to open
|
||||
/// </param>
|
||||
/// <returns locid="38">
|
||||
/// Promise containing the contents of the file, or def.
|
||||
/// </returns>
|
||||
return WinJS.Promise.as(this.storage[fileName] || def);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
WinJS.Namespace.define("WinJS.Application", {
|
||||
local: new InMemoryHelper(),
|
||||
temp: new InMemoryHelper(),
|
||||
roaming: new InMemoryHelper()
|
||||
});
|
||||
}
|
||||
|
||||
if (window.Windows && Windows.Storage && Windows.Storage.ApplicationData) {
|
||||
initWithWinRT();
|
||||
}
|
||||
else {
|
||||
initWithStub();
|
||||
}
|
||||
|
||||
|
||||
WinJS.Namespace.define("WinJS.Application", {
|
||||
sessionState: { value: {}, writable: true, enumerable: true },
|
||||
_loadState: function (e) {
|
||||
var app = WinJS.Application;
|
||||
|
||||
// we don't restore the state if we are already running, or if we are
|
||||
// booting for the first time
|
||||
//
|
||||
if (e.previousExecutionState !== 0 /* ApplicationExecutionState.NotRunning */ && e.previousExecutionState !== 1 /* ApplicationExecutionState.CurrentlyRunning */) {
|
||||
return app.local.readText("_sessionState.json", "{}").
|
||||
then(function (str) {
|
||||
app.sessionState = JSON.parse(str);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return WinJS.Promise.as();
|
||||
}
|
||||
},
|
||||
_oncheckpoint: function (e) {
|
||||
var app = WinJS.Application;
|
||||
e.setPromise(app.local.writeText("_sessionState.json", JSON.stringify(app.sessionState)));
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||