internal void SetAutoHideSize() { IOwner owner = m_Owner as IOwner; IOwnerBarSupport ownerBar = m_Owner as IOwnerBarSupport; IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport; Control parentControl = this.GetOwnerControl(); if (owner == null || parentControl == null || ownerBar == null || ownerAutoHide == null) return; int width = parentControl.ClientSize.Width; int height = parentControl.ClientSize.Height; int x = 0, y = 0; //if(ownerBar.TopDockSite.Parent is UserControl) { switch (m_LastDockSiteInfo.DockSide) { case DockStyle.Left: { width = ownerBar.LeftDockSite.Parent.Width; height = ownerBar.LeftDockSite.Parent.Height; Point pLoc = ownerAutoHide.LeftAutoHidePanel.Location; x = pLoc.X + ownerAutoHide.LeftAutoHidePanel.Width; y = pLoc.Y; break; } case DockStyle.Right: { width = ownerBar.RightDockSite.Parent.Width; height = ownerBar.RightDockSite.Parent.Height; Point pLoc = ownerAutoHide.RightAutoHidePanel.Location; x = pLoc.X; y = pLoc.Y; break; } case DockStyle.Top: { width = ownerBar.TopDockSite.Parent.Width; height = ownerBar.TopDockSite.Parent.Height; Point pLoc = ownerAutoHide.TopAutoHidePanel.Location; x = pLoc.X; y = pLoc.Y + ownerAutoHide.TopAutoHidePanel.Height; break; } default: { width = ownerBar.BottomDockSite.Parent.Width; height = ownerBar.BottomDockSite.Parent.Height; Point pLoc = ownerAutoHide.BottomAutoHidePanel.Location; x = pLoc.X; y = pLoc.Y; break; } } } switch (m_LastDockSiteInfo.DockSide) { case DockStyle.Left: { // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)>ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite)) // { // height-=ownerBar.TopDockSite.Height; // y=ownerBar.TopDockSite.Bottom; // } // if(ownerAutoHide.HasBottomAutoHidePanel) // height-=ownerAutoHide.BottomAutoHidePanel.Height; // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)>ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite)) // height-=ownerBar.BottomDockSite.Height; height = ownerAutoHide.LeftAutoHidePanel.Height; width = m_LastDockSiteInfo.DockedWidth; if (width == 0) { int index = -1; if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem) index = this.SelectedDockTab; else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem) index = 0; if (index >= 0) width = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Width, ((DockContainerItem)this.Items[index]).Width); this.EnableRedraw = false; try { this.Size = new Size(width, height); this.RecalcSize(); } finally { this.EnableRedraw = true; } width = this.Width; m_LastDockSiteInfo.DockedWidth = width; } // if(!(ownerBar.TopDockSite.Parent is UserControl)) // { // x=ownerAutoHide.LeftAutoHidePanel.Right; // } // else // y+=ownerBar.TopDockSite.Top; break; } case DockStyle.Right: { // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)>ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite)) // { // height-=ownerBar.TopDockSite.Height; // y=ownerBar.TopDockSite.Bottom; // } // if(ownerAutoHide.HasBottomAutoHidePanel) // height-=ownerAutoHide.BottomAutoHidePanel.Height; // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)>ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite)) // height-=ownerBar.BottomDockSite.Height; height = ownerAutoHide.RightAutoHidePanel.Height; width = m_LastDockSiteInfo.DockedWidth; if (width == 0) { int index = -1; if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem) index = this.SelectedDockTab; else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem) index = 0; if (index >= 0) width = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Width, ((DockContainerItem)this.Items[index]).Width); this.EnableRedraw = false; try { this.Size = new Size(width, height); this.RecalcSize(); } finally { this.EnableRedraw = true; } width = this.Width; m_LastDockSiteInfo.DockedWidth = width; } // if(!(ownerBar.TopDockSite.Parent is UserControl)) // x=ownerAutoHide.RightAutoHidePanel.Left-width; // else // { x -= width; //y+=ownerBar.TopDockSite.Top; //} break; } case DockStyle.Top: { // if(ownerAutoHide.HasLeftAutoHidePanel) // { // width-=ownerAutoHide.LeftAutoHidePanel.Width; // x+=ownerAutoHide.LeftAutoHidePanel.Width; // } // if(ownerAutoHide.HasRightAutoHidePanel) // { // width-=ownerAutoHide.RightAutoHidePanel.Width; // } // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)<ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite)) // { // width-=ownerBar.RightDockSite.Width; // } // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)<ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite)) // { // width-=ownerBar.LeftDockSite.Width; // x+=ownerBar.LeftDockSite.Width; // } width = ownerAutoHide.TopAutoHidePanel.Width; height = m_LastDockSiteInfo.DockedHeight; if (height == 0) { int index = -1; if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem) index = this.SelectedDockTab; else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem) index = 0; if (index >= 0) height = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Height, ((DockContainerItem)this.Items[index]).Height); this.EnableRedraw = false; try { this.Size = new Size(width, height); this.RecalcSize(); } finally { this.EnableRedraw = true; } height = this.Height; m_LastDockSiteInfo.DockedHeight = height; } // if(!(ownerBar.TopDockSite.Parent is UserControl)) // y=ownerAutoHide.TopAutoHidePanel.Bottom; break; } default: { // if(ownerAutoHide.HasLeftAutoHidePanel) // { // width-=ownerAutoHide.LeftAutoHidePanel.Width; // x+=ownerAutoHide.LeftAutoHidePanel.Width; // } // if(ownerAutoHide.HasRightAutoHidePanel) // width-=ownerAutoHide.RightAutoHidePanel.Width; // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)<ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite)) // { // width-=ownerBar.RightDockSite.Width; // } // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)<ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite)) // { // width-=ownerBar.LeftDockSite.Width; // x+=ownerBar.LeftDockSite.Width; // } width = ownerAutoHide.BottomAutoHidePanel.Width; height = m_LastDockSiteInfo.DockedHeight; if (height == 0) { int index = -1; if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem) index = this.SelectedDockTab; else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem) index = 0; if (index >= 0) height = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Height, ((DockContainerItem)this.Items[index]).Height); this.EnableRedraw = false; try { this.Size = new Size(width, height); this.RecalcSize(); } finally { this.EnableRedraw = true; } height = this.Height; m_LastDockSiteInfo.DockedHeight = height; if (m_TabDockItems != null) m_LastDockSiteInfo.DockedHeight += m_TabDockItems.Height; } y -= height; // if(!(ownerBar.TopDockSite.Parent is UserControl)) // y=ownerAutoHide.BottomAutoHidePanel.Top-height; // else if(this.Parent!=null) // { // Point p=ownerAutoHide.BottomAutoHidePanel.PointToScreen(Point.Empty); // p=this.Parent.PointToClient(p); // y=p.Y-height; // } break; } } Rectangle r = new Rectangle(x, y, width, height); AutoHideDisplayEventArgs eventArgs = new AutoHideDisplayEventArgs(r); if (AutoHideDisplay != null) { AutoHideDisplay(this, eventArgs); r = eventArgs.DisplayRectangle; } if (ownerBar != null) { ownerBar.InvokeAutoHideDisplay(this, eventArgs); r = eventArgs.DisplayRectangle; } this.Bounds = r; //this.Size=r.Size; //new Size(width,height); //this.Location=r.Location; //new Point(x,y); this.RecalcSize(); if (m_LastDockSiteInfo.DockSide == DockStyle.Bottom) { if (this.Height != height) this.Top += (height - this.Height); } else if (m_LastDockSiteInfo.DockSide == DockStyle.Right) { if (this.Width != width) this.Left += (width - this.Width); } }
void IOwnerBarSupport.InvokeAutoHideDisplay(Bar bar,AutoHideDisplayEventArgs e) { if(AutoHideDisplay!=null) AutoHideDisplay(bar,e); }