Converting hex string into Color (Windows Phone)

In Windows Phone (Silverlight) there is no System.Drawing.ColorTranslator.FromHtml(“#cccccc”); or similar that can help you convert a hex string into a color object. To do this you’ll have to parse the string yourself. So is a simple method that will do so, it supports both “argb” and “rgb” with or without “#” in front of it. … Read more

Async callback to awaitable Task<>

The Async-Await feature in .Net is really super. At least until it comes to debugging, exception handling and race conditions. In short it cuts down on code, bugs, complexity and allows for linear programming. Traditional async programming uses callbacks (events) that adds to code complexity, it also forces an unnatural break in your code. Luckily … Read more

Battlefield Heroes Rcon .Net library

What is BFH? Battlefield Heroes is a free-to-play first person cartoon shooter. 8×8 players battle it out on different maps using traditional weapons and special abilities. My server http://www.battlefieldheroes.com/en/bookmark/server:0104ea2f-1c0f-42a1-b05e-e19e33a6f4ba You need to bookmark, start the game, select “Game finder”, select “Bookmarked” and locate the server to join it. Background For the past few years I … Read more

Async/await HTTP server in C#

Since there has been a bit of interest for the code below I mocked together another version: Kernel.HttpServer.zip Background Ok, so there are already alternatives for web servers in C#. Some of them are very feature rich. http://cassinidev.codeplex.com/ http://webserver.codeplex.com/ http://www.codeproject.com/Articles/137979/Simple-HTTP-Server-in-C http://www.codeproject.com/Articles/1505/Create-your-own-Web-Server-using-C http://kayakhttp.com/ http://mikehadlow.blogspot.no/2006/07/playing-with-httpsys.html http://ultidev.com/products/cassini/ http://lmgtfy.com/?q=c%23+webserver But I wanted to play around with TPL and async/await a … Read more

.Net Dictionary speed and memory

I love writing and optimizing stuff that puts strain on memory and CPU. Lately I’ve been wondering how well the .Net Dictionary object performs, and after looking at the source code for it, Googling and SO’ing I thought it would be good to complete the project with some real-world data that could be shared. So … Read more

Resolving application path in .dll Web, Console, WinForms and WPF applications

When sharing .dll’s between desktop applications and web applications finding the current application path can be troublesome. For desktop applications you can usually just use the path of a loaded assembly (.exe or .dll) in the application directory. For web applications that won’t work since the .dll’s are copied to a temporary directory when the … Read more

Locating config file from .dll in both Desktop and Web applications

I’m using Nini for most my config needs. Nini is a .Net library for reading/writing/merging all kinds of config files. It provides a good API with type conversion, default values, etc. To be able to access both app.config and web.config using Nini in .dll files included in test projects, desktop applications, services, web applications, webservices, … Read more

Unsafe kernel32-mapped memory Bitmap WPF

Okay, its vacation time so I thought I’d take time from vacation (and from reading news about the terror attacks in Oslo that happened a few miles from here) to do a little post. This time is an unsafe kernel32 memory mapped bitmap image I’m constantly improving upon. I do a lot of DSP-related stuff … Read more

Early alpha release: Kinect C# Starter Kit

NOTE: Microsoft has released Kinect SDK since this article was written. You probably want that instead of this. 🙂 Much of the stuff I’m doing with Kinect involves two input pictures and one output I figured I’d make a platform to make it easy to test new stuff. The main idea is that I can … Read more

Kinect

Yesterday I bought a Kinect and hooked it up to my PC. After a couple of hours of compiling drivers and finally realizing I had to switch USB ports for the camera to work I could start writing code. I used the CLNUIDeviceTest as a base since it already had the lines of code required … Read more