June 06, 2013

expense tracker - part 4

Here's my app now.  Looks better


But for now the code still looks messy.  Now that I've got the basic functionality I want and I'm starting to learn more about MVVM, I think I'm gonna start moving my code around so it follows those principles.  I've been experimenting with data binding and the IConverter interface as well - I'm binding both Textbox Foreground colors to a Boolean value and using a Converter class, so now I don't have to manually update the color in my code because it automatically fires depending whether the Boolean satisifies the default settings or not.

Here's a neat little MessageBox trick I discovered:

Timing it so the purple shows was quite tricky

Now when the user clicks delete, the app verifies the action before removing all the data.  I'm sure there would have been instances where I accidentally brush the trash can and inadvertently remove all of my data.  At least now this is slightly more idiot proof.  Here's the code used to implement that:

private void clear_button_Click(object sender, EventArgs e) {
  MessageBoxButton button = MessageBoxButton.OKCancel;
  string s = "";
  MessageBoxResult result = MessageBox.Show("Are you sure you want to clear all values?", s, button);
  if (result == MessageBoxResult.OK)
     my_storage.Clear();
}

The pencil button on the app bar is the edit button, which I haven't implemented yet.  When you click it all it does is display a MessageBox informing you that you clicked it.  It's not very helpful yet but I'll make it so the user can remove single fields that they no longer need.  And I'll probably keep the app bar at four buttons, any more and it'll start to look too busy.

Another nifty feature - the "running tally" text at the bottom of the main page, and the LongListSelector used to display all of the name, value pairs are data bound to the user's current accent color, so it's not my fault it the user doesn't like the color.  I'm just starting to get used to this data binding stuff but I've found I can simplify the code and add many more cool features with it.