internal override Rectangle CalculateConnectedArea()
        {
            if (this.OwnerItem != null && !this.OwnerItem.IsOnDropDown && !(this.OwnerItem is MdiControlStrip.SystemMenuItem))
            {
                ToolStrip parent = OwnerItem.GetCurrentParent();
                if (parent != null)
                {
                    Point owner_screen_loc = parent.PointToScreen(OwnerItem.Location);
                    return(new Rectangle(owner_screen_loc.X - Left, 0, this.OwnerItem.Width - 1, 2));
                }
            }

            return(base.CalculateConnectedArea());
        }
        private void MoveInsideContainer(ToolStrip toolStripToDrag, Point clientLocation)
        {
            ISupportToolStripPanel panel = toolStripToDrag;

            if (!panel.IsCurrentlyDragging || this.DragBounds.Contains(clientLocation))
            {
                bool flag = false;
                ClearDragFeedback();
                if ((((toolStripToDrag.Site != null) && toolStripToDrag.Site.DesignMode) && base.IsHandleCreated) && ((clientLocation.X < 0) || (clientLocation.Y < 0)))
                {
                    Point pt = base.PointToClient(WindowsFormsUtils.LastCursorPoint);
                    if (base.ClientRectangle.Contains(pt))
                    {
                        clientLocation = pt;
                    }
                }
                ToolStripPanelRow toolStripPanelRow = panel.ToolStripPanelRow;
                bool flag2 = false;
                if (((toolStripPanelRow != null) && toolStripPanelRow.Visible) && (toolStripPanelRow.ToolStripPanel == this))
                {
                    if (toolStripToDrag.IsCurrentlyDragging)
                    {
                        flag2 = toolStripPanelRow.DragBounds.Contains(clientLocation);
                    }
                    else
                    {
                        flag2 = toolStripPanelRow.Bounds.Contains(clientLocation);
                    }
                }
                if (flag2)
                {
                    panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), clientLocation);
                }
                else
                {
                    ToolStripPanelRow row2 = this.PointToRow(clientLocation);
                    if (row2 == null)
                    {
                        int count = this.RowsInternal.Count;
                        if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
                        {
                            count = (clientLocation.Y <= base.Padding.Left) ? 0 : count;
                        }
                        else
                        {
                            count = (clientLocation.X <= base.Padding.Left) ? 0 : count;
                        }
                        ToolStripPanelRow row3 = null;
                        if (this.RowsInternal.Count > 0)
                        {
                            if (count == 0)
                            {
                                row3 = this.RowsInternal[0];
                            }
                            else if (count > 0)
                            {
                                row3 = this.RowsInternal[count - 1];
                            }
                        }
                        if (((row3 != null) && (row3.ControlsInternal.Count == 1)) && row3.ControlsInternal.Contains(toolStripToDrag))
                        {
                            row2 = row3;
                            if (toolStripToDrag.IsInDesignMode)
                            {
                                Point endClientLocation = (this.Orientation == System.Windows.Forms.Orientation.Horizontal) ? new Point(clientLocation.X, row2.Bounds.Y) : new Point(row2.Bounds.X, clientLocation.Y);
                                panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), endClientLocation);
                            }
                        }
                        else
                        {
                            row2 = new ToolStripPanelRow(this);
                            this.RowsInternal.Insert(count, row2);
                        }
                    }
                    else if (!row2.CanMove(toolStripToDrag))
                    {
                        int index = this.RowsInternal.IndexOf(row2);
                        if (((toolStripPanelRow != null) && (toolStripPanelRow.ControlsInternal.Count == 1)) && ((index > 0) && ((index - 1) == this.RowsInternal.IndexOf(toolStripPanelRow))))
                        {
                            return;
                        }
                        row2 = new ToolStripPanelRow(this);
                        this.RowsInternal.Insert(index, row2);
                        clientLocation.Y = row2.Bounds.Y;
                    }
                    flag = toolStripPanelRow != row2;
                    if ((!flag && (toolStripPanelRow != null)) && (toolStripPanelRow.ControlsInternal.Count > 1))
                    {
                        toolStripPanelRow.LeaveRow(toolStripToDrag);
                        toolStripPanelRow = null;
                        flag = true;
                    }
                    if (flag)
                    {
                        if (toolStripPanelRow != null)
                        {
                            toolStripPanelRow.LeaveRow(toolStripToDrag);
                        }
                        row2.JoinRow(toolStripToDrag, clientLocation);
                    }
                    if (flag && panel.IsCurrentlyDragging)
                    {
                        for (int i = 0; i < this.RowsInternal.Count; i++)
                        {
                            LayoutTransaction.DoLayout(this.RowsInternal[i], this, PropertyNames.Rows);
                        }
                        if (this.RowsInternal.IndexOf(row2) > 0)
                        {
                            System.Windows.Forms.IntSecurity.AdjustCursorPosition.Assert();
                            try
                            {
                                Point point3 = toolStripToDrag.PointToScreen(toolStripToDrag.GripRectangle.Location);
                                if (this.Orientation == System.Windows.Forms.Orientation.Vertical)
                                {
                                    point3.X += toolStripToDrag.GripRectangle.Width / 2;
                                    point3.Y  = Cursor.Position.Y;
                                }
                                else
                                {
                                    point3.Y += toolStripToDrag.GripRectangle.Height / 2;
                                    point3.X  = Cursor.Position.X;
                                }
                                Cursor.Position = point3;
                            }
                            finally
                            {
                                CodeAccessPermission.RevertAssert();
                            }
                        }
                    }
                }
            }
        }
 private void MoveInsideContainer(ToolStrip toolStripToDrag, Point clientLocation)
 {
     ISupportToolStripPanel panel = toolStripToDrag;
     if (!panel.IsCurrentlyDragging || this.DragBounds.Contains(clientLocation))
     {
         bool flag = false;
         ClearDragFeedback();
         if ((((toolStripToDrag.Site != null) && toolStripToDrag.Site.DesignMode) && base.IsHandleCreated) && ((clientLocation.X < 0) || (clientLocation.Y < 0)))
         {
             Point pt = base.PointToClient(WindowsFormsUtils.LastCursorPoint);
             if (base.ClientRectangle.Contains(pt))
             {
                 clientLocation = pt;
             }
         }
         ToolStripPanelRow toolStripPanelRow = panel.ToolStripPanelRow;
         bool flag2 = false;
         if (((toolStripPanelRow != null) && toolStripPanelRow.Visible) && (toolStripPanelRow.ToolStripPanel == this))
         {
             if (toolStripToDrag.IsCurrentlyDragging)
             {
                 flag2 = toolStripPanelRow.DragBounds.Contains(clientLocation);
             }
             else
             {
                 flag2 = toolStripPanelRow.Bounds.Contains(clientLocation);
             }
         }
         if (flag2)
         {
             panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), clientLocation);
         }
         else
         {
             ToolStripPanelRow row2 = this.PointToRow(clientLocation);
             if (row2 == null)
             {
                 int count = this.RowsInternal.Count;
                 if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
                 {
                     count = (clientLocation.Y <= base.Padding.Left) ? 0 : count;
                 }
                 else
                 {
                     count = (clientLocation.X <= base.Padding.Left) ? 0 : count;
                 }
                 ToolStripPanelRow row3 = null;
                 if (this.RowsInternal.Count > 0)
                 {
                     if (count == 0)
                     {
                         row3 = this.RowsInternal[0];
                     }
                     else if (count > 0)
                     {
                         row3 = this.RowsInternal[count - 1];
                     }
                 }
                 if (((row3 != null) && (row3.ControlsInternal.Count == 1)) && row3.ControlsInternal.Contains(toolStripToDrag))
                 {
                     row2 = row3;
                     if (toolStripToDrag.IsInDesignMode)
                     {
                         Point endClientLocation = (this.Orientation == System.Windows.Forms.Orientation.Horizontal) ? new Point(clientLocation.X, row2.Bounds.Y) : new Point(row2.Bounds.X, clientLocation.Y);
                         panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), endClientLocation);
                     }
                 }
                 else
                 {
                     row2 = new ToolStripPanelRow(this);
                     this.RowsInternal.Insert(count, row2);
                 }
             }
             else if (!row2.CanMove(toolStripToDrag))
             {
                 int index = this.RowsInternal.IndexOf(row2);
                 if (((toolStripPanelRow != null) && (toolStripPanelRow.ControlsInternal.Count == 1)) && ((index > 0) && ((index - 1) == this.RowsInternal.IndexOf(toolStripPanelRow))))
                 {
                     return;
                 }
                 row2 = new ToolStripPanelRow(this);
                 this.RowsInternal.Insert(index, row2);
                 clientLocation.Y = row2.Bounds.Y;
             }
             flag = toolStripPanelRow != row2;
             if ((!flag && (toolStripPanelRow != null)) && (toolStripPanelRow.ControlsInternal.Count > 1))
             {
                 toolStripPanelRow.LeaveRow(toolStripToDrag);
                 toolStripPanelRow = null;
                 flag = true;
             }
             if (flag)
             {
                 if (toolStripPanelRow != null)
                 {
                     toolStripPanelRow.LeaveRow(toolStripToDrag);
                 }
                 row2.JoinRow(toolStripToDrag, clientLocation);
             }
             if (flag && panel.IsCurrentlyDragging)
             {
                 for (int i = 0; i < this.RowsInternal.Count; i++)
                 {
                     LayoutTransaction.DoLayout(this.RowsInternal[i], this, PropertyNames.Rows);
                 }
                 if (this.RowsInternal.IndexOf(row2) > 0)
                 {
                     System.Windows.Forms.IntSecurity.AdjustCursorPosition.Assert();
                     try
                     {
                         Point point3 = toolStripToDrag.PointToScreen(toolStripToDrag.GripRectangle.Location);
                         if (this.Orientation == System.Windows.Forms.Orientation.Vertical)
                         {
                             point3.X += toolStripToDrag.GripRectangle.Width / 2;
                             point3.Y = Cursor.Position.Y;
                         }
                         else
                         {
                             point3.Y += toolStripToDrag.GripRectangle.Height / 2;
                             point3.X = Cursor.Position.X;
                         }
                         Cursor.Position = point3;
                     }
                     finally
                     {
                         CodeAccessPermission.RevertAssert();
                     }
                 }
             }
         }
     }
 }