S
Sergei Shelukhin
Hi. I am new to C# and .NET programming iin gneral, but I already have great
plans
I have this question about design approach. I am switching over from (mosly)
BCB, so the freedom and complexity I have in .NET environment are kind of
breathtaking
I will give an example, cause that's hard to explain the concept in general.
Well, at least it is for me
Oh, and remember that's just an example, I know there are standart things o
display images, but it's just an example
Suppose I make and app for image displaying; I creat some class cImage with
standart DrawToForm() method, and inherit cBmpImage, cGifImage and
cJpgImage from it. It would be fine if images were all down to bmp, gif ,
and jpeg - I could just add associations with appropriate file in
if-then-else if-then-else if... blocks at design time, but suppose I want to
add some means for extensions' adding.
Suppose someone has my cImage class source, so he inherits cPcxImage from it
and creates a class that will display pcx images. What we need now is to
make original app use this class, without changing its original code;
recompilation is acceptable if it can be hidden from the user.
I vision it like this... User has file associations setup window. He gets
new class in some form, source to be compiled on his machine using some gui
tool that shouldn't be hard to write, or some kind of package. He does
something with it (first question... how does he add it?), and then he pops
up this file association dialog.
As it loads, the app get the list of all classes that can be derived from
cImage (how?). Then, the user inputs *.pcx as file mask and picks
appropriate class name from some dropdown list; he presses ok, and the
association is saved.
Ok then, he is about to view his images. What happens (well, what should
happen in my ideal world yet untainted by knowledge
)? He picks some
file, be it bmp, jpeg, pcx or whatever. Applications looks thru fle
associations' table and finds matching association and class name. It takes
MyImage variable of type cImage and creates an instance of
cAppropriateClassDerivedFromcImage into it (how od I write code for that?);
then, it calls its DrawToForm() method and woah, the image is on the form.
1) Is it even possible? I ma planning to use C# .NET.
2) Am I overlooking a better way to do the same thing?
If the questions below are answered 1) yes and 2) no, please refer to the
questions in the text or tell me search keywords on msdn/tutorials etc.
If 2) is yes, please elaborate
Thanks in forward for yout attention, and excuse me for bad English, just in
case...
plans

I have this question about design approach. I am switching over from (mosly)
BCB, so the freedom and complexity I have in .NET environment are kind of
breathtaking

I will give an example, cause that's hard to explain the concept in general.
Well, at least it is for me

Oh, and remember that's just an example, I know there are standart things o
display images, but it's just an example

Suppose I make and app for image displaying; I creat some class cImage with
standart DrawToForm() method, and inherit cBmpImage, cGifImage and
cJpgImage from it. It would be fine if images were all down to bmp, gif ,
and jpeg - I could just add associations with appropriate file in
if-then-else if-then-else if... blocks at design time, but suppose I want to
add some means for extensions' adding.
Suppose someone has my cImage class source, so he inherits cPcxImage from it
and creates a class that will display pcx images. What we need now is to
make original app use this class, without changing its original code;
recompilation is acceptable if it can be hidden from the user.
I vision it like this... User has file associations setup window. He gets
new class in some form, source to be compiled on his machine using some gui
tool that shouldn't be hard to write, or some kind of package. He does
something with it (first question... how does he add it?), and then he pops
up this file association dialog.
As it loads, the app get the list of all classes that can be derived from
cImage (how?). Then, the user inputs *.pcx as file mask and picks
appropriate class name from some dropdown list; he presses ok, and the
association is saved.
Ok then, he is about to view his images. What happens (well, what should
happen in my ideal world yet untainted by knowledge

file, be it bmp, jpeg, pcx or whatever. Applications looks thru fle
associations' table and finds matching association and class name. It takes
MyImage variable of type cImage and creates an instance of
cAppropriateClassDerivedFromcImage into it (how od I write code for that?);
then, it calls its DrawToForm() method and woah, the image is on the form.
1) Is it even possible? I ma planning to use C# .NET.
2) Am I overlooking a better way to do the same thing?
If the questions below are answered 1) yes and 2) no, please refer to the
questions in the text or tell me search keywords on msdn/tutorials etc.
If 2) is yes, please elaborate

Thanks in forward for yout attention, and excuse me for bad English, just in
case...
