Windows Live Writer is a desktop application that makes it easier to compose compelling blog posts using Windows Live Spaces or your current blog service. For Windows Live Writer I created a plugin called SyntaxColor4Writer that enables you to embed syntax highlighting in your blog posts. More details about SyntaxColor4Writer can be found here. This is how the plugin looks:
This is an example of a xml fragment generated by SyntaxColor4Writer:
<system.web>
<compilation defaultLanguage="VB" debug="true" />
<customErrors mode="RemoteOnly" />
</system.web>
It has been quiet for some time on my blog, but that will change now. It was mainly due to the fact that we bought a new house in Hombeek, we didn't know that little village before :). Every weekend we spend time on painting and some chores. But the fact that we moved now, and that practically everything is done, I can again spend more time for programming and sharing with the community.
That's right, a public preview of Office 2007 Beta 2 is available. You can download the bits from here. Note that right now it is very difficult to connect to the server, due to high traffic.
BindingListView<T> is a project hosted on GotDotNet that gives you search, sorting and filtering capabilities to a plain BindingList. For example if you have the following Person entity:
public class Person { string firstName = string.Empty; int age = 0;
public string FirstName { get { return firstName; } set { firstName = value; } }
public int Age { get { return age; } set { age = value; } }
public Person(string firstName, int age) { this.firstName = firstName; this.age = age; } }
And you want to have a collection of persons bind to a datagrid, you can simply write the following:
BindingList<Person> persons = new BindingList<Person>(); persons.Add(new Person("Bill", 45)); persons.Add(new Person("Gert", 33)); persons.Add(new Person("Johan", 12)); persons.Add(new Person("An", 27));
personsGrid.DataSource = persons;
What if you need to do some filtering, or simply sorting on the datagrid? Therefore you would need to create a custom collection class that implements a bunch of interfaces for having sorting, filtering and searching capabilities.
The BindingListView<T> class has all these functionalities built-in. You simply have to pass a list, and bind the BindingListView to the datagrid. The same way you would do with a DataSet and DataView. This means:
BindingListView<Person> personsView = new BindingListView<Person>(persons); personsGrid.DataSource = personsView;
Sorting on a BindingListView is done through the Sort property, the same as on a DataView. For example:
personsView.Sort = "FirstName";
Filtering is done through the Filter property and uses anonymous delegates. So for example to filter all persons that are less than 30, you can write:
personsView.Filter = BindingListView<Person>.CreateItemFilter(new Predicate<Person>( delegate(Person person) { return (person.Age < 30); } ));
You can also merge multiple sources to one view (functionality that the DataView doesn't support) through the AggregatedBindingListView<T>.
One of the ways for extending the WebBrowser 2.0 control is to inherit from WebBrowserSiteBase. According to the documentation, you have to override the method CreateWebBrowserSiteBase and return your specific implementation of WebBrowserSiteBase.
Everything is there to plug-in your implementation of WebBrowserSiteBase, but the problem is that the constructor of WebBrowserSiteBase is marked as internal, and so there is no way to inherit from. I am pretty sure that it was possible with the beta release of .NET 2.0, but for some reason they marked it as internal in the RTM version. This means that implementing some interfaces that are described here are not possible.
I am planning to release a .NET 2005 version of my IStaySharp.WebBrowser project. More info coming soon.
The Service Factory is a cohesive collection of various forms of guidance that have been build with the primary goal of helping you build high quality connected solutions in a more consistent way with less effort.
Check it out: http://practices.gotdotnet.com/projects/svcfactory
Finally I have updated my site, called IStaySharp to MediaWiki. MediaWiki is one of the best wiki based engines available and it's written in PHP and MySQL. Thankfully my hosting, webhost4life, has PHP & MySQL support.
The intention of IStaySharp is to document and archive my code snippets, articles, components, projects, etc. that I am working on, and to share my experiences that I encounter during my .NET development. Visitors to the site can use the discussion page to give feedback, remarks, suggestions, etc. to the associated page.
I didn't encounter much problems when installing MediaWiki on webhost4life, except the e-mailing didn't work directly. The problem was that MediaWiki uses the format: 'myname <myname@domain.com>' in the 'to' field of the mail function, and with the current settings and setup of webhost4life this resulted in an invalid address. Therefore I had to change the method 'toString()' of the 'MailAddress' class inside 'UserMailer.php' to
function toString() { return $this->address; }
instead of
function toString() { if( $this->name != '' ) { return wfQuotedPrintable( $this->name ) . " <" . $this->address . ">"; } else { return $this->address; } }
IStaySharp uses also the extension that I wrote for having syntax highlighting. Some other nice extensions are coming!
I am planning to install MediaWiki for my site www.istaysharp.net. This way I can easily add/update content, because currently the site is static, and that's thre reason why it's not updated frequently.
It was planned for this evening to update www.istaysharp.net, but a new version has been released of MediaWiki, version 1.6.1. I hope the upgrade will go smooth and that my code will still work :)
One other interesting point, is that apparently there is an experimental support for connecting to an Oracle database (read release notes). Are there any plans for supporting MS SQL Server 2000? If so, please let me know!!!
When reviewing code, you see a lot of 'bad' use of exception handling. As Pieter Gheysens mentioned, you see a lot of code that looks like:
try { // code statements } catch(Exception exc) { throw exc; }
No extra logic defined inside the catch-block, like logging, and when it is meant to re-throw an exception, the 'throw' statement must be used, instead of 'throw ex'. The statement 'throw ex' will erase the original stacktrace. Best practice for exception handling is
try { // code that could throw an exception } catch(Exception exc) { // log exception throw; }
In case of a traditional layered architecture, UI, Business Logic (BL) & Data Access Logic (DAL), you will catch a DAL exception inside the BL layer, and translate it to a 'meaningfull' business exception. Each layer has a specific purpose and domain, and so are the exceptions!
It's also a good idea to subscribe to the Application.ThreadException (in case of a form application) and do the logging in there. Here log4net is used as logging tool.
ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { log.Error("Application error", e.Exception); // show custom error dialog or throw }
Recently I have a new LCD monitor, the Samsung 204B. It's a 20.1 inch LCD monitor, with a resolution of 1600 x 1200 and a response time of 5 ms.
I am freak when it comes to monitors. I like to have a high resolution and the quality of the screen must be perfect. My current monitor is a Sony F520 (CRT), which is very expensive, but it has a resolution of 2048 x 1536@86Hz and a pitch of 0.22mm. Therefore I was afraid about the quality of the Samsung 204B compared with my CRT monitor.
In one word, the quality is superb of the Samsung. The colors are vivid and the text is very clear (no ghosting or blur). No dead pixels found, has an ergonomic 4-way adjustable stand and I like the design very much. One more detail, it's about 50 pounds (23 kg) lighter than my current CRT monitor :)

Modern GPUs are increasing in programmability and these chips can do more than just graphical computations. They can now be used as a coprocessor, and they can be integrated for a set of tasks. GPGPU (General-Purpose compuation on GPUs) is such an initiative that contains a catalog where the GPU can be used for general-purpose computation.
The big challenge, is to translate the everyday applications to two-dimensional graphic functions, like texture mapping. In other words: Pretend that everything is a game (source).
As an example in this article and results, a quicksort algorithm of 18 million records in Visual C++ took 21 seconds, while the GPU took 2 seconds! What are the results for a Quad SLI setup? 
Microsoft research is apparently working on a system that simplifies the programming of GPU to general-purpose tasks, it's called Accelerator (simplified programming of graphics processing units for general-purpose uses via data-parallelism).
Wikipedia is the biggest and most famous online encyclopedia available. They have now more than 1 million articles, and it's still growing! This page gives you an idea about the architecture and the specification of the servers. The master database, called Samuel, contains all articles and has about a capacity of 400GB. Here you can monitor the wiki servers.
Continuous integration is the process that continuously build, analyze and test your sources. In many cases the process is triggered when changes are notified in the version control system, like VSS, CVS, etc. Martin Fowler has a good article about continuous integration.
In the .NET world, the most famous tool is CruiseControl.NET in combination with NAnt & NUnit. Getting an e-mail or popup from CruiseControl.NET is nice when a build is broken, but notifying the build status through traffic lights is much cooler.
Michael Swanson integrated CC.NET with the Ambient Orb. I think that the Ambient Orb is not an option for Europe, but you can integrate by using the X10 home automation technology. A good article about integrating X10 with .NET can be found on Coding4Fun and is called Controlling Lights with .NET.
Here are some (other) implementations:
I am going for a walk this evening, and I think that tomorrow a traffic light will be missing

CAB is an application block for building smart clients in .NET 2.0 and contains proven practices for building complex UI forms with so called SmartParts and Workspaces. The DeckWorkspace enables you to show and hide controls and SmartParts in an overlapped manner with no visible frame.
If you switch between controls, you will notice that the controls are painted while there are initializing. During the loading you will see that there is some overlapping and it doesn't give you a professional user experience.

Therefore I extended the DeckWorkspace, so that the the controls are only redrawed when they are initialized. This can be done through the WM_SETREDRAW message. Note that this technique can also be used for other workspaces.
public class DeckWorkspaceEx: DeckWorkspace { int freezePainting = 0; const int WM_SETREDRAW = 0xB;
[DllImport("User32")] static extern bool SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
protected void FreezePaintingOn() { if (IsHandleCreated && this.Visible) { if (0 == freezePainting++) { SendMessage(Handle, WM_SETREDRAW, 0, 0); } } }
protected void FreezePaintingOff() { if (freezePainting != 0) { if (0 == --freezePainting) { SendMessage(Handle, WM_SETREDRAW, 1, 0); Invalidate(true); } } }
protected override void OnActivate(Control smartPart) { FreezePaintingOn(); try { base.OnActivate(smartPart); } finally { FreezePaintingOff(); } }
protected override void OnClose(Control smartPart) { FreezePaintingOn(); try { base.OnClose(smartPart); } finally { FreezePaintingOff(); } }
protected override void OnHide(Control smartPart) { FreezePaintingOn(); try { base.OnHide(smartPart); } finally { FreezePaintingOff(); } }
protected override void OnShow(Control smartPart, SmartPartInfo smartPartInfo) { FreezePaintingOn(); try { base.OnShow(smartPart, smartPartInfo); } finally { FreezePaintingOff(); } } }
One of the most popular markup languages is HTML. A markup language contains text and meta data about the text, such as layouts, styles, etc. Now Wiki sites are becoming more and more popular, and most of them use a customized markup language for HTML. One of the popular wiki sites is Wikipedia and is based on MediaWiki which uses WikiText as a markup language.
Here you find the syntax of WikiText. For example an asterix (*) is used for generating lists, the equal sign (=) can be used for sections, and there are many other constructions possible. For example templates are also possible, then contructions such as this can be made:
| Template |
|
Result |
{{chess position|=
8 |rd|nd|bd|qd|kd|bd|nd|rd|=
7 | |pd|pd|pd|pd|pd|pd|pd|=
6 |pd| | | | | | | |=
5 | | | | | | | | |=
4 | | | | | | | | |=
3 | | | | | | | | |=
2 |pl|pl|pl|pl|pl|pl|pl|pl|=
1 |rl|nl|bl|ql|kl|bl|nl|rl|=
a b c d e f g h
|30}}
|
|
 |
There is also an extension called Wikitex for WikiText which is based on LaTeX. Where is the time that I wrote my thesis with pdfLaTeX using the MiKTeX distribution and WinEdt as my editor, very powerfull tool! However, with WikiTex you can even describe your music notes:
Template: <music>
\relative c' {
e16-.->a(b gis)a-.->c(d b)c-.->e(f dis)e-.->a(b a)
gis(b e)e,(gis b)b,(e gis)gis,(b e)e,(gis? b e)
}
</music>
Result:
One of the things I really like and I will certainly incorporate with MediaWiki is UMLGraph. With this library you can also describe your uml and a picture is generated for you. Examples can be found here.
| Template |
|
Result |
# UML User Guide: Figure 18-2
.PS
copy "sequence.pic";
boxwid = 1.1;
movewid = 0.5;
# Define the objects
object(C,"c:Client");
pobject(T);
object(P,"p:ODBCProxy");
# Message sequences
step();
active(C);
cmessage(C,T,":Transaction");
oconstraint("{Transient}");
step();
message(C,T,"setActions(a,d,o)");
active(T);
message(T,P,"setValues(d,3.4)");
active(P);
step();
inactive(P);
message(T,P,"setValues(a,\"CO\")");
active(P);
rmessage(T,C,"committed");
inactive(T);
inactive(P);
async(); dmessage(C,T);
step();
inactive(C);
step();
complete(C);
complete(P);
.PE
| |
 |
In my opinion, it becomes more important to have markup languages for the web (generates html, images, javascript, etc.). The big advantage is the flexibility of adding and updating the content very easily, without the need of extra tools and/or uploading images. Certainly when you have a wiki based site, where everybody can change the content.
On every site, whether through MediaWiki, Sharepoint, DotNetNuke or something else, knowledge has to be shared, and each site has its purpose. For example, a developer site has the need for syntax highlighting, uml diagrams, etc, whereas a mathematical site has the need for writing formulas, plots, etc.
I think there is a need for a new library (application block) in the .NET community similar to WikiText. A markup language for the web that can be customized, extended and that can be incorporated in each application. Wouldn't it be great that you could write your blog through WikiText.NET? :) I think this can be a good subject for the contest.
Building an application and/or library usually starts with an OO design. Typically from that design you will define interfaces and implement base classes, which can be used as a starting point for building your application.
Defining the signature of a base class is very important. More specific, the visibility (public, protected & private) and purpose (virtual or not) of the methods are very important. Take for example an order-entry form based application that contains several screens for adding and updating data. Every screen will need to implement a kind of save method for persisting the changes. The very basic structure of your design can be:
public interface IDataView { void Save() }
public class DataViewBase: IDataView { public virtual void Save() { } }
Here the intention is that for example every screen of your application need to inherit from DataViewBase and implement the Save method. The problem with this design, is that the interface is marked as virtual (see Virtuality) and is responsible for two jobs, namely that it is part of an interface and for specifying the implementation.
A better way is to apply the Template Method design pattern, also called the 'Hollywood principle', that is, 'Don't call us, we'll call you'. (This pattern is also used a lot throughout the .NET SDK library.)
public class DataViewBase: IDataView { public void Save() { DoSave(); }
protected virtual void DoSave() { } }
This way you have complete control of the interface and you can easily add some logging before and after the save for example, extra checks, etc. If for example you need to implement whether a form-screen is dirty or not, you can easily plug it in as follow:
public class DataViewBase: IDataView { public void Save() { // do some checks // do some logging
if (IsDirty()) DoSave(); }
protected virtual void DoSave() { }
protected virtual bool IsDirty() { return true; } }
If for example you need to extend the application such that when the screen is dirty you get a dialog box asking if you want to save or not. You can simply change the Save method without affecting the derived classes
public class DataViewBase: IDataView { public void Save() { // do some checks // do some logging
if (IsDirty()) if (MessageBox.Show("Do you want to save?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) DoSave(); }
protected virtual void DoSave() { }
protected virtual bool IsDirty() { return true; } }
Due to the fact that the interface and the custom implementation is separated, we can easily extend and have control of the interface. In the other case we would have a lot of code duplication and in most cases we would violate the Liskov Substitution principle.
Here I describe how you can add syntax highlighting (C#, SQL, Javascript, etc.) in MediaWiki. In MediaWiki you can add syntax highlighting through GeSHiHighlight but I found it interesting for combining the world of PHP and .NET.
Microsoft announces on the msdn site that service pack 1 for Visual Studio 2005 will appear around Q3 of 2006.
Internet Explorer 7 Beta 2 has been released to the public, and can be downloaded here. I installed IE7 on a clean WinXP SP2 without any problems through VPC. My blog site and IStaySharp.NET rendered correctly with IE7.

The coolest feature I found, is the integrated rss reader...

|