|
-
June 29th, 2006, 09:48 AM
#1
Property grid control from C# files
Hi,
We are developing a project whereby we have several ini files which contain the configuration data . The objective at hand is
there many times we have to change these ini files as and when new features are added or defects are added. We have decided
to automate this process by means of a GUI instaed of manually changing the ini files.
As UI is concerned we have taken the Property Grid of .Net.
The first step is to convert this ini file to a C# file.The property grid takes this C# file and exposes its properties by
rendering it on the grid.
Two things here; I need to convert the ini file to C# file and secondly I need to pass the data of the ini file to the grid.
The notion here is to dynamically create data object of C# file and pass it to the grid.
My question are
1) Is there any way better than this or this approach could lead to errors?
2)There are several tools to automate the process of conversion of xml file to C# file assuming that the ini file has been
converted to xml file.Any expert comments on the best ones.
3)Which is a good tool to generate xml file conforming to a schema from an ini file. Or in another words is there as tool by
which I can get the XML from any given ini file?
4)There are many subsections within a section in the ini file or to say a collection of objects. How do I handle the same?
5)Will the property grid just need to include the C# file generated to dynamically populate itself?
6) The tool needs to update the values back to the ini file in case the user changes it from the UI. Will serialization be
used for this?
Thanks
-
July 1st, 2006, 02:47 PM
#2
Re: Property grid control from C# files
I would solve this like this:
1. Implement a class that can read an ini file, let's call it IniFile. It should also be able to save an IniFile. I will not get into details on how to implement this.
2. Implement a class inheriting from System.ComponentModel.TypeConverter, call it IniFileTypeConverter. Override methods GetPropertiesSupported() (return true), and GetProperties() (return a collection of SimplePropertyDescriptors, see below)
3. Implement a class inheriting from SimplePropertyDescriptor, which will be responsible for describing category, name, description, value etc. for each "property" in the ini file, it could be called IniFileTypeConverter.IniPropertyDescriptor
4. Define an attribute for the IniFile class specifying that the type converter used for it should be your type converter, e.g. [TypeConverter(typeof(IniFileTypeConverter))]
For the property grid, just set selected object to the class defined in 1. This should be it.
I hope this is what you asked for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|