March 18, 2013

first app?

Question mark because all I pretty much did was follow the directions on here, and all that amounted to was dragging a textbox, dragging a button, and dragging a webBrowser control onto a blank app and copying and pasting four lines of code.  Guess we all gotta start somewhere eh?

So here's the code that Microsoft provided for us:
    private void Go_Click(object sender, RoutedEventArgs e)
    {
        string site = URL.Text;
        MiniBrowser.Navigate(new Uri(site, UriKind.Absolute));
    }
I also tried
MiniBrowser.Navigate(new Uri(site));
MiniBrowser.Navigate(new Uri(site, UriKind.Relative) // this hated me
MiniBrowser.Navigate(new Uri(site, UriKind.RelativeOrAbsolute))

I noticed, that for (site, UriKind.Absolute) and just (site), if I removed the "http://" from the website address ("www.bing.com" instead of "http://www.bing.com") then the emulator would take me to an Application_UnhandledException.  But removing the "www" didn't produce errors ("http://bing.com"), while removing both the "www" and "http://" produced errors, but that's because the "http://" was missing.  (site, UriKind.Relative) didn't work for anything, but when I removed the "http://" then it rewrote the MiniBrowser with a "We're having trouble displaying this page" instead of throwing an exception.  So when I tried the (site, UriKind.RelativeOrAbsolute) for the above options, it didn't throw an exception but went into the "We're having trouble displaying this page", which I prefer.  Of course when a null address was input, then it threw an exception for all of the cases.

So taking these into account, here is a more robust version:
    private void Go_Click(object sender, RoutedEventArgs e)
    {
        string site = URL.Text;
        if (String.IsNullOrEmpty(site)) return;
        if (!site.StartsWith("http://") && !site.StartsWith("https://"))
            site = "http://" + site;
        MiniBrowser.Navigate(new Uri(site, UriKind.RelativeOrAbsolute));
    }

And here is a picture:
(bing gets jealous when I use this app and launches itself in full page version.  I took this screenshot in a two-second window.  This app works for other sites though.)

March 16, 2013

Overhaul

Except not.  I tried to rewrite my template from scratch, thinking it would be fun.  And it would have been.. I just don't have the time to learn all of this extra stuff on top of everything else I'm trying to get done.  Then I realized blogger provides templates for a reason - other people doing work that I can mooch off of so I don't have to do as much.  It's what they're teaching me in my CSE curriculum anyway - the best programmers are the laziest ones.

This will have to do for now.

March 03, 2013

Updating

Website is undergoing a makeover.  Plan:
  • Combine "art", "computer science", and "musings" blog into one
  • Links to aforementioned pages on top frame
  • Colors that aren't awful
  • Some organization of blog posts
  • Frame on the side to display timeline of posts
On the plus side, I understand pointerz now.  I look at the posts below and shake my head.