C#

Async CustomMessageBox on Windows Phone

UPDATE: There’s a new Version with .NET4.5 Support, Code Samples Hey there, As you may know, there’s just a limited set of MessageBoxButtons available in Silverlight for WP. However, you can make your own MessageBox in your Silverlight app using the Microsoft.Xna.Framework.GamerServices namespace as explained in this tutorial by Den Delimarsky. This method uses the old style async, which really sucks, so I decided to go the cool and smart new async way. You need Visual Studio Async CTP and Visual Studio 2010 to do this. The trick is to wrap the old async methods together with async Tasks, resulting in a Task<int> that shows the custom message box and returns the selected button in just one line: int result = await CustomMessageBox.ShowAsync(“Dinner time!”, “What do you prefer?”, 0, CustomMessageBoxIcon.Alert, “German”, “Italian”); Asynchronously and therefore non-UI-thread-blocking, of course If you’re interested you can have a look at the source: CustomMessageBox.cs…

Metro

Column-Styled GridView

Today I had to figure out a way to make a single-row, column-styled GridView that looked like this: Some minor design improvements are still to be made, but the hardest part is done. Particulary tricky was, that the items didn’t want to Stretch the height. (I wanted to avoid hard-coding the height, because of different screen resolutions.) Finally I’m using a GridView – I archived almost the same results with a ListView, but the ScrollBar was gone.. Maybe this is possible with a ListBox as well, but maybe I want to integrate this with a SemanticZoom control later, which requires ListView or GridView. Here’s a screenshot of the XAML code: You can copy/paste the following: <GridView ItemsSource=”{Binding Mensen}” SelectionChanged=”GridView_SelectionChanged”>                 <GridView.ItemTemplate>                     <DataTemplate>                         <Grid Background=”Green” Width=”250″>                             <Grid.RowDefinitions>                                 <RowDefinition Height=”Auto” />                                 <RowDefinition Height=”*” />                             </Grid.RowDefinitions>                             <TextBlock Grid.Row=”0″ Text=”{Binding Titel}” Foreground=”{StaticResource ListViewItemOverlayForegroundThemeBrush}” Style=”{StaticResource TitleTextStyle}” Height=”60″ Margin=”15,0,15,0″…

C#

Making a reverse Autocomplete-TextBox on Windows Phone

I’m sure you’re familiar with autocomplete textboxes and maybe you’ve even used them in a project yourself. They provide a fast and easy way for the user to select something, but they lack one important feature: they don’t show what could be selected. ReverseAutocompletePopup is a mixture between an autocomplete text box and the kind of popup you get when a ComboBox has more than five items. At first it displays all options in a ListBox and as you type non-matching ones are filtered out. (And brought back when you delete the text!) EDIT: In the newer version, the user can hit Enter to select, or optionally use his input as the result. When working with it there’re a few things you need to have in mind: The Popup control is no real navigation-thing, so you are in charge to handle OnBackKeyPress according to the guidelines! The Options for the…

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…

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…

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…