Category Archives: Windows

using UITypeEditor on Winform with a Generic Type Editor

If you are a developer, than I guess Property Grid isn’t a stranger to you. Property grid  has been used in win form designer to manipulate the properties of the selected object in the designer. Property Grid can also be used as control to use on your own form , to give user a compact way to manipulate properties( It is not available in the tool box , you will need to add it by using choose item option in Visual Studio). Property Grid has an interesting feature , it can show Type specific editor if one is available . e.g editing a color value will result in opening a color box, similarly for font and other types. If you want to have an editor for your custom data type , then you can implement a UITypeEditor and bind it to the target type using attirbute.

Some times you don’t use the whole Property Grid , but only want to display a certain type editor on your form, e.g you want to give user , option to edit a font , and want to utilize the font editor . How this can be achieved? Well, its simple , all you need to do is implement the IWindowFormsEditorService interface and provide a form or control to host the uitype editor. 😀

I came across a very insightful article on DevX about implementing these requirements. Emmanuel Tissandier has not only explained the underlying architecture of UITypeEditor  but also impelement a control which can be used to host any UITypeEditor, and so you can have a generice type editor.

Article can be accessed here:  Build A Property Editor That Can Edit Any .Net Type

regards

Advertisements

Regular Expression : Escaping Meta Characters within character classes

Many of us have written applications where we have used regular expression for different tasks, like validation , parsing and other related task. Regular Experssion is quite a powerful tool, and has been available in most of the programming languages that are used today (either natively supported or by using libraries).

Usually in a regular expression ‘\’ is used as a the escape sequence (it may be different for different languages , I am using C# convention), to escape meta characters. Regular Expression also support a construct called ‘character classes’ ,which can be roughly taken as a set of characters. There are some pre-defined character classes like \d \w \s etc. and if you need a more customized version you can define your own using Square brackets notation ‘[]’.

The world inside the square brackets is much different than the one outside.  Inside the brackets , there are only two meta characters, ‘^’ and ‘-‘; even an opening bracket ‘[‘, asterisk ‘*’ , plus sign ‘+’ are not considered as meta inside []. Furthermore , [] has no escape sequence within them. Now what you will do if you want to have ‘^’ , ‘-‘  and ‘]’ inside a character class.

Well these characters are escaped using particular placement within brackets.

One key syntactic difference is that the backslash is NOT a metacharacter in a POSIX bracket expression. So in POSIX, the regular expression [\d] matches a \ or a d. To match a ], put it as the first character after the opening [ or the negating ^. To match a -, put it right before the closing ]. To match a ^, put it before the final literal – or the closing ]. Put together, []\d^-] matches ], \, d, ^ or -.

source :http://www.regular-expressions.info/posixbrackets.html

Problem Solved . 😀

By the way , this web site gives a good introduction about Regular Expressions.

regards

Faraz

Some Articles

well.. 🙂

I am back after a loooonnnng vacation. :D. I have been really busy during that period (if activity of wasting time is cosidered as a task 😛

Just to start with something, here are some of articles that I have read during my so called vacations.

  • Natural Number Comparer:

Have you ever noticed , how Windows XP Explorer sorts files in a directory by file name.  It does an intelligent sorting by considering the file names and also take into account if there is digit in the file name. e.g file1.txt , file2.txt and file10.txt . Ordinary string sorting places  these 2 strings as file1.txt ,file10.txt, file2.txt, which isn’t the right order. XP sees these strings differently and sort them in almost correct orderi.i.e file1.txt, file2.txt and file10.txt.

This type of sorting might be required in other applications as well. Pascal Ganaye has written an execellent article on Natural Number Comprarer .

  • Colors:

Nice article on Manipulating Colors in .Net by Guillaume Leparmentier in which he discussed the different color models and their inter-conversion. Very informtive!!!

  • Cab File Manipulation:

Often you need good compression and archiving APIs, so why not use the Microsoft’s own cab file implementation. Thats exactly what Elmue has done and explained in his article Cabinet File : Compression and Extraction.

Demonoid is back once again

Well after a long time, once again, Demonoid is back,  the user accounts are still there, and our upload /download statistics are still intact. enjoy !!

ونڈوز پر اردو کے استعمال کے لیے چند مشورے اور جُگاڑیں

Computer usage in one’s own native language is getting popular these days, and many Softwares now include several languages to overcome the language barrier of the users. It has its own joy of interacting with computers in mother tongue.

Urdu is also one of the languages which is gaining popularity in computer usage. Efforts have been conducted by Pakistani Universities and other professionals to enhance the presence of urdu in general computing activities. These efforts are often supported by Govt. of Pakistan. NUCES Lahore Campus has contributed significantly to the cause with their CRULP ( Center for Research in Urdu Language Processing) initiative.

Following is a list of few good utilities for using urdu on PC from CRULP.

Just to let you know about the complexity of fonts for languages in arabic script is that the actual appearance of character /alphabet is dependent on the context. e.g م is meem, in محمود there are 2 positions for meem, initial and middle,and in علم meem is in final position:)
Now urdu uses alphabets from arabic language, but it follows persian script “Nastaleeq”, which may be a bit difficult for computers, as each new character is connected at a lower level and the whole word follows a slanting path.

So use these utilities, and send your suggestion to the developers, so that they may come up with a better and enhanced version.

regards

faraz

LPT0006 passed away ! – Obituary

Its really sad for me to break that my laptop ‘lpt0006’ has passed away on wednesday 8th January, 2008 at around 2:45 pm (local time). 😦 The exact cause of death is still unknown, but initial reports claim that it was due to hard disk controller failure. However I am still waiting for an official autopsy and hopes that it may be able to rise again :).

‘lpt0006’ was from the family of acer ferrari 4000 series ( ferrari 4005 WLMI). The departed soul had been in service since 26th March 2006 11:am and meticulously executed it duties during that period. During this period which spanned over 654 days, ‘lpt0006’ served 18-20 hours /day, while the disk I/O usage is estimated at 500 mb read writes /day ( this is only for user data and does not include paging and caching i/o). Awesome thorughput , I would say, from this family. But its sudden death was an extremely surprising incident.

Although I didn’t like the machine , but hey it was free and an above average performer, and didn’t cost me any thing 😀 .  I usually spend most of my after office time over my laptop, and suddenly after getting deprived of it, I had no other choice but to stare the roof while lying on my bed :).  ( I have already taken my xbox and complete Harry Potter books set back to Pakistan  while visiting during this winter vacation) . But the worst part isn’t over yet, the next three days were holiday , Thursday was off  due to 1st Muharram,  while Friday and Saturday are our usual off-days of the week.  So I had nothing to do , literally nothing , to do at home, except for sleeping 😀 .

Anyway , I used Dell Inspiron 8600 ,borrowed from Khurram bhai, for sometime, until I got a replacement laptop tablet notebook. Its LT-20 from LG, bundled with Windows XP Tablet PC edition. Its really cool to use it. It has a touchscreen and can be turned into a small notebook or tablet , by rotating and flipping the screen. Though machine is not so strong, apart from being bloated with support softwares( input panel, keyboard surrogate, bla bla) which consumes almost 80% of available physical memory (400 out of 512 megs, consumed after getting logged in to the system). Anyway its lighter to carry ,with 11″ screen. Helpful in taking notes, preparing documents, chatting, light browsing activities, but nothing more then that. :P.

I am planning  to buy a notebook for myself, after going through some reviews, I am finally settled for Dell XPS M1530  , cool han!  I am waiting for DSF promotions which will be starting from 24 th January 2008. Mean while , I will look into products from other vendors, most probably from Alienware ( Personally I don’t like HP pavillon, Lenovo thinkpad).

By the way, did I mention it was an obituary for the deceased one 🙂

regards

faraz

dotCompilerator first release

well I am building my compiler studio from scratch using some other techniques that I didn’t use last time when I developed compiler studio. I don’t have any prescribed scope right now and I am building it bit by bit right now. But still some of the major enhancements that I would like to be included in the new one are following:

regular expression parser able to parse expression directly into DFA(partially done)
combined dfa support
design restructuring
LR parser implementation
Abstract Syntax tree generation
Visualizers (Grammars, FA, other)
enhanced support in RE for other operator (other then *,+,|,?)
support for multiple language description format( BNF ,EBNF, custom)
custom IDE
Integration with other IDE, (eclipse and VS.net)

and this list goes on.

I have just started to work on the list, and it needs a bit of dedicated time, I was able to write a parser regular expression that parses the string into a Abstract Syntax Tree and calculates its firstpos, followpos, lastpos values for the node to construct a dfa. ( this is implemented as described in Compiler: Principles, Techniques and Tools by Aho, Sethi and Ulman). Now I am working on object model for FA/DFA/NFA and then RE conversion into FA.

download code from http://s.faraz.mahmood.googlepages.com/CompilerStudio20071010.zip

regards

faraz