J'ai mon shell et jai 1 module qui est loaddé. Dans workitem de ce module, j'enrégistre un CommandHandler sur ma méthode
Sur le run de ce workitem, je créé un ExplorerBarGroup qui est ensuite placé dans le site (ExplorerBarWorkspace) qui est situé sur dans mon shell
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 [CommandHandler("DispatchClick")] public void OnGroupClick(object sender, EventArgs e) { this.Activate(); Schedules.MainWorkItem schedules = WorkItems.AddNew<Schedules.MainWorkItem>("Schedules"); schedules.Run(Workspace); LineUp.MainWorkItem lineUp = WorkItems.AddNew<LineUp.MainWorkItem>("LineUp"); lineUp.Run(Workspace); }
L'enrégistrement de mon site dans le program.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 void ISubSystem.Run(IWorkspace workspace) { Run(); Workspace = workspace; UltraExplorerBarGroup group = new Shell.Common.CommandExplorerBarGroup("Dispatch", "DispatchClick"); group.Text = "Dispatch"; group.Settings.AppearancesLarge.HeaderAppearance.Image = Properties.Resources.Dispatch; group.Settings.Style = GroupStyle.LargeImagesWithText; UIExtensionSites["MainExplorerBar"].Add<UltraExplorerBarGroup>(group); UIExtensionSites.RegisterSite(Dispatch.Common.Sites.SIDEBAR, group.Items); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 protected override void AfterShellCreated() { base.AfterShellCreated(); RootWorkItem.UIExtensionSites.RegisterSite("MainExplorerBar", this.Shell.MainExplorerBarWorkspace); RootWorkItem.UIExtensionSites.RegisterSite("MainToolBar", this.Shell.MainToolBarWorkspace.Ribbon); CreateMainMenu(); }
Quand je sélectionne un explorerBarGroup dans mon shellform, j'exécute la command qui est associé à ce group
Voila que je suis surpris, le RootWorkItem.Commands[commandGroup.CommandName] ne contient pas ma commande. Pourtant elle devrait y être.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 private void explorerBarWorkspace_GroupClick(object sender, Infragistics.Win.UltraWinExplorerBar.GroupEventArgs e) { Common.CommandExplorerBarGroup commandGroup = e.Group as Common.CommandExplorerBarGroup; if (commandGroup != null) { RootWorkItem.Commands[commandGroup.CommandName].Execute(); } }
Si je rajoute un handler directement dans mon shellform
Et bien, magie, mes 2 handler se font appeler (celui de mon shellform et celui dans mon module de dispatch).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 [CommandHandler("DispatchClick")] public void OnGroupClick(object sender, EventArgs e) { }
Qqn sait pk mon handler de mon module n'est pas enrégistré dans la collections de commands du RootWorkItem ?
Partager