winjs

HTML5 Canvas performance very poor using rect()

一曲冷凌霜 提交于 2019-12-01 19:54:36
I'm writing a game, which displays the score at the top of the screen in the following fashion: canvasContext.fillStyle = "#FCEB77"; canvasContext.fillText(' Score: ' + Math.floor(score) + ' Lives: ' + Math.floor(lives) + ' other info: ' + Math.floor(otherInfo)); Which works fine. What I then wanted to do was to draw a box around that text; so I tried the following: canvasContext.rect(2, 1, 210, 30); canvasContext.rect(2, 1, 80, 30); canvasContext.rect(80, 1, 70, 30); canvasContext.strokeStyle = "#FCEB77"; canvasContext.stroke(); And when I ran the game the impact of performance was

How to draw string to a bitmap image in WinRT

此生再无相见时 提交于 2019-12-01 19:26:19
How do you draw a string to an image in winRT ? In WinForms that could be done using drawstring() method inside the system.drawing namespace but i couldn't find its equivalent in WinRT API. Direct2D is a replacement for GDI in WinRT. So you'll have to use C++/CX with DirectX for drawing text. I don't have any examples for you, but maybe this link (and the links included) can help you on your way. In Windows 8.1 they finally support rendering of XAML controls to bitmap. Now you can use var renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(uiElement, width,

Handle application exit

↘锁芯ラ 提交于 2019-12-01 12:48:40
I want to run some cleanup code(like unregistering scheduled notifications) when a user quits the application by using the Alt-F4 or swipe down gesture. Is there any way to handle an application exit in WinJS? I've read the docs for the WinJS.Application object but don't see any methods to handle user exits. There is no special event that indicates that an app is being closed: There's no special event to indicate that the user has closed an app. After an app has been closed by the user, it's suspended and terminated, entering the NotRunning state within about 10 seconds. If an app has

Handle application exit

心已入冬 提交于 2019-12-01 10:26:17
问题 I want to run some cleanup code(like unregistering scheduled notifications) when a user quits the application by using the Alt-F4 or swipe down gesture. Is there any way to handle an application exit in WinJS? I've read the docs for the WinJS.Application object but don't see any methods to handle user exits. 回答1: There is no special event that indicates that an app is being closed: There's no special event to indicate that the user has closed an app. After an app has been closed by the user,

Why does toStaticHTML remove data-* attributes

杀马特。学长 韩版系。学妹 提交于 2019-12-01 08:09:24
My application dynamically builds HTML content as a string and when finished the content is being attached to the DOM. In WinJS however this throws exceptions once I try to attach the string to the DOM. In order to work around these exceptions I have to sanitize the HTML by running it through toStaticHTML, which is globally defined in WinJS as well as in Internet Explorer. The issue that I am having is that there are quite a lot of use of data-* html5 attributes. Once I run those through toStaticHTML they are being stripped. Why does toStaticHTML remove data-* attributes? What is the real

Why does toStaticHTML remove data-* attributes

大憨熊 提交于 2019-12-01 07:03:24
问题 My application dynamically builds HTML content as a string and when finished the content is being attached to the DOM. In WinJS however this throws exceptions once I try to attach the string to the DOM. In order to work around these exceptions I have to sanitize the HTML by running it through toStaticHTML, which is globally defined in WinJS as well as in Internet Explorer. The issue that I am having is that there are quite a lot of use of data-* html5 attributes. Once I run those through

WinJS loading local json file

非 Y 不嫁゛ 提交于 2019-12-01 05:34:16
I am banging my head on this one. I cannot find a way to open a simple json file from a subfolder in my WinJS App. I have tried Ajax and WinJS.xhr, both to no avail. I have also looked into opening the file the "old fashioned" way with something like File.Open in .NET, but I couldn't find anything besides WinJS.Application.local.readText, which I tried with both an absolute and a relative path. I'm at the end of my rope here, does anyone have a working snippet that you can share? You can refer to files in the app package using URLs in the form: ms-appx:///data/data.json (Notice that there are

How do I hide virtual keyboard for select element in Win8 JavaScript app?

三世轮回 提交于 2019-12-01 05:14:58
I'm creating a Windows 8 application in JavaScript. I have these html elements in the markup: <input id="myField1" type="number"></input> <select id="myField2"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> </select> When I tap myField1 on the device without physical keyboard, virtual keyboard appears. After that if I tap on the myField2 , the keyboard remains in place. But I don't want to have typeahead in this particular <select> field. Is there a way to hide the virtual keyboard for it, enabling it only for <input> fields? Sushil As

WinJS loading local json file

杀马特。学长 韩版系。学妹 提交于 2019-12-01 03:14:25
问题 I am banging my head on this one. I cannot find a way to open a simple json file from a subfolder in my WinJS App. I have tried Ajax and WinJS.xhr, both to no avail. I have also looked into opening the file the "old fashioned" way with something like File.Open in .NET, but I couldn't find anything besides WinJS.Application.local.readText, which I tried with both an absolute and a relative path. I'm at the end of my rope here, does anyone have a working snippet that you can share? 回答1: You can

How do I create a pre-build step for a javascript metro app in VS11?

风格不统一 提交于 2019-11-30 16:19:09
I want to run some custom batch code just before every build. In a VS<11/C# app I could set the pre-build events in the project settings. I can't find similar settings in a javascript metro VS11 solution. Anyone know where it is, or if the option is gone (!) what kind of workaround I can do in its place? You can use the BeforeBuild target in the Visual Studio .jsproj file to accomplish this: <Target Name="BeforeBuild"></Target> <Target Name="AfterBuild"></Target> To get here: Right-click your project in Visual Studio and choose Open Folder in Windows Explorer In Explorer, right-click the