Saturday, October 31, 2009

WPF And Multiple CollectionViews With Filtering

This one drove me nuts for a bit. You can have multiple views against a single data set. So if you have:

ObservableCollection orders;

you could have one view for Late Orders, another view for New Orders, etc.

You do this using collectionviews. However most of the examples you find show something like this:

ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(orders);

However, if you create multiple views like this on orders, you will actually still be working off the default view. If you put a filter on one view, that will actually apply to all views. You need to create the view like this:

ListCollectionView view = new ListCollectionView(orders);

Then you can apply filtering to that view without affecting other views.

Tuesday, August 25, 2009

ASP.NET MVC Numeric Textbox

Introduction

So I've been having a bit of a look at ASP.NET MVC as part of the public facing section of the Silverlight project I am working on. I've been able to get running the main part but wanted to neaten up the validation. I wanted to be able to add a TextBox on my form that would only accept a number. From what I could see jquery was the way to go. (If you have a look here you can see an example of how the numeric entry works.) But that raised a number of questions:

  • How to use jQuery?
  • How to add scripts?
  • How to add the TextBox?
  • How to specify the class of a TextBox?

Using Google it took quite a bit of time to track down all the pieces to make this work. As a result, I've written this one post that hopefully brings it together.

Making A Head Content Available

In order to use jQuery, you need to be able to add some scripts to the page generated by the view. This really needs to be in the head section, but on my view pages, there was no where to add it. I had an asp:content tag for TitleContent and one for MainContent but nothing where I could put the script.

In the Site.Master page I modified the head section from this:

<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
</head>


To this:

<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="head" runat="server" />
</head>


See the ContentPlaceHolder? That will allow me to define a head section in my view pages.

Adding The Scripts

Now that I have a ContentPlaceHolder, I can edit my view pages to add scripts. Just below the Page command I can add the code that will appear in the head section of the page.


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Construction.Service.Claim>" %>
<asp:Content ID="Scripts" ContentPlaceHolderID="head" runat="server" >
<script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> 
<script type="text/javascript" src="/Scripts/jquery.numeric.pack.js"></script> 
<script type="text/javascript">
$(document).ready(function() { 
$("input.numeric").numeric(); 
}); 
</script>
</asp:Content>




Few things to note here:
  • Everything in the asp:Content ID="Scripts" section will appear in the head section on the generated page. Just what I wanted.
  • In the scripts I've added reference to "/Scripts/jquery-1.3.2.min.js". This is the jQuery library that ships with ASP.NET MVC V1.0.
  • The next line is for "/Scripts/jquery.numeric.pack.js". This tells the page that we want to use the jquery numeric library which can be found here. I downloaded this file and then added it to the scripts section of my project. This line in my head section references that file. That link shows the jQuery numeric usage. So once you have this basic one going, you can refer back to that link to see how you might extend your options.
  • The next part is the 'ready' function for jQuery. I'm new to jQuery but from what I can work out, this is the function where you put all your stuff to prepare things for later use. In this case we are telling the system that things identified as 'input.numeric' will be numeric. The 'input' simply refers to the fact this will be associated to an input textbox. The '.numeric' indicates that this will be used by any input control that is of *class* 'numeric'. We'll see how this works next.

Making A TextBox Numeric

The last part is to create a TextBox in the view that needs to be numeric entry only. In my case I used code like this:


<%= Html.TextBox("ApprovedPercentage, ViewData.Model.ApprovedPercentage,
new { size = "5" ,@class="numeric" })%>


This is basically just creating a textbox on the form. The magic that pulls all this together is the clause:
@class="numeric"


This links it back to the input.numeric reference in the script and the textbox will be limited to a numeric. You can have as many textboxes on the form as you require and provided you include the '@class="numeric" ' part, they will all be numeric entry only.

You can set the textboxes up by id if you want. So in the ready function you would have this:

$(document).ready(function() { 
$("input#approvedpercentage").numeric(); 
$("input#approvedamount").numeric(); 
}); 


In this case, the # means treat the following word as the id of the textbox, not the class. You have to specify each one.

Then on the textbox you would have:

<%= Html.TextBox("ApprovedPercentage, ViewData.Model.ApprovedPercentage,new { size = "5" ,id="approvedpercentage" })%> 


Note, I didn't set the @class this time, I set the id.

Conclusion

Its actually pretty easy to get the numeric textbox working once you know all the pieces. Hopefully, someone finds this useful!

Friday, August 21, 2009

Lite Versions

Its the last month of winter and its 30 degrees. Celsuis - not farhenheit. Absolutely gorgeous weather. Bring on summer!

Its a Friday. I've had a pretty good couple of weeks doing some Delphi work. Now its time to get back to some iPhone lovin'. So today I've produced lite versions of Taekwondo ITF Patterns and Beach Rescue. In the case of ITF Patterns, only the first three patterns will be available. For Beach Rescue, a game will end when the player reaches 100 points.

The ITF Patterns sales have gone down a bit. Still selling but not as well as it was. I swapped war stories with the developer at Skunkscape who has done a similar program for WTF taekwondo. (Can you believe that the two best tkd apps in iTunes are develop within 100km of each other? Must be the sunny weather.) Seemed like a nice bloke. I won't discuss his sales but I was very impressed by the number of downloads that his lite version has had. So I figure its worth a try. I'm pretty confident in my app to let people try it before buying it.

Beach Rescue sales on the other hand have been pretty dismal. We'll see if a lite version can rescue Beach Rescue! With games though I do think I will have to spend some money on advertising. Still not willing to put my hand in my pocket for that just yet.

Been working after hours on another app which I hope will be ready soon. Just gathering the content for it. The programming work has all been done. Hopefully finished soon!


Wednesday, August 12, 2009

iPhone Musings

Been a little while since my last post. Finally got google ads working after getting a letter from Apple saying I was authorised to use iPhone in an ad. First couple of days the ad was getting heaps of hits from about 60 different countries. I think that was due to having quite a high bid for the keywords. I've had to reduce that though. Given the small profit margin per sale, you have to be careful the adword costs don't exceed profits. Since then the number of clicks has reduced to a few a day. Been playing around with CPC rates and ad text. Still not real sure how some of these quality scores are calculated though...

So was it worthwhile? Can't really say it has been. Sales haven't gone up at all. They remain consistent. I was hoping for a bit of a spike. I'll keep it going because its not costing me a lot and it gets me out there.

I was put on to an app called AppViz which is quite cool. The best feature is being able to see any reviews from any app store worldwide. I had thought I'd received no reviews but there as one from the UK for 5 stars. The person was also asking for some blackbelt patterns to be included as well as self defence. At this stage I'd need more requests before committing to adding more content.

But I have got a great idea for a new feature iI can apply to the existing content. I already think I have the best TKD app on the appstore, but this feature would cement it. Just a case of whether I think its worth spending the time on it or not.

Beach Rescue has not gone particularly well. Made some sales but no where near covering costs, so while games are fun to work on I can't see any more happening at the moment. I've sent out requests for reviews and promo codes but so far nothing much. Most traffic has been from the cocos2d forum where I had told them about the game I had developed with the cocos2d framework. For this app, I might have to spend some money on advertising and just get it out there a bit more.

Thursday, July 16, 2009

Price Seems Ok

I had a two day sale last weekend just to test the price. Sales didn't increase at all. This would seem to indicate that the price is not really a factor. The market is only small but the information is important enough to the market to buy the app at $3.99USD, so for the time being the price will not change. If the sales had increased, indicating that there was a larger market that was price sensitive, it may have been worthwhile dropping the price. But frankly, $3.99 in the overall cost of obtaining a blackbelt is nothing. The market seems to think its worthwhile and it gives me some sort of return on my development time/costs. I'm still out of pocket, but its been a worthwhile learning exercise.

I noticed one of my competitors has a Lite version of their app. I'm considering whether its worth doing the same and having an ITF Patterns Lite that shows the first 3 patterns. It shouldn't be too hard to implement. Again, would be done in the spirit of experimentation just to see what works and what doesn't.

I've given up on google for the time being. They don't want to budge on the iphone as a trademark issue, even though I believe it should be showing in the US with their recent trademark policy change there. I actually had a lady ring me from google the other day to tell me they had noticed my ad wasn't working very well and offering me training. Grr....

So now I am chasing Apple but so far they haven't been very helpful either. Its hard to believe that advertising an iPhone app can be this difficult...

Monday, July 6, 2009

Its Finished!

My first iPhone game is finished! Beach Rescue is a fun little game where you control two lifesavers who have to keep their beach safe. I've just submitted it to Apple for review. Hopefully it will be ready for sale in a couple of weeks.

Its been a fun little exercise. I've drawn the animations and I'm pretty happy with them. The screenshot doesn't really do them justice because you aren't seeing the movement. At the end of the day, its still just programming with the usual memory leaks and bugs. But playing around with the graphics, sound, gameplay, etc has been a lot of fun. Hopefully, others will find the game fun too play and the game becomes a bit of a hit.

The marketing for this will need to be different from the ITF Patterns app. I will have to contact a number of the review sites and see if I can get interest in the game. Its not something that you would expect anyone to google on. Mind you, google hasn't been very successful for me so far with ITF Patterns either. Google support has been quite pathetic. There is basically a five day turnaround for every question I ask them. At the moment I am getting hits on the content network but not the search network and I'm not getting satisfactory answers. Has not been a very pleasing experience at all.

Saturday, June 27, 2009

Advertising Blues

Well this online advertising is not as straight forward as it seems. My first Google ad was finally approved with limited use because it contains the word 'iPhone' which is a trademark. Limited means apparently it can be seen only in the US, which is probably ok since US is the biggest market anyway. But its still not showing in general search. It does show up on related content sites (so if you go to a taekwondo website and they have google ads showing, my ad is being displayed, I think). But I have no idea why the search is not working and google support is terrible.

I also tried to place a similar ad on Bing. It was disapproved for landing page relevancy. I got on to MS support and it was actually not rejected for that but again for trademark issues with iPhone. At least the support was nice and prompt with LiveChat.

So I am still not sure how you successfully advertise iPhone apps. I don't want to say its for a smartphone. I'll get clicks from Blackberry and Palm devices which is a total waste of time and money.

Still learning...


New App Is Coming Along Nicely

I have been working on my first game for the iPhone and it is coming together nicely. The basic gameplay is now there, as are some the graphics. I think I'm in the final stretch. Its now about making it look like a finished product. Am hoping it will be available for sale before the end of July. Pictures once it looks a little more complete.

Wednesday, June 24, 2009

Well That Was Disappointing

So after saying how I was going to use Adwords to raise awareness of my app, nothing has happened. Well nothing positive anyway. I created the ad last Monday. Now this being google, I sort of expected an immediate result. However, its now Wednesday (that's 9 days!) and my ad still isn't available. How do I know that? Well it certainly isn't from any obvious clue on the Adwords website. It tells me my campaign is Active. However, the Diagnostics tool, tells me none of my keywords trigger my ad. What the...? So after emails to google support, they tell me the ad is still waiting to be approved. Would be nice if the website told me that.

After reading the numerous complaints on the Adwords discussion group, I found that the new beta interface does show the ad status. This doesn't work under Safari 4 on iMac. I've fired up, Firefox and checked it out. Woohoo! It shows its 'under review'. So at least I can see that its not actually started yet. But how does it take over a week to approve approximately 140 chars of text? Seems to be a lot of people on the forums bagging Adwords and recommending yahoo or msn advertising. Might be worth a go...

Google sent me a 'how did we do?' survey email on Friday. Needlessly to say, that was a fail. I even mentioned the fact the web site doesn't show the ad status. No one suggested that I try the new interface. Grr...

Some positive news is that the app is still selling ok. Not big numbers but consistent. Will be nice if that keeps going.

Monday, June 15, 2009

TKD Results

So after the first few days of availability, I've averaged about 4-5 sales a day. Not the thousands per day I need to retire, but its nice to think anyone thought the app was worth $3.99 USD at all. Its a bit hard to tell how many of these were people who searched the app store specifically for taekwondo or just happened to find it as a newly released program. To really measure that I think I would have to leave sales go for another couple of weeks, so the app isn't really new anymore. But I don't want to leave it just hang at those sorts of sale levels.

The Google Analytics for the product page has been interesting to look at. Been a few hits from facebook checking me out (thanks friends!) but most hits seem to be direct links which would mean they have come from iTunes. At the same time, I know I have made sales in France and Norway and these don't show on analytics at all. So as a rough estimate I would think 40% of people who visited the products page bought the app. Would more have bought it if it was cheaper? Maybe. But at this stage, I don't see the need to decrease the price. I still think I have a quality product. Pity there is no way to measure how many people visited your app link in iStores (at least I don't think there is).

So what's next? Google Adwords, that's what. I've read articles that examined different ways to increase sales for your iPhone app. Adwords was actually towards the bottom of the list. I can see that being the case for a lot of apps, especially games. They really need to be reviewed, get on to featured lists, etc. In this case though, my app is targeted for people who are learning their taekwondo patterns. I know from personal experience that Google is a great place to look for examples and instructions. So I reckon that for my app, Adwords should achieve something. Anyway, I've set up some Adwords so we'll see what results I get.


Wednesday, June 10, 2009

First iPhone App

Well I got an email overnight to say that my first iPhone app is available for sale. So I am on my way to financial freedom as the hordes download my app :-).

Taekwondo ITF Patterns is an information app which describes how to perform the ten patterns you need to perform to get your black belt. Its got pictures of each step of the pattern and allows you to view them from four different angles. I think the interface works pretty well.

It will be interesting to see how this sells and what marketing I can do with it. Given that its more of an information app, its not really something I feel could be successfully reviewed on one of the many iphone app review sites around the place.

Price point will be interesting. I have priced at $3.99USD to start with. Since this is a specialised app with specific domain knowledge, I feel its justified having a higher price. I know I would easily have paid $3.99USD to have this info with me while I was going for my blackbelt. When I first got the idea for this, there were no comparable apps on iTunes. Just in the last week though I have noticed there is a patterns app, priced at $0.99USD. So already there is pressure to drive the app down in price. However, its content is simply a scan of pages that already exist on the web. It doesn't seek to make that content more accessible as I believe I have done. So at this stage I believe the $3.99USD price is still justifiable.

For the first week I will simply leave it be and see what sort of hits it gets from iTunes. I doubt this will achieve much but since this is my first app, its going to be a learning experience as to what makes sales, what works, etc. Next week I will start to try a few things and see what impact it has.

Welcome

Welcome to my blog. Here I hope to post experiences of my developments with various technologies, including iPhone, Silverlight and WPF, as I seek to make a comfortable living as a freelance developer.