private static bool DragComponentContainsToolStrip(DropSourceBehavior.BehaviorDataObject data)
 {
     if (data != null)
     {
         ArrayList list = new ArrayList(data.DragComponents);
         foreach (Component component in list)
         {
             if (component is ToolStrip)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public override void OnDragDrop(Glyph g, DragEventArgs e)
        {
            ToolStripPanelSelectionGlyph glyph = g as ToolStripPanelSelectionGlyph;
            bool      flag     = false;
            ArrayList controls = null;

            DropSourceBehavior.BehaviorDataObject data = e.Data as DropSourceBehavior.BehaviorDataObject;
            if (data == null)
            {
                if ((e.Data is DataObject) && (controls == null))
                {
                    IToolboxService service = (IToolboxService)this.serviceProvider.GetService(typeof(IToolboxService));
                    IDesignerHost   host    = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
                    if ((service != null) && (host != null))
                    {
                        ToolboxItem tool = service.DeserializeToolboxItem(e.Data, host);
                        if (((tool.GetType(host) == typeof(ToolStrip)) || (tool.GetType(host) == typeof(MenuStrip))) || (tool.GetType(host) == typeof(StatusStrip)))
                        {
                            ToolStripPanelDesigner designer = host.GetDesigner(this.relatedControl) as ToolStripPanelDesigner;
                            if (designer != null)
                            {
                                OleDragDropHandler oleDragHandler = designer.GetOleDragHandler();
                                if (oleDragHandler != null)
                                {
                                    oleDragHandler.CreateTool(tool, this.relatedControl, 0, 0, 0, 0, false, false);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                controls = new ArrayList(data.DragComponents);
                foreach (Component component in controls)
                {
                    ToolStrip strip = component as ToolStrip;
                    if ((strip != null) && (strip.Parent != this.relatedControl))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    Control parent = this.relatedControl.Parent;
                    if (parent != null)
                    {
                        try
                        {
                            parent.SuspendLayout();
                            this.ExpandPanel(false);
                            Rectangle bounds = glyph.Bounds;
                            glyph.IsExpanded = true;
                            this.behaviorService.Invalidate(bounds);
                            this.behaviorService.Invalidate(glyph.Bounds);
                            this.ReParentControls(controls, e.Effect == DragDropEffects.Copy);
                        }
                        finally
                        {
                            parent.ResumeLayout(true);
                        }
                    }
                }
                data.CleanupDrag();
            }
        }