Posts

Showing posts from 2011

Wix: Set MSI filename based on version

A nice post on how to change the output MSI file name in Wix project based on the primary assembly’s version:http://blog.tentaclesoftware.com/archive/2009/05/03/38.aspx

25 beautifully designed Windows apps

Wix: Showing debug information on dialog boxes

In Wix, a property value can be <empty> or with some value.One way to find debugging information in Wix is to show it on the setup dialog boxes. For instance, we can show the product code on the welcome dialog box if we find any previous version of the product. We can do this as follows:

<!-- FOR DEBUGGING -->
<ControlId="Debug1"Type="Text"X="135"Y="150"Width="220"Height="60"Transparent="yes"NoPrefix="yes"Text="!(loc.Debug.WelcomeDlgTitleForUpgrade)">
<ConditionAction="show">DEBUGGING</Condition>
<ConditionAction="hide">NOT DEBUGGING</Condition>
</Control>

Now we can pass the DEBUGGING parameter as one of the console argument:

msiexec /i "TestApp.msi" DEBUGGING=X                    ------when we want to show debugging information
(you can assign any value to DEBUGGING even 0 (zero), it will work as long as it is not empty)

msie…

WPF: TreeView example (Part 4)

Image
In the example shown in Part 3, we saw how to show a tree, with depth of 3.

But what about scenarios, where we do not really know the depth of the tree? Best example is Windows Explorer, it shows a tree with folders, sub-folders, more sub-folders and so on. How do build such a tree?Let’s try to implement this. We create a class Folder:

publicclass Folder
{
publicstring Name
{
get
{
if (!String.IsNullOrEmpty(Path))
{
return io.Path.GetFileName(Path);
}
returnnull;
}
}
publicstring Path
{ get; set; }
public List<Folder> Folders
{ get; set; }
public Folder()
{
Folders = new List<Folder>();
}
publicstatic Folder CreateFolderTree(string rootFolder)
{
Folder fld = new Folder { Path = rootFolder };
foreach (var item in io.Directory.GetDirectories(rootFolder))
{
fld.Folders.Add(CreateFolderTree(item));
}
return fld;
}
}
XAML…

WPF: TreeView example (Part 3)

Image
Continuing from the last post, let us add another level to our tree. For this we have to:

1> Change the DataTemplate to HierarchicalDataTemplate for the second level
2> Add a new DataTemplate to show the third level

The classes used in the sample:

publicclass Category
{
publicstring Name
{ get; set; }
public List<Company> ItemList
{ get; set; }
}
publicclass Company
{
publicstring Name
{ get; set; }
public List<Product> Products
{ get; set; }
}
publicclass Product
{
publicstring Name
{ get; set; }
}Loading data in Window class:

privatevoid Load()
{
Company cMS = new Company { Name = "Microsoft", Products = new List<Product>() { new Product { Name = "Windows" }, new Product { Name = "MS Office" } } };
Company cApple = new Company { Name = "Apple", Products = new List<Product>() { new Product { Name = "iPhone" }, new Product { Name = "…

WPF: TreeView example (Part 2)

Image
After creating the TreeView in XAML and code, let us bind the TreeView to a collection.

We create a list of strings and set it as DataContext to TreeView:
List<string> items = new List<string>() {"Apple","Oracle","IBM","Microsoft" };
this.DataContext = items;
XAML:<TreeViewMargin="10,10"DockPanel.Dock="Right"Name="tvList"ItemsSource="{Binding}">
</TreeView>

Result is:

This is working like a ListBox, what we need to use is hierarchical data. Let’s create the classes which we will use in binding.

Class Category:
publicclass Category
{
publicstring Name
{ get; set; }
public List<string> ItemList
{ get; set; }
}

In the Window code-behind - we create two categories, add them to a list and set the list as the DataContext:
Category c1 = new Category { Name = "Software Companies", ItemList = new List<String>() { "Microsoft", "Oracle", } };
Cat…

WPF: TreeView example (Part 1)

Image
Let’s look at another often used control in business applications – TreeView. It is a great control to visualise hierarchical data. Take an example – of customer, their orders and order details. A lot of data without using TreeView – it can get little bit complex to show the relationship between the data.

Just like we have ListBox and its ListBoxItem where we can include any control – not just text; we have TreeView has TreeViewItem.

The XAML goes as:
<TreeViewMargin="10,10">
<TreeViewItemHeader="Sony">
<TreeViewItemHeader="Order-123">
<TreeViewItemHeader="LCD TV"/>
<TreeViewItemHeader="Wii"/>
<TreeViewItemHeader="Vaio"/>
</TreeViewItem>
</TreeViewItem>
<TreeViewItemHeader="Apple">
<TreeViewItemHeader="Order-1">
<TreeViewItemHeader="iPod"/>
<TreeViewItemHeader="iPhone"/>
<TreeViewItemHeader="iPad"/>
</TreeViewIte…

Apple

A great line about Steve Jobs, who passed away today: “It is easy to sell your work if you believe in it”.Steve, you will be missed!

TO READ

Good link - .NET/WPF Performance leaks

WPF: Binding example (Part 6)

This post deals with performance problems with DataGrids.If you test the WPF Task Manager application we have been developing in last few posts, you will notice that we experience a lag when we scroll the process grid – or click the grid to open its row details containing the threads. There is a concept of ‘virtualization’ in WPF. It basically means the UI object which is not shown on the screen is virtualized or to say taken out of memory. This reduces the no. of objects which is supposed to improve performance.Grid has two properties which change the virtualization - EnableRowVirtualization and EnableColumnVirtualization.By default: EnableRowVirtualization is true and EnableColumnVirtualization is false. This is why when you scroll down or up quite quickly you notice a lag – the virtualized objects are being brought to life when they become visible.In WPF task manager if we change the value EnableRowVirtualization to false (it is true be default) you will notice a considerable impro…

WPF: Binding example (Part 5)

Image
Continuing with our WPF binding series with WPF Task Manager – today we will work with row details in DataGrid control.We were able to see all the processes in the grid:You will note an additional column – ThreadCount which indicates the no. of threads active in that process.Each process can have many threads, so the Process object which we are using to fill our List<Process> collection – has a property Threads which is ProcessThreadCollection containing objects of type ProcessThread.We will modify our grid to show details of these threads for a process. For this design using RowDetails would be an ideal solution.In XAML file just below the data grid columns definition, we add the <DataGrid.RowDetailsTemplate> tag to define the row detail. This is just like ItemTemplate in ListBox and we can use any control or layout here. But since we are showing a collection (of threads) in row details why not use another grid here. The XAML is:<DataGridGrid.Column="0"Grid.R…

CruiseControl.NET: Display error/warning on the ccnet project’s main page

How do we display an error or warning message on the ccnet project’s main page?We generally write ECHO messages:<echo message="Problem with your build: ${error.code}."/>
But this will log the message only to the ‘NAnt Output’ log.To display the message on the project’s home page, we need to add the Level attribute with an appropriate setting: Error or Warning.
<echo message="Problem with your build: ${exit.code}." level="Error"/>

WPF: Binding example (Part 4)

Image
We saw in the last post how we can change the UI of our WPF Task Manager to show all the processes in a grid layout using a ListView control. ListView is useful when we are restricted to .NET 3.5, because in .NET 4.0 framework we have the DataGrid control. There are certain shortcomings in ListView – one being it doesn’t allow automatic sorting of rows. Even if we implement sorting it doesn’t give a visual hint on the column we clicked to sort data. DataGrid is a complete control with all the important features. So let’s modify our application to use the DataGrid control.We start by removing the ListView tag in XAML and replacing it with:<DataGrid Grid.Column="0" Grid.Row="1" ItemsSource="{Binding Path=ProcList}" Background="Gray" Foreground="Black" Name="lst" HorizontalContentAlignment="Stretch">
</DataGrid>And we get this:Cool! All the columns are automatically generated and the cell type changes based …