C#

Running a synchronous method in an asynchronous context

In WinRT a significant portion of all native methods are asynchronous. Using an asynchronous method is very easy an can help you to speed up you application. The requirement to use an async method is that the calling method has an async modifier. It’s easy to use async methods from a native API, but it can be useful as well to run synchronous operations off the UI thread. This should be done to prevent the UI thread from beeing blocked by time-consuming or resource-intensive operations like calculating ϖ or the answer to the ultimate question for the life, the universe and everything. To show you how to run things like this asynchronously we take the following synchronous method: private void synchonousMethod() { do { i++; } while (i < Int32.MaxValue / 2); } This method obviously lacks the async and await keywords and it’s usual implementation would be something like…

C#

SettingsContractWrapper – the easy way to integrate w/ settings

In the previous post I introduced the Flyout control. Now the most common use case for the Flyout controls is in the inegration with the settings contract. Integrating with the settings contract is usually a two-step procedure. First you have to add a SettingsCommand to the charm and then attach a Flyout or similar to it. Now that you have a Flyout you could do that on your own, but with the SettingsContractWrapper it is even more fun. To use it you  need to define one or more instances of SettingsEntry. This class holds the information required to set up the Flyout Its constructor takes three arguments: Title, FlyoutDimension, Content. The SettingsContractWrapper takes five arguments: Foreground, Background, Theme, Icon, SettingsEntries. The required namespaces are ‘TCD.Controls’ and ‘TCD.Controls.Settings’. As soon as you called the SettingsContractWrapper constructor you can forget about the settings contract integration. Just make sure that the UserControls you hand…

C#

Flyout control for Windows 8 Metro (XAML/C#)

IMPORTANT: This post ist partly outdated. TCD.Controls is now available on NuGet, so you don’t have to import the *.xaml into your project anymore! All code shown in this post still applies. Please refer to this post for more information on the changes. In Windows 8 Metro style apps there’s something called ‘Flyouts’. It’s a panel that slides in from the right. Sadly the control is not available to C#/VB developers. In this post Tim Heuer shows how to integrate with the settings contract using flyouts. Based on his code I developed a Flyout control for XAML/C# solutions. Here’s a list of what it can or can’t do: It does: light dismissal, back button easy integration of ‘content’ swipe-in transition custom color theme ‘narrow’ and ‘wide’ mode It does not: theming of the BackButton beeing attached to the left construct it in XAML I would like to provide you with a dll, but there’s a…

C#

KinDrive (for Kinect for Windows SDK 1.0)

Recently I migrated from Beta2 to Kinect for Windows SDK 1.0, so here’s a quick review of the new features: works w/ Kinect for Windows hardware AND the ‘old’ Kinect for XBox360 requires Kinect for Windows SDK 1.0 (or at least its runtime) tracks two players (you can play split-screen-games…) sends not only WASD keys, but also UHJK racing-mode only, no detection of additional gestures! (like the ones in the older versions) you can use the DLLs to write your own interface (and detect more gestures) –> mail me, or comment if you have questions Oh and one random thought: I think the delay you feel when playing a game with it, is due to the slowness of your hands rather than b/c of software-delay – it’s just a theory I can’t prove, but compare it with playing w/ a hardware steering wheel… Here’s the download link

C#

Kinect over Sockets

There’s no Kinect support in Windows 8 Metro, so I had to come up with a network-based solution to use the tracked skeleton data. A byproduct of this are the TCD.Networking and TCD.Kinect namespaces. Both have a Server and a Client child namespace (with simple network communication or Kinect over network..). What I can make available today is a sample of how to send Kinect-skeleton-data from a WPF server application through the network (or to localhost..) to a WPF client application. While an advantage of network-based routing is that you can have multiple clients, a major disadvantage is that you can’t use the tracking-engines methods to render 3D-coordinates to a pixel coordinate. I had to make a CustomSkeletonData class as well, b/c the JSON deserialization is kind of fussy. You may use all code and libraries you find in the solution to power your own projects =) Most of it…

Life

Try something new for 30 days

A few days ago I was inspired by this TED talk: [ted id=1183] I liked the idea and thought of what I could try for 30 days: Studying was never my favorite thing to do (at least not sitting there for hours, reading stuff..). So I bought a bag of 30 tea candles and now I study every day until the candle burned out. The important thing is that you must now allow yourself to got to bed while it is still burning. What I can tell you so far is that studying a whole candle-unit each day will be way to much for me, so when I passed all my exams I’ll extend the allowed activities to programming and things like that. There’re plenty of new things you can try out for 30 days, no doubt about that, so get crackin’!

Kinect

KinDrive enhanced – working w/ every game using DirectX input

Last week – on thursday to be precise – I stumbled over a library to send input to the system on DirectX-level, called InputManager (a big different to all the tons of SendKeys()-wrappers out there!!). So great thanks to Shay from Israel for making this awesome library!! As all the rest of the architechture was up and running already, I just made a simple WPF application to show the Skeleton and listen for a gesture as well. The gesture (streching your arms in the air) causes the WASD-input to halt, a press of the F-Key (which I usually use to enter vehicles/use weapons in games..) and finally after 3.5 seconds everything continues as before. Here’s a video of the KinDrive for GTA WPF application: Then of course: GTA IV: And just for fun – Need For Speed Carbon: For those interested in DirectX-level Keyboard/Mouse input: I’ll blog about the InputManager anytime soon. My plan is to open source…

Politik

Lesen: ACTA

Ich werde hier nicht viel darüber schreiben, was ACTA ist und warum es gefährlich ist, aber unter den Tisch fallen will darf ich es auch nicht einfach. Einen guten Überblick bietet dieser text bei Telemedicus. Wer dann einige der Paragrafen aufmerksam gelesen und auch festgestellt hat, dass so etwas nicht in Kraft treten darf, dem sei auch der 11. Februar als europaweiter internationaler Anti-ACTA Tag mitgeteilt, an dem in allen großen Städten Demonstrationen stattfinden!

Root

WikiSearch – a quick and dirty Windows 8 Metro App

I’ve been playing around with Windows 8 Metro development the last months and one day I did a quick Wikipedia App that integrates into the Search. The first version took me – no joke – less than 20 minutes, cause it’s just so easy! All you have to do to integrate into the search is to add this method to your App.xaml.cs: protected override void OnSearchActivated(SearchActivatedEventArgs args) { base.OnSearchActivated(args); if (mainPage == null) mainPage = new MainPage(); Window.Current.Content = mainPage; mainPage.OpenWiki(args.QueryText); Window.Current.Activate(); } After that go into Package.appxmanifest, switch to the Declarations tab and add a ‘Search’ declaration. mainPage.OpenWiki() would be a method that composes a Wikipedia-Search-URL from the queryText and tells a WebView to navigate to it. (webView.Source = new Uri(“http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=” + “queryString”);) I won’t go into any more detail at this point, but that is all the magic you have to do. Today I added multiple-language support to…