2012 was an amazing year, here’s a summary!

Posted by Filip Ekberg on January 8 2013 1 Comment

Saying that a lot happened in 2012 is probably an understatement. At least both on this blog and in my personal life, a bunch of amazing things have happened. I really hope that your previous year was good and let’s hope for an even better 2013. To start this year off I want to summarize all the great posts that were shared on this blog in 2012.

Personally the two biggest achievements of last year was me getting engaged to my lovely Sofie and publishing my book C# Smorgasbord. As you might have seen already this year has already started very good as I have been awarded Microsoft MVP in Visual C#!

Let me know what you found most interesting on this blog from the collection of posts below! Here is the 2012 summary!

Architecture

Tips & Tricks

Screencasts

Software & Tool information

Windows 8, Windows RT, WinRT and Surface

C# Smorgasbord and Self-publishing

Other

I hope you found this collection of posts useful and that you’ve learnt a lot in 2012! Enjoy 2013 and let me know what you think of the posts! Before we take part for this time, I want to share with you an image that describes the feeling I got when I held the first printed copy of C# Smorgasbord:

Vote on HN

Introduction to SignalR – Creating a Cross-Platform game

Posted by Filip Ekberg on November 29 2012 5 Comments

Have you had a chance to play with SignalR yet? If not, you’re really missing out! While preparing for a Swedish .NET User Group presentation, I did a test screencast on all my content that was going into the presentation. This screencast is uploaded to youtube so go check it out! It’s a bit over 1 hour long but well worth it if you want to get started with SignalR or just get some new inspiration!

Vote on HN

How do I choose where I want the new start screen in Windows 8?

Posted by Filip Ekberg on November 23 2012 7 Comments

If I would have gotten a penny for every time that someone told me or tweeted: “I want the old start button back in Windows 8!” I would have been richer than Bill Gates. First of all, the problem is that people seem scared of change, not willing to step out of their comfort zone and try something different. I’ve been running Windows 8 since February 2012 and I’ve come to love it a lot. Despite the lack of the old start button, I still find the operating system much more productive than before and it’s very intuitive!

Windows 8 doesn’t lack a “Start button” but they’ve replaced the old one. Install a tool like Start8 is like painting a new red Ferrari F50 as a rainbow; simply not by design.

Windows 8 has different use-cases

When I attended //BUILD/ Microsoft gave me a very nice Surface that I really like and what I like the most is that the transition between a tablet and a desktop computer is an awesome experience. I use the two devices completely different but still feel like home when using both of them. I rarely go into the standard desktop mode on my Surface, I only do so when I need to do some Word-processing or just manage files and on my Workstation I rarely go into the new Start screen (Modern UI), I only do so when I want to use the very powerful search.

There’s a Start button on Surface and it’s required by all vendors as far as I know that it’s there. This hardware button is one of the replacements for the old start button!

I don’t really use that so much because I find it much easier to just swipe from the right and get another start button. You can also press Win + C to get to this menu and you can also bring the pointer to the right corners to get this menu showing up!

So far there has been four ways to get a start button showing up which brings you to the new powerful start menu. The hardware button can easily translate into the keyboard start button and the swipe from the right is the point in corners version.

However, that is not it! There’s actually another way to show a start button, which also dictates where the start menu will show up.

How do I know where the start screen shows up?

I’ve heard people saying that they think the behavior of where the start screen is showing up is random, but frankly it is not. If you have a Modern UI application running on Screen 2, this is where the start screen will show up. If you move the application to Screen 1, that is where the start screen will show up.

But if you don’t have a Modern UI application running, what then?

Use the start button in the corners!

This start button shows up when you hover the different left bottom corners on any of your monitors and it will bring up the start screen on that monitor.

So you were saying there’s no start button? The old start button is gone, the old start menu is gone. It has been replaced by something much more productive and intuitive, step out of your comfort zone and just adapt to it!

It’s all about HCI (Human-Computer-Interaction) and making the experience better for everyone, but it takes time change an old behavior. Why do you so eagerly want the old start button/menu back?

In case you’ve missed it C# Smorgasbord is currently on sale and I’m giving away discount codes for 35% off!

Vote on HN

Microsoft delivers at BUILD 2012

Posted by Filip Ekberg on November 1 2012 1 Comment

Yesterday was the first day of //BUILD/ at Microsoft Campus in Redmond, Seattle. There has been a lot of expectations on Microsoft for this event and boy did they deliver! The past year has been all about Windows 8, Windows Phone 8 and the very awesome updates to Windows Azure. //BUILD/ this year follows in its predecessor´s footsteps and deliver information about how we can write awesome applications for both Windows 8 and Windows Phone 8.

Me and my colleague from Star Republic arrived in Seattle a couple of days before the conference started to avoid being jetlagged during the session and be able to see a bit of Seattle. Despite all the rain in Seattle we have had a very nice visit so far. We’ve been able to see the Space Needle, the underground (which is awesome by the way), the harbor and much more. I really enjoy Seattle, maybe it is because it feels pretty much like Gothenburg. What’s best about it though is that it is flooded (not with water despite the rain) with geeks.

The days before the conference I had a chance to meet up with Scott Hanselman and a lot of the other amazing guys working on the ASP.NET team. If you haven’t seen the Day 2 Keynote the next part of this sentence is going to be a spoiler; I’m somewhat in the keynote! When I met Scott he needed material for his presentation, me and some other guys’ danced Gangnam style for him which was recorded and put in his and Scott Guthrie’s presentation. I don’t have the video available at the moment, it’s going to be available on C9 as soon as the keynote is uploaded. I recorded a little with my compact camera, but I forgot to bring a cable for it and unfortunately the Surface RT don’t accept an SD card!

All that was day two, besides for the actual recording, so up until now everything has been awesome. The sessions were all similar to the ones that we have seen over the year since last //BUILD/ but now that everything is shipped it’s more hands-on examples. I attended a couple of sessions about Windows 8 development with HTML and Javascript (and of course CSS). The most interesting session was the one about optimizing your web application by thinking about CPU usage. There are some very interesting tools in the Windows SDK that you can use to analyze the performance of a web application. Basically in most applications on the web, time is spent on waiting for resources to be downloaded which means it could be done asynchronously if possible and the other thing that is common is slow javascript with lots of DOM access.

As an attendee the highlight of the day was when Ballmer announced that everyone is getting 100GB of SkyDrive! I am actually going to swap from DropBox for a while to see if it is better or not. However that awesome present wasn’t enough for Ballmer so he also announced that everyone attending would get a Surface RT 32GB! When everyone calmed down and promised to write awesome apps for Windows RT, the VP for Nokia comes out on stage and gives away a Lumina 920 to everyone attending the confidence. At this time I wanted to lay down on the floor and cry of happiness. This was announced in the morning so we had to wait for our awesome devices for the entire day!

As soon as we picked up our stuff we went back to the hotel and I recorded an unboxing (I know most people hate those!) and hands-on.

Are you planning on getting a Surface?

I’m having high hopes for the ASP.NET session and hoping to see some things that will help me in my daily work. So far the Azure upgrades with Mobile Services and Add-Ons are Very promising and I am really looking forward to playing with it more. What is funny is that Halo 4 that is being release in the next months or so uses Azure a lot which forced them to rethink the server architecture.

Speaking of games, since everyone got a voucher for the company store which has heavy discount, I might grab an xbox controller to use for my next Windows 8 game. Do you have any experience with that? I would love to hear about it!
If you’re at //BUILD/ be sure to look me up and say hello and if not, just ping me!

Before we take part, I just want to say that I wrote this entire post on my Surace with the TouchCover. Takes some time getting used to.

Vote on HN

10 questions about Surface

Posted by Filip Ekberg on October 17 2012 4 Comments

The Microsoft Surface is due to be released October 26, 2012 and this is less than 10 days from now. There’s been a lot of hype around this particular tablet and I’m very happy that the release date is in just 1½ weeks!

Some background

If you’ve somehow missed what the Surface is or what the Surface looks like, below is a very nice picture of it. Basically it’s a powerful and lightweight tablet that runs Windows 8.

Up until today, at least I have always felt that I at least needed 3 devices. One touch optimized tablet (iPad), One laptop to bring in to meetings that I can also code on and last but not least a very powerful workstation that I can work on. With the Microsoft Surface, we’re closing up with the all-in-one device — simply bring the Surface with you to meetings, watch movies with it in the couch or work on it.

How come information about such hardware ends up on a programming blog? Because the programming model is very interesting! If you’re an iOS developer or an Android developer, you’re most likely familiar with the whole “store” life-cycle; which is great. This will (hopefully) lead to much more high quality applications and less bogus software.

Surface comes in two (majorly) different models

The first Surface that is released October 26 will run Windows RT on an ARM architecture. The RT version of Windows 8 is designed for limited use such as:

  • Watching movies, surfing the web, chatting and all that other tabletty stuff
  • Minor work in Office; Word, Excel, Powerpoint, etc.
  • Only run applications from Windows Store

There’s of course a little more to it, but the last point is the most interesting one. You’ll only be able to run applications on the device that comes from Windows Store! Hence that you will not be able to put an application on an USB drive (yes Surface has a fully functional USB 2 port) and run it.

This might not be new information to you, but it’s still pretty interesting. That’s why there’s another Surface version released in January, called Surface Pro. This version runs on an Intel Core i5 and used the full version of Windows 8. This lets you install any applications that you want and use it as any other computer that you are used to. Plus it’s still a tablet!

Below is an overview of the Windows RT Architecture; The RT API is a little bit different (limited).

Now with a little bit of background, let’s take a look at 10 questions and answers about the Surface!

All the following information is based on information given by the SurfaceTeam on reddit.

1. Why doesn’t surface come with 3G/4G

For 3G/4G we looked at several elements when deciding on what features to include. We knew that the primary use was going to be in the home, we looked at tablet sales data 2/3 WiFi, 1/3 Mobile Broadband. Of the 1/3 sold, 1/2 were activated. Phone hotspot / tethering use was also a consideration.

2. Will Surface be available in any other countries than listed at the moment on the release date?

Unfortunately, no.

Of the primary launch Markets we are launching in, we have keyboards specific to those languages
We are not announcing any new markets beyond what we said today. However, we will for sure be expanding to more markets in the future.

3. Why is there no USB3 port, only USB2?

Currently there’s no ARM SoCs that have an USB 3 controller and Surface is based on ARM, which means no USB 3.

USB 2.0 based on capability of the ARM SoCs during our development timeframe.

4. How much will it cost?

There are a couple of different options available (USD prices only).

  • Surface with 64GB Storage and TouchCover – 699 USD
  • Surface with 32GB Storage and TouchCover – 599 USD
  • Surface with 32GB Storage without TouchCover – 499 USD

5. Is there any NFC or GPS on Surface?

There isn’t a NFC feature in Surface RT; We use Wi-Fi based location services, the device doesn’t have a physical GPS sensor.

6. Why is the kickstand angled as it is?

We wanted the screen to be normal to the face. Voila, you then have a 22 degree angle.
Seriously we did a ton of studies around lighting, reflection, ergonomics, table height, etc…. and then made sure it looked perfect and felt perfectly balanced.

7. Will Surface support bluetooth headsets?

Yes, Surface supports Bluetooth 4.0 and will work with Bluetooth headsets.

8. What happens when I flip the touch cover to the back of the device, will there be accidental keystrokes?

Both TouchCover and TypeCover have sensors that understand orientation relative to Surface… in fact the Type and Touch Covers talk to Surface to figure out their relative position no matter the orientation of gravity of the device (pretty neat!). There are 3 positions modes: Closed (keys and mouse are off), Open to 180 degrees (keyboard and mousepad on), beyond 180 degrees to the back (keys and mouse off). That way you can flip back the covers and feel secure you are not pressing keys by mistake.

9. How does the TouchCover work?

Touch Cover has a very special digitizer that we invented.. it senses the impact force of your key presses. We designed super-fast electronics and smart algorithm in the keyboard so that Touch Cover can profile your key press down to a 1ms (1000 times a second). Using that information Touch Cover can infer if the user meant to press the key or not.. It is a smart key. So even though there is no key travel, the user can rest their hands on top of the keyboard and find home position without accidentally triggering keys.. pretty cool! The first time I typed on a full working version of Touch Cover, I typed just as fast as I do on a normal keyboard. I am confident you will be able to type significantly faster on Touch Cover than an onscreen keyboard. And with a little practice you will even do better (maybe even faster!) For folks who really love and really need keys that have travel, then Type Cover is one of the best keyboards I have ever used (desktop or other). It has a super awesome snappy key mechanism that feels great (has a strong hysteresis curve)

10. So there’s no NFC, why?

For the product design experience we were aiming for with Surface, the Mg metal enclosure, including the back case, was critical. This made good antenna design for NFC a trade-off in our development process.

To learn more about Surface, check out the video below!

Personally I can say that I am very excited about the Surface products, both RT and Pro.

How excited are you?

Vote on HN

Creating a Windows Metro style application in C++

Posted by Filip Ekberg on May 2 2012 2 Comments

I am going to step out of my comfort zone a bit and write a post that touches the surface of C++ in Windows 8. Let us start off by looking at an image of what the new WinRT(Windows Runtime) look like:

As you can see, there are a lot of powerful ways to create both metro style and desktop applications. Notice that in Metro style applications, XAML is connected to both C++ and C#/VB.

During my years of .NET development, the reason for using C# or VB has been; RAD(Rapid Application Development). In a world filled with consultants where the customers only see the end result, it can often be hard to convince that putting down 200% more time using C++ is a great idea.

Because let’s face it, it takes a lot more time creating a desktop application in C++ using MFC than what it would to use C# and XAML. Before someone throws a stick at me I have to say that it of course depends on what kind of application you are creating.

The downside from using a managed programming language is that it tends to be a bit slower; in some cases this is critical. Most customers do not care if they have to wait a couple of extra nano-seconds for a control to render.

What does this have to do with Windows 8 and the Windows Runtime?

I really got a nice tingly feeling in my stomach when I first saw that you could use XAML with C++ in Windows 8. But that is not the best part, the best part is that it is fully native!

This means that the designers can make the interface in expression blend and we can dig down into C++ on the backend.

Let us have a look at this! You will need to have Windows 8 Consumer Preview and Visual Studio 11 beta installed (or later) in order follow these examples.

Start off by creating a new blank Windows Metro style application, this is found under “Other languages -> Visual C++”:

When the project is created, you will see some files that have been generated, these are pretty similar to what we are used to see in a normal XAML application in .NET:

Open up the file “BlankPage.xaml”, this will bring you into the designer view of the XAML file. Add a TextBlock to the page:

As you can see in the preview, it shows a tablet with the current view inside it. Remember that we are working with a Metro application, the idea is that you have a metro application in fullscreen or pinned to one of the sides on your screen.

By only adding the TextBlock, this is the XAML that we have now:

<Page
   x:Class="WinRTDemo.BlankPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="using:WinRTDemo"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d">

    <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
        <TextBlock x:Name="MyTextBlock"></TextBlock>
    </Grid>
</Page>

If we now navigate to the file “BlankPage.xaml.cpp”, this is where we can actually access the TextBlock. When you compile your solution, the XAML will also be compiled to C++, just like the XAML in a normal .NET application is compiled.

However, to access the TextBlock and set the text of it to the current date, what do we write?

The TextBlock is actually a TextBlock^, the “^” is called a “hat”. Think of this as a pointer, but a pointer that you do not have to worry about disposing.

This means that you do not have to do delete on the object yourself, because it will be automatically removed once the context of it has been exited.

So in order to set the value of the TextBlock we do:

MyTextBlock->Text = "Hello World!";

We can test-run this before we display the current time. First, let’s select to run it in a simulator like this:

This will bring up a tablet emulator that mirrors your system:

Now let’s take a look at how to get the current date there instead of that “Hello World!” text. In WinRT you can access an object called Calendar which you can use to get the date and time.

In order to get a pointer/hat, you need to modify the instantiation a tiny bit. Instead of just writing this:

new Calendar();

You write:

ref new Calendar();

This lets the compiler know that this will in fact be a hat/”managed pointer”. Something that I have missed a lot when not working in C# is the keyword var and this has finally come to C++ with the more appropriate name auto.

So in order to get a calendar object, calibrate it to the current time and then set the text to the current date we can simple do it like this:

auto calendar = ref new Windows::Globalization::Calendar();

MyTextBlock->Text = calendar->YearAsString() + " " +
                    calendar->MonthAsString() + " " +
                    calendar->DayAsString();

This has been a short post about how to create your first C++ Metro style application in Windows 8 and I hope you enjoyed the read, if you have any questions do not hesitate to leave a comment, tweet or e-mail.

Vote on HN