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


Supinfo-Projects.com
Supinfo Students' projects



Projects
  Last project
  Top projects
  All projects

106 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

8 The IComponentChangeService service

The IComponentChangeService service is an interface of the namespace System.ComponentModel.Design. It provides methods for management of the menus and the verbs (To consult the MSDN to know all its methods, properties and events). One recovers this service via the GetService method of the DesignSurface class, while passing the System.ComponentModel.Design.IComponentChangeService type in parameter. 

 

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

- The ComponentAdded event which is raised when a component is added to the host.

- The ComponentChanged event which is raised when a component is modified on the host.

- The ComponentRemoved event which is raised when a component is withdrawn from the host. 

- The ComponentRename event which is raised when the name of a component changed host.

 

IComponentChangeService is a service by default of the class DesignSurface, it is not necessary to add it except if you wish to customize it.

 

We go associated the events ComponentAdded, ComponentRemoved and ComponentRename with the IComponentChangeService service. We will modify the Form1_Load event as follows:

private void Form1_Load(object sender, EventArgs e)

{

   

 

   //Select the service IComponentChangeService and assocation of evenements ComponentAdded, ComponentRemoved, ComponentRename    System.ComponentModel.Design.IComponentChangeService componentChangeService = (System.ComponentModel.Design.IComponentChangeService)designer.GetService(

typeof(System.ComponentModel.Design.IComponentChangeService));

    componentChangeService.ComponentAdded +=

new System.ComponentModel.Design.ComponentEventHandler(

componentChangeService_ComponentAdded);

    componentChangeService.ComponentRemoved +=

new System.ComponentModel.Design.ComponentEventHandler(

componentChangeService_ComponentRemoved);

    componentChangeService.ComponentRename +=

new System.ComponentModel.Design.ComponentRenameEventHandler(

componentChangeService_ComponentRename);     

}

 

// Release the ressources

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

    // Release the evenements on the service of IComponentChangeService    System.ComponentModel.Design.IComponentChangeService componentChangeService = (System.ComponentModel.Design.IComponentChangeService)designer.GetService(

typeof(System.ComponentModel.Design.IComponentChangeService));

    componentChangeService.ComponentAdded -=

new System.ComponentModel.Design.ComponentEventHandler(

componentChangeService_ComponentAdded);

    componentChangeService.ComponentRemoved -=

new System.ComponentModel.Design.ComponentEventHandler(

componentChangeService_ComponentRemoved);

    componentChangeService.ComponentRename -=

new System.ComponentModel.Design.ComponentRenameEventHandler(

componentChangeService_ComponentRename);

 

    // Release the evenements on the service of selection    System.ComponentModel.Design.ISelectionService selectionService =

         (System.ComponentModel.Design.ISelectionService)

        designer.GetService(typeof(System.ComponentModel.Design.ISelectionService));

 

    selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);

 

    // Release the evenements on the view of host

     ((Control)designer.View).DragDrop -= new DragEventHandler(Form1_DragDrop);

 

    // Delete the view of designer of panel    panel1.Controls.Remove((Control)designer.View);

 

    // Release the designer to the form

     designer.Dispose();

}

 

// Component renamed

void componentChangeService_ComponentRename(object sender, System.ComponentModel.Design.ComponentRenameEventArgs e)

{

    MessageBox.Show("Le composant " + e.OldName + " a été renommé en "+ e.NewName);

}

 

// Component deleted

void componentChangeService_ComponentRemoved(object sender, System.ComponentModel.Design.ComponentEventArgs e)

{

    MessageBox.Show("Le composant " + ((Control)e.Component).Name + " a été supprimé");

}

 

// Component added

void componentChangeService_ComponentAdded(object sender, System.ComponentModel.Design.ComponentEventArgs e)

{

    MessageBox.Show("Le composant " + ((Control)e.Component).Name + " a été ajouté");

}

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

 

Exemple ComponentChange.JPG

 

When one adds, for example, a textbox, one can see that the ComponentAdded event was indeed raised.



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 :