May 31, 2013

expense tracker app - part 3

I've made some changes since my last update, but they were minor changes, and still related to the two Textbox input fields that I am for some reason extremely picky about.

Comparing the functionality of my previous changes to the Microsoft provided bing app again, I noticed some subtle changes.  I won't go into all of the details here because it's boring and tedious, but I changed my Textboxes so that they wouldn't clear out the values every time they were clicked (unless the values shown are the default values).  Rather, upon clicking, they highlight the entire box for easy editing.  Also, the default format is greyed out while any user submitted input is black.  The changes are a big deal to me but probably very boring to anyone else reading this.

Just to illustrate, now here are screenshots:



I removed any EventRaisers in my XAML code and moved it all to the code-behind.  I'm starting to develop more of an understanding of EventRaisers, Events, EventHandlers, Delegates, etc., enough to get my implementation working, but I still feel like I'm not doing things the "proper" way or following good design patterns in my code (MVVM????)  For right now, I'm just trying to get the thing working and as I understand more as I go along, I can clean it up and do things the "proper" way.

However, I'm glad to say that when it comes to entering user input and deleting user input in the Textboxes, my app works the same as the bing app.  (Yes, I tested for null input too.  It works!)

Here are some snippets of my code that implement the text input.

In my MainPage class:
const string DEFAULT_TXT = "Expense";
static string current_txt = DEFAULT_TXT;
static bool txt_default_settings = true;


In the constructor for my MainPage class:
txtInput.GotFocus += txtInput_GotFocus;
txtInput.LostFocus += txtInput_LostFocus;

And some event handlers:
private void txtInput_GotFocus(object sender, RoutedEventArgs e) {
   txtInput.Foreground = new SolidColorBrus(Colors.Black);
  
   if (txt_default_settings) {
      txtInput.Text = "";
   }
   else {
      txtInput.SelectAll();
   }
}

private void txtInput_LostFocus(object arg1, RoutedEventArgs arg2) {
   if (txtInput.Text == String.Empty) {
      txtInput.Foreground = new SolidColorBrush(Colors.Gray);
      txtInput.Text = DEFAULT_TXT;
      current_txt = DEFAULT_TXT;
      txt_default_settings = true;
   }
   else {
      txtInput.Foreground = new SolidColorBrush(Colors.Black);
      txt_default_settings = false;
      current_txt = txtInput.Text.Trim();
   }
}


I think now my next goal is to display a separate page that lists the expenses when the "Display" button is clicked, instead of tons of MessageBoxes flashing across the screen like it does now.

May 28, 2013

expense tracker app - part 2

Just to give an idea of what I've been working on.




These images show a problem I've been trying to fix, which isn't terribly obvious.  But think about trying to use this app, and clicking on the Expense field to enter in new input.  Clicking on the textbox only moves the blinking cursor to the right of the word, which means you have to manually delete the string, which sucks.  It might take only a few seconds but it's annoying if you use it a lot.

In contrast, here are the same set of images, with the same set of actions, done for my bing app:



And notice that clicking on the textbox automatically clears the field for you, which really helps the usability  (I also like how they've dimmed the rest of the app).

Well, I tried all sorts of things, experimented with eventhandlers and delegates, and finally settled on this:

private void txtInput_Click(object sender, MouseButtonEventArgs e) {
   txtInput.Text = "";
}

private void txtInput_LostFocus(object arg1, RoutedEventArgs arg2) {
   txtInput.Text = DEFAULT_TXT;
}

private void numInput_Click(object sender, MouseButtonEventArgs e) {
   numInput.Text = "";
}

private void numInput_LostFocus(object arg1, RoutedEventArgs arg2) {
   numInput.Text = DEFAULT_INT.ToString();
}

With the above in the code-behind, and the below in the XAML (with many things left out):

<TextBox Name="txtInput"
                 InputScope="Text"
                 MouseLeftButtonDown="txtInput_Click"
                 LostFocus="txtInput_LostFocus" />

<TextBox Name="numInput"
                 InputScope="Digits"
                 MouseLeftButtonDown="numInput_Click"
                 LostFocus="numInput_LostFocus" />

I'd like to point out the InputScope field, which specifies the appropriate keyboard to be used.  The "Text" input scope provides a keyboard supplied with characters, and an automatic spellchecker (sometimes I feel guilty about all the functionality that is provided - I thought adding a custom keyboard and a spellchecker would be really complicated).  The "Digits" input scope just provides the digits, obviously, which is all that is needed to add the monetary amount.

And now this is what I have:



May 27, 2013

expense tracker app - part 1

I've been working on another app, that actually serves some functionality besides my "Is It Christmas Yet?" app that happens to say yes on the wrong day..  Yes, I get a lot of crap for that, not enough to change it.  I really did think Christmas was on the 24th when I was writing it.

I'm in the process of implementing a budget tracker because I'm floored every time I see my VISA bill.. I realized it would be nice to have some advance warning.  While I have a very crude version of it, it's actually been helping me to curb my spending.

Here's what I have so far!

(Windows Phone FTW)

Basically the user enters in expenses for the month, although filling in the "Expense" field is optional (the new entry gets filed under "Other").  My display button functionality is a bit awkward, like I said it's a very crude version.  Clicking the display unleashes a torrent of message boxes for each category, here's one:

My drive from Cleveland to Columbus this weekend :(
But I plan on making it more user friendly as I add more functionality.

I think the hardest part initially was figuring out how to store all of the info.  After some research I found out about the IsolatedStorageSettings class, which was perfect for what I needed.

This app definitely needs work.. but it's been a lot of fun to write!  And very useful, I wish I had the idea to make this sooner!