Making COM Collections Easily Consumable by .NET

April 13, 2015

In .NET, developers are accustomed to using constructs such as foreach to iterate over collections. In .NET, “Collection” refers to two types of objects: 1. Those that implement the IEnumerable or IEnumerable<T> interface.2. objects that don’t implement these interfaces, but have a method called GetEnumerator that return some object that has the following: a. Has a MoveNext method that returns a boolean and accepts nothing.b. Has a Current property that returns the type of object that the collection provides. Notice that no IEnumerator interface implementation is required. All this means that the (e.g. C#) compiler does pattern matching...
no comments

Building a Cross Platform Game with MonoGame – Part 2

March 19, 2015

In the first part we’ve seen how to install MonoGame for use with Visual Studio and how to create a new project. We’ve seen some of the boilerplate code created by the project wizard and discussed briefly the game asset file. We are now ready to put our own special stuff into the game. We’ll start by doing some cleanup, as our project has the default spinning cube. I’ve also renamed the Game class from Game1 to InavdersGame and the C# file correspondingly. Open InvadersGame.cs and remove all the code in the Draw method except the Clear call:protected override void Draw(GameTime...
one comment

Building a Cross Platform 2D Game with MonoGame (Part 1)

March 12, 2015

Ever since Microsoft ditched the XNA framework (for whatever reason), it didn’t provide any viable alternative for .NET developers. Microsoft attempted to encourage developers to switch to native DirectX to do game development (and other apps that would otherwise benefit from XNA). But DirectX is not a real alternative “out of the box” for .NET (and even C++) developers; DirectX is very low-level, and it’s almost impractical to create a full-fledged game with DirectX directly; DirectX is a great base for game engines. For writing an actual game, developers typically use some framework that sits on top of...
one comment

File Open Picker in Windows Phone 8.1

February 18, 2015

The Windows 8 Store model introduced the FileOpenPicker class, which is kind of the modern replacement for the classic Windows open file dialog. Technically, it’s more than that – it can get files from “virtual” locations such as Facebook and OneDrive; and besides, it looks much better than the classic open file dialog. Showing the FileOpenPicker is just a matter of calling PickSingleFileAsync or PickMultipleFilesAsync and awaiting for the result: var picker = new FileOpenPicker {         FileTypeFilter = { ".jpg", ".png" },         ViewMode = PickerViewMode.Thumbnail }; var file = await picker.PickSingleFileAsync();   When Universal apps came along, it...
no comments

Tip: Enable Kernel Debug output on Vista and up

December 17, 2014

Those writing device drivers, or are interested in seeing outputs from a kernel driver’s calls to the KdPrint macro or the DbgPrint function may find that the messages don’t appear on Windows Vista or newer versions of Windows. Even when using a tool such as DebugView (from SysInternals), running with administrative privileges, with kernel capture turned on, nothing seem to appear from expected drivers: The reason is that in Vista and up kernel output is conditional, based on some flags that can be set in KdPrintEx, DbgPrintEx, etc. A complete explanation can be found in the MS...
no comments

Introduction to Win2D

November 19, 2014

The Windows Runtime UI stack uses XAML for general 2D layout and graphics. It provides various controls, such as TextBox, ItemsControl and DatePicker. It even provides shape-like elements such as Line, Ellipse, Rectangle and Path. However, the XAML layout and rendering engine, while flexible, may not be performant enough for certain kind of applications and games. Also, it does not support general “drawing” functions (WPF for example, does provide that with the DrawingContext class). Win2D is a new Windows Runtime library that is currently in development by Microsoft that provides a WinRT wrapper over Direct2D. Direct2D is a DirectX...
no comments

WRL Class Library Template for Windows Phone 8.1

October 6, 2014

The Windows Runtime Library (WRL) is a C++ class library that can be used to author Windows Runtime components in standard C++, without resorting to the C++/CX extensions. The flip side is that it’s much more verbose than C++/CX, looks somewhat similar to authoring COM components with the Active Template Library (ATL). Also, WRL can be used to consume WinRT types without any special extensions. Visual Studio does not provide a project template out of the box for authoring WinRT components with WRL. The team at Microsoft, however, created such a template back in the Windows 8, Visual Studio...
no comments

Windows 10 Preview – First Impressions

October 1, 2014

The curtain is lifted… Microsoft’s new OS is revealed in all its preview – Windows 10. Yes, the name is unexpected. Better guesses were “Windows 9”, “Windows One”, just “Windows” and probably a few others. I admit I don’t like the “10” name. Even-numbered Windows names/versions lately tend to have issues… To install Windows 10 all you need to do is go to , register as an “insider” (which really means anyone), download the bits and install. Of course, I would not use it on a production system. I installed mine on a Hyper-V virtual machine (I’ve used...

“Universal” Mandelbrot

September 10, 2014

Those of you following my blog may have noticed a somewhat “obsessiveness” with the Mandelbrot Set. In the past, I’ve created a WPF version and a C++ AMP version (and privately a few more versions). I thought it was high time to write yet another version as a “Universal” app, running on Windows 8.1 and Windows Phone 8.1, while sharing as much code and XAML as possible. My approach was to port the WPF version to universal. First, I created a blank new Universal App project in C#: This results in 3 projects being created – Mandelbrot.Windows, Mandelbrot.WindowsPhone...
no comments

Tip: Accessing Binary Resources in Portable Class Library

August 10, 2014

Portable Class Libraries (PCLs) provide a nice way to share code by allowing the library to be referenced from a number of different types of projects. As I’ve blogged before, when targeting Windows Phone 8.1 and Windows 8.1 the common surface for the PCL grows significantly and even allows sharing of XAML and other UI-related types. However, when targeting more frameworks such as the desktop .NET, the common surface drops significantly. One of the things we may want to do is to add some binary resource (image, XML file, etc.) and process it as part of the PCL. This...
no comments