Sep 22, 2010

Add Syntax Highlighting Control

Background

How to choose free, easy to use, extendable and good quality syntax highlighting control for .NET program?

Scintilla

First, what i have try to use, was ScintillaNet, but i have no luck to get it worked in test program. It need to setup before use, require unmanaged companion library, what make difficult to multiplatform use. After all i see my Visual Studio C# 2010 Express very unstable, after adding ScintillaNet control to Toolbox. After many experiments i get it worked, but result seems unstable and unrepeatable. Personally i not recommend to use Scintilla in .NET application, but possible it good choice for C++ project.

ICSharpCode.TextEditor

After searching i found editor control from a well known open source IDE SharpDevelop. Syntax Highlighting Text Editor Control looks very good and light after Scintilla. It requires less time to load and seems much more stable.

Sep 4, 2010

Check And Upgrade Existing Database

How to change database schema, adding or deleting field or table, to be sure of new version of application will work correctly and existing users not lose their data?

You working on application and have customers. One wonderful day customer ask you for new functionality. But you see it need to change database scheme. You made local changes, but many customers have old database. How to upgrade existing database, not harming to customers data. Make migration script and copy data from old database to new one? Not so good way.

What about programmatically change database schema on fly? For example you have table 'customers' and need to add field 'mob_phone'; You can use SQL statement to add field, only need to care if database schema already up to date.

Sep 2, 2010

Enumerate Embedded Resource Names

How to know and enumerate names of all resources, embedded into assembly?

Well, we know how to load embedded font to memory from resources, but... stream, returned from GetManifestResourceStream is always null??

Ok, you have to be sure about resource name. In general resource name consists from {assembly namespace}.{folder}.{file name}. If your resource not in folder at solution space than it simply {assembly namespace}.{file name}. And at last property of file should be "Embedded Resource".

Sep 1, 2010

Embedding Font To Resources

How to load and use custom font, embedded in assembly resources.

We leared how to load font not installed in system. But what about embedding font into assembly resources? We will use PrivateFontCollection as in previous example private font loading. But we'll need little bit more action.

First we add font file into project. Place it in root folder of project. Go to property and choose action Embedded Resource for font file.

Next add code to read font from resource.