Welcome to EMC Consulting Blogs Sign in | Join | Help

Mark Davies' Blog

A blog about coding and development

  • Silverlight with Windows Phone 7 – An introduction

    In this tutorial I aim to introduce you to Silverlight development on Windows Phone 7. To help achieve this aim we will create a simple application that will allow you to get the BBC News Top Stories RSS feed and display them for easy browsing. It will also include the ability to click on a story of interest to read it in full on their website.

    Requirements

    To develop with Silverlight for Windows Phone 7 you will need a few things installed.

    NOTE: You should install these applications in the order they are shown below.

    You will also need:
    •     A knowledge of WPF.
    •     A knowledge of how to use visual studio (creating projects, adding classes etc).
    •     A knowledge of C# will be helpful but is not a major requirement as it is pretty easy to learn.


    Creating the Application

    Now you have all.....

     

    Click Here to read the rest of this blog post


  • Stored Procedure’s

    I am a Microsoft developer (.Net primarily) and I try to stay away from things to do with databases. However, the project I am currently on is using stored procedures. When I first joined the project I had no idea what a stored procedure was so I thought I would look into them. Below is what I have found out from my research (and why I will be using them in future).

    NOTE: Within this piece I talk about creating a stored procedure and I will be using MSSQL. You can create stored procedures in MySQL and Oracle however the syntax is slightly different, but with a Google search you will find out how to create them easily enough.

    What are stored procedures?

    Stored procedures are a mechanism to simplify database development by allowing you to group SQL statements into manageable blocks. Stored procedures are extremely similar to the construct.....

     

    Please go Here to read the rest of this blog post

  • Windows Phone 7 – My Impression!

    So, I have had my windows phone 7 for around two weeks now and I thought I would do a little post with my thoughts on the phone that I got and also the OS.

    The phone

    I purchased the HTC HD7 on a 24 month contract from O2. I got the HD7 as at the time of writing, it has the largest display on a WP7 phone and the storage size is one of the largest as well (16GB). Overall the phone is very nice; however, some have said it feels a little heavy, but I prefer a phone that has a little weight behind it (as it reminds me that I do actually.....

    Follow the link to view the full post

    Original Article

  • Windows Phone 7 Event

    I recently attended an event from Microsoft that introduced Windows Phone 7 to digital agencies. The event was designed primarily to get digital agencies to say "ok we need to get in on this and start trying to get clients".

    From the event specifications they put online I thought it was going to have more of a technical focus, however, this was not the case. Although there were some technical aspects discussed the event mainly focused on design aspects within Windows Phone 7.

    However, the event in the end turned out to be very informative and many issues discussed resonated with the agencies in attendants and with myself. Below I go into some detail on what I believe are the core elements of the Windows Phone 7 platform and although some of this information is just repeating what is out there already hopefully there is some new information contained within this post that you may have not seen.

    Note: at the time of writing this the information was correct. However, things could have changed as the platform is not officially out.

    Minimum Spec

    Every windows phone 7 device that is created by a manufacture must have the following hardware specifications. However, manufactures can improve on these specifications to make their product more appealing to potential customers.

    Every phone needs at least:

    • GPS.
    • Wifi.
    • Bluetooth.
    • A Camera (5 megapixels) with flash.
    • Accelerometer.
    • Compass.
    • Proximity (so the phone knows when it is near your face so it can deactivate the keys).
    • 256 MB of internal memory.
    • 8GB of flash storage.
    • DirectX9 compatible GPU.
    • ARMv7 Cortex/Scorpion CPU.
    • HVGA screen (800X480, however 480X320 is being added at launch for an alternative screen resolution).
    • 4 point touch screen display.
    • 3 hardware buttons on the front of the phone(back, start and search).
    • 1 hardware button on the side of the phone for the camera.

    Optional Extras

    • Hardware keyboard

    As you can see from the above specifications the hardware should be pretty powerful and for manufactures to set themselves apart from the rest improvements could be made to the camera, internal ram, flash storage, CPU and screen.

    Design

    Throughout the event I could see a theme that was very dominate - Design. Microsoft has put a lot of effort into designing Windows Phone 7 and they have completely revamped the windows mobile series. The system is now much sleeker than previous versions and it feels a lot more fluid to use.  There inspiration for the design of Windows Phone 7 was taken from the metro system (underground to us Londoners Smile) in New York and with that in mind the design principles can be seen throughout Windows Phone 7, with information presented to the user in an uncluttered manor but still being informative.

    Marketplace

    At the current time of writing this the cost to be able to deploy products to the marketplace is £67 to subscribe for a year. For this subscription charge you can upload as many paid products as you want and you can upload 5 free products (after your 5 free applications there is around a £20 charge for future free product uploads. If I recall correctly deleting one of your 5 free apps you have already uploaded gives you one space back so you can upload another free product at no additional cost, but this needs to be verified before I say that is gospel.)

    To sell your products you will need to use the marketplace (Unlike older versions of windows mobile where you could have your apps on your own website for people to download ). The marketplace allows you to give your products away for free or to sell them and there is also built in functionality that allows you to have trial versions of you products (when the trial period ends the user can buy the product from within the product and the full version is unlocked for the user to use).

    Currently there is no subscription model in place within the marketplace (useful for applications that deal with monthly subscription such as a magazine application) and there is currently no offering of in-app purchasing. However, according to the speakers at the event they said there would be no reason for you not to implement it yourselves within your own applications by either rolling your own soloution or using a third party soloution.

    Within the web portal for the marketplace you can set the cost for your product on a per country basis and you can specify which countries you want your application to be available in for purchase. Through this web portal you can also see which countries are purchasing your product and through this it allows you to change the pricing of your product to allow you to reach a larger audience.

    When you upload a product to the marketplace you can also use your web portal to track how far your product is along the verification process. This therefore gives you an understanding of when to start advertising your product, which will therefore keep you from wasting marketing money too early.

     

    Developers

    This section will only probably be relevant to developers that will be deploying applications to local devices to test their creations which is why I put it at the end of the post.

    To test applications on a device you will need a marketplace subscription, this subscription then allows you to unlock your device to enable it as a developer device which will allow you to deploy your product to it for testing purposes.

    It is important to note that you can only deploy 10 applications to a device that is unlocked as a developer device. So at any one time you can test up to 10 applications on your phone.

    At the moment that is all I have for you, but please ask questions if something does not make sense and I will answer them to the best of my ability. Thanks for reading my post and hopefully you took something away from it.

    Mark

     

  • Tips N Tricks

    Hello, Let me start off by saying thanks for taking the time to read through this post, and hopefully it won't waste too much of your time (unless that was your plan Smile). Anyway I'm Mark and I have been at EMC Consulting for just over a month now and I thought it was about time I put up a post. So without further delay let's get into the actual point of this post.

    A couple of weeks ago I went to a conference called Guathon. It was an event sponsored by Microsoft to tell developers about Visual Studio 2010, ASP.net  4, MVC 2 and some other technologies. Within the presentations that were given MVC 3 was introduced along with the new razor view engine for ASP.net. Many improvements have been made to MVC 3 to streamline the development process, with a very big emphasis put on rebuilding and deploying code faster.

    However, I digress as the post is called "Tips N Tricks" and not "MVC 3 and the Razor view engine". As Visual Studio (VS) 2010 is being adopted by more developers, it is important to know how we can utilise it effectively to get the most out of the IDE. Although some of you reading this will probably know some of the tips and tricks that can be done within the IDE not everyone does and hopefully you will at least learn one thing from this.

    A quick side note is that although ReSharper offers most of this functionality but it is important to know that Visual Studio 2010 offers this out of the box and therefore allows you to get rid of clunky add-on's and stops you from spending a fair bit of money.

    WARNING: this post is biased towards using VS 2010 with C# and C++ but I imagine the tips and tricks discussed should work with the majority of environments.

     

    IntelliSense

    Within VS 2010 the IntelliSense search is performed with a fuzzy search (meaning that possible relevant answers to your search arguments are shown).

    An example of this is if we wanted to find HttpStyleUriParser typing this out each time is quite mundane but with IntellisSense's fuzzy search typing in just "h" shows a list of possible matches that we can scroll through to find the correct one.

    Image 1

    However, if we type "HSUP" (the first letter of each world within HttpStyleUriParser) we generate a much shorter list to be able to select our desired object from.

    Image 2

    The accuracy of the " HSUP" style search does differ depending on whether or not you have other classes, methods or variables with the same name styling. An example of this could be seen if you had one class called HelpFunctions and another called HelloFoo, within this instance both option would be shown within the drop down box of possible options whe you enter HF.

    Image 3

     

    Box Selection

    I don't think box selection is the correct name for this, however, due to the lack of a better name this is what I am calling it Smile.

    This little feature is useful for when you need to change something in bulk; for example we have declared 5 variables:

    Image 4

    But we realise these should not be of type int they be of type string, sure you can click on each one and rename them or you can perform a box selection (I bet you never saw that coming Wink).

    To perform a box selection you simple click just before the first "i" on the first row you want to select (or click just after the last "t" on the last row you want to select) and hold the mouse button down and then you hold the alt key and simply drag the mouse down (or up) to select all the properties you want to change. Once the selection has been made you can then just start typing to replace "int" with "string".

    Image 5

    (Another way to perform this action is by clicking just before the first "i" on the first row you want to select and then holding the Shift key and Alt key and clicking just after the last "t" on the last row you want to select.)

     

    Collapsing and Expanding Methods

    When classes get a little on the large size it can be a pain to scroll through them to find the method you want. However, that need not be a problem anymore with the help of ctrl+m+o and ctrl+m+l.

    By pressing ctrl+m+o you can collapse all of the methods that you have within your class so you can then browse through the class to quickly find the method you want.

    Image 6

    Then with the press of ctrol+m+l you can quickly expand all of the methods again to see then in full detail.

    Image 7

     

    Block Comments

    Block Comments

    If you have a large chunk of code that you want to quickly comment out you have multiple options you can go through.

    • Comment each line:

                    //int m_demo1;

                    //int m_demo2;

    • Do a block comment

                    /* int m_demo1;

                       int m_demo2;

                     */

    Or use a keyboard shortcut.

    To use the keyboard shortcut you simply select the block of code you want to comment out and then press ctrl+k+c.

    Image 8

    To uncomment the block of code you simply select the block of code and press ctrl+k+u.

    Image 9

     

    Move between open tabs

    When you have multiple tabs open within VS 2010 it can me quite difficult to find the tab that you want, but by pressing ctrl+tab you can scroll through your open tabs and find your desired tab more efficiently. Once you have pressed ctrl+tab a box similar to the one below is shown.

    Image 10

    By then hitting the tab key you will cycle through the open tabs and the highlighted tab will change within the box. Once you release the keys it will go back to the main IDE with the selected tab being shown. It is important to note that you need to keep ctrl held or the box disappears, tapping the tab key will cycle through the open tabs.

    When this box is open you can also just click on the file you want to show, instead of pressing the tab key to cycle through them.

     

    Auto complete of statements

    For each type of statement that can be generated (such as for, foreach, while, try catch, if etc) visual studio 2010 lets you auto create templates of them with dummy information filled in ready for you to change.

    For example a foreach statement would look like the image below.

    Image 11

    As you can see there are three sections that you can change; the type of the object, the name you want to give each item that is pulled from the collection and the collection to loop through.

    1. To create a template statement you type the statement name you want and then hit the tab key twice.
    2. The first section to change is the data type that the item should be. Once you have typed that in you then hit the tab key (when you hit the tab key it moves over to the next editable parameter).
    3. The next section to change is the name you want to give the item. Once you have typed that in you then hit the tab key again.
    4. Finally the last section is the collection you want to use. Once you have typed that in you hit the enter key and your foreach statement is ready to use.

    Image 12

     

    Incremental Search

    Incremental search allows you to perform a quick search within the currently selected class you have open.

    To use it all you do is press ctrl+i and then start typing, as you type results matching your search text are highlighted within the editing area. Note that what you are typing appears in the bottom left of the windows in the status bar area and not in any form of popup window.

    To exit incremental search you just hit the escape key (or click the left mouse button inside the editing area).

     

    View Call Hierarchy

    Sometimes you want to know where a specific method within a class is being called. You could do this by putting a break point within the method in question and then tracing your program through to see where the code returns to. However an easier option is to use the call hierarchy.

    Within the call hierarchy calls to your selected method and calls from your selected method are shown. This allows you to quickly jump to the sections of your code where your selected method is being called from.

    To view the call hierarchy of a method simple select the method you want to view and press ctrl+k+t alternatively you can right click on your selection and select "View Call Hierarchy". Once you have done this the call hierarchy will be shown and look something like this

    Image 13

    By double clicking on RandomFunction() you would be take to the method called RandomFunction().

     

    That is all you're getting from me for now, as there are so many little tips and tricks books could be written on them (besides I think I have wasted enough of your time).

    Thanks for reading the post and hopefully you did learn something new.

Powered by Community Server (Personal Edition), by Telligent Systems