public HostSurface() : base() { this.AddService(typeof(IMenuCommandService), new MenuCommandService(this.ServiceContainer)); //You only need to do your own implementation if you want to do something special. this.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(this.ServiceContainer)); this.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService(this.ServiceContainer)); // AJOUT : UndoEngine UndoEngine undoEngine = new UndoEngineImpl(this.ServiceContainer); //- enable the UndoEngine undoEngine.Enabled = true; if (undoEngine != null) { //- the UndoEngine is ready to be replaced this.ServiceContainer.RemoveService(typeof(UndoEngine), false); this.ServiceContainer.AddService(typeof(UndoEngine), undoEngine); Menu = new MenuCommandServiceImpl(this.ServiceContainer); Menu.Designer = this; ServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), Menu); Menu.AddCommand(new MenuCommand(new EventHandler(this.ExecuteUndo), StandardCommands.Undo)); Menu.AddCommand(new MenuCommand(new EventHandler(this.ExecuteRedo), StandardCommands.Redo)); } }
public HostSurface(IServiceProvider parentProvider) : base(parentProvider) { Menu = new MenuCommandServiceImpl(this.ServiceContainer); Menu.Designer = this; ServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), Menu); Menu.AddCommand(new MenuCommand(new EventHandler(this.ExecuteUndo), StandardCommands.Undo)); Menu.AddCommand(new MenuCommand(new EventHandler(this.ExecuteRedo), StandardCommands.Redo)); // idem correction // this.AddService(typeof(IMenuCommandService), new MenuCommandService(this.ServiceContainer)); // Ajout : les 2 lignes de code suivantes. this.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(this.ServiceContainer)); this.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService(this.ServiceContainer)); this.AddService(typeof(UndoEngine), new UndoEngineImpl(this.ServiceContainer)); }