Wednesday, September 26, 2012

Windows Phone and Silverlight FAQ

Recently I was encouraged by the people at work to venture into building Windows Phone (WP) native application.

The enticement was in the form of a Windows Phone; the Nokia Lumia 710, to be exact.

So the following were some caveats that I found that I thought would be interesting to post here just in case someone else also happen to encounter the same issues.

Issue 1
Displaying images dynamically; threading issue.

First of all, I understood the way to retrieve images dynamically from say somewhere in the world wide web. That was not my problem and should you have troubles with that, this is not the place to look.

WP works on threads. My XAML had a image tag with a name of "imgOne" for simplicity purposes and I need to change the source based on some user input.


In the code behind, the XAML.cs file, you will have access to the image tag should you type "imgOne." and Visual Studio intellisense should bring up the available properties for "imgOne".

However, if you attempt to set the source there; imgOne.Source = someBitmapObject
You will encounter the UnhandledAccessException similar to something like this

 

To fix this problem, you would have to use the Dispatcher.BeginInvoke function. Something similar to this



Issue 2
DataContext.

My application is a very small one, so the route I took with it was to not implement MVVM, although it would have been easier to have done so.

So, if you would like to go down this path, here goes.

Each item in the XAML has a DataContext and by default, each of these data context works in a "One Way" mode. So once you set it, the DataContext won't change unless you reset it but here comes the wacky part.

You will have to set the DataContext to null before resetting it to another object.

Tuesday, August 7, 2012

Recently, I upgraded to Mountain Lion for my Mac and guess what happened?

My lovely trackpad failed to work.

So after some painful searching through the goog, I manage to find the solution.

I am posting here so you (and I) will know what to do in the future.

1 - Hit "Command + Option + Esc" or if you are on a PC-keyboard like me, it is "Win + Alt + Esc"

2 - Terminate all processes and relaunch Finder

3 - Put your Mac into sleep mode by clicking on the Apple icon on the top left hand corner

4 - Wake your Mac by using the keyboard

5 - Restart your Mac by clicking on the Apple icon once again and select "Restart"

6 - Shut down your Mac by clicking on the Apple icon once again and then hit the power button.

This should make your trackpad work with gestures again.

Wednesday, July 18, 2012

iOS post 1

In my educational land, there was the massive beast of a library called DotNet and then now, there is a new creature that appeared.

I've taken the initiative to check out GHUnit, OCUnit and OCMock.

All of which I think is paramount to get any form of iOS going.

Infact, for work, we need to get it going for DotNet too but I will let that take shape whenever that is possible.

From this point forward for this article, I will be just be pasting article snips found all over the internet to assist my learning and also to compile my own library of tutorials. 
ViewController.xib (XIB file for short) is the interface layout file. You visually create/design the screen that’s displayed on the iPhone device using this file.
ViewController.m is the interface controller class. The interface layout file is linked to this class. This happens automatically, so at this stage you don’t need to think about it other than to know that any objects or events you set up in your interface class can be linked to your interface layout very easily. This is the file that will contain the Objective-C code you’re about to create.
ViewController.h is the interface controller class header file, where you’ll declare the instance variables, as well as the objects and events that you need to access from the interface screen.
The IBOutlet keyword means that quote_text is an object that can be linked to an interface element on the XIB file so that the view controller can access (or change) properties of the interface element. In this case, we’ll be setting the displayed text for the UITextView control but we could just as easily change the color, font, size, etc.
The IBAction keyword indicates that quote_btn_touch is an action that can be linked to an event for a UI control on the screen. In this case, we will be connecting to the quote button touched event.
In case you’re wondering, id means “any object that derives from NSObject”. Usually when you set up callbacks that buttons and other controls will call, they pass whatever button/control is sending the callback as the first parameter. Since we don’t necessarily know what type it is, we put id here.
 

Excerpts from here


Sunday, May 20, 2012

Venturing into native application development

I have been playing around with a new development tool.

I realized that when creating an Android or iOS application, the Application Id and Project name is very important.

If you happen to use camel casing, you will have to ensure that the Application ID is exactly the same name as the project name.

For example, when you create a project name and name it FirstApplication, the Application ID must be something like com.somedomain.FirstApplication

Thursday, July 7, 2011

Moving from 1 SVN Repository to another

To move from 1 SVN repository to another on Windows, perform the following.

For the purposes of this task, I am going to be assuming that you are on the same server as the SVN Repository AND you are using VisualSVN as your SVN Repository server.

Step 1
Power up SVN Repository server.

Step 2
Start up the command prompt from it.

Step 3
Type "svnadmin dump -r [revision_num] [SVN_From_repository] > [SVN_dump_file_name]"

Step 4
Head to unxutils.sourceforge.net to get UnxUtils

Step 5
Unzip the zipped file

Step 6
Head back to the command prompt in Step 2

Step 7
Type "cat [SVN_dump_file_name] | svndumpfilter include [folders_to_include] > [NEW_SVN_dump_file_name]"
I would keep the path of the SVN dump file and the NEW SVN dump file in the same folder

Step 8
Type "svnadmin load [SVN_To_repository] < [NEW_SVN_dump_file_name]

And you're done.

Monday, July 4, 2011

DropDownList in MVC2 using jQuery

Hi all, I apologize for the long hiatus but today, I discovered something new.

My new role allows me to play with a few more cool toys, eg: WCF, MongoDB, Fluent NHibernate and MVC.

Today I am going to be touching a little bit on MVC and specifically having to deal with retaining the value after selecting a drop down list item.

Previously, in Web Forms, we have the SelectedIndexChanged function that helped us.

However, there is none of that in MVC.

Thus, to solve this, I leverage the power of jQuery.

Before I begin, this was done using MVC2.

What I did was to use the standard Html.Select control on the View and have a hidden field (Html.Hidden in MVC2). Both the hidden and select control must use the same parameter. See the example below,

Html.Hidden( x => x.Field1).Id("hiddenFieldId")
Html.Select( x => x.Field1).Options([INSERT LIST TO BIND HERE]).Selected(Model.Field1).Id("dropDownListId")

After this, I leveraged jQuery in the document.ready() function to implement the change function for the drop down list.

Place the below within the document.ready() function.

$("#dropDownListId").change(function(e) {
var value = $(this).val();
$("#hiddenFieldId").attr("value", value);
});

We can now leverage the Html.Hidden field; Field1 in our code behind.

Tuesday, February 15, 2011

LINQ - Not In

Recently I had to do this query and the follwing showed me how to


var query =

from c in dc.Customers

where !(from o in dc.Orders

select o.CustomerID)

.Contains(c.CustomerID)

select c;


I took this from this link, Marco Russo's blog