Monday, December 24, 2012

Merry Christmas...

...and a Happy New Year to everyone.

Sunday, December 16, 2012

Finally Android version 4

Thank you Samsung!

My Samsung Galaxy Tab finally got upgraded to Android 4 (4.0.4). For too long I have lived with version 3 which in my opinion was a major mistake from Google. The tab feels a lot quicker in graphics and responsiveness.

But I still don't understand why there is a need for a screen-dump-button in the lower button menu. How often do you need to take a screen dump?

Tuesday, October 16, 2012

Changing development environment

Due to a couple of reasons, but mainly because my computer has been reinstalled, I had to setup a new development environment for my LegLogger web application. My choice was to either continue using myeclipse, or to install a plain eclipse. My choice fell on plain eclipse because it’s free and I don’t get too many functions I won’t use. The setup of my different Android projects was no problem but the web application were more troublesome.
 
I realized that creating a web application with myeclipse (as I did some years ago when I first created the LegLogger web) is very easy and the environment do have some nice features that are missing from the plain eclipse. However, and this is the main problem I think, you don’t get the full control of which jar packages are needed and used by the application. Sure, it’s nice to click “Use Hibernate” and everything just works, but then you don’t know which packages are required for Hibernate to work.
 
So I had to spend a couple of hours figuring out which packages was needed for Struts, Hibernate, Facebook and other functions or frameworks used by my web application.
 
Lesson learned: Think carefully before deciding which development environment to use. Maybe it’s a good idea not to have too many helpers and wizards.
 

Wednesday, August 29, 2012

REST

I have just started to look at REST and how to use it in future projects. The list below are just some of the sites I have visited and found interesting:

Monday, August 27, 2012

Windows touch command

If you like the unix command touch and want to to something similar in Windows, i.e. change the time stamp of a file, then there is not built-in command for that. Instead use the copy command like this:

copy /b foo.txt +,,

If you really want a touch command, then place it in a batch file called touch...

Sunday, June 10, 2012

Show tooltip on disabled control

By default are tooltips not showing on disabled controls, but sometimes you want to inform the user about why the control is disabled. Simple add ToolTipService.ShowOnDisabled="true" to the control and the tooltip will always be visible. Example:



<Button Content="Example" ToolTipService.ShowOnDisabled="True" />


See more at Microsoft MSDN.

Saturday, May 05, 2012

File organization of a WPF project


A few months ago I started with a new project at work. The goal is to create a design tool for warehouses and the application will be running on the Windows platform. After the design choice landed on WPF I started to think about the project’s file structure. This is my first Windows application that is not build on Windows Forms but on WPF. The design tool is not that big of an application, so I think my tips in this article will suit small to medium sized applications well.

First of all, how should the application be organized on the highest level? Does the application consist of only one executable file, or one executable file and several assemblies (e.g. DLL files)? For instance, the design tool has an output functionality that formats the warehouse data to a specific protocol and then uploads it to an embedded computer. The output functionality could well be located in a separate project (i.e. an assembly) that is referenced in the main application’s project.

How should the main application’s project be organized (the “WPF”-project)? My personal opinion is that all dialog windows (or views) should be located in the main project and not in assemblies. The assemblies should handle stuff like business logic or data storage, and not user interaction. However, controls (with or without user interaction) could very well be located in assemblies. You should also keep the dialog’s business logic as plain as possible, meaning that code executed when e.g. the OK button is pressed should be fairly simple. When needed, refactor and move the code to a new class or even to another project (e.g. a business logic assembly). When I started to organize the design tool project I found the article A WPF Project Needs Structure posted on the Dr. WPF web site very useful. The article gave me a good starting point which I have adapted to suit the needs of the design tool. The project consists of a number of base folders for the logically different files used in a WPF project. The Controls folder holds the controls that for one or another reason should not be located in a separate assembly. The Resources folder consists of different types of resources, e.g. images, styles, cultural strings etc. I would suggest the use of subfolders in the Resources folder; you might even want to separate small and large images into sub folders. The Views folder holds all the views or dialogs. For most parts, I try to divide views into logical groups. The design tool use different kinds of templates for the data; I therefore have a Templates subfolder. Another approach could be to separate views into the order they are used, if that is applicable. The largest folder is Utils; this folder consists of both business logic and more WPF style functionality such as converters or validation classes.

This is how the design tool project is organized:
  • Controls
    • ...
  • Resource
    • CultureStrings
      • Controls
      • Views
      • Common
    • DataDefinition
      • E.g. XSD files
    • Help
      • E.g. CHM helper files
    • Images
      • 32x32
      • Icons
    • Styles
  • Utils
    • Converters
    • Validators
    • ...
  • Views
    • Data
    • Main
    • Templates
    • ...
Further reading:

Tuesday, April 24, 2012

Visual Studio crashes when trying to adding/edit a macro

Some days ago I wanted to add a macro to my new installation of MS Visual Studio 2010 and I received the following error message:

Cannot find one or more components. Please reinstall the application.

The installation of Visual Studion seems corrupt. After some digging I found the solution and only needed to repair the installation, and not to do a complete re-installation. Follow the instructions at this site if you experience the same problem.

If the link is broken, this is what to do:
  1. Delete the following file:
    * On a 64-bit operating system: "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\1033\Microsoft.VSDesignerUI.dll"
    * On a 32-bit operating system: "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\1033\Microsoft.VSDesignerUI.dll"
  2. On the Add or Remove programs page, select Uninstall/Change Visual Studio 2010 and then click Next.
  3. Select Add or Remove features.
  4. Clear and then re-select any of the features in the list. This causes the update state to be enabled.
  5. Finish the Setup wizard. Visual Studio Macro Tools should be installed.

Sunday, April 15, 2012

Problem updating the Android SDK in Eclipse

When updating the Android SDK from the Android SDK Manager in Eclipse you may encounter an error with the following message:

-= warning! =- A folder failed to be renamed or moved. On Windows this typically means that a program Is using that Folder (for example Windows Explorer or your anti-virus software.) Please momentarily deactivate your anti-virus software. Please also close any running programs that may be accessing the directory 'C:\opt\android-sdk-windows-1.5_r3\tools'. When ready, press YES to try again.

Many forums suggests to disable the antivirus software and retry, but that didn't work for me. The solution turned out to be very simple. Close Eclipse, open a command prompt and navigate to the tools folder of your Android SDK, in my case C:\opt\android-sdk-windows-1.5_r3\tools. Then give the command:

android update sdk

The environment will now be updated.

Thursday, January 19, 2012

How to update a database

Keeping a database's structure up to date can be a rather complicated task. If one is maintaining a web server then it's at first sight a simple task of updating the database when the server is updated. But what to do when the web server is the actual product delivered to customers? Another problem is perhaps more obvious, the product is an application that gets regular updates with bug fixes or new features.

Read my full article at The Code Project.

Thursday, January 12, 2012

A WPF book I recommended

I have just started to develop a new application together with my customer and we are going to use the Windows Presentation Framework (WPF) and .NET 4. Since this is new to me I needed some literature in the subject. One book I have used is WPF 4 Unleashed by Adam Nathan (ISBN 978-0-672-33119-0). I can very much recommend this book. The reader must be familiar with the .NET framework and C#; no time is spent in describing .NET or programming in general. Together with Google this book will help you when developing WPF applications.