Click here to Skip to main content
12,817,112 members (35,385 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 16 Jan 2013

App template for speeding Ultra-book developmental

, 16 Jan 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
A template code to help starting ultra book development fast


With the app-innovation contest we all learned so much. And now its our time to give back. 

In this article

  1. I am describing creating a simple app and problems "with solutions"
  2. Will talk about my entry
  3. Provide a template for speeding your app why reinvent the wheel when you can use one available and modify it.  

Starting a win 8 desktop app

Just start a new project a console or window form app is good to go it is all same and depends what you are planning to start.

Here we have chosen a windows form app. As we are going to use Windows RT sensors API we are choosing .NET Framework 4.5

By default you cant add wincore (WinRT API to window desktop apps )

So unload the project  

Perform following steps:

  1. Edit the .csproj file .
  2. Add

    just after start of <PropertyGroup>

  3. Reload Project

Now add the reference to windows inside core which is now available. It is not available if you don't follow above steps and try directly. 

Add reference to system.runtime, system.runtime.interopservices etc. they are all are inside program files or program files x86 sub folder "\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5"

Now your app is ready to use sensors.

If you are planning to use XNA like my entry terminal velocity you will need to add references of XNA DLL too.

Using a sensor in your app.

 private Accelerometer acel;
 private SimpleOrientationSensor orientationSensor;
  public form1() {    
   acel = Accelerometer.GetDefault();
      if (this.acel != null)
    {  acel.ReadingChanged += Aceloro;
  orientationSensor = SimpleOrientationSensor.GetDefault();
            if (this.orientationSensor != null)
                orientation = this.orientationSensor.GetCurrentOrientation();
                this.orientationSensor.OrientationChanged += OrientationChange;
 private void OrientationChange(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
          if (this.InvokeRequired)
                IAsyncResult result = BeginInvoke(new MethodInvoker(delegate()
                   Data1.Text = "Orientation " + args.Orientation + "\n";
            else if (this.IsHandleCreated)
                Data1.Text = "Orientation " + args.Orientation + "\n";
        private void Aceloro(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
            if (this.InvokeRequired)
                IAsyncResult result = BeginInvoke(new MethodInvoker(delegate()
                    DATA.Text = "x= " + args.Reading.AccelerationX + ". Y= " + args.Reading.AccelerationY + ".Z= " + args.Reading.AccelerationZ + "\n";
                // wait until invocation is completed
            else if (this.IsHandleCreated)
                DATA.Text = "x= " + args.Reading.AccelerationX + ". Y= " + args.Reading.AccelerationY + ".Z= " + args.Reading.AccelerationZ + "\n";


As Win 8 devices can be tablet and have changing orientation so it is necessary to make that in consideration and change your game code to support many different configurations.


We can know about rotation using the orientation listener. Now we need to use this and width and height difference to make our app work in other orientation too. 

My app is a game using accelerometer so using x axis when in portrait is not what a user expect from my app. Using orientation listener I can know which side orientation my app is and use that to change the axis of accelerometer in use for moving plane. Like x for normal use -x for 180 degree rotation -y for 90 degree rotation and y for 270 degree rotation. 

After Finishing Your App

When your game is ready you can use code signer tool to sign the exe and pack using wix or install-shield, sign the packed MSI or EXE and then you can submit to Intel AppUp store.

If you are submitting an app as an MSI package make sure your app stores its install directory in reg and read it from there to open files etc. (not doing so will crash your app from Intel appup client). 

If you are planning to use XNA ensure your workstation has Visual Studio 2010 with latest Windows Phone SDK thus you can get the compile the XNA resources for using with your project.


This article is linked and a spin of terminal velocity article series.

  1. The Android version of the same game, all code is opensource. Nearly most code is commented and article explains jni and many other,
  2. The original app-innovation article,

Story Of Terminal Velocity

Terminal velocity was a game specially planned for app innovation contest.

But due to delay in having my device on time I was unable to tune accelerometer on time and even had not implemented touch as I was sure Win 8 converting mouse input to touch and my game use accelerometer was not a touch based game. But now all of them is implemented and this game will release soon on inlet app up .

Mean while the game had got chance to get ported to Windows Phone and Android.

Android users can download it form here

Source code form here

Windows phone app will be live soon.

Using the Code

This article provide a template app for speeding up ultra book development. The main interesting part would be using multi touch with your app and that is already implemented here.

All touch related data is polled to variable e in these functions use it .

Touchup(object sender, EventArgs e); 
Touchdown(object sender, EventArgs e); 
Touchmove(object sender, EventArgs e); 
//Dummy  function body to get touch data
{ if (e.IsPrimaryContact)
                idc = e.Id - 1;

Points of Interest

Interesting thing I learned while writing terminal velocity.

  1. I used XNA and finished whole game that was old work, then I came to know that my app is not using single touch functions as it took 2 clicks to get a touch register.
  2. I used XNA with winform and implemented touch by searching and reading old touch related code in various example on msdn and finally found this method.
  3. I used a time based invalidate but you can use it on last line of draw() to get fast drawing.

Content of Template

  1. Implementation of touch api
  2. Implementation of sensors
  3. Implementation of xna in win form with code to toggle to full screen


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chief Technology Officer InductionLabs
India India
Currently I am an independent developer usually develops under brand name Induction games sometimes under Induction labs ,Can say that I am professionally developing apps for more than 4 years .

Some links to my apps in different apps stores are ..

Windows Phone


Blackberry Store

Flash Games :
*my flash portal is no longer active so the quiz game cant be played .

Perceptual computing phase 1 first prize Winner app (air piano)

My Blog

You may also be interested in...


Comments and Discussions

QuestionTo get Touch on xna window Pin
PraveenOjha27-Sep-13 4:33
professionalPraveenOjha27-Sep-13 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 16 Jan 2013
Article Copyright 2013 by PraveenOjha
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid