|
// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
"use strict";
var app = WinJS.Application;
// This function responds to all application activations.
app.onactivated = function (eventObject) {
if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
// TODO: Initialize your application here.
WinJS.UI.processAll();
document.querySelector("#btnDownloadImg").addEventListener("click", function () {
getImage();
});
getImage();
};
function getImage() {
var imgUrl = document.querySelector("#txtUrl").value;
var fileName = document.querySelector("#txtFileName").value;
imgDownloader.download(imgUrl, fileName).then(function () {
imgDownloader.fileExists(fileName).then(function (file) {
document.querySelector("#mainImg").src = URL.createObjectURL(file, false);
// using the ms-appdata:// protocol.
document.querySelector("#mainImg2").src = "ms-appdata:///Local/" + fileName;
document.querySelector("#filePath").textContent = "Path: " + file.path;
document.querySelector("#fileType").textContent = "Display Type: " + file.displayType;
document.querySelector("#dateCreated").textContent = "Date Created: " + file.dateCreated;
drawGallery();
}, function (err) {
var msg = new Windows.UI.Popups.MessageDialog("Picture Not Found");
msg.showAsync();
});
});
}
}
function drawGallery() {
Windows.Storage.ApplicationData.current.localFolder.getItemsAsync().then(function (items) {
var div = document.querySelector("#existingFiles");
div.textContent = "";
items.forEach(function (storageItem) {
if (storageItem.fileType === ".png" || storageItem.fileType === ".jpg" || storageItem.fileType === ".jpeg") {
var image = document.createElement("img");
image.style.width = "100px"
image.style.height = "100px"
image.src = URL.createObjectURL(storageItem);
image.alt = image.src;
div.appendChild(image);
}
}, function (e) {
var msg = new Windows.UI.Popups.MessageDialog(e);
msg.showAsync();
});
});
}
app.start();
})();
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.
My Blog: http://blogs.microsoft.co.il/blogs/shair/