Home » Archive by category "Programming"

Set the same assembly info, once, for multiple projects in the same solution

Let’s suppose we have a solution (LibrarySolution), with 2 projects:

  1. a class library for the data (DataLayer project)
  2. a WPF user interface (LibraryUI project).

Each of these projects have their own assembly info, as shown below.

Each project has its own AssemblyInfo

The issues is that each time the version number is changed in one of the projects, you have to manually change it in the other project as well. This maybe wouldn’t be such a burdain if there were only 2 projects and the same person would be responsible to update them. But when you have multiple projects or multiple people updating the versions and they are not aware of the necesairy update, then you have a big problem.

The solution would be to create a class library to keep the common version info – and this way you have to change it only once and it will change in all the places that it is referenced.

Create a new class library to store the common AssemblyInfo data

This new project (AssemblyData) doesn’t need any classes, just place the common assemblyInfo data that you want to use in multiple .net projects from this solution.

Set the common AssemblyInfo data

Now, in every project that you want to use this version you have to:

  1. Add a reference to the AssemblyData project
  2. Add an “existing file” link to the AssemblyInfo.cs file from the AssemblyData project
  3. Remove the common assembly data from the project, and specify it only in the AssemblyData project

Step 1 – Add a reference to the AssemblyData project

Step 2 – Add an “existing file” link to the AssemblyInfo.cs file from the AssemblyData project

Both projects have references to the AssemblyData project and link to AssemblyInfo.cs

Step 3 – Remove the common assembly data from the project, and specify it only in the AssemblyData project

Now if we build the solution and change the version number in the AssemblyInfo.cs file from AssemblyData project, we will have the same version for both DataLayer and LibraryUI projects

Same version number for all the projects

WPF Ribbon (CTP) – Part 6 – Creating a Ribbon Color Control

Creating a Ribbon Color Control

Let’s take Word for example: we can easily select the color for a piece of text or for a shape. The CTP version does not have any such control, so I would like to give you an example of how you can create one.

Entire Tutorial:

Summary

  • Step 1: Creating a new application
  • Step 2: Creating the custom RibbonColorButton
  • Step 3: Binding the RibbonColorButton to the TextBlock

Read more

WPF Ribbon (CTP) – Part 5 – Creating Custom Controls and Viewing Templates

Creating Custom Controls

Sometimes the default controls might not be enough for our needs. So what can we do then? Well, it’s simple: create our own controls. For example the CTP version does not have a color picker, but we can create our own.

Entire Tutorial:

Summary

  • Step 1: Creating a new application
  • Step 2: Implementing the IRibbonControl interface
  • Step 3: Changing the template of an existing RibbonControl – e.g. RibbonTextBox
    • Step 3a: Removing the image from the RibbonTextBox
    • Step 3b: Set a fixed width for the visual text area inside the RibbonTextBox
    • Step 3c: Set a fixed width for the label and text area inside the RibbonTextBox
  • Step 4: Viewing the templates of the basic ribbon controls
    • RibbonTab
    • RibbonButton
    • RibbonDropDownButton
    • RibbonSplitButton
    • RibbonCheckBox
    • RibbonTextBox
    • RibbonLabel
    • RibbonComboBox

Read more

WPF Ribbon (CTP) – Part 4 – Resizing Groups

Resizing Groups

Continuing with the example from the end of part 3 of the tutorial, I will show you how groups resizing is done, how you can change the order the groups resize and also how you can prevent a group from collapsing.

Entire Tutorial:

Summary

 

  • Step 1:The Default Group Resizing
  • Step 2: Specifying the Group Size Reduction Order
  • Step 3: Preventing a RibbonGroup from resizing and collapsing
  • Step 4:Resizing Issues

Read more

WPF Ribbon (CTP) – Part 3 – Adding Ribbon Controls

Continuing with the previous part of the tutorial, I will show you how to add ribbon controls on the ribbon groups. For now, I will present the controls as they are and in the next tutorials we will begin to create our own custom controls and manipulate the already existing ones.

Entire Tutorial:

Summary

  • Step 1: Adding a RibbonButton
    • RibbonButton’s Properties
  • Step 2: Setting the GroupSizeDefinitions
  • Step 3: Adding a RibbonToggleButton
    • RibbonToggleButton’s Properties
  • Step 4: Adding a RibbonDropDownButton
    • RibbonDropDownButton’s Properties
  • Step 5: Adding a RibbonSplitButton
  • Step 6: Adding a RibbonCheckBox
    • RibbonCheckbox Properties
  • Step 7: Adding a RibbonTextBox, a RibbonLabel and a RibbonComboBox
    • The RibbonControlGroup
    • RibbonLabel Properties
    • RibbonComboBox Properties
    • Issues with the RibbonTextBox

Read more

WPF Ribbon (CTP) – Part 2 – Adding tabs and groups

Continuing the application from the previous tutorial, we will add tabs and groups on them.

Entire Tutorial:

Summary

  • Common Properties for the Ribbon Controls
  • Step 1: Adding Tabs
    • From XAML
    • From Code-Behind
    • RibbonTab’s Properties
    • Why some properties seem to have no visual effect?
    • Issues
  • Step 2: Adding Groups
    • From XAML
    • From Code-Behind
    • RibbonGroup’s Properties
    • Issues

Read more

WPF Ribbon (CTP) – Part 1 – Add Ribbon and Customize

The ribbon-like look and feel seems to be a general trend. Once we got used with look and feel of the Office applications, we might as well want to use it our own applications.

For .NET users, the ribbon is accesible using MFC Feature Pack or the WPF CTP release. I will focus on the WPF version, which can be found on wpf.codeplex.com, where you can find a discussion list and an issue traker list. Being the CTP release, there still are some known issues and some of the controls that you normally have in an Office application are not yet available (for exemple Color Picker, Color Button, Gallery etc), but hopefully this things will be solved when the Ribbon V1 will be available.

After you downloaded the WPF Ribbon binaries, you can start creating your first application that uses the ribbon.

Minimum requirements for this tutorial:

  • Visual Studio 2008 SP1 and .NET Framework 3.5 – needed for this version of ribbon to work; in .Net Framework 4.0 a better version for the WPF ribbon will be available.
  • Basic knowledge about WPF and bindings

Entire Tutorial:

Summary

  • Step1: Creating a new WPF Application Project
  • Step 2: Including the RibbonControlsLibrary.dll
  • Step 3: Adding the Ribbon inside the main window
  • Step 4: Customizing the Ribbon
  • Step 5: Adding images as resources to the project
  • Step 6a: Defining the RibbonApplicationMenu from XAML
  • Step 6b: Defining the RibbonApplicationMenuItem from Code Behind
    • Loading an image from code behind
    • Creating a RibbonCommand from code behind
  • Step 7: Defining a RibbonSeparator in XAML
  • Step 8: Defining a RibbonApplicationSplitMenuItem in XAML
  • Step 9: Defining the RibbonApplicationMenu.RecentItemList
  • Step 10: Defining the Quick Access Toolbar (QAT)
  • Step 11: Removing the titlebar

Read more

Geek Meet #5 in Brasov

Last Saturday, on the 25th of July 2009, I participated at Geek Meet #5, which was held in Brasov, at the “Okian” Library. The first presentation was mine, about “Genetic Algorithms” and you can download it from here – it’s in Romanian, and soon, I hope to also add the translated version in English.

Architecture Explorer in VS2010 Beta

Visual Studio 2010 Beta is public and can be freely downloaded from here, and you can choose from 2 editions: Visual Studio 2010 Professional Edition and Visual Studio Team System 2010.

I downloaded a few weeks ago the Team System edition and started to make some projects and discover what’s new. The most interesting thing I found new in this version is the UML support (finally, I don’t need another tool to design the diagrams!) and the architecture support, in a new window called Architecture Explorer. I tried to find some detailed information about what can be done with this new functionality, but unfortunately I didn’t find enough, so I was back to my initial thought: just try and see what it can do!

You can view the Architecture Explorer window by selecting it in the View menu (for now it does not have a key shortcut combination). A new window will appear and you have 2 ways of viewing an exiting project from the architectural perspective:

  1. Class View
  2. Solution View
ArchitectureExplorer

Architecture Explorer

The basic idea of this Architecture Explorer is that it allows you to navigate easy between different levels of the project, going from a top and general view (the solution’s projects, for example) inside a more detailed vision (to class members and even code implementation). From one level to another there is always a new panel that can be hidden or displayed and you can go back just by clicking a intuitive arrow.

In the Class View situation, the levels for navigations would be: Namespaces -> Types (classes and interfaces) -> Members (methods or attributes for a class); If you choose a method, you can go further and see the parameters, the blocks of code and so on.

Architecture Explorer - Class View

Architecture Explorer - Class View

In the Solution View situation, the levels for navigations would be: Projects -> Project Items (which is like a directory structure – it contains the files and the folders in that project) -> Classes -> Members (from here it’s the same as Class View)

Architect Explorer - Solution View

Architect Explorer - Solution View

For each level in the Architect Explorer, there is a filter, which can be used by selecting the header of the level’s column and afterwards selecting the ‘down’ arrow, which will popup the filter’s options. I will present some of them as images, because the options are very intuitive.

Filters for Projects

Filters for Projects

Filters for Project Items

Filters for Project Items

Filters for Classes

Filters for Classes

Filters for Members

Filters for Members

Filters for Code

Filters for Code

The basic options on the Architect Explorer are:

  • Export DGML File – allows you to save the DGML (Directed Graph Markup Language) file somewhere on the disk; If you want to find out more about DGML, read here.
  • Refresh Content – refreshes the Architecture Explorer‘s visual content
  • Save Query to Favorites – afterwards you can access it via the Architecture Explorer window
  • Create new Graph Document and populate it with the contents of the current selection – you must select a element layer, and VS will generate for you a diagram (using Directed Graph Markup Language) that contains the full path you got to that element; You can see this diagram in the main window and also, you can see the generated dgml code (but more on that in another post)

    DGML Example Generated from Architect Explorer

    DGML Example Generated from Architect Explorer

  • Copy the selected nodes from the Architect Explorer to the current active Document Graph , which will add in the current diagram the nodes and the relationships between them, like this:

    DGML Example with Relationship Between Nodes

    DGML Example with Relationship Between Nodes

That’s just a preview on what the Architect Explorer can do, I hope this made you curious and you’ll give it a try and use it, because it has great flexibility, it is intuitive, user-friendly and also:

  • It can generate diagrams from existing code (this is a great advantage of build-in tools).
  • It makes it easier to explain a certain part of a solution to any team member.
  • It simplifies the communication process between the team members (architects and developers).
  • It offers a simple and efficient way of understanding the system and its components, the way they are related and can be used; it will reduce considerably the time needed to get acquainted with the code and the project.