Hi,

Its an c# winform application.

I have different parameters such as UI colors, Fonts, control size which user changes from UI and saves it.
Each parameter implementation is kind of big so we have a saparate assemblies also.

All the parameters will be displayed in one UI and if user changes any of the parameter (parameter eg:
say clicks a button to change the color of the text) I have to change a text "Current" available in the corner of the UI to "Parameterz Edited" indicating that some of the parameter have been edited by the user.

For each parameter I have a saparate implementation class or for few I have a saparater assemblies.

Now am not sure how do I design this requirement i.e on change of any of the parameter by the user, how do I change the text i.e to "Parameter Edited"

In future some more parameter can be added also. So I am looking for a flexible design which should accomodate any number of parameters that can
be added in future.

Can someone guide me how should I go ahead with the design. A class diagrame wud help a lot or any idea.

Thanks a lot.

Regards,
Sumitra

Recommended Answers

All 6 Replies

instead of passing them as different parameter pass it as a single one.

i.e, if text1 contains color and text2 contains font size, then

code:

string param= text1+"%"+text2;

while passing it it will be resembling like

param = "#ffffff,12"

(here [%] is considered as a string, called as string seperator)

on the destination form (where it has to executed) follow the procedures mention below.

1) count how many % are there in the passed param?

2) open a loop till count value

3) code like..strings till 1st count it is color and strings till second count it is font like that...

Hope this helps.

Have a happy code.

It might be better to use XML...

<StyleSettings>
    <control name="text1">
        <font size="12">Consolas</font>
        <forecolour>Red</forecolour>
        <backcolour>Yellow</backcolour>
    </control>
    <control name="text2">
        <font size="11">Arial</font>
    </control>
</StyleSettings>

This is also much more readable :)

You could also make sub-children:

<control name="text1">
    <font>
        <size>12</size>
        <name>Consolas</name>
    </font>
</control>

But this depends on your personal style. I prefer a mix of nodes and attributes. Some people prefer node heavy, some people prefer attribute heavy.

I am having a doubt Ketsuekiame,but I have a question "WHETHER XML IS FLEXIBLE???" Because sumitrapaul123 needs a flexible code...

XML is extremely flexible. In fact the abbreviation stands for eXtensible Markup Language.

I would argue that your method is inflexible as you have to have predefined knowledge of the ordering of the variables and their parameters.

I didnt mean that bro. I asked you to learning purpose only.The asker is asking that the parameters can increased or decreased. So based on the asker's question, Is there any method to do it in a xml. Please tell me bro Ketsuekiame.

Yes, XML is exactly what you define it as. Until you start restricting it (using schema XSD files), it can contain any data that you wish.

<People>
    <Person>
        <Name>Ketsuekiame</Name>
        <Age>Over 9000</Age>
        <Height>220</Height>
    <Person>
    <Cat>
        <Name>Tibbles</Name>
        <Age>2</Age>
    </Cat>
    <qwertyuiop>
        <lol>Text :D</lol>
    </qwertyuiop>
</People>

My example is incredibly bad design, you wouldn't do anything remotely like that in the real world, however, that XML is valid. So that can give you an idea about how flexible XML can be :)

Apologies for misunderstanding you, I thought you were saying that XML isn't flexible. Language barrier I think.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.