I want to start adding video tutorials to my blog in order to make it a bit more interesting and fun.

My first video will be a short movie of how to use Flajaxian file uploader. The topics covered in this video are:

Continued...

Writing unit tests for any application that connects to a database is always challenging, because deviation from the expected alterations of the database may influence the work of the business objects. The same tests have to run over and over again – after each change of the code, in order to ensure that the previous functionality has not been broken by the newly introduced changes. Altering the data so many times may have unpredictable consequences.

One of the most popular solutions of that problem in the Java and .NET worlds is the usage of mocking framework, for example Rhino Mocks. And despite the enormous advantages of this approach it has also some noticeable drawbacks. For example it is not hard to imagine a situation where your tests will pass well with the mocked data but will fail on the real database. And what if you have a lot of business logic in stored procedures that also need to be tested?

Continued...

When you have to save hierarchical data inside a database you can traverse the tree with recursion and for each note call the database to save it. But that is not the most elegant solution; because your tree might be quite big and you can end up with lots of calls to the database. You may also need to wrap this whole thing inside a transaction but as we all know stretching a transaction between several calls is not the best approach.

What we actually want is to transfer the hierarchical tree inside a single stored procedure and process it there. But how can you pass a hierarchical data to a single stored procedure? Well the answer as often is XML. Let’s assume you have this hierarchical XML:

Continued...

Normally when generating Json you would serialize typed .net objects. In most cases this is the right way to go, but if you have important reasons not to use this approach, for example if the format of the coming data cannot be predicted at compile time and you don’t want to generated dynamically typed objects, for performance reasons, you may consider generating Json code as string. A common way to go is to use StringBuilder, but I would not call it as a very json friendly tool, so here is an alternative.

Json builder can help you iterate through collections and hide json related string transformations from you. Here is how you use it:

Continued...

Often in a Silverlight client you will need to delay the execution of a particular action. There is no intrinsic setTimeout function like in JavaScript window object but you can use System.Windows.Threading.DispatcherTimer object. If you are looking for a tidy wrapper around this object you may want to consider this solution:

Continued...

If you want to define the number and the type of Silverlight DataGrid columns at runtime you can use the following approach. The technique can actually be used not only for Silverlight but also anywhere where you have to transform IDictionary (for example Dictionary or Hashtable, SortedDictionary etc) into anonymous typed object with each dictionary key turned into an object property.

Continued...

This is a simple tool for traversing the file system in search for a file or folder or doing something to many files.

The source is available here: http://www.bodurov.com/files/FileSystemIterator.zip

And here is a sample application that searches for the first file with extension .aspx

Continued...

Another Flajaxian.com tool is the adapter that you can use together with Flajaxian FileUploader, the tool is FREE and open. You can use it to enable file upload to a CS3 Amazon Service.

Flajaxian S3 Amazon Service Uploader is adapter for the Flajaxian FileUploader .NET web control designed for asynchronous file upload to an Amazon Service of multiple files at the same time, without a page post back and with a progress bar indicating the current upload progress. This control and adapter do not require full trust environment.

For download and documentation, please go to: http://www.codeplex.com/FlajaxianS3Upload

The web site is: http://www.Flajaxian.com

You can see a Wiki page here: http://flajaxian.com/flajaxian.com/docs/html/HowToUseAmazonUploader.htm

Continued...

I would like to present one project I am starting together with a friend – Flajaxian.com. This is a web site providing FREE, open source tools for AJAX web development.

The first tool you can find there is .NET web control for AJAX style file upload designed for asynchronous file upload of multiple files at the same time, without a page post back and with a progress bar indicating the current upload progress. This control does not require full trust environment. The control can be extended with the addition of server side and client side adapters. Flajaxian FileUploader uses Adobe Flash Player 8 or higher Flash player for the file upload.

For download and documentation, please go to: http://www.codeplex.com/FlajaxianFileUpload

The web site is: http://www.Flajaxian.com

Continued...

Here I would like to present a tool for formatting and coloring raw JSON code. Very often if you use JSON generated by server side code it will be in a nice compact format but at the same time it will be quite hard to read it and possibly alter it. So the tool allows you to make your JSON more readable. For example if you have code like this:

[[{anArray:[2,3,4,["string1","string2",{aa:[]}],{"type":"simpleObject"},null],abotherProperty:"",anObject:{justANumber:2,func:function(){if(1>0)return false; else return true;}}}],true]

it is a real challenge to find something you need inside the graph. In this case the JSON formatter is the right tool for you.

You can see it at: http://bodurov.com/JsonFormatter/

Continued...

IDictionary options - performance test - SortedList vs. SortedDictionary vs. Dictionary vs. Hashtable

Here is a simple performance test to compare four different implementations of the IDictionary interface. I have measured insertion time, search time and memory allocated by each one. The test included the following code:

Continued...

One problem you can encounter while working with Flash CS3 ScrollPane component with WMODE=”Transparent” in Firefox, Safari or Opera is that the pane content will be seen as 85 by 85 pixels square and no scrollbars will be activated. The bug is caused by the fact that for those browsers in transparent mode the draw() method never gets called.

The solution is to force calling it and of course make sure you don’t call it twice. The solution I propose is the following one:

Extend the ScrollPane class as follow:

Continued...

Using CSS (Cascading Style Sheets) in Action Script - Helper class (for TextField, Label Control, or other text control)

This is a helper class for using Cascading Style Sheets for the assignment of different properties with CSS.

import flash.text.*;
import fl.controls.* 

var ss:StyleSheet = new StyleSheet();
s.parseCSS(".lblStyle{ font-size:12;font-family: Arial;color:#000000; } .textFieldStyle{font-size:12;font-family: Arial;color:#FF0000;}")

var lbl:Label = new Label();
CssHelper.setStyle(lbl.textField, ss, ".lblStyle");

var tf:TextField = new TextField();
CssHelper.setStyle(tf, ss, ".textFieldStyle");

This is a sample CSS that you could store in an XML file:

Continued...

This is one useful utility for tracing objects in ActionScript 3 code. The name of the class is just t (from tracer). I find that short name easier to type. If you have the interface mx.collections.IList you can download it from here or if you don't from here

So if you want to trace just a string you can use it as:

t.str("some string");

// the trace: 
// some string

or you can use multiple arguments:

t.str("some string", 15, true);

// the trace: 
// some string | 15 | true

or if you have an object defined for example like this one:

Continued...

The lack of control over the background, border and focus indicator of ActionScript 3 TextArea control is quite annoying and here is the control, extension of the original TextArea that can be a solution of that problem. Create folder fl in your class path (class path can be defined at File - Publish Settings - Flash - Settings) then create folder controls inside of fl folder then create EnhancedTextArea.as file and paste the following class.

Here is how you can use it:

Continued...

This is a very simple but useful application for viewing the sequence of bytes or bits in a binary file. I have modified my old bytes viewer and added the option to view the sequence of bits as well.

You can choose the start and end index of the bytes / bits being viewed.

This is how the application looks:

The application also supports dragging and dropping files into the form.

You can use it together with Fiddler by selecting a session and then choosing for example File - Save - Request - Request Body.... Then open it with the bytes viewer to view the sequence of bits and not only bytes as it is in HexView of Fiddler.

The source:

www.bodurov.com/BytesViewer/BytesViewerSource.zip

And the executable (requires .NET 2.0 installed):

Continued...

Here I would like to describe a solution for the common need to use mouse wheel in DHTML programs. It is based on Sam Stephenson’s Prototype JavaScript framework.

First you have to start listening for the scroll mouse wheel event and unfortunately it is different for the different browsers.

Continued...

This is a simple program for conversion of Windows Media Player WMV files into MP4 Movies playable by I-pod (resolution of 640 by 480 pixels for MPEG-4). It is a Windows wrapper around FFmpeg program. The program is open source, free, given under Gnu Lesser General Public License. It has very simple interface as you can see it here:

Continued...

Here is a simple example of how to create a web proxy for a flash file.

Flash has many restrictions for files loaded from a different domain. When you don't have any control over the flash file located on a remote server, a solution might be the creation of a web proxy like the following one:

Continued...

This is a simple example of a dynamic Silverlight movie – the new Microsoft tool for online vector graphics. The JavaScript code is based on Microsoft AJAX.ASP.NET framework (former Atlas).

 

http://www.bodurov.com/BouncingBall/

 

Continued...

This is an example of a simple client side web grid with an interface similar to excel office application.

The code is based on Microsoft AJAX Extensions Framework 1.0 (ex Atlas).

An example of the object definition:

Continued...

Here you can see the first beta version of the new menu that I called LucidMenu. It is based on Sam Stephenson’s Prototype 1.5.

Demo: http://www.bodurov.com/lucidmenu/

Source: http://www.bodurov.com/lucidmenu/lucidmenu.zip

Some or the features like right to left text or having selected nodes are not yet completed, but other new features are already available.

What you can see here is:

  • Loading the content as JSON from an external file with AJAX
  • Isolated reneding – you can implement your function of what should be rendered. Here it is implemented in LucidMenuGenerator function. You can pass your CustomRenderingFunction function with the Menu constructor like this:
var menu = new LucidMenu("LucidMenu1", CustomRenderingFunction);
menu.load("MenuContent.txt");

Here I would like to share some of the tools I've developed.

www.bodurov.com/soft/TracerLog.zip

This is a class for viewing the stack trace. You can use it as:
TracerLog.ToFile(path);
if you want to have the stcktrace as file, or
TracerLog.ToString(path);
if you want to have it as string.

The class:

 

Continued...