Showing posts with label windows phone. Show all posts
Showing posts with label windows phone. Show all posts

Monday, April 20, 2015

New Xamarin Courses!

Due to the popular demand of the Xamarin courses, I have decided to redesign the courses so that they can better fit the needs of developers:

1. MOB102 - 1-Day Writing iOS Apps using Xamarin and C# - S$799
Who should attend?
Developers who are primarily interested in leveraging their C# skill set to build iOS apps. Developers will learn how to encapsulate their business logic in separate DLLs and use them in their iOS apps. DLLs can also be reused in Android apps.

2. MOB103 - 1-Day Writing Android Apps using Xamarin and C# - S$799
Who should attend?
Developers who are primarily interested in leveraging their C# skill set to build Android apps. Developers will learn how to encapsulate their business logic in separate DLLs and use them in their Android apps. DLLs can also be reused in iOS apps.

3. MOB104 - 1-Day Writing Cross Platform iOS and Android Apps using Xamarin.Forms and C# - S$799
Who should attend?
Developers who want to write apps that target Android and iOS platforms. Using a common set of UI elements from Xamarin.Forms, developers will be able to write their apps and run them on iOS and Android devices.

Developers who are interested to develop cross platform mobile apps are strongly advised to take the three courses. Participants who register for the three courses can enjoy a discount course fee of S$2,000 for the three courses. 

Tuesday, August 06, 2013

Windows Phone Tip: JSON to Data Contract Generator

If you are consuming a JSON web service, you can use the DataContractJsonSerializer class to deserialize a JSON string into an object so that you can manipulate the JSON string like an ordinary object. However, it is always a challenge to convert a JSON string into its class representation.

A good and easy way to convert a JSON string into its class representation is to use the tool at http://jsontodatacontract.azurewebsites.net/.

Suppose you have the following JSON string to convert:

{
    "postalcodes": [
        {
            "adminCode3":"70828",
            "adminName2":"Reutte",
            "adminName3":"Reutte",
            "adminCode2":"708",
            "postalcode":"6600",
            "adminCode1":"T",
            "countryCode":"AT",
            "lng":10.724044444,
            "placeName":"Ammerwald",
            "lat":47.490988888,
            "adminName1":"Tirol"
        },
        {
            "adminCode3":"70805",
            "adminName2":"Reutte",
            "adminName3":"Breitenwang",
            "adminCode2":"708",
            "postalcode":"6600",
            "adminCode1":"T",
            "countryCode":"AT",
            "lng":10.7050916669573,
            "placeName":"Bad Kreckelmoos",
            "lat":47.4900855904715,
            "adminName1":"Tirol"
        }
    ]
}

All you need to do is to navigate to http://jsontodatacontract.azurewebsites.net/ and paste it your JSON string. Also, give a name to the root class that will be generated for you (in this case I have called it PostalResult, select the language you want it to generate in (C#), and select the DataContract serialization model. Click the Generate code! button.



The following classes are automatically generated:

// Type created for JSON at <>
[System.Runtime.Serialization.DataContractAttribute()]
public partial class PostalResult
{   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public Postalcodes[] postalcodes;
}

// Type created for JSON at <> --> postalcodes
[System.Runtime.Serialization.DataContractAttribute(Name="postalcodes")]
public partial class Postalcodes
{   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminCode3;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminName2;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminName3;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminCode2;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string postalcode;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminCode1;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string countryCode;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public double lng;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string placeName;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public double lat;
   
    [System.Runtime.Serialization.DataMemberAttribute()]
    public string adminName1;
}

You can paste the above classes into your project. To make use of it, use the following code snippet:

using System.Runtime.Serialization.Json;
using System.Diagnostics;
using System.IO;
using System.Text;

        private void JSON_Demo()
        {
            string json = @"
                {
                    ""postalcodes"": [
                    {
                        ""adminCode3"":""70828"",
                        ""adminName2"":""Reutte"",
                        ""adminName3"":""Reutte"",
                        ""adminCode2"":""708"",
                        ""postalcode"":""6600"",
                        ""adminCode1"":""T"",
                        ""countryCode"":""AT"",
                        ""lng"":10.724044444,
                        ""placeName"":""Ammerwald"",
                        ""lat"":47.490988888,
                        ""adminName1"":""Tirol""
                    },
                    {
                        ""adminCode3"":""70805"",
                        ""adminName2"":""Reutte"",
                        ""adminName3"":""Breitenwang"",
                        ""adminCode2"":""708"",
                        ""postalcode"":""6600"",
                        ""adminCode1"":""T"",
                        ""countryCode"":""AT"",
                        ""lng"":10.7050916669573,
                        ""placeName"":""Bad Kreckelmoos"",
                        ""lat"":47.4900855904715,
                        ""adminName1"":""Tirol""
                    }]
                }";

            //---convert the json string into a memorystream
            // object---
            MemoryStream stream = new
                MemoryStream(Encoding.UTF8.GetBytes(json));

            var serializer = new DataContractJsonSerializer(
                typeof(PostalResult));

            PostalResult result = (PostalResult)
                serializer.ReadObject(stream);

            for (int i = 0;
                 i <= result.postalcodes.Length - 1;
                 i++)
            {
                //---print out the place name---
                Debug.WriteLine(
                  result.postalcodes[i].placeName.ToString());

                //---print out the latitude---
                Debug.WriteLine(
                  result.postalcodes[i].lat.ToString());

                //---print out the longitude---
                Debug.WriteLine(
                  result.postalcodes[i].lng.ToString());
                Debug.WriteLine("----------");
            }
        }

The above code will print out the following result:

Ammerwald
47.490988888
10.724044444
----------
Bad Kreckelmoos
47.4900855904715
10.7050916669573
----------


Friday, August 02, 2013

New Flipboard Magazines for Developers

If you are a developer, here is a good way for you to keep up to-date with the latest in the software development world. I have created four Flipboard magazines focusing on the following areas - iOS, Android, Windows Phone, and Xamarin. Each magazine covers the tips and tricks of each development platform. Click on the following magazines to start reading!

  

  


Sunday, July 14, 2013

Windows Phone Tip: Getting the Device GUID

Sometime you may want to uniquely identify a Windows Phone, such as when you are implementing push notifications. The best way to identify a unique Windows Phone is through its device GUID.

The following code snippet shows how to obtain the GUID of a Windows Phone device:

using Microsoft.Phone.Info;

    public static byte[] DeviceId()
    {
        object uniqueId;
        if (DeviceExtendedProperties.TryGetValue(
        "DeviceUniqueId", out uniqueId))
        {
            return (byte[])uniqueId;
        }
        return null;
    }
    ...
    ...

    byte[] guid = DeviceId();           
    MessageBox.Show("Device GUID - " +

        Convert.ToBase64String(guid));

For the code above to work, you need to check the ID_CAP_IDENTITY_DEVICE setting in your WMAppManifest.xml file.

Friday, July 12, 2013

Windows Phone Tip: Updating the UI from an Asynchronous Thread

One of the most common tasks you need to perform in a Windows Phone application is updating the UI from a separate thread. For example, you may be download some content asynchronously using a WebClient class and when the operation is completed, you want to update the UI with the content that was downloaded. Updating the UI directly from an asynchronous thread is not allowed, as UI controls are not thread-safe.  

The easiest way to update the UI from an asynchronous thread is to use the Dispatcher class. To determine if you can update an UI directly, you can use the CheckAccess() method. If this method returns a true, it means you can directly update the UI. Else, you have to use the BeginInvoke() method of the Dispatcher class to update the UI in a thread-safe manner. The following code snippet makes this clear:

    if (Dispatcher.CheckAccess() == false)
    {
        //---you have to update the UI through the
        // BeginInvoke() method---
        Dispatcher.BeginInvoke(() =>
            txtStatus.Text = "Something happened..."
        );
    }
    else
    {
        //---you can update the UI directly---
        txtStatus.Text = "Something happened..."
    }

If you have more than one statement to perform in the BeginInvoke() method, you can group them into a method and call it like this:


        private void UpdateUI(String text)
        {
            txtStatus.Text = text;
            btnLogin.Content = text;
        }
        ...
        ...

            Dispatcher.BeginInvoke(() =>
                UpdateUI("Something happened...")

            );

Thursday, July 11, 2013

Windows Phone Tip: Check if App is Running on Emulator

There are times where you want to check if your app is running on the emulator. For example, Bluetooth functionality can only be tested on a real device. Hence, in your code you could check to see if the app is running on an emulator. If it is, then terminate the app.

The following code snippet checks for the current device type. If it is running on an emulator, terminate the app:

//---check if your app is running on the emulator---
if (Microsoft.Devices.Environment.DeviceType ==
    Microsoft.Devices.DeviceType.Emulator)
{
    MessageBox.Show("Running on emulator!");
    //---terminate the app---
    App.Current.Terminate();
}

Monday, March 18, 2013

New courses and updated course schedules!


Courses
Mar 2013
Apr 2013
May 2013
Jun 2013
iOS/iPhone/iPad




S$997/pax
5-6 Mar
(Tue-Wed)
8-9 Apr
(Mon-Tue)
9-10 May
(Thu-Fri)
12-13 Jun
(Wed-Thu)
S$997/pax
7-8 Mar
(Thu-Fri)
11-12 Apr
(Thu-Fri)


S$599/pax

10 Apr
(Wed)


S$599/pax
18 Mar
(Mon)
29 Apr
(Mon)
Updated


S$599/pax




S$599/pax




S$1000/pax




IOS206 – Developing Core Data Applications
S$599/pax
20 Mar
(Wed)



IOS207 – Developing iPhone Web Apps using Dashcode
S$997/pax 
14-15 Mar
(Thu-Fri)








Android




S$997/pax
25-26 Mar
(Mon-Tue)
22-23 Apr
(Mon-Tue)
16-17 May
(Thu-Fri)
19-20 Jun
(Wed-Thu)
S$997/pax
27-28 Mar
(Wed-Thu)
24-25 Apr
(Wed-Thu)


S$599/pax




S$599/pax




S$599/pax
11 Mar
(Mon)
5 Apr
(Fri)
22 May 2013
(Wed)

S$599/pax

3 May 2013
(Fri)
Updated

23 May 2013
(Thu)
14 Jun
(Fri)
S$599/pax


21 May 2013
(Tue)
18 Jun
(Tue)





Windows Phone




S$997/pax

16-17 Apr
(Tue-Wed)
6-7 May
(Mon-Tue)

S$997/pax

18-19 Apr
(Thu-Fri)
13-14 May
(Mon-Tue)






Macintosh




S$599/pax
4 Mar
(Mon)



S$599/pax
19 Mar
(Tue)








Microsoft Programming




S$599/pax
12 Mar
(Tue)



S$599/pax
13 Mar
(Wed)



S$997/pax


2-3 May
(Thu-Fri)





27-28 Jun
(Thu-Fri)
Hardware




S$599/pax



21 Jun
(Fri)