Cottleston Pie

Fernando Felman’s thoughts on software development

  • Categories Navigation

  • Topics

  • Archives

  • Advertisements

Projex, exercising with WinForms

Posted by Fernando Felman on March 9, 2007

I did quite a bit of SharePoint related projects and I learned that one of the most important things you’ve to know when you’re coding a SharePoint Web Part is the Web Control Lifecycle: what events are being called by the infrastructure, when are they called and on which conditions. To that model you’ve to aggregate the SharePoint-specific lifecycle, such as when the Web Part Communication events are being fired and how does that relate to the regular Web Control lifecycle.

So I can say I know about Web Controls quite a bit. But what about WinForm Controls? I wanted to upgrade my knowledge in the WinForms technology to know more about creating Windows Controls, considerations and restrictions I should be aware of, etc. I wanted to investigate the following key aspects in a Widows Control: how does data binding works (and not just how to use it), what are the best practices for coding controls and what internal methods should I be familiar with.

There’s only one good way to learn all of that: experiencing… So I give you my open source, free to use Projex application. This application allows you to create drawings based on a shape I call the Webex, a spider-web shape combined of two points and a mutual anchor point.
Here is how a single Webex looks like:
Simple Webex

And here are some sample of what the application allows you to do (click to enlarge):
Canvax Sample 4 Canvax Sample 3 Canvax Sample 2

The code is constructed in the following way:

  • ProjectXWin: The Windows application. This application has 2 namespaces:
    • Drawing: contains the Pointex and the Webex classes. Both are mathematical representations of a drawing object and aren’t bound to any Control (so you can use them in any displaying technology, including a windows control).
      • Pointex: represents a single Point with anchoring-aware capabilities. I coded this class to encapsulate the anchoring functionality so when the user moves or resizes the drawing area (the window displaying the drawing), the Pointexes will move to their anchored locations causing the drawing to shrink or grow.
      • Webex: a single spider-web drawing represented in an abstract mathematical way. I coded this class to encapsulate the logic of calculating the lines and the resizing functionality for a single Webex.
    • Windows: contains the WinForm controls. This namespace contains many User Controls representing the various value-editors I needed (like Color selector, Pointex editor, etc.) and also have these 2 Custom Controls:
      • WebexPainter: this control display a single Webex. It was coded to facilitate the task of painting a Webex in the form and binding it to its editors.
      • Canvax: a container for multiple WebexPainters. I coded this class to allow the Webex painters to share the same drawing canvas (the same Graphics object).
  • TestProjex: the unit test project implement in MSTest . I usually use NUnit and I wanted to experience with the Microsoft unit test platform to see which is more suitable for me and my team.

Hope you’ll find this project interesting!
Enjoy, and remember that you can leave comments both on the project main page and on the relevant discussion group.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: