Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Supinfo Students' projects



Projects
  Last project
  Top projects
  All projects

94 User's online
3168 Projects


My Supinfo-Projects

   Login
   Create account


Synopsis

   6 Hits
   Visitors Score : 20
    (3 Voter)
   0 Comments

   Read the article

Evaluate this article

20
18
16
14
12
10
8
6
4
2
0


Comment this article

Author :

Email :

Your comment :



 
2006 - Pérennisation
Use and customize of host of forms of Visual Studio 2005 in your applications .net
[30 mn of reading - published 6/6/2006 8:37:04 PM - Target : Confirmé]

Author

wildarkWilliam GUIOUBLY
Student-Engineer Supinfo Paris
SUPINFO graduate year  2007

   Write to the person
   All projects of the same author
   Mini-CV of the author

2 The DesignSurface class

The class System.ComponentModel.Design.DesignSurface goes allows us to create a basic host of forms. It is by this class that one will be able to add or customize the functionalities of the originator via services (IDesignerHost, ISelectionService, INameCreationService…) which we will study in the next chapters.

 

Let us examine somebody of these methods, properties and events:

- The property IsLoaded indicating if the originator to host be charged.

- The property View, it is seen on the host.

- The property ServiceContainer makes it possible to modify the services associated with the host.

- The method BeginLoad makes it possible to charge the control container or control root, as well as the host.

- The method GetService makes it possible to obtain the services associated with the host.

 

To start we will create a class "Designer" in the project which will inherit the DesignSurface class as follows:

public class Designer : System.ComponentModel.Design.DesignSurface {

 

    //Constructor

    public Designer(){}

}

This class will allow us to add or to modify the services of DesignSurface bus according to the MSDN one can make only in the constructor of the DesignSurface class from where the need to create this class. For the moment one will leave this class just as it is, us will modify it with the wire of the chapters in order to add the various services presented.

 

We will modify our example by associating an event Load and FormClosing (to release the resources) the form of the application: 

 

Designer designer = null;

 

// event of loading of the form of application (event Load)

private void Form1_Load(object sender, EventArgs e)

{

    // Creation the host of the form

    designer = new Designer();

 

    // Assocation of the control container to the designer

     designer.BeginLoad(typeof(Form));

 

    // Throw a exception if the designer isn't loaded

    if (!designer.IsLoaded)

        throw new Exception("Le concepteur n'a pu être chargé");

 

    // It is specified that view it of the designer extend on all the control which will host it

    ((Control)designer.View).Dock = DockStyle.Fill;

 

    // Add the view of designer in the panel

    panel1.Controls.Add((Control)designer.View);

}

 

// Release the ressources

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

     // Delete the view of designer of panel

     panel1.Controls.Remove((Control)designer.View);

 

     // Release the designer to the form

     designer.Dispose();

}

 

The BeginLoad method of the DesignSurface class makes it possible to charge the control container or control root, it is with a statement the control relative which will accomodate all other controls which will be associated there. For example in Visual Studio 2005, at the time you to publish a form, the latter is the control container of the host. The BeginLoad method can take in parameter the type of the control container which can be of all kinds (for example a button, a panel, a userControl…). Here in the example one associated Form to the host. The View property of the DesignSurface class represents seen it of the host and to use it it is necessary to add it to a control which goes the reception. In the example, it is the panel which will play this role.

 

To compile and launch the project and here what you obtain:

 

Exemple Concepteur de form.JPG

The panel changed, one can distinguish there a form which will be the control container of the originator.



Articles de la même catégorie

 Pages : Top


5 Hits
0 Comments
ID3 and C4.5 algorithms
[40 mn of reading - published 6/6/2006 7:48:47 PM - Target : Confirmé]

More


9 Hits
0 Comments
Generics with .NET
[30 mn of reading - published 6/6/2006 3:37:29 PM - Target : Confirmé]

More


5 Hits
0 Comments
Widget Development
[10 mn of reading - published 6/6/2006 3:03:12 PM - Target : Débutant]

More

Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :