K-Mug Mobile App Dev event 23 Nov 2013 – Review

Unlike past UG events, this event got hardly two weeks for inviting the members. But like in past we didn’t have to make any special arrangements as ORION India Systems were supportive as always by providing their training hall and making arrangements. Really I did not expect much people as it was short notice but the hall was almost house full. Thanks to the bulk mailing features and social media :).

I reached the venue by 8:45 as I was not pretty sure whether the housekeeping staff is aware of the event. Lilly chechi, the “housekeeping lead” made quick arrangements for refreshments, hall cleaning and seating arrangements. There were client visits happening at the company so admin was too much busy with them but he made the arrangements on time.  Thanks to Pramod, the ORION admin for supporting us.

I took the attendance sheet printouts, notepads, pens and bugs. I did packing it last day itself so it was not a major job now. By the time Anuraj came and helped me to take items to the venue. As usual Praseed Pai actively present at the venue :).

By 9:15, seats started filling and by 9:30 we had around 15. By 10 we had almost all seats filled. Nishanth Anil, the evangelist from Xamarin and Shiju Varghese entered the hall with T-Shirts and Xamarin leaflets. We had 35+ techies sitting in hall and 12 T-Shirts. I had to quickly decide on a strategy to distribute it. The crowd consists of beginners, intermediate, and advanced techies, and had many mobile app developers .

I kick started the event by welcoming people and speakers and did an introduction to K-Mug and thank Orion’s support.

Nish took a cool session on Xamarin, IDE, Emulator, Debugging etc. which was easy for beginners to kick start mobile application development. The demonstration he did was interesting and he was actively answering to participant questions. Being Microsoft technology lovers the Xamarin-VisualStudio partnership was an exciting news.

Tea break.

My T-Shirt & ORION-Mug distribution strategy was like this:

  • Few – by a lucky dip with feedback forms
  • Few – by Trivia with the help of Sagar (I should appreciate him for his willingness and ability making things happen without preparations)
  • Balance to those who actively participated – We gave those to Praseed Pai  and Sagar
  • One T-Shirt I gave to Lilly chechi as she helps K-Mug events a lot on Saturdays by cleaning and tea arrangements. I thought I should value her contributions. Sorry K-Mug leads for not discussing it.

Sagar did a mobile app trivia and many people won T-Shirts and ORION-Mugs.

Next Shiju started his Azure Mobile Services session. But I had to leave the room due to a hospital appointment. But I heard the feedback his session was excellent.

Shekhar, an ORION employee delivered Vote-of-Thanks speech.

Thanks to Anuraj for posting live-photos in Facebook.

Nish promised to send T-Shirts to K-Mug leaders from his office. Let us wait for it now… πŸ™‚


Use WIFI mouse as a slide switcher using C#

I wanted a presenter mouse for a long time but most of my public sessions are hands-on so a presenter mouse is not really mandatory. But whenever I see someone using that device I will restart thinking about getting one. Today I saw Nish, the evangelist from Xamerin using one at the Kochi K-Mug event and thought to buy one. Went through few shopping sites and found that the price is all Rs. 1800+ and a good one will cost around Rs. 6,000/.

Problem Statement
I am not a person who like to sit infront of the laptop and do sleepy lecturing. I like to walk around the stage and audience to make the session interactive. So basically what I will require is a device to switch through slides and a lazer pointer which will be an added advantage.

I did some Google to  check if a tool/source is already present. There were few but all used office interop.  I do not like a bulky tool for this small requirement. Also interop will cause my tool stop working when used with a different office version laptop.

I did not think much. The mouse in front of me now is far enough for my requirement. This piece of device cost only Rs. 499/- from SnapDeal – a Dell wifi mouse. Here, the lazer pointer I will have to compromise. So here is my plan:

  • Mouse got 2 buttons LEFT and RIGHT. I can use them as “previous” and “next” in PowerPoint slides
  • Make a utility which can be invoked at the time of presentation
  • Hook/Catch all the mouse clicks and convert them to LEFT and RIGHT keyboard events
  • Done!

I was successful in making a tool but a problem raised. Once the presentation is over, I am not always able to  close the PPT or move to other applications. So here comes the SOS switch – the mouse middle button to UnHook. Below goes what I did really in 45 minutes while developing and testing the tool:

  1. Get Win32 API calls for .NET/C# from Google
  2. Make the tool capture Global mouse events
  3. Check if PowerPoint is running/presenting (otherwise the application is not really required)
  4. If a mouse click (WM_RBUTTONDOWN/WM_LBUTTONDOWN) event is raised, hook it and send keyboard events of {LEFT} and {RIGHT} keyboard arrow keys. 
  5. Suppress the mouse click events
  6. In case if a quick exit is required, click the middle/scroll button.

Let me know if you want the tool I made. I don’t mind sharing the code. I put the code name for my tool – the “DumbPresenter”.


BigData – learn now! – from Pinal Dave


BigData – learn now! – from Pinal Dave


Find the number of occurrences of a character in a string using C#

This was somebody’s homework question. Thought to solve it for the sake of language skill refresh πŸ™‚


Sort a list of numbers in a file without using arrays or inbuilt methods in C#

It’s been a long time since I wrote any school level problems. Today I saw a homework help request in Facebook and thought to give a try by playing with Random Access mode. Here is the snippet.

Problem: Write a C# program to sort a list of integers from a file. The sorted list need to be stored in a new file with “_sorted” suffix. This should be accomplished without using any array methods or built-in sort methods.

Code snippet:


Make a simple web server using .NET with TcpListner

Code snippet:

A Windows Forms application is used here. You can make it a console applcation or a windows service as well


Web API development with ASP.NET – Tutorial

This is no more a new topic but is still a fresh topic. Most people started to explore the possibilities recently only and many still believe WebAPI is for MVC applications.

Here I am going to demonstrate how to integrate Web API capabilities to an empty/existing ASP.NET website.

My environment: Visual Studio 2012 Professional with .NET Framework 4.5

Step 1: Create a new β€œASP.NET Empty Web Site”.

Note: you can choose β€œASP.NET Empty Web Application” as well. In this sample I am planning to use IIS.


Step 2: Add Web API Controller Class

Right click on the Solution Explorer project –> Add –> Web API Controller Class


Important: Make sure you have β€œController” word at the end of name your your controller class. I have used β€œDataController”.


This is my DataController.cs looks like:

Step 3: Add Global Application Class (Global.asax)

(In the same way you have added Controller class)


Step 4: Add URL routing information in Global.asax

Our aim is to call the url like api/data/9. Below entry in Global.asax does the trick. Also note that we are making the id field is optional so that api/data also works.

  • api/data/9 will point to Get(int id)
  • api/data will point to Get()
  • …so on

Note: Required namespaces: System.Web.Http & System.Web.Routing

Step 5: Test the URL

We are finished integration now. Its time to test.Try your URL in a browser (or just execute in Visual Studio and add api/data)

This is my URL to my local IIS: http://localhost/trdata/api/data

Different browsers treat this url differently. In IE, you will be asked to download a file like data.json. In Firefox and Chrome you might see XML like below. In safari you will see β€œvalue1value2” where, you will have to check view-source to see XML.


If you are able to see what is mentioned above, you can confirm your Web API integration is successful.

Sample Application

Next, let me demonstrate how to call a Web API method from a HTML/aspx page.

Step 1: Add a new web form.

I named mine as Default.aspx.

Step 2: Add jQuery

I am a fan of jQuery so I will include jQuery script. Instead of downloading, you can use a CDN url also. I have used a CDN.

Note that communication can be achieved without jQuery as well and you can use JavaScript. But jQuery contains ajax methods which will let you save a lot of lines of code.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Step 3: Place a button,

Drag a button from toolbox. You can use ordinary HTML button as well.

Step 4: Add script to call Web API method

Here is my Default.aspx looks like:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
    <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
        $(function () {
            $(“#Button1”).click(function () {
                $.ajax(“api/data”).done(function (msg) {
                return false; // blocking form submit
    <form id=”form1″ runat=”server”>
        <asp:Button ID=”Button1″ runat=”server” Text=”Button” />

When you try this is browser and click the button, you should see a messagebox/alert like this:


jQuery explanation and parsing the output are out of scope of this article.

Please feel free to reach me if you want assistance.