Rob Kraft's Software Development Blog

Software Development Insights

LucidChart.com is your online alternative to Visio

Posted by robkraft on May 24, 2011

I just recently started making use of the online charting tool http://www.LucidChart.com and I highly recommend it as your alternative to Visio.  I used IE9 and found the charting tools to work very much like a Windows desktop application.  It is very easy to click and drag, copy and paste, draw connector lines, change captions and do so many of the core tasks that you can do in Visio.  I believe this product is much better than the open source and free products such as OpenOffice Draw or Dia.  There appears to be no direct print option, but I am 100% happy without that feature because you can save to PDF and print from the nice-looking PDF document.  I am also impressed by the number of templates available at start and that I can use the product for free.  I can even share my diagram with 2 other people under the free model.  LucidChart offers several free priced plans and we are evaluating the tool now to determine a pricing plan to follow, but you can use the free version indefinitely if you would like.  Finally, you can import your existing Visio diagrams into LucidChart, though I did not try this.

If you want to make any diagrams and you don’t own Visio, or even if you do own Visio, you should spend a few minutes to check out LucidChart.com.

Posted in Free tools | Leave a Comment »

How to programmatically make the Windows Phone 7 Keyboard open

Posted by robkraft on May 15, 2011

I wrote a Windows Phone 7 application with a search page.  When a user clicks on the search icon I wanted to take them to the search page, set focus on the text box, and have the on phone keyboard pop open for the TextBox.  Since the TextBox was the only control on the page I figured it would get focus and the keyboard would open up; but it didn’t work that way.  To make it work, I used the Focus event on the TextBox.  The only trick to this is that you can’t call the .Focus on the TextBox in page constructor because the XAML has not all rendered and events are not yet tied to all the page elements.  So, you need to create a load event in the constructor, and have the load event call Focus on your textbox.  This will cause the keyboard to open as soon as someone navigates to the page.

public SearchPage
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(SearchPage_Loaded);
}

void SearchPage_Loaded(object sender, RoutedEventArgs e)
{
SearchBox.Focus();
}

Posted in Code Design, Silverlight, Windows Phone 7 | 1 Comment »

BooleanToVisibility Converter – Yes, you must write your own for your Phone

Posted by robkraft on May 6, 2011

You must code your own BooleanToVisibilityConverter in Windows Phone 7 development as of May 2011.  That may change when Silverlight 4 can be used for Phone 7 development.  Until then, I recommend you write your own, and start with a good example like the ones found here:

http://compiledexperience.com/blog/posts/useful-calue-converters

I spent more time than I expected on this project attempting to use a boolean value in my viewmodel to control the visibility of an error message on the form.  What I learned is that I DO need to write my own Converter class that implements Iconverter.  I had the impression from many blog posts that this was built it, but it is not – at least not in Windows Phone 7 with Visual Studio 2010 after the NoDo updates and all Phone SDK updates available through April of 2010.  I did not have to write my own converter though, I just copied this code I found elsewhere on the net.  Then I had to make 3 entries in my XAML:

  1. xmlns:loc=”clr-namespace:MyAppNamespace” where MyAppNamespace is the namespace over the class containing my converting.  This entry was already in my XAML for other purposes – and of course “loc” is just a variable name that you can replace with anything.
  2. Add this little bit of code in the Xaml after the first big block that imports the namespaces.  The name BooleanToVisibilityConverter needs to be the class name of the class you created for this.
    <phone:PhoneApplicationPage.Resources>

<loc:BooleanToVisibilityConverter x:Key=”BooleanToVisibility” />

</phone:PhoneApplicationPage.Resources>

  1. Then use it on one to many Visibility properties with code like the following.  In this case, I have a property named SearchFactsFound on my ViewModel.

Visibility=”{Binding SearchFactsFound, Converter={StaticResource BooleanToVisibility}}”

Posted in Silverlight, Windows Phone 7 | 1 Comment »

Dramatically improve build times with new hardware

Posted by robkraft on April 30, 2011

Ok, so I gave away the punch line in the article title, but I wanted to share my joy at the big difference we experienced in build times when we got a new build server.  Our old build server was running 4 VMs, and one of those VMs contained our build process which we tried to run 3 times per day, along with unit tests and other build jobs.  The average compile time for our C# code was 50 minutes.  This was tolerable when
everything going well and we are not approaching a release deadline.  But we are now approaching a release deadline and we are in the midst of renaming a lot of projects and DLLs which is causing an unusually large number of build failures.  I was spending more than half of my day each day running builds.  We finally bought a new computer, not really a server, just a power tower PC and moved our main build VM to that
machine.  The build times went from 50 minutes down to 16 minutes on average.   This allows us to find problems more quickly, get the bugs fixed more quickly, and we are already even responding to bugs found in QA more quickly.  If we had known the build times would have improved so dramatically we would have done this 6 months ago.

We still haven’t even defragged the hard drive in the VM, or increased its disk space. We hope to do both next week and I expect a small gain, but nothing like we experienced with the new hardware.  So don’t go cheap on the hardware!  Saving time is saving money!

Posted in Dev Environment | 1 Comment »

How to tell Visual Studio 2010 to open files in the correct window when you double-click

Posted by robkraft on April 28, 2011

I tend to tolerate minor annoyances in order to focus on more important tasks I want to accomplish. Recently though I finally got tired of my documents opening in the wrong window in Visual Studio when I double-clicked on them. Generally this occurs when I do a find across all files, and the find results pane is docked in a shorter window at the bottom of Visual Studio 2010. When I double-click on one of the lines in the Find Results pane, it opens the intended document in the same lower window, not the larger window on top where I generally view the source code I am interested in. It took me a little while to resolve this and to tell Visual Studio to open the windows in the top pane instead of the bottom pane. The fix is simply to select ‘Reset Window Layout’ from the Windows menu in Visual Studio 2010. I guess that menu option could also be called “Make Visual Studio open documents correctly again.”. I don’t know why my window layout began misbehaving in the first place.

Posted in Visual Studio 2010 | 18 Comments »

How to edit your application icons for the application list and tile for Windows Phone 7

Posted by robkraft on April 26, 2011

I hoped to find a totally freeware version of an icon I could use for my Windows Phone 7
application somewhere on the Internet.  I am not a graphics guy and I don’t expect my application to make enough money to justify hiring an artist.  I did find a PNG file that was good enough, but it only came in one size (48X48), not the 62×62 and 173×173 dimensions I needed for the phone.  I decided to try to resize the PNG but it did not resize well by default.  I decided to try again using Paint.Net.  I chose the “Nearest Neighbor” resampling option in the Resize dialog and fortunately this gave me a nicer looking large PNG than the default resampling
options had.

Posted in Windows Phone 7 | Leave a Comment »

How to make your own application icons for Windows Phone 7

Posted by robkraft on April 25, 2011

I searched around the Internet for 48×48 PNG images that I could use for Application Bar Icons on my Windows Phone 7.  I was hoping to find an icon that represented “menu”, but I did not.  Finally, I decided to try to edit something I felt was close and I am glad I did because it was very easy to do.  I obtained a free icon editor called IcoFX from download.com (I almost always download from download.com because they have already ran virus checks against the files they host).  I then opened an existing image and began making the minor edits I desired for my new image.  I made sure that the image was a “True Color”, or “32bit” image.   I saved it as an .ico, then used the Export Image option from the File menu of IcoFX to export it to a .PNG.

Posted in Windows Phone 7 | Leave a Comment »

How to capture screen shots for Windows Phone 7

Posted by robkraft on April 24, 2011

To publish an application to the Windows Phone 7 store you must provide at least one screen capture of your application. I believe the best method to do this is to run your application in the emulator and use the “snipping tool” in Windows 7.

  • Set the zoom size of the emulator to 100%.
  • If the full screen does not fit on your monitor, rotate the emulator 90 degrees to take the screen shot.
  • If your application supports both portrait and landscape orientation, but you want a portrait image, change your code to only support portrait mode long enough to take a screen capture.
  • Use the “Window snip” from the snipping tool and save the image as PNG.
  • Use Paint.Net to rotate the image back to vertical if you had to rotate it for your screen capture.

Posted in Windows Phone 7 | Leave a Comment »

MVVM Rocks! It helped me past a PivotControl bug.

Posted by robkraft on April 24, 2011

MVVM rocks! I thought I would be spending many hours to convert my PivotControl UI to a simple Page UI after I discovered that some PivotControl features don’t work. But the switch took me less than an hour to create 4 new pages and get them all functional. Changing the UI was simple because all of my logic was in my viewmodel. When I bound new forms to my ViewModel to replace the previous PivotControl form, everything just worked. Score a victory for MVVM!
The PivotControl feature that does not work that I needed was the ability to set the Index of the PivotControl and allow the ViewModel to cause navigation to the specified Index. Unfortunately, as of April 2011 in Visual Studio 2010 with Phone 7 it does not matter what value you provide to the SelectedIndex or SelectedItem in the PivotControl, you can only cause the PivotControl to display starting with index zero. I expect this bug will be fixed in the next release of the PivotControl.

Posted in Windows Phone 7 | Leave a Comment »

Use string.Format instead of string concatenation

Posted by robkraft on April 15, 2011

I recently learned a good reason for writing my C# code like this:

return string.Format("{0} was deposited in your account.", amount);

instead of

return amount + " was deposited in your account.";

Both return the same result when the string is in English, but if you want your code to support other languages, then you need to be aware that the sentence structure of another language may not match English and that using string.Format gives the language translator more control over the format of the entire message. The English sentence, “The man went to the store”, may sound like, “To the store went the man” for speakers of languages that put the subject of the sentence at the end. Many bilingual speakers find these differences to be a major challenge to speaking new languages fluently. To myself, the message “$100 was deposited in your account.” sounds like good English, but in another language that may sound like “Was deposited amount of $100 to your account.”.

When you write your code using concantenation, you are forcing the translator to place part of the sentence where you would place it in your native language. But, if you use string.Format, and convert your string to a resource to support localization, the translator can fully control the translation.

return string.Format(AppResources.DepositSuccessful, amount);
en-US = AppResources.DepositSuccessful = "{0} was deposited in your account."
es-SP = AppResources.DepositSuccessful = "Fue depositado {0} en su cuenta."

Disclaimer – I am not fluent in Spanish so my translation might sound terrible to Spanish speakers. My apologies.

Posted in Code Design | Leave a Comment »

 
Design a site like this with WordPress.com
Get started