HighTechTalks DotNet Forums  

Where does the designer code come from?

Dotnet Framework (WinForms DesignTime) microsoft.public.dotnet.framework.windowsforms.designtime


Discuss Where does the designer code come from? in the Dotnet Framework (WinForms DesignTime) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
schneider
 
Posts: n/a

Default Where does the designer code come from? - 07-09-2007 , 03:00 PM






How does the designer determine what code is used in the form designer code?

For example 1, when you drag a control (using the object name?):

private System.Windows.Forms.TextBox txtUserName;

this.txtUserName = new System.Windows.Forms.TextBox();


Thanks,
Schneider



Reply With Quote
  #2  
Old   
OD
 
Posts: n/a

Default Re: Where does the designer code come from? - 07-15-2007 , 08:28 AM






Quote:
How does the designer determine what code is used in the form designer code?
For example 1, when you drag a control (using the object name?):
private System.Windows.Forms.TextBox txtUserName;
this.txtUserName = new System.Windows.Forms.TextBox();
When you drag a component onto the designer surface, VS is knowing the
class, then using reflection, it can get the list of public properties
and events. As all components must implement IComponent (providing
functionnality required by all components) and must inherit from
Control, it is easy to generate the "new" code and to manage other
common component behaviors.

Nothing really magic, just object programming :-)

--


OD___
www.e-naxos.com




Reply With Quote
  #3  
Old   
schneider
 
Posts: n/a

Default Re: Where does the designer code come from? - 07-16-2007 , 10:54 PM



Yes, I guess I should have said "What .NET objects are used to generate the
code?" I want to alter the behavior.

Thanks,
Schneider


"OD" <webmaster @ e-naxos dot com> wrote

Quote:
How does the designer determine what code is used in the form designer
code?
For example 1, when you drag a control (using the object name?):
private System.Windows.Forms.TextBox txtUserName;
this.txtUserName = new System.Windows.Forms.TextBox();

When you drag a component onto the designer surface, VS is knowing the
class, then using reflection, it can get the list of public properties and
events. As all components must implement IComponent (providing
functionnality required by all components) and must inherit from Control,
it is easy to generate the "new" code and to manage other common component
behaviors.

Nothing really magic, just object programming :-)

--


OD___
www.e-naxos.com





Reply With Quote
  #4  
Old   
OD
 
Posts: n/a

Default Re: Where does the designer code come from? - 07-17-2007 , 08:23 AM



Quote:
Yes, I guess I should have said "What .NET objects are used to generate the
code?" I want to alter the behavior.
The way code is generated mostly depends on the component itself.
For example, attributes such as Description, Browsable, default values,
default event, etc, are used in component source code and help VS to
display properties, to generate default event when you double-click the
component under design, etc.. Changing this attributes will change the
component behavior under design.

But can you be more precise about what you're wanting to do, give a
little sample if possible. I'm not sure to fully understand your goal.


--


OD___
www.e-naxos.com




Reply With Quote
  #5  
Old   
schneider
 
Posts: n/a

Default Re: Where does the designer code come from? - 07-17-2007 , 10:35 AM



I'm looking for what classes are used in creating the code.

Some X object/s must look at the component and decide what to generate code
for and what to ignore or decide where the code should be or look like.

There is also something that decides to put code into different
methods/regions, and creat comments like below.
I'm looking for info on how all this is done.

Thanks,
Schneider
#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent() {


"OD" <webmaster @ e-naxos dot com> wrote

Quote:
Yes, I guess I should have said "What .NET objects are used to generate
the code?" I want to alter the behavior.

The way code is generated mostly depends on the component itself.
For example, attributes such as Description, Browsable, default values,
default event, etc, are used in component source code and help VS to
display properties, to generate default event when you double-click the
component under design, etc.. Changing this attributes will change the
component behavior under design.

But can you be more precise about what you're wanting to do, give a little
sample if possible. I'm not sure to fully understand your goal.


--


OD___
www.e-naxos.com





Reply With Quote
  #6  
Old   
OD
 
Posts: n/a

Default Re: Where does the designer code come from? - 07-17-2007 , 04:15 PM



Quote:
I'm looking for what classes are used in creating the code.
Generating the code is the VS job. There is no framework class for this
task. VS does it just by inspecting the class of the component and
taking into account all the supported attributes.
The way VS generate the code by separating some parts (design), etc, is
the specific job of the application "Visual Studio". Rules are changing
from one version to another (VS 2005 doesnt generate the same code than
VS 2003 for example).
You can write a code that performs the same task just using reflection,
but the way the code is finally "rendered" will be precisely your
application job, as VS does it its own way.

--


OD___
www.e-naxos.com




Reply With Quote
  #7  
Old   
schneider
 
Posts: n/a

Default Re: Where does the designer code come from? - 09-20-2007 , 12:08 PM



Thanks, that's what I was looking for. Looking to improve the designer code
for my components.

Schneider


"Sigurbjörn Valdimarsson" <sigurbj (AT) hotmail (DOT) com> wrote

Quote:
You might want to look at CodeDomSerializer and the
DesignerSerializerAttribute.


"schneider" <eschneider (AT) ooooooooo (DOT) com> wrote in message
news:u4jLI2ByHHA.3564 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Yes, I guess I should have said "What .NET objects are used to generate
the code?" I want to alter the behavior.

Thanks,
Schneider


"OD" <webmaster @ e-naxos dot com> wrote in message
news:mn.7b647d77437ca577.18651 (AT) e-naxosdotcom (DOT) ..
How does the designer determine what code is used in the form designer
code?
For example 1, when you drag a control (using the object name?):
private System.Windows.Forms.TextBox txtUserName;
this.txtUserName = new System.Windows.Forms.TextBox();

When you drag a component onto the designer surface, VS is knowing the
class, then using reflection, it can get the list of public properties
and events. As all components must implement IComponent (providing
functionnality required by all components) and must inherit from
Control, it is easy to generate the "new" code and to manage other
common component behaviors.

Nothing really magic, just object programming :-)

--


OD___
www.e-naxos.com









Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.