Right now I have to come back to the practical and make a decision. Do I load the data from a button click or try to finish the full API to load the data? Since the mapping engine is progressing so quickly, I think I need to get some data working on the map, which means I need to read the data from the server and populate some objects so I can draw them on a map. I don't need the UI right now as I can hardcode the data retrieval for now. Time to switch gears. Before I do that I need to get the project building again as I was so tired yesterday that I just had to give up and call it a night. Plus I had several of hours in the evening that I had to work on some marketing literature to give to a potential client. But today is a new day so time to start out on a positive note. Since I am a morning person it is much easier for me to thing clearly in the early morning so starting out at 5am when it is dark and quite suits me just fine.
I need to read a bit more about Data Binding before I totally give up on the UI changes I was trying to make to show the data load dialog. New plan - I have tons of working examples to compare to my project and find out what I am doing wrong in loading multiple pages from a selection list. That is a common paradigm that runs thru all of the example so this should be solvable by looking at any complex example. Even newer plan - bring up the example code on my Mac and then compare the project code on my Windows laptop since I am still at home and do not have the super fancy monitors like at work. That did not take long to find the missing piece. The Microsoft examples all come with the common folder that contains a class called "LayoutAwarePage" which contains all of the logic that I was missing to navigate between two pages. It is very involved so I certainly do not want to reinvent the wheel and just need to use it so I can get past my compile issues and see my pages working. But wait, there is way more to this than it appears on the surface. The example code uses a whole different paradigm to load secondary pages so I need to learn how to do this the correct way using VSE. Now I am giving up temporarily and going to get the data loading without a UI.
So far having spent half of the day trying to get the data from the secure server within the project I created. I keep getting a build error 'Could not copy the file "obj\x86\Debug\Bing.Maps\Themes\Generic.xbf" because it was not found'. I find if I try the use F7 to rebuild that most times it will work. Only two times did that not work so in those cases I had to clean the project and rebuild it from scratch. Odd that I have been seeing these messages today. I wonder if it has something to do with me running multiple VSE and apps in the debugger at the same time? I don't believe that is it because only my project uses Bing Maps.
Many hours later I have the the code completed that retrieves the 3 parts of the data from the secure server and saving the results to 3 different files. I have been learning way more about C# than I ever thought or wanted to know. In order to get the model code to work I had to learn about calling a super class, which has to be the most odd syntax I have ever see. On the method you have to add " : base()" and if the parent method or constructor requires then those have to be passed into "base()". Creating an abstract class, and protected variables is very straight forward. I kept struggling with how to show debug statements to the debugger output window. The code really changes depending on the target platform and the language used to build the Windows app. I kept finding code that did not compile. Finally I discovered the correct package as I had to add "System.Diagnostics" and then I could call "Debug.WriteLine". I then had to learn about "String.Format", which is very similar to other languages on formatting string given arguments. I then had to learn about DateTimeOffset class as I had to do some time math. It was not the easiest way I have seen as Ruby beats them all with beautiful things like "3.days.ago" or "2.hours.from_now". That is just so easy as it should be. I had to learn about switch statements, well I didn't actually have to but I wanted to instead of using a series of IF/ELSE statements. I spent way too much time trying to debug a problem with using a MessageDialog from within a background thread. I was close but then I would encounter a run-time error occasionally so I abandoned that for Debug.WriteLine as it was only for debug. Eventually I need to add a progress bar to show as data is being retrieved and loaded onto the map, but NOT today. There is only way to show a message dialog and that is using an "await" statement preceding the "ShowAsync()" method call. To make sure this can be done in a background thread you have to add this magic code:
var ignore = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { await messageDialog.ShowAsync(); }I know it is complicated to do such things as it is not much easier in iOS as there is special Apple magic there as well. This kind of code just makes me want to start my Thanksgiving break earlier!
I also learn about Exceptions and try/catch/throw, which is basically the same in all languages I have used, so that knowledge transferred nicely. I went back into my C# class files and cleaned up all of the imports, which is very similar to how that is done in Java. I am kind of disappointed that VSE does not add the "using" statements automatically as that would be very helpful. As it is I have to go searching all over the planet for the location of the class I want to use. That is why it took me so long to find the Debug statement.
Now that I have the data on downloaded from the server, I need to process the JSON data and store it into objects. It is amusing how every framework has it's own terminology for the model objects. Windows loves the term DAO. I am not a fan but I just don't run in those circles. Turns out it is pretty easy to get the data into objects as Windows 8.1 has a very nice JSON supporting library. I even saw a reference to the Apple iOS documents in one of the Microsoft class library document pages today. I cannot remember which one it was but I found it amusing. The only tricky part was getting the JSON list of objects to be stored in an ObjectCollection. I may have to wake up a bit early tomorrow so I can finish it off before going to a special Thanksgiving meal.
It just never fails. I was super frustrated yesterday and felt little progress was made. I tried to calm down and start all over today by throwing away most of what I had done yesterday and chalking it up to a learning experience and it certainly helped. Today I got the API working as I wanted to finish that this week. I still have nothing showing up on the map so that will have to wait for another day next week. The only unsolvable problem I had today was I wanted to show my customer what I had working but GoToMeeting works on my Mac but when I downloaded the app from the Windows Store it only let me join the meeting. I could not change presenter to my Windows laptop. I tried to exit and it still showed me as being off line. I will have to try to solve that problem before our iteration meeting next week.
No comments:
Post a Comment