Tuesday, March 6, 2012

extracting the hardcoded info


PAX East schedule is out! I need to get cracking on this. I also got another response to my app survey today, where the only feature requested is 'update for pax east'. 

So, last week I implemented the ability to download a hardcoded file from my server. Now I need to adapt that so that I can download whatever files are available, and that I only do this if they are updated from my version.  I want to add this option in an app bar, but I need the collapsed app bar which is only available in mango, and I'm hoping to get one last usable version for pax east out in pre-mango format. So I've added this button in the about page (terrible design, I know). I might also want to add a little notification to the front menu letting the user know if a new version is available?
I should add a 'what's new' popup on first run, like 4th and Mayor.

I wired up a button in the about screen to look for a new schedule on my server, and put a really lame 'version info' file on the server, looks like this
3.1.2012
"East/2012"

So this is - date = last time the server schedule was updated, and location= folder location to look in on the server. In that folder will be a zip file of all the xml files. Each zip needs to be a complete set - I'm not going to try and manage just sending the new events or anything like that. (I'm mostly being inspired here by this article on downloading and reading from a zip - http://www.galasoft.ch/mydotnet/articles/article-2008032301.html

I actually format the event schedule  into xml by hand. I copy the plain text from the official website, then
  1. Remove special characters - /&" are the main ones. Also odd quote chars like ’ and — and …
  2. Manually insert an 'Event' heading for each event
  3. arbitrarily decide on the 'type' of the event, basically I put as 'show' anything that doesn't sound like it'll have audience participation/questions. 
Etc etc

I've hardcoded lots of things that need changing. I haven't gotten a full plan for how to best handle this instead.
  1. Panorama title says' PAX Prime 2011' - updated
  1. Maps are all of Seattle - I have the bcec and boston maps, but will the pax specific ones change? I should probably wait here...nah, I'll almost definitely need to send out another update later. For now let's put in last year's maps.
  1. Useful links are seattle based - updated


public get, private set, public crash?


Goodness,  I seem to have found the weirdest bug. I decided to pull all the event headings into the Schedule class ("Manticore" etc) as a precursor to loading these dynamically from a settings file.  I set up the lists like this:

        
public List<string> eventDays
        {
            
get { return eventDays; }
            
private set { }
        }

However, all of a sudden I found that the app would completely and silently crash, not even throwing an exception for me, when it tried to access any of these list variables - even from within the same class. I removed the get/set so they were just public variables, and the app worked fine again. Then I put back this get/set code, and the app crash reliably reproduced, and then visual studio itself crashed.

    public Schedule()
        {
            
ObservableCollection<Event> events = new ObservableCollection<Event>();
            Events = events;
            eventDays = 
new List<string>();
        }

        private void readSchemaFile()
        {
            
if (eventLocations == null)
            {
                eventLocations = 
new List<String>();
            }
   //populate list
      }


edit: the next day, when it was not 2am, someone pointed out to me that I had obviously put a recursive get on eventDays, so it was crashing with a stack overflow. Way to go, me. 

xaml fiddling


Took a 2 day course at work that gave me a good overview of the changes available in mango, but was overall aimed at a new developer and probably not worth my entire two days. I did spend the time working on the app and updated the search to look and act like marketplace search on the device
  • Got rid of the separate search.xaml so that now it is presented in the schedulepivotview.xaml like any other view of events
  • Had to add a bunch of items to this (search header, search textbox, text to show if a view is empty) and found that if I put it all in a stackpanel, the list of events doesn't scroll (documented online in a couple of places - the list needs to be inside something with a set size, when it's in a stackpanel it thinks it has unlimited viewspace and so doesn’t need to scroll). However if I just put all the items in the top grid and hid the non-relevant ones, then the touch didn't seem to work on the pivot, presumably because other items were 'in the same place'. I worked around this by putting all the extra controls in a stackpanel that was collapsed by default, like this
  • <Grid>
    • <StackPanel>
      • <textblock search header>
      • <textbox search entry>
    • <Pivot>
    • <StackPanel>
      • <textblock empty search text>
      • <textblock empty 'my schedule' text>

  • As a bonus, this made it easy to also implement a notice when the user enters my schedule and has not yet added any items to it.

Also added an inline star to all items that are in your schedule, so you can tell without clicking on details whether you've already added this one.