Skip to content

Instantly share code, notes, and snippets.

@Convicted202
Last active August 29, 2015 14:10
Show Gist options
  • Save Convicted202/9e2fe51551f2162bc0a8 to your computer and use it in GitHub Desktop.
Save Convicted202/9e2fe51551f2162bc0a8 to your computer and use it in GitHub Desktop.
Usefull files for MCSD
<h2><span data-win-res="{textContent: 'greeting'}"></span></h2>
and resource file with .resjson extension within strings folder:
eng
{
"greeting" : "Hello",
"_greeting.comment" : "A welcome greeting"
}
dutch
{
"greeting" : "Hallo",
"_greeting.comment" : "A welcome greeting"
}
http://msdn.microsoft.com/en-US/library/windows/apps/windows.devices.pointofservice.barcodescanner
var barcodeScanner = Windows.Devices.PointOfService.BarcodeScanner;
/CheckHealthAsync - Tests the state of the barcode scanner./;
/ClaimScannerAsync - Attempts to get an exclusive access to the barcode scanner./;
/GetDefaultAsync - Returns the first available barcode scanner./;
/GetDeviceSelector - Returns an Advanced Query Syntax (AQS) string this is used to enumerate available barcode scanners./;
http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.cameracaptureui.photosettings.aspx
// Takes a photo with specified settings.
function takePhoto() {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
captureUI.photoSettings.allowCropping = true;
captureUI.photoSettings.croppedAspectRatio.height = 3;
captureUI.photoSettings.croppedAspectRatio.width = 4;
captureUI.photoSettings.croppedSizeInPixels.height = 0;
captureUI.photoSettings.croppedSizeInPixels.width = 0;
captureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg;
captureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable;
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
if (capturedItem) {
document.getElementById("message").innerHTML = "User captured a photo."
}
else {
document.getElementById("message").innerHTML = "User didn't capture a photo."
}
});
}
https://code.msdn.microsoft.com/windowsapps/Magnetic-stripe-reader-30aa2ca5
http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.pointofservice.magneticstripereader.aspx
function startRead() {
// Get the default magnetic stripe reader.
Windows.Devices.PointOfService.MagneticStripeReader.getDefaultAsync().then(function (reader) {
if (reader !== null) {
_reader = reader;
WinJS.log && WinJS.log("Default Magnetic Stripe Reader created.", "sample", "status");
WinJS.log && WinJS.log("Device Id is:" + reader.deviceId, "sample", "status");
// Claim the magnetic stripe reader for exclusive use.
//=================================================
// This function call way to review in future!!!
//=================================================
reader.claimReaderAsync().done(function (claimedReader) {
_claimedReader = claimedReader;
claimedReader.isDecodeDataEnabled = true;
WinJS.log && WinJS.log("Claim Magnetic Stripe Reader succeeded.", "sample", "status");
// Register event listeners
claimedReader.addEventListener("bankcarddatareceived", onBankCardDataReceived);
// Enable receiving data
claimedReader.enableAsync().done(function () {
WinJS.log && WinJS.log("Enable Magnetic Stripe Reader succeeded.", "sample", "status");
WinJS.log && WinJS.log("Ready to swipe...", "sample", "status");
document.getElementById("startReadButton").disabled = true;
document.getElementById("endReadButton").disabled = false;
}, function error(e) {
WinJS.log && WinJS.log("Error enabling reader..." + e.message, "sample", "status");
});
}, function error(e) {
WinJS.log && WinJS.log("Could not claim reader..." + e.message, "sample", "status");
});
}
else {
WinJS.log && WinJS.log("Could not claim reader...", "sample", "status");
}
}, function error(e) {
WinJS.log && WinJS.log("Magnetic Stripe Reader not found. Please connect a Magnetic Stripe Reader.", "sample", "status");
});
}
function onPrintTaskRequested(printEvent) {
var printTask = printEvent.request.createPrintTask("Print Sample", function (args) {
args.setSource(MSApp.getHtmlPrintDocumentSource(document));
// Choose the printer options to be shown.
// The order in which the options are appended determines the order in which they appear in the UI
printTask.options.displayedOptions.clear();
printTask.options.displayedOptions.append(Windows.Graphics.Printing.StandardPrintTaskOptions.copies);
printTask.options.displayedOptions.append(Windows.Graphics.Printing.StandardPrintTaskOptions.mediaSize);
printTask.options.displayedOptions.append(Windows.Graphics.Printing.StandardPrintTaskOptions.orientation);
printTask.options.displayedOptions.append(Windows.Graphics.Printing.StandardPrintTaskOptions.duplex);
// Preset the default value of the printer option
printTask.options.mediaSize = Windows.Graphics.Printing.PrintMediaSize.northAmericaLegal;
// Register the handler for print task completion event
printTask.oncompleted = onPrintTaskCompleted;
});
}
http://msdn.microsoft.com/en-us/library/windows/apps/hh465229.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/hh921583.aspx
To enable make changes in CAPABILITIES tab in app manifest:
- Enterprise authentication (enterpriseAuthentication): Uses Windows credentials for access to a corporate intranet. This is typically used in line-of-business apps that connect to servers within an enterprise. You don't need this capability for generic communication across the internet.
- Shared User Certificates (sharedUserCertificates): Enables an app to access software and hardware certificates, such as certificates stored on a smart card. This is typically used for financial or enterprise apps that require a smart card for authentication.
- Documents library (documentsLibrary): Allows programmatic access to the user's Documents library, filtered to the file type associations declared in the package manifest. Apps can use the file picker to access a user's Documents library without declaring this capability.
- Important Apps using this capability can only be submitted from developer accounts which can demonstrate they have acquired an Extended Validation (EV) code signing certificate from a certificate authority (CA). See Account types, locations, and fees for more info.
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/NsIWorkerScope#close()
var w = WebWorker('web.js');
to terminate a web worker following might be used:
- invoking w.terminate() from the main calling code
- calling close() from within the WebWorker, so it can be closed by itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment