Monday, April 16, 2012

Windows 8 JavaScript–Change Lock Screen Image

In the past couple of months I’ve worked a lot with Windows 8 JavaScript and C#, I’ve also wrote plenty of posts on that subject and there is much more stuff to talk about.

In this post I’ll show two things:

Using File Picker using JavaScript
Change Windows 8 Lock Screen Image Programmatically

Inline image 1

Step 1: Create Blank JavaScript Project

In the app.onactivated function we add the following code to listen the Choose Picture button and calling the displayCurrentImg function. 
When you click the Choose Picture button we call the openFilePicker function.

app.onactivated = function (eventObject) {
    if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
       $("#btnBrowse").addEventListener("click", function () {
            openFilePicker();
        }, false);
 
        displayCurrentLockImg();
        WinJS.UI.processAll();
    }
};

Step 2: Find The Current Lock Screen Image

You might notice that in the previous step I used $ char to find the button element, no I’m not using JQuery, I’ve just create a function that return the querySelector return value based on the value we pass. I said it before and I’ll say it again there is not need to add JQuery to Windows 8 Application everything you need is there!

Read more: Shai Raiten
QR: Inline image 2

Posted via email from Jasper-Net