// Affichage du contexteMenu // Affiche la commande supprimer public override void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y) { // Création du contextMenu ContextMenuStrip contextMenu = new ContextMenuStrip(); ToolStripMenuItem contextMenuitems = new ToolStripMenuItem(); contextMenu.Items.AddRange(new ToolStripMenuItem[] { contextMenuitems }); System.ComponentModel.Design.MenuCommand command; // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Undo); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Annuler", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Redo); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Rétablir", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } contextMenu.Items.Add(new ToolStripSeparator()); // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Cut); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Couper", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Copy); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Copier", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Paste); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Coller", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Delete); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Supprimer", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } contextMenuitems.DropDownItems.Add(new ToolStripSeparator()); //// Ajout de la commande //if (Designer != null) //{ // VelerSoftware.Design.Toolkit.KryptonContextMenuItem Select_menuItem; // VelerSoftware.Design.Toolkit.KryptonContextMenuItems Selects_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItems(); // if (Variables.Langue == "fr") { Select_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerTexte, null, null); } else { Select_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerTexte_EN, null, null); } // foreach (System.ComponentModel.Component item in Designer.ComponentContainer.Components) // { // VelerSoftware.Design.Toolkit.KryptonContextMenuItem Component_menuItem; // Component_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(item.Site.Name, new EventHandler(OnSelectComponentEvent2)); // Component_menuItem.Tag = item; // Selects_menuItem.Items.Add(Component_menuItem); // } // Select_menuItem.Items.Add(Selects_menuItem); // contextMenuitems.Items.Add(Select_menuItem); //} // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.SelectAll); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Sélectionner tout", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } contextMenuitems.DropDownItems.Add(new ToolStripSeparator()); // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.BringToFront); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Mettre en avant", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.SendToBack); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Send to back", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } contextMenuitems.DropDownItems.Add(new ToolStripSeparator()); // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.LockControls); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Lock", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } contextMenuitems.DropDownItems.Add(new ToolStripSeparator()); // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.ViewCode); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Voir le code", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.DocumentOutline); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Créer un évènement", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Ajout de la commande command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Properties); if (command != null) { ToolStripDropDownButton menuItem; { menuItem = new ToolStripDropDownButton("Propriétés", My.Resources.Resources.class_libraries, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenu.Items.Add(menuItem); } // Affichage du contextMenu // erreur sur Designer.View : conversion impossible de 'object' en system.windows.form.control IUGConceptor _editeur = new IUGConceptor(); _editeur.metroContextMenu1.Show(IUGConceptor.HostC, new Point(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y)); }
// Affichage du contexteMenu // Affiche la commande supprimer public override void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y) { // Création du contextMenu VelerSoftware.Design.Toolkit.KryptonContextMenu contextMenu = new VelerSoftware.Design.Toolkit.KryptonContextMenu(); VelerSoftware.Design.Toolkit.KryptonContextMenuItems contextMenuitems = new VelerSoftware.Design.Toolkit.KryptonContextMenuItems(); contextMenu.Items.AddRange(new VelerSoftware.Design.Toolkit.KryptonContextMenuItemBase[] { contextMenuitems }); System.ComponentModel.Design.MenuCommand command; // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Undo); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.AnnulerTexte, Resources.undo, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.AnnulerTexte_EN, Resources.undo, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Redo); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.RetablirTexte, Resources.redo, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.RetablirTexte_EN, Resources.redo, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } contextMenu.Items.Add(new VelerSoftware.Design.Toolkit.KryptonContextMenuSeparator()); // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Cut); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CouperTexte, Resources.cut, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CouperTexte_EN, Resources.cut, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Copy); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CopierTexte, Resources.copy_small, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CopierTexte_EN, Resources.copy_small, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Paste); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CollerTexte, Resources.paste_sma, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CollerTexte_EN, Resources.paste_sma, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Delete); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SupprimerTexte, Resources.delete, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SupprimerTexte_EN, Resources.delete, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } contextMenuitems.Items.Add(new VelerSoftware.Design.Toolkit.KryptonContextMenuSeparator()); // Ajout de la command if (Designer != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem Select_menuItem; VelerSoftware.Design.Toolkit.KryptonContextMenuItems Selects_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItems(); if (Variables.Langue == "fr") { Select_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerTexte, null, null); } else { Select_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerTexte_EN, null, null); } foreach (System.ComponentModel.Component item in Designer.ComponentContainer.Components) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem Component_menuItem; Component_menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(item.Site.Name, new EventHandler(OnSelectComponentEvent2)); Component_menuItem.Tag = item; Selects_menuItem.Items.Add(Component_menuItem); } Select_menuItem.Items.Add(Selects_menuItem); contextMenuitems.Items.Add(Select_menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.SelectAll); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerToutTexte, null, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.SelectionnerToutTexte_EN, null, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } contextMenuitems.Items.Add(new VelerSoftware.Design.Toolkit.KryptonContextMenuSeparator()); // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.BringToFront); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.MettreaupremierplanTexte, Resources.BringToFrontHS, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.MettreaupremierplanTexte_EN, Resources.BringToFrontHS, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.SendToBack); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.MettreenarrièreplanTexte, Resources.SendToBackHS, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.MettreenarrièreplanTexte_EN, Resources.SendToBackHS, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } contextMenuitems.Items.Add(new VelerSoftware.Design.Toolkit.KryptonContextMenuSeparator()); // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.LockControls); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.VérouillerlescontrôlesTexte, Resources.ProtectFormHS, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.VérouillerlescontrôlesTexte_EN, Resources.ProtectFormHS, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } contextMenuitems.Items.Add(new VelerSoftware.Design.Toolkit.KryptonContextMenuSeparator()); // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.ViewCode); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.AfficherlesfonctionsTexte, null, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.AfficherlesfonctionsTexte_EN, null, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.DocumentOutline); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CréerunévènementTexte, Resources.lightning, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.CréerunévènementTexte_EN, Resources.lightning, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Ajout de la command command = menuCommandService.FindCommand(System.ComponentModel.Design.StandardCommands.Properties); if (command != null) { VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem; if (Variables.Langue == "fr") { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.PropriétésTexte, Resources.Propriété, new EventHandler(OnMenuClicked)); } else { menuItem = new VelerSoftware.Design.Toolkit.KryptonContextMenuItem(Resources.PropriétésTexte_EN, Resources.Propriété, new EventHandler(OnMenuClicked)); } menuItem.Tag = command; contextMenuitems.Items.Add(menuItem); } // Affichage du contextMenu if (Designer.View != null) { //contextMenu.Renderer = new VelerSoftware.SZC.Office2007Renderer.Office2007Renderer(); contextMenu.Show(Designer.View, new Point(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y)); } }