//- Management of the Drag&Drop of the toolboxItems contained inside our Toolbox private void OnListboxMouseDown(object sender, MouseEventArgs e) { ToolboxServiceImp tbs = this.GetIToolboxService(); if (null == tbs) { return; } if (null == tbs.Toolbox) { return; } //if (null == tbs.Toolbox()) // return; //var tool = tbs.Toolbox; //if (tool == null) // return; //var hit = tool.CalcHitInfo(e.X, e.Y); //if (hit.RowHandle < 0) // return; //tbs.Toolbox.DoDragDrop(tool.GetRow(hit.RowHandle), DragDropEffects.Copy | DragDropEffects.Move); }
public void EnableDragandDrop() { // For the management of the drag and drop of the toolboxItems Control ctrl = this.GetView(); if (null == ctrl) { return; } ctrl.AllowDrop = true; ctrl.DragDrop += new DragEventHandler(OnDragDrop); //- enable the Dragitem inside the our Toolbox ToolboxServiceImp tbs = this.GetIToolboxService(); if (null == tbs) { return; } if (null == tbs.Toolbox) { return; } tbs.Toolbox.MouseDown += new MouseEventHandler(OnListboxMouseDown); }
private void InitServices() { //- each DesignSurface has its own default services //- We can leave the default services in their present state, //- or we can remove them and replace them with our own. //- Now add our own services using IServiceContainer //- //- //- Note //- before loading the root control in the design surface //- we must add an instance of naming service to the service container. //- otherwise the root component did not have a name and this caused //- troubles when we try to use the UndoEngine //- //- //- 1. NameCreationService _nameCreationService = new NameCreationServiceImp(); if (_nameCreationService != null) { this.ServiceContainer.RemoveService(typeof(INameCreationService), false); this.ServiceContainer.AddService(typeof(INameCreationService), _nameCreationService); } //- //- //- 2. CodeDomComponentSerializationService _codeDomComponentSerializationService = new CodeDomComponentSerializationService(this.ServiceContainer); if (_codeDomComponentSerializationService != null) { //- the CodeDomComponentSerializationService is ready to be replaced this.ServiceContainer.RemoveService(typeof(ComponentSerializationService), false); this.ServiceContainer.AddService(typeof(ComponentSerializationService), _codeDomComponentSerializationService); } //- //- //- 3. IDesignerSerializationService _designerSerializationService = new DesignerSerializationServiceImpl(this.ServiceContainer); if (_designerSerializationService != null) { //- the IDesignerSerializationService is ready to be replaced this.ServiceContainer.RemoveService(typeof(IDesignerSerializationService), false); this.ServiceContainer.AddService(typeof(IDesignerSerializationService), _designerSerializationService); } //- //- //- 4. UndoEngine _undoEngine = new UndoEngineExt(this.ServiceContainer); //- disable the UndoEngine _undoEngine.Enabled = false; if (_undoEngine != null) { //- the UndoEngine is ready to be replaced this.ServiceContainer.RemoveService(typeof(UndoEngine), false); this.ServiceContainer.AddService(typeof(UndoEngine), _undoEngine); } //- //- //- 5. IMenuCommandService this.ServiceContainer.AddService(typeof(IMenuCommandService), new MenuCommandService(this)); _toolboxService = new ToolboxServiceImp(this.GetIDesignerHost()); if (_toolboxService != null) { this.ServiceContainer.RemoveService(typeof(IToolboxService), false); this.ServiceContainer.AddService(typeof(IToolboxService), _toolboxService); } }