This Blog Has Been Moved !

This Blog Has been moved to http://aleemkhan.wordpress.com

And here we are on the last day of 2005. It was a good year, I do have some targets set for 2006, but I am not going to make them public J

The atmosphere here in Dubai is a little windy today, a light cool breeze.

A couple of days ago I found Haroon Shafiq’s Blog (added that to my recommended Blogs Section), it was good to find him, he is really a gr8 guy and has a wonderful Blot too, his Blog took me to Worst Tech Moments in 2005. Interesting happenings, especially I found a few of them quite interesting, like

  1. US Commerce Department blocks .xxx domain
  2. A narrow escape from the repetition of Columbia Disaster [NASA Story]
  3. Yahoo Helps China Imprison a Dissident

Though I myself support the decision of US Commerce department regarding the blocking of .xxx domains, but still it is depressing to know that Internet content and Domain system is under the influence (*control*) of a government and specially with Mr. Bush leading that government, highly degrades my confidence while using the internet L. However, the most depressing is what Yahoo! Did, I never knew my mails were not safe, I think the private policy does not say anything like this, our content, communication and mail nothing has any privacy. I can only say this

“We are not culturally and morally developed to use the technologies and inventions that we have created.”

Wow !


One of my colleagues gave me this link to a wonderful article by Grady Booch.
http://www-128.ibm.com/developerworks/rational/library/2082.html



Great article and true analysis of the software design/development, and its limitations and problems.



Also, while reading Occam's Razor in the article, I researched on it a bit on Wikipedia and found what it really meant "Entities should not be multiplied unnecessarily", I remeber Occam's Razor from the Judy Foster's Film Contact, but did'nt know the exact meaning.



Also, liked the Newton's and Eienstien's illustrations of the same phrase



"We are to admit no more causes of natural things than such are both true and sufficient to explain their appearances." -- Issac Newton



"Everything should be made as simple as possible, but not simpler" -- Albert Eienstien.



Anyway, a good and useful reading.

I just thought the following conversation could be useful to others as well.
 
The .NET PropertyGrid Control is a wonderful control which enables you to load any object (or set of objects) in it and displays/exposes all the public properties of the object through reflection. The Framework class library provides various Attributes and Classes to cutomize the way your proerties look. Generally, when you need to customize the way your properties look in the property Grid, either you use the TypeConverters or you create a new Cusotm Editor for your properties. Let me explain this further,
 
No.1 - Custom Editors for Properties
You must have used a Collection Editor, if your class contains a collection property then visual studio shows a button in-front of the colle ction property and clicking that opens a new dialog in which you can add/edit collection items.
 
No.2 - Using TypeConverters for Properties
You must have seenn a Font Property in various controls, this property as you see is expandable and then with all the combination of the selected values you can actually show the Font Property, also you must have seen the Icon Property which shows an Icon Image in-front of the property or there are certain properties which show a drop-down in-front of property, these properties use the TypeConverters. There are various type converters available in System.ComponentModel namespace.
 
I have written some code using the type converters which nearly solves your problem, but the problem with the type converters is that they always update the property after the value has been entered, I mean you won't be able to update it character by character as you want in your case. You will only be able to convert your property value into '**********' after teh full property has been entered. Consider you have the following class which contains public properties which are to be shown in the property Grid.
 
public class NewClass
{
  private string _text;
  //Add this Attribute to Specify the TypeConverter
  [TypeConverter(typeof(CustomPassConverter))]
  public string Text
  {
    get
    {
      return _text;
    }
    set
    {
      _text = value;
    }
  }
}
 
Look above and see the Attribute that I am using on the Property, this attribute specifies that the CusotmPassConeverter, is the converter to be used for this property. Let me implement the CusotmPassConverter now.
 
public class CustomPassConverter : System.ComponentModel.StringConverter
{
  public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  {
    string passValue = (string) value;
    string pass = new string('*',passValue.Length);
    return pass;
  }
}
 
Now when you will load this class in the PropertyGrid, and edit the value of the property, after editing the value your value will be changed in '***********'.
I have also tried using the UITypeEditor, which is one of the editors which allows you to draw in the Property and has a PaintValue method, but it has the same problem that it modifies the property after it has been edited.
 
IF AN EXACT SOLUTION IS POSSIBLE
 
I beleive that I can always go the old Win32 way. I can write a CustomPropertyGrid Control by inheriting from the original PropertyGrid control overrideing its WndProc, searching for messages and then can do anything. BUT this solution will not work in case for Visual Studio as it is not using my Custom Control.
 
Yes the correct solution is possible in one way, you can write a custom editor dialog like the Collection Editor Dialog we talked ablut above, let the user enter the Password in that custom dialog (Collection Editor also allows that). Actually when you write a separate dialog as an editor you have complete control over it. So its better to Implement a Custom Dialog. I'll try to write this if I get some extra time.
 
 
 
Regards,
Abdul Aleem
Senior Software Engineer
KalSoft (Pvt) Limited
Dubai, UAE
Cell: +971-502196733
 
______________________________________________________________

fakhar siddiqui <fakhar_83@yahoo.com> wrote:
Hello,
 
Its me Fakhar. I am facing some problem  in C#  when using “Property Grid”. If u people used Property Grid then u obviously know the properties which we define in our class are mapped to Property Grid after storing the object of that class in “PropertyGrid” .
The Problem is that I have property in my Class named “Password”. I want when user will edit that field in property grid it should display “*” instead of  the character which is typed. I think attributes in namespace [using System.ComponentModel] may help. But I could not find any solution.
 
If you can help me in this regard, I will appreciate it.
 
Thanks You Very Much.
Best Regards,
Fakhar


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping

As usual posting after a long time, the last few weeks have been quite busy and also so many things were changing that I could not get time to post.


I left Systems Private Limited, a gr8 place where I spent the last one year and it was great learning, they tried all they could to stop me, but I made the decesion to move on. It was an extremely tough decision and I have been under a lot of proessure. Anyway I was offered a job by KALSoft in Pakistan which included working for Vertscape in Dubai and I accpeted the offer. Its been a week now since I have joined the new company. Actually my office is at the client location at Dubai Airport Free Zone, West Wing Building 3.


Its a little challenging here with people from all cultures and its an experience getting adjusted. Also, the market is very competitive. The work is nearly the same, ASP.NET project with SQL Server and no documentation :).


Our Apartment is at a gr8 place, thats is the chorniche area at the start of Sharjah, and its a good place for walking and hanging out. I am spending most of the evenings just hanging here and there because I dont have a PC yet. I am thinking of getting a Notebook, there is a lot of brands to select from here and it is not very expensive also.

Anyway still getting accustomed to the project, thats the important thing.