public MenuCommandServiceImpl(IServiceProvider serviceProvider) : base(serviceProvider) { this.serviceProvider = serviceProvider; menuCommandService = new System.ComponentModel.Design.MenuCommandService(serviceProvider); MenuCommand undoCommand = new MenuCommand(new EventHandler(ExecuteUndo), StandardCommands.Undo); menuCommandService.AddCommand(undoCommand); MenuCommand redoCommand = new MenuCommand(new EventHandler(ExecuteRedo), StandardCommands.Redo); menuCommandService.AddCommand(redoCommand); MenuCommand ViewCodeCommand = new MenuCommand(new EventHandler(OnExecuteViewCode2), StandardCommands.ViewCode); menuCommandService.AddCommand(ViewCodeCommand); MenuCommand PropertyCommand = new MenuCommand(new EventHandler(OnExecuteViewProperty2), StandardCommands.Properties); menuCommandService.AddCommand(PropertyCommand); MenuCommand CreateEventCommand = new MenuCommand(new EventHandler(OnExecuteCreateEvent2), StandardCommands.DocumentOutline); menuCommandService.AddCommand(CreateEventCommand); }
public override void Initialize(IComponent component) { base.Initialize(component); sections = new List<BaseSection>(); // We need to listen to change events. If a shape changes, // we need to invalidate our view. // this.componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (this.componentChangeService != null) { this.componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); // this.componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); // this.componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); this.componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); this.componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); } // Add the menu commands we support. We must be a member of the VSIP program to // define new menu items, but we can handle any item located within the StandardCommands // class because Visual Studio already defines them. // menuCommandService = (MenuCommandService)GetService(typeof(MenuCommandService)); /* if (menuCommandService != null) { /* m_menuCommands = new MenuCommand[] { new MenuCommand(new EventHandler(OnMenuCut), StandardCommands.Cut), new MenuCommand(new EventHandler(OnMenuCopy), StandardCommands.Copy), // new ImmediateMenuCommand(new EventHandler(OnMenuPasteStatus), new EventHandler(OnMenuPaste), StandardCommands.Paste), new MenuCommand(new EventHandler(OnMenuDelete), StandardCommands.Delete) }; foreach(MenuCommand mc in m_menuCommands) { m_menuCommandService.AddCommand(mc); } System.Console.WriteLine("RootDesigner menuService set"); } */ // Select our base shape. By default there is nothing selected but that looks // strange (the property grid is empty). // selectionService = (ISelectionService)GetService(typeof(ISelectionService)); if (this.selectionService != null) { this.selectionService.SetSelectedComponents(new object[] {component}, SelectionTypes.Replace); this.selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); } host = (IDesignerHost)GetService(typeof(IDesignerHost)); menuCommandService = (MenuCommandService)host.GetService(typeof(MenuCommandService)); if (host != null) { host.LoadComplete += OnLoadComplete; } //Dragdropp only allowed in Section this.Control.AllowDrop = false; }