Archive for the ‘Miscellaneous’ Category

>Visual studio net database edition does not handle data

July 13th, 2009

>

The title is not totally correct; it does handle data. But it cannot do version management on your database if you have data in it properly.

Like this:
A year into the project you/the customer realize that a Customer can be split into InternalCustomer and ExternalCustomer and a decision is made to make Customer the base class and the other two children.  An accordingly correct decision is made to create two new tables in the database and have them have their corresponding fields.

Technically, or database script wise, this means
1) create two new tables
2) select data from the Customer table into the two child tables <- oops
3) drop some fields in the Customer table

Visual studio database edition can handle 1) and 3) but there is no way to tell it to run a custom script in between.

This unfortunately makes the product useless for me.

Which open source license to choose

February 20th, 2009

At the time of wrintig there are like 78 open source licenses to choose from. The original creator of the open source license idea has an argument that 3 or 4 should do.

So if you ever think of choosing a license for you work the linke below might a good place to start.

http://itmanagement.earthweb.com/osrc/article.php/3803101/Bruce-Perens-How-Many-Open-Source-Licenses-Do-You-Need.htm 

Update: A similar article is here.

>Annotate in TFS

February 4th, 2009

>

There is a somewhat hidden feature in Visual Studio TFS edition (or whatever it is called) for checking who changed a row.  It is called Annotate and can be reached through the context menu.  After some number crunching it gives you a semi graphic view of which row was edited by who.

Further Annotate can be done on other rows but not the same row again; I don’t know why.

>Change control name in Visual Studio

December 11th, 2008

>

VSNet remembers which attribute use used lastly so just start typing, there is no need to click.

Like so:
You layout a WinForm in Visual Studio.  Either when you are finished or as you layout the controls you name them.  There is no need to click and mark the Name attribute in the Atribute panel; VSNet remembers which attribute you typed last.

Example: Drop a label on the form.  Click the Name attribute.  Write the name.  Drop another label on the form.  Just start typing the new name without clicking anywhere.  What you type goes right into the right property.

Might save some time.

>Change window in Visual Studio

November 17th, 2008

>

Change window in Visual Studio 2008 through the shortcut ctrl-tab.  It goes through the windows in recent order so you get back to where you where.

If you want to get back to where you where in the same window use ctrl-minus.  Go forward again with ctrl-plus.
Note: for older versions of Visual Studio you have to have the US keyboard layout, the swedish does not work with ctrl-minus.

To show the open windows either use the Window menu (alt-w-w) or the “small window menu” dropdown ctrl-alt-down.

Open source – which licens to choose

November 1st, 2008

When you have decided that open sourcing your code would be a good idea the next question follows; which license?

Claes Mogren wrote a short and good description about some licenses and the thoughts behind them: http://informationhunger.blogspot.com/2008/10/open-source-license-primer.html

Update other articles are here and here.

>WPF and shortcuts

November 1st, 2008

>

Forcing the user to sprout a third arm to use a mouse is considered bad programming.

All menus should have shortcuts.  To be frank almost all controls should have shortcuts.  To use a few seconds to add shortcuts to the controls as they are made is considered good.

Shortcuts in WPF is done by prefixing with underscore, like E_xit and _Open. (WinForm is done by prefixing with ampersand, like E&xit.  Web applications should have this too and there it is called Accesskey.

Then to add the nice “Ctrl-O” text beside Open and “Ctrl-S” beside Save is trickier in WPF.  By no special order these are the pages I had to read to understand CommandBinding and RoutedUICommand:
http://anuraj.wordpress.com/2008/06/23/shortcuts-keys-in-wpf-menu/
http://en.csharp-online.net/WPF_Concepts—Built-In_Commands
http://colbycavin.spaces.live.com/blog/cns!5FFDF795EBC7BEDF!129.entry

>Retrieve the plain text from the RTF control in WPF

July 18th, 2008

>The rich text control in WPF is way more versatile than the Win32 one.
Versatility often means more complex and more complex means that the simpler things are sometimes lost. Like for instance retrieving the plain text from a RTF control.

It is not hard to do but I didn’t find any good example through google so here is an example of how to retrieve the plain text from a WPF rich text control:
    TextRange textrange = new TextRange(
        rtfControl.Document.ContentStart, rtfControl.Document.ContentEnd);
    string plainText = textrange.Text;

HTH

>Writing code or conducting it

July 7th, 2008

>

A friend of mine said something wise. A programmer’s job could be to conduct the code instead of writing it. Think of it like components that all handle their part very well and plays well together. The conductor is there to facilitate and point in the right direction. I believe he is on to something.

XamlParseException in WPF

June 8th, 2008

>When hacking WPF one sometimes get
System.Windows.Markup.XamlParseException was unhandled
Message=”Cannot create instance of ‘FormMain’ defined in assembly ‘Kopain2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation. Error in markup file ‘Forms/FormMain.xaml’ Line 1 Position 9.

which does not give much of a clue.

So copy exception details to your favourite editor (Copy exception detail to the clipboard…) and scroll down. Typically at the second last row you can read something like
at Kopain2.FormMain..ctor() in C:\Data\Projects\Kopain2\Kopain2\Forms\FormMain.xaml.cs:line 101
which is a magnitude more helpful.