Friday, September 18, 2009

Next try to start blogging

Well, years are flown and I decided to start English blog again. So please welcome my new blog - Most of my articles are about .NET, DDD (Domain Driven Development), about integration with technology stacks ranging from java to ruby. I hope to write interesting things about my experience in the enterprise development. About Security, about Patterns, about Practices. About Entity Framework, Linq 2 SQL and NHibernate. About MVC Framework and Windsor Castle. About WCF, ADO.NET and RIA Data Services.

Thursday, November 30, 2006

Ukrainian Developer Community

The purpose of this Community is provide a place to meet for Ukrainian Windows developers, get help and help others, share knowledge and ideas. Our experts will answer all your quesitons on today and tomorrow Microsoft technilogies.

Thursday, May 25, 2006

Asp.Net 2.0 Flash Control

One of my sites needed Flash. Okay, I was tried to use standard markup. However I need XHTML compliant pages and that markup not for me. XHTML does not allow "embed" tag! To avoid next problems with other sites I was develop control that just renders proper XHTML markup.

Next was well-known issue with loading of the ActiveX controls by IE. My control addresses this issue too. However this is experimental so it is turned off by default.

Of course, as always full design time support.

Download and try Asp.Net 2.0 Flash Control.

Possible that somebody will like control however he will need standard (capable) rendering. Just let me to know. I will add this.

Tuesday, May 16, 2006

PowerShell Tasks for MsBuild

Build eneginering MSBuild have many benefits. One of them is great extesibilty with custom tasks. In other case Windows PowerShell is very powerfull tool to do automated work. I was develop library that brings power of the Windows PowerShell to the MSBuild. Please review this at the Home page of the PowerShell Tasks for MsBuild.

Extending SiteMap Xml file

Sometimes you need to store information on per page basis. For example you need keywords or publish date. I think good choice for this can became Web.SiteMap.

To implement this just add namespace to the root of the XML file. Something like: <sitemap xmlns="" xmlns:exs="SiteMap-Extend" > Now you can easely add your attributes without any validation warnings. For example:
<sitemapnode url="~/Default.aspx" title="Home" description="" exs:keywords="test, something, oops" > From this time this attributes accesible from the code like: SiteMap.CurrentNode["exs:keywords"]


Tuesday, May 02, 2006

.Net 2.0 Updatable Xml DataSource Control

Month ago I was publish post about XML back-end for the site. I was about problem of this back-end it is read-only. Now I post .Net 2.0 Updatable Xml DataSource Control - this seems to be solution for this problem. This is editable replacment for the XmlDataSource. In real live this is not full replacement because it support only tabular data, but in most cases this is true.

Thursday, April 27, 2006

Integration of the blog with my site.

Heh, easy ;) and clean results. Now if you will not look at the address bar you will not even see differences.

Monday, April 10, 2006

Asp.Net 2.0 refresh-less wizard

In Asp.Net 2.0 Microsoft was release Wizard Web Server Control, also you can find Wizard Web Server Control Overview. However if you will try this you will see that for every page it need postback. Even for quick connections this will cause flickering and so on. Good news that we have clear solution for this...

We will use another Microsoft’s product called Atlas, this is cool AJAX framework. We will use UpdatePanel. You may simply wrap wizard control with update panel. This is mostly all ;)).

To avoid misunderstandings you may be familiar with all this stuff. For example if you will click finish button and change something on the page, this will not show on client. I mean that update panel can only change something that is inner it. However in most cases this is not a problem. For example when clicking on the Finish button in my application code will save something in database and then redirect to another page.

Sunday, April 09, 2006

Great news for applications that can use Source Safe, now thay can do this with Visual Studio 2005 Team Foundation Server.

Microsoft was published Visual Studio 2005 Team Foundation Server MSSCCI Provider, tool that give ability to connect your Dreamweaver or another application that support SourceSafe aka MSSCCI to the Visual Studio 2005 Team Foundation Server. Now I am downloading Trial Team Foundation Server Software so in few days I will write results of my experiments.

Wednesday, April 05, 2006

DSL tools. New paradigm of the programming?

Firstly short intro. DSL tools provide functionality to build languages that can completely replace UML languages. But DSL can do many more. One of the keyed features is Code Generation. Theoretically this is great idea.

For example in the DSL tools you can find sample of the Wizard DSL Language. With this language you can draw diagram of the wizard pages and then generate many code. Okay templating and code generation is great. But what we have. With standard development process we use base class that has most functionality and then we derive custom classes and add functionality we need. Possible that someone will think that this is easier to add code from the base class to the template and then generate all. Hope you are not from this "someone". This is wrong way. And you may understand that in most cases you will not be able to regenerate all code. So if in your code will be issue you will not be able to fix this in one place.

Other thing that I think that this is great way to automate database developing. Somebody may create language for the database. Possible that Microsoft will do this or someone else. However I will try this in nearest future.

Microsoft Office 2007 Look

Some minutes ago I was finish installation of the Microsoft Office 2007 ("Office 2007"). This is great. Of course I am not thinking that this is revolution version, it have too many things from old versions. However Ribbon Toolbars and how they use title space - this is great-great ideas.

Okay, all is great. However as always something wrong. Now this wrong is that Office 2007 has too many interfaces. Word, Excel, PowerPoint have new Ribbon toolbars, Outlook have new colored but still old toolbars, and other application have old toolbars at all. Of course possible that this is only because it is beta. Hope Microsoft will have new interface in all their applications.

P.S. Tomorrow I will try to install proofing tools from Office 2003 and post result here.

Saturday, April 01, 2006

Asp.Net 2.0 XML back-end

In most cases developers use databases for the site back-end. However for small sites or sites where most content is not needed database you can use XML.

In Asp.Net 2.0 you can use XmlDataSource with many databound controls like FormView or . This provides easy way to show various data.

For example I can describe one of the strategies what I use. This is the Sources folder of my site. On the start page it have list of all sources. They have title, description, screen url, details url and download url. For details page I need the same list of the data plus long description (article). This means that many of the identical data stored in the different places of the site. Of course I want to have one place for this information. How I was resolving this? I was added sources.xml file in the App_Data directory that has all this data. Now for the start page I use DataList binded to the XmlDataSource that retrieve information from the sources.xml. For details page I use FormView with XmlDataSource that retrieve information from the same xml file, however I use XPath that filters this file to show only appropriate information. Clear?

I think this technology is useful for many places. However it has big issue... XmlDataSource is read-only.

P.S. Possible that in few days I will post UpdatableXmlDataSource. But of course I can not promise something.

Asp.Net Meta Control - Easy way to control your meta data.

Something like in response to the previous post I was develop Asp.Net Meta Control. This control provides easy, high-level access to the edit HTML Meta Tag information. It has full design time support in face of the editors for different meta tag types.

Be sure it has full support of the databinding :).

Meta tags in the

Meta tags in the is rendered by HtmlMeta control. Just in the OnPageLoad add this control to the Header.Controls collection.

IE7 and standards

As you know Internet Explorer 7("IE7") is new version of the Microsoft's browser. One of the keyed features of it is support of the standards. Okay this is great, however it still does not have even full CSS2 support (I am not say about CSS3 at all). What this mean for developers? Yes you are right. This means that in the list of the browsers like Gecko, Opera and IE we need to add... IE7! Now IE7 does not properly renders sites that was designed for IE6 and it still does not properly renders standard compliance sites. Great!

But let take view in the nearest future. What Microsoft can add in the IE8? Of course more security, but we do not talk about security; they adding it in the every version. Other features are already here (I mean tabs, png, rss). I think they will add more standard compliance. And what we will have? Yes! We will have to add additional browser in our developer list.

Hope at least IE8 will have standard compliance rendering.

Monday, February 20, 2006

.Net 2.0 ToolStrip Rebar Renderer

Sometimes “Internet Explorer Rebar”’s look is more professional instead of “Microsoft Office Toolbar”’s one. For this reason I was develop RebarRenderer - .Net Rebar style ToolStrip Rendrer.

Some features:

  • Renders ToolsStrip and MenuStrip with Microsoft Internet Explorer Rebar style.
  • Full support of themes (including third-party themes and software like StyleXP).
  • Clear rendering with disabled themes.
  • Support of both Rtl and Ltr directions.
  • Sources included.

For more detailed description and sources on .Net 2.0 ToolStrip Rebar Renderer Home Page.

Friday, July 29, 2005

Long and short file name conversion in c#

Hello. Here is very simple code for short to long and long to short file names conversion.

Short to long:

using System;
using System.Runtime.InteropServices;
using System.Text;

public class _Main
    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    public static extern int GetLongPathName(
        string path,
        StringBuilder longPath,
        int longPathLength
    public static void Main()
        StringBuilder longPath = new StringBuilder(255);
        GetLongPathName(@"D:\MYTEMP~1\RESOUR~1\sql.txt", longPath, longPath.Capacity);

Long to short:

using System;
using System.Runtime.InteropServices;
using System.Text;

public class _Main
    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    public static extern int GetShortPathName(
        string path,
        StringBuilder shortPath,
        int shortPathLength
    public static void Main()
        StringBuilder shortPath = new StringBuilder(255);
            GetShortPathName(@"D:\My Temp\ResourseProvider\sql.txt", shortPath, shortPath.Capacity);

Please note that file must exists on the disk. This occur because file system need to know if other files. Two long names produce same names in short form and if so file system will add unique indexes to them.

Sunday, March 27, 2005

Hierarchical TreeView control with data binding enabled

Some time ago my task was to write something like virtual file system. Of course I decide to use typed DataSets because I am already wrote framework to work and update them easily. With this technology there are very easy to display content of the folder. Relation DataTables are very great tool for this. That’s all right but when I have seen the result - I had died! This is not look and feel that I mentioned for my client! So I am open google and start searching for TreeView with data binding enabled. Of course I found something: this (Data Binding TreeView in C#) is pretty but this is not hierarchy in my understanding; this (How to fill hierarchical data into a TreeView using base classes and data providers) is pretty too but I am not understood why author do not like standard binding. Both are not for me! And as real Ukrainian man I decide try to write my own!

See article on "Code Project".

Tuesday, March 15, 2005

Custom drawing cursors


Some time ago I have decided to try to make something like a "Photoshop" in C#. The first problem has appeared was custom cursors. If you are familiar with "Photoshop" you know that when you change brush size the cursor size also changes. This is solution to make this possible in C# . Note: hare will described only black and white cursors. It is possible that I will upgrade this article or create new for 32-bit cursors.

Standard realization of class Cursor practically completely repeats Win API for the cursor except for method CreateCursor . This method is necessary for drawing custom cursor. So we import it from library user32.dll.

private static extern IntPtr CreateCursor(
    IntPtr hInst,
    int xHotSpot,
    int yHotSpot,
    int nWidth,
    int nHeight,
    byte[] pvANDPlane,
    byte[] pvXORPlane

The method needs handle to the current window, coordinates of the cursor's hot spot, the size and mask of the image.

The sizes of the cursor :

Win API contains method GetSystemMetrics which returns the possible size of cursor, but it always return 32/32 for standard video devices or 64/64 for hi-resolution devices. In the experimental way I have find out that the sizes of the cursor should be multiple 16 px. So we will not use GetSystemMetrics . Attempt of use of the non-standard size leads to wrong display of the image. As greater accuracy is necessary for us than 16 px we shall take the size of the cursor with a stock. All that remains will be in visible so this is for us!

Masks of the cursor:

The image of the cursor is set by means of two masks (AND and XOR masks). Masks consist from array of byte where every b i t designates one pixel. Here results of a combination of two pixels:

AND mask XOR mask Result
0 0 Black
0 1 White
1 0 Screen
1 1 Reverse screen

Result code:

Using CreateCursor function this is simple to create new cursor from masks:

byte[] andMaskCursor = new byte[]
    0xFF, 0xFC, 0x3F, 0xFF,   // line 1 
    0xFF, 0xC0, 0x1F, 0xFF,   // line 2 
    0xFF, 0x00, 0x3F, 0xFF,   // line 3             
    0xFF, 0xC3, 0xFF, 0xFF,   // line 31 
    0xFF, 0xFF, 0xFF, 0xFF    // line 32 

byte[] xorMaskCursor = new byte[]
    0x00, 0x00, 0x00, 0x00,   // line 1 
    0x00, 0x03, 0xC0, 0x00,   // line 2 
    0x00, 0x3F, 0x00, 0x00,   // line 3             
    0x00, 0x00, 0x00, 0x00,   // line 31 
    0x00, 0x00, 0x00, 0x00    // line 32 

IntPtr cursorHandle = CreateCursor(
    handle,             // app. instance 
    radius,             // hot spot horiz pos
    radius,             // hot spot vert pos 
    sideLength,         // cursor width 
    sideLength,         // cursor height 
    andMaskCursor,      // AND mask 
    xorMaskCursor       // XOR mask 

Cursor.Current = new Cursor(cursorHandle);

Huuh.. now we can create cursors programmatically . Masks now are hard coded that is not applicable for us! Lets create mask with circle cursor:

int sideLength = radius*2;          
if (sideLength%16 != 15)
    sideLength = sideLength + 16-sideLength%16;
int length = sideLength*sideLength/8;
byte[] andMaskCursor = new byte[length];
byte[] xorMaskCursor = new byte[length];
for (int i = 0; i < sideLength; i++ )
    for (int j = 0; j < sideLength; j++ )
        double x = i - radius;
        double y = j - radius;
        double pRadius = Math.Pow(
            Math.Pow(x, 2) + Math.Pow(y, 2), 0.5
        if ((int)pRadius != radius)
            int ii = (i*sideLength)+j;
            andMaskCursor[ii/8] =
                (byte)Math.Pow(2, 7-ii%8);

That's all! Enjoy.

Tuesday, March 08, 2005

Beep, MessageBeep

Here is three very simple methods to Beep.

  • Most simple way.
  • Second one is WinAPI MessageBeep function using PInvoke.
    using System;
    using System.Runtime.InteropServices;
    public class _Main
        #region Win32
        static extern void MessageBeep(uint uType); 
        const uint MB_OK                = 0x00000000;
        const uint MB_ICONHAND          = 0x00000010;
        const uint MB_ICONQUESTION      = 0x00000020;
        const uint MB_ICONEXCLAMATION   = 0x00000030;
        const uint MB_ICONASTERISK      = 0x00000040;
        public static void Main()
  • Third is PInvoke too. This is WinAPI Beep function.
    using System;
    using System.Runtime.InteropServices;
    public class _Main
        #region Win32
    static extern bool Beep( uint dwFreq, uint dwDuration ); #endregion public static void Main() { Beep(150, 150); } }


MessageBeep function

The MessageBeep function plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.


uType:Sound type, as identified by an entry in the registry.

Beep function

The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes.


dwFreq:Frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). dwDuration:Duration of the sound, in milliseconds.

Return Values:

If the function succeeds, the return value is true. If the function fails, the return value is false.