/// <summary> /// Estimates the docking position and size of a given bar for outline purposes during drag&drop /// </summary> /// <param name="bar">Bar to find estimated docking position and size for</param> /// <param name="pDockInfo">Docking information</param> /// <returns>Preview Rectangle in screen coordinates.</returns> internal Rectangle GetDockPreviewRectangle(Bar bar, ref DockSiteInfo dockInfo) { DocumentBaseContainer referenceDoc=GetDocumentFromBar(dockInfo.MouseOverBar); Rectangle r=Rectangle .Empty; // Handle edge case docking first if (m_Container.Dock!= DockStyle.Fill && (dockInfo.DockLine == 999 || dockInfo.DockLine == -1)) { return GetEdgeDockPreviewRectangle(bar, ref dockInfo); } else if(referenceDoc!=null) { if(dockInfo.MouseOverDockSide==eDockSide.Left) { r=referenceDoc.DisplayBounds; r.Width=r.Width/2; } else if(dockInfo.MouseOverDockSide==eDockSide.Right) { r=referenceDoc.DisplayBounds; r.X+=r.Width/2; r.Width=r.Width/2; } else if(dockInfo.MouseOverDockSide==eDockSide.Top) { r=referenceDoc.DisplayBounds; r.Height=r.Height/2; } else if(dockInfo.MouseOverDockSide==eDockSide.Bottom) { r=referenceDoc.DisplayBounds; r.Y+=r.Height/2; r.Height=r.Height/2; } else if(dockInfo.MouseOverDockSide==eDockSide.Document) { r=referenceDoc.DisplayBounds; } r.Location=m_Container.PointToScreen(r.Location); } else { if (m_Container.Dock == DockStyle.Fill) { r = m_Container.ClientRectangle; r.Location = m_Container.PointToScreen(r.Location); } else if (m_Container.Dock == DockStyle.Right) { r = m_Container.ClientRectangle; r.Location = m_Container.PointToScreen(r.Location); if (r.Width == 0) { r.Width = bar.GetBarDockedSize(eOrientation.Vertical); r.X -= r.Width; } } else if (m_Container.Dock == DockStyle.Left) { r = m_Container.ClientRectangle; r.Location = m_Container.PointToScreen(r.Location); if (r.Width == 0) { r.Width = bar.GetBarDockedSize(eOrientation.Vertical); } } else if (m_Container.Dock == DockStyle.Top) { r = m_Container.ClientRectangle; r.Location = m_Container.PointToScreen(r.Location); if (r.Height == 0) { r.Height = bar.GetBarDockedSize(eOrientation.Horizontal); } } else if (m_Container.Dock == DockStyle.Bottom) { r = m_Container.ClientRectangle; r.Location = m_Container.PointToScreen(r.Location); if (r.Height == 0) { r.Height = bar.GetBarDockedSize(eOrientation.Horizontal); r.Y -= r.Height; } } } return r; }
internal void SaveLastDockInfo(Bar bar, DocumentBarContainer doc, DockSiteInfo info) { if (bar.m_LastDockSiteInfo == null) return; //bar.m_LastDockSiteInfo.LastRelativeDockToBar = null; //bar.m_LastDockSiteInfo.LastRelativeDocumentId = -1; // Tries to find relative dock-to-bar so un-docked bar can be returned back if (!(doc.Parent is DocumentDockContainer)) return; DocumentDockContainer dockParent = (DocumentDockContainer)doc.Parent; DocumentBaseContainer nextBarDocument = GetNextDocument(dockParent, dockParent.Documents.IndexOf(doc)); if (nextBarDocument == null) { DocumentBaseContainer prevBarDocument = GetPreviousDocument(dockParent, dockParent.Documents.IndexOf(doc)); if (prevBarDocument != null) { Bar prevBar = null; if (prevBarDocument is DocumentBarContainer) { prevBar = ((DocumentBarContainer)prevBarDocument).Bar; bar.m_LastDockSiteInfo.LastRelativeDockToBar = prevBar; prevBar.m_LastDockSiteInfo.LastRelativeDockToBar = bar; prevBar.m_LastDockSiteInfo.LastRelativeDocumentId = doc.Id; } bar.m_LastDockSiteInfo.LastRelativeDocumentId = prevBarDocument.Id; if (dockParent.Orientation == eOrientation.Horizontal) { bar.LastDockSide = eDockSide.Right; if (prevBar != null) prevBar.LastDockSide = eDockSide.Left; } else { bar.LastDockSide = eDockSide.Bottom; if (prevBar != null) prevBar.LastDockSide = eDockSide.Top; } } } else { Bar nextBar = null; if (nextBarDocument is DocumentBarContainer) { nextBar = ((DocumentBarContainer)nextBarDocument).Bar; bar.m_LastDockSiteInfo.LastRelativeDockToBar = nextBar; nextBar.m_LastDockSiteInfo.LastRelativeDockToBar = bar; nextBar.m_LastDockSiteInfo.LastRelativeDocumentId = doc.Id; } bar.m_LastDockSiteInfo.LastRelativeDocumentId = nextBarDocument.Id; if (dockParent.Orientation == eOrientation.Horizontal) { bar.LastDockSide = eDockSide.Left; if (nextBar != null) nextBar.LastDockSide = eDockSide.Right; } else { bar.LastDockSide = eDockSide.Top; if (nextBar != null) nextBar.LastDockSide = eDockSide.Bottom; } } if (GetDockSide(bar) != eDockSide.None) bar.m_LastDockSiteInfo.LastDockSiteSide = GetDockSide(bar); }
public Rectangle GetBarDockRectangle(Bar bar, ref DockSiteInfo pDockInfo) { if(pDockInfo.objDockSite==null) return Rectangle.Empty; if(pDockInfo.objDockSite.Dock==DockStyle.Fill || m_DocumentDockContainer!=null) { DocumentDockUIManager m_UIManager=GetDocumentUIManager(); return m_UIManager.GetDockPreviewRectangle(bar,ref pDockInfo); } Rectangle r=Rectangle.Empty; if(pDockInfo.InsertPosition<0 && pDockInfo.NewLine) pDockInfo.DockLine=-1; else if(pDockInfo.InsertPosition>=this.Controls.Count && pDockInfo.NewLine) pDockInfo.DockLine=999; if(pDockInfo.TabDockContainer!=null) { r=pDockInfo.TabDockContainer.Bounds; r.Location=this.PointToScreen(r.Location); } else if(pDockInfo.DockLine==999 || pDockInfo.DockLine==-1) // Handle the edge cases { int fullSizeIndex=-1; int partialSizeIndex=-1; if(pDockInfo.FullSizeDock) fullSizeIndex=this.GetFullSizeIndex(); else if(pDockInfo.PartialSizeDock) partialSizeIndex=this.GetPartialSizeIndex(); // Docks the bar to the edge switch(this.Dock) { case DockStyle.Top: { r.Width=this.ClientRectangle.Width; r.Height=bar.GetBarDockedSize(eOrientation.Horizontal); if(fullSizeIndex>=0) { r.Width+=GetSiteZOrderSize(m_Owner.LeftDockSite,true).Width; r.Width+=GetSiteZOrderSize(m_Owner.RightDockSite,true).Width; pDockInfo.DockSiteZOrderIndex=fullSizeIndex; } else if(partialSizeIndex>=0) { // Reduce by the size of the left and right dock site r.Width-=GetSiteZOrderSize(m_Owner.LeftDockSite,false).Width; r.Width-=GetSiteZOrderSize(m_Owner.RightDockSite,false).Width; pDockInfo.DockSiteZOrderIndex=partialSizeIndex; } Point p=Point.Empty; if(pDockInfo.DockLine==-1) { p=this.PointToScreen(this.ClientRectangle.Location); } else { p=this.PointToScreen(new Point(this.ClientRectangle.X,this.ClientRectangle.Bottom)); p.Y++; } if(fullSizeIndex>=0) p.X-=GetSiteZOrderSize(m_Owner.LeftDockSite,true).Width; else if(partialSizeIndex>=0) p.X+=GetSiteZOrderSize(m_Owner.LeftDockSite,false).Width; r.Location=p; break; } case DockStyle.Bottom: { r.Width=this.ClientRectangle.Width; r.Height=bar.GetBarDockedSize(eOrientation.Horizontal); if(fullSizeIndex>=0) { r.Width+=GetSiteZOrderSize(m_Owner.LeftDockSite,true).Width; r.Width+=GetSiteZOrderSize(m_Owner.RightDockSite,true).Width; pDockInfo.DockSiteZOrderIndex=fullSizeIndex; } else if(partialSizeIndex>=0) { // Reduce by the size of the left and right dock site r.Width-=GetSiteZOrderSize(m_Owner.LeftDockSite,false).Width; r.Width-=GetSiteZOrderSize(m_Owner.RightDockSite,false).Width; pDockInfo.DockSiteZOrderIndex=partialSizeIndex; } Point p=Point.Empty; if(pDockInfo.DockLine==-1) { p=this.PointToScreen(new Point(this.ClientRectangle.X,this.ClientRectangle.Y-r.Height)); } else { p=this.PointToScreen(new Point(this.ClientRectangle.X,this.ClientRectangle.Bottom-r.Height)); p.Y++; } if(fullSizeIndex>=0) p.X-=GetSiteZOrderSize(m_Owner.LeftDockSite,true).Width; else if(partialSizeIndex>=0) p.X+=GetSiteZOrderSize(m_Owner.LeftDockSite,false).Width; r.Location=p; break; } case DockStyle.Right: { r.Height=this.ClientRectangle.Height; if(fullSizeIndex>=0) { r.Height+=GetSiteZOrderSize(m_Owner.TopDockSite,true).Height; r.Height+=GetSiteZOrderSize(m_Owner.BottomDockSite,true).Height; pDockInfo.DockSiteZOrderIndex=fullSizeIndex; } else if(partialSizeIndex>=0) { // Reduce by the size of the top and bottom dock site r.Height-=GetSiteZOrderSize(m_Owner.TopDockSite,false).Height; r.Height-=GetSiteZOrderSize(m_Owner.BottomDockSite,false).Height; pDockInfo.DockSiteZOrderIndex=partialSizeIndex; } r.Width=bar.GetBarDockedSize(eOrientation.Vertical); Point p=Point.Empty; if (pDockInfo.DockLine == -1) { p=this.PointToScreen(new Point(this.ClientRectangle.X-r.Width,this.ClientRectangle.Y)); } else { p=this.PointToScreen(new Point(this.ClientRectangle.Right-r.Width,this.ClientRectangle.Y)); p.X--; } if(fullSizeIndex>=0) p.Y-=GetSiteZOrderSize(m_Owner.TopDockSite,true).Height; else if(partialSizeIndex>=0) p.Y+=GetSiteZOrderSize(m_Owner.TopDockSite,false).Height; r.Location=p; break; } default: { r.Height=this.ClientRectangle.Height; if(fullSizeIndex>=0) { r.Height+=GetSiteZOrderSize(m_Owner.TopDockSite,true).Height; r.Height+=GetSiteZOrderSize(m_Owner.BottomDockSite,true).Height; pDockInfo.DockSiteZOrderIndex=fullSizeIndex; } else if(partialSizeIndex>=0) { // Reduce by the size of the top and bottom dock site r.Height-=GetSiteZOrderSize(m_Owner.TopDockSite,false).Height; r.Height-=GetSiteZOrderSize(m_Owner.BottomDockSite,false).Height; pDockInfo.DockSiteZOrderIndex=partialSizeIndex; } r.Width=bar.GetBarDockedSize(eOrientation.Vertical); Point p=Point.Empty; if(pDockInfo.DockLine==-1) { p=this.PointToScreen(new Point(this.ClientRectangle.X,this.ClientRectangle.Y)); } else { p=this.PointToScreen(new Point(this.ClientRectangle.Right,this.ClientRectangle.Y)); p.X++; } if(fullSizeIndex>=0) p.Y-=GetSiteZOrderSize(m_Owner.TopDockSite,true).Height; else if(partialSizeIndex>=0) p.Y+=GetSiteZOrderSize(m_Owner.TopDockSite,false).Height; r.Location=p; break; } } } else { Bar barInsertPos=null; if(pDockInfo.InsertPosition>=0 && pDockInfo.InsertPosition<this.Controls.Count) { barInsertPos=this.Controls[pDockInfo.InsertPosition] as Bar; if(!pDockInfo.NewLine) { // Docking on the same line the DockLine should match if(barInsertPos.DockLine>pDockInfo.DockLine) { int ipos=pDockInfo.InsertPosition-1; while(ipos>=0) { Bar b=this.Controls[ipos] as Bar; if(b!=null && b.LayoutType==eLayoutType.DockContainer && b.DockLine==pDockInfo.DockLine) { barInsertPos=b; break; } } } else if(barInsertPos.DockLine<pDockInfo.DockLine) { int ipos=pDockInfo.InsertPosition+1; while(ipos<this.Controls.Count) { Bar b=this.Controls[ipos] as Bar; if(b!=null && b.LayoutType==eLayoutType.DockContainer && b.DockLine==pDockInfo.DockLine) { barInsertPos=b; break; } } } } } else if(pDockInfo.InsertPosition<0) barInsertPos=this.Controls[0] as Bar; else if(pDockInfo.InsertPosition>=this.Controls.Count) barInsertPos=this.Controls[this.Controls.Count-1] as Bar; int i=pDockInfo.InsertPosition+1; while(i<this.Controls.Count && (bar==null || barInsertPos.LayoutType!=eLayoutType.DockContainer || !barInsertPos.Visible)) { barInsertPos=this.Controls[i] as Bar; i++; } if(barInsertPos==null) return r; // Docks the bar to the edge switch(this.Dock) { case DockStyle.Top: case DockStyle.Bottom: { r.Height=bar.GetBarDockedSize(eOrientation.Horizontal); if(pDockInfo.NewLine || barInsertPos==bar) { r.Width=barInsertPos.Width; if(r.Width==0) r.Width=this.Width; Point p=this.PointToScreen(new Point(barInsertPos.Left,barInsertPos.Top)); r.Location=p; } else { if(barInsertPos.DockOffset>pDockInfo.DockOffset) { // Left half r.Height=barInsertPos.Height; r.Width=barInsertPos.Width/2; Point p=this.PointToScreen(new Point(barInsertPos.Left,barInsertPos.Top)); r.Location=p; } else { // Split Right Half r.Height=barInsertPos.Height; r.Width=barInsertPos.Width/2; Point p=this.PointToScreen(new Point(barInsertPos.Left+r.Width,barInsertPos.Top)); r.Location=p; } } break; } default: // Covers both Right and Left { r.Width=bar.GetBarDockedSize(eOrientation.Vertical); if(pDockInfo.NewLine || barInsertPos==bar) { r.Height=barInsertPos.Height; Point p=this.PointToScreen(new Point(barInsertPos.Left,barInsertPos.Top)); r.Location=p; } else { if(barInsertPos.DockOffset<pDockInfo.DockOffset) { // Bottom half r.Width=barInsertPos.Width; r.Height=barInsertPos.Height/2; Point p=this.PointToScreen(new Point(barInsertPos.Left,barInsertPos.Top+r.Height)); r.Location=p; } else { // Split Top Half r.Width=barInsertPos.Width; r.Height=barInsertPos.Height/2; Point p=this.PointToScreen(new Point(barInsertPos.Left,barInsertPos.Top)); r.Location=p; } } break; } } } return r; }
private Rectangle GetEdgeDockPreviewRectangle(Bar bar, ref DockSiteInfo dockInfo) { Rectangle r = Rectangle.Empty; int fullSizeIndex = -1; int partialSizeIndex = -1; if (dockInfo.FullSizeDock) fullSizeIndex = m_Container.GetFullSizeIndex(); else if (dockInfo.PartialSizeDock) partialSizeIndex = m_Container.GetPartialSizeIndex(); // Docks the bar to the edge switch (m_Container.Dock) { case DockStyle.Top: { r.Width = m_Container.ClientRectangle.Width; r.Height = bar.GetBarDockedSize(eOrientation.Horizontal); if (fullSizeIndex >= 0) { r.Width += m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, true).Width; r.Width += m_Container.GetSiteZOrderSize(m_Container.Owner.RightDockSite, true).Width; dockInfo.DockSiteZOrderIndex = fullSizeIndex; } else if (partialSizeIndex >= 0) { // Reduce by the size of the left and right dock site r.Width -= m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, false).Width; r.Width -= m_Container.GetSiteZOrderSize(m_Container.Owner.RightDockSite, false).Width; dockInfo.DockSiteZOrderIndex = partialSizeIndex; } Point p = Point.Empty; if (dockInfo.DockLine == -1) { p = m_Container.PointToScreen(m_Container.ClientRectangle.Location); } else { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.X, m_Container.ClientRectangle.Bottom)); p.Y++; } if (fullSizeIndex >= 0) p.X -= m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, true).Width; else if (partialSizeIndex >= 0) p.X += m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, false).Width; r.Location = p; break; } case DockStyle.Bottom: { r.Width = m_Container.ClientRectangle.Width; r.Height = bar.GetBarDockedSize(eOrientation.Horizontal); if (fullSizeIndex >= 0) { r.Width += m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, true).Width; r.Width += m_Container.GetSiteZOrderSize(m_Container.Owner.RightDockSite, true).Width; dockInfo.DockSiteZOrderIndex = fullSizeIndex; } else if (partialSizeIndex >= 0) { // Reduce by the size of the left and right dock site r.Width -= m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, false).Width; r.Width -= m_Container.GetSiteZOrderSize(m_Container.Owner.RightDockSite, false).Width; dockInfo.DockSiteZOrderIndex = partialSizeIndex; } Point p = Point.Empty; if (dockInfo.DockLine == -1) { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.X, m_Container.ClientRectangle.Y - r.Height)); } else { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.X, m_Container.ClientRectangle.Bottom - r.Height)); p.Y++; } if (fullSizeIndex >= 0) p.X -= m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, true).Width; else if (partialSizeIndex >= 0) p.X += m_Container.GetSiteZOrderSize(m_Container.Owner.LeftDockSite, false).Width; r.Location = p; break; } case DockStyle.Right: { r.Height = m_Container.ClientRectangle.Height; if (fullSizeIndex >= 0) { r.Height += m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, true).Height; r.Height += m_Container.GetSiteZOrderSize(m_Container.Owner.BottomDockSite, true).Height; dockInfo.DockSiteZOrderIndex = fullSizeIndex; } else if (partialSizeIndex >= 0) { // Reduce by the size of the top and bottom dock site r.Height -= m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, false).Height; r.Height -= m_Container.GetSiteZOrderSize(m_Container.Owner.BottomDockSite, false).Height; dockInfo.DockSiteZOrderIndex = partialSizeIndex; } r.Width = bar.GetBarDockedSize(eOrientation.Vertical); Point p = Point.Empty; if (dockInfo.DockLine == -1) { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.X - r.Width, m_Container.ClientRectangle.Y)); } else { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.Right - r.Width, m_Container.ClientRectangle.Y)); p.X--; } if (fullSizeIndex >= 0) p.Y -= m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, true).Height; else if (partialSizeIndex >= 0) p.Y += m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, false).Height; r.Location = p; break; } default: { r.Height = m_Container.ClientRectangle.Height; if (fullSizeIndex >= 0) { r.Height += m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, true).Height; r.Height += m_Container.GetSiteZOrderSize(m_Container.Owner.BottomDockSite, true).Height; dockInfo.DockSiteZOrderIndex = fullSizeIndex; } else if (partialSizeIndex >= 0) { // Reduce by the size of the top and bottom dock site r.Height -= m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, false).Height; r.Height -= m_Container.GetSiteZOrderSize(m_Container.Owner.BottomDockSite, false).Height; dockInfo.DockSiteZOrderIndex = partialSizeIndex; } r.Width = bar.GetBarDockedSize(eOrientation.Vertical); Point p = Point.Empty; if (dockInfo.DockLine == -1) { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.X, m_Container.ClientRectangle.Y)); } else { p = m_Container.PointToScreen(new Point(m_Container.ClientRectangle.Right, m_Container.ClientRectangle.Y)); p.X++; } if (fullSizeIndex >= 0) p.Y -= m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, true).Height; else if (partialSizeIndex >= 0) p.Y += m_Container.GetSiteZOrderSize(m_Container.Owner.TopDockSite, false).Height; r.Location = p; break; } } return r; }
protected override void OnMouseDragEnd(bool cancel) { if(!this.IsDockableWindow) { base.OnMouseDragEnd(cancel); return; } this.Control.Capture = false; Cursor.Clip = Rectangle.Empty; Bar bar=this.Control as Bar; if(cancel || bar==null || !m_DragDrop) { base.OnMouseDragEnd(cancel); return; } m_DragDrop=false; IDesignerHost designerHost=this.GetService(typeof(IDesignerHost)) as IDesignerHost; if(designerHost==null) { EndBarOwnerDocking(bar); m_IsDocking=false; m_MouseDownSelectedTabIndex=-1; base.OnMouseDragEnd(cancel); return; } if(m_IsDocking) { EndBarOwnerDocking(bar); // Moves and docks the selected DockContainerItem or bar Bar referenceBar=m_DockInfo.MouseOverBar; if(m_DockInfo.MouseOverDockSide!=eDockSide.None && m_DockInfo.MouseOverDockSide!=eDockSide.Document && (referenceBar!=bar || m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1)) { DesignerTransaction trans=designerHost.CreateTransaction("DotNetBar Docking"); IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService)); try { Bar newBar=null; if(m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1) newBar=BarFunctions.CreateDuplicateDockBar(bar,this); else newBar=bar; cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"]); if(m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1) { DockContainerItem item=bar.Items[bar.SelectedDockTab] as DockContainerItem; cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]); cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]); bar.Items.Remove(item); cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null); cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null); cc.OnComponentChanging(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]); cc.OnComponentChanging(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]); newBar.Items.Add(item); cc.OnComponentChanged(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null); cc.OnComponentChanged(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null); } cc.OnComponentChanging(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["Controls"]); cc.OnComponentChanging(newBar,null); cc.OnComponentChanging(referenceBar,null); cc.OnComponentChanging(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"]); m_DockInfo.objDockSite.GetDocumentUIManager().Dock(referenceBar,newBar,m_DockInfo.MouseOverDockSide); cc.OnComponentChanged(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"],null,null); cc.OnComponentChanged(referenceBar,null,null,null); cc.OnComponentChanged(newBar,null,null,null); cc.OnComponentChanged(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["Controls"],null,null); } catch { trans.Cancel(); throw; } finally { if(!trans.Canceled) trans.Commit(); } } else if(m_DockInfo.MouseOverDockSide==eDockSide.Document && bar!=referenceBar) { BarDesigner referenceDesigner=designerHost.GetDesigner(referenceBar) as BarDesigner; if(referenceDesigner!=null) referenceDesigner.DelayedDockTabs(bar,m_MouseDownSelectedTabIndex); } m_DockInfo=new DockSiteInfo(); } else if(m_MouseDownSelectedTabIndex!=-1) { if(m_MouseDownSelectedTabIndex!=bar.SelectedDockTab) { IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService)); if(cc!=null) { cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null); cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"],null,null); cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null); } } } m_IsDocking=false; m_MouseDownSelectedTabIndex=-1; base.OnMouseDragEnd(cancel); }
private DockSiteInfo GetDockSiteInfoV(IDockInfo pDock, int x, int y) { DockSiteInfo pInfo=new DockSiteInfo(); Rectangle thisRect=new Rectangle(this.PointToScreen(new Point(0,0)),this.Size); Point pInsertionPoint=this.PointToClient(new Point(x,y)); Control objCtrlToDock=pDock as Control; System.Drawing.Size objDockSize=pDock.PreferredDockSize(m_DockOrientation); if(this.Height==0) { thisRect.Height=10; if(this.Dock==System.Windows.Forms.DockStyle.Bottom) thisRect.Y-=10; } else if(this.Width==0) { thisRect.Width=10; if(this.Dock==System.Windows.Forms.DockStyle.Right) thisRect.X-=10; } // If mouse is not inside exit thisRect.Inflate(8,8); // m_DockMargin if(!thisRect.Contains(x,y) || pDock==null) return pInfo; bool bDockedHere=(pDock.DockedSite==this); int[] lineCount=new int[255]; int iMaxDockLine=0; int iDockLine=-10; bool bDocked=false; foreach(Control objCtrl in this.Controls) { if(!objCtrl.Visible) continue; IDockInfo pCtrlDockInfo=objCtrl as IDockInfo; lineCount[pCtrlDockInfo.DockLine]++; iMaxDockLine=pCtrlDockInfo.DockLine; } int iLockedDockLine=-1; for(int i=0;i<this.Controls.Count;i++) { Control objCtrl=this.Controls[i]; if(!objCtrl.Visible) continue; IDockInfo pCtrlDockInfo=objCtrl as IDockInfo; if(pInsertionPoint.X>objCtrl.Left+4 && ((pInsertionPoint.X<objCtrl.Left+objDockSize.Width-4 && objDockSize.Width<=objCtrl.Width) || pInsertionPoint.X<objCtrl.Right-4 && objDockSize.Width>objCtrl.Width)) { if(pCtrlDockInfo.Stretch && objCtrl!=objCtrlToDock) { if(objCtrl is Bar && objCtrlToDock is Bar && ((Bar)objCtrl).LayoutType==eLayoutType.DockContainer && ((Bar)objCtrlToDock).LayoutType==eLayoutType.DockContainer && ((Bar)objCtrl).CanTearOffTabs) { if(!objCtrl.Bounds.Contains(pInsertionPoint)) continue; iDockLine=pCtrlDockInfo.DockLine; if(((Bar)objCtrl).IsPositionOnDockTab(x,y)) { pInfo.DockLine=pCtrlDockInfo.DockLine; pInfo.DockOffset=pCtrlDockInfo.DockOffset; pInfo.InsertPosition=i; pInfo.objDockSite=this; pInfo.DockSide=this.Dock; pInfo.TabDockContainer=objCtrl as Bar; return pInfo; } } else { iDockLine=pCtrlDockInfo.DockLine-1; } } else { iDockLine=pCtrlDockInfo.DockLine; } break; } else if(objCtrl==objCtrlToDock && pInsertionPoint.X<=objCtrl.Left+4 && pInsertionPoint.X>objCtrl.Left && lineCount[pCtrlDockInfo.DockLine]>1) { int iInsertPosition=i; for(int iInsertIndex=i-1;iInsertIndex>=0;iInsertIndex--) { if(((IDockInfo)this.Controls[iInsertIndex]).DockLine==pDock.DockLine) iInsertPosition=iInsertIndex; else break; } pInfo.DockLine=pDock.DockLine; pInfo.DockOffset=pDock.DockOffset; pInfo.InsertPosition=iInsertPosition; pInfo.objDockSite=this; pInfo.DockSide=this.Dock; pInfo.NewLine=true; return pInfo; } else if(this.Dock==DockStyle.Left && objCtrl==objCtrlToDock && pInsertionPoint.X>=objCtrl.Right-4 && pInsertionPoint.X<objCtrl.Right && lineCount[pCtrlDockInfo.DockLine]==1 && pDock.DockLine!=iMaxDockLine) { int iInsertPosition=i; for(int iInsertIndex=i+1;iInsertIndex<this.Controls.Count;iInsertIndex++) { if(((IDockInfo)this.Controls[iInsertIndex]).DockLine==pDock.DockLine+1 && (((IDockInfo)this.Controls[iInsertIndex]).DockOffset<=pDock.DockOffset || pDock.Stretch) || ((IDockInfo)this.Controls[iInsertIndex]).DockLine==pDock.DockLine) iInsertPosition=iInsertIndex; else break; } pInfo.DockLine=pDock.DockLine+1; pInfo.DockOffset=pDock.DockOffset; pInfo.InsertPosition=iInsertPosition; pInfo.objDockSite=this; pInfo.DockSide=this.Dock; return pInfo; } } if(iDockLine==-10) { if(pInsertionPoint.X<=-5 && !(bDockedHere && pDock.DockLine==0 && lineCount[0]==1)) { iDockLine=-1; } else if(!bDockedHere) { if(pInsertionPoint.X>this.Width) iDockLine=iMaxDockLine+1; else iDockLine=iMaxDockLine; } else if(pInsertionPoint.X>this.Width+4 && !(bDockedHere && pDock.DockLine==iMaxDockLine && lineCount[iMaxDockLine]==1)) { iDockLine=iMaxDockLine+1; } if(iDockLine==-10) { pInfo.DockLine=pDock.DockLine; pInfo.DockOffset=pDock.DockOffset; pInfo.InsertPosition=this.Controls.GetChildIndex(objCtrlToDock); pInfo.objDockSite=this; pInfo.DockSide=this.Dock; return pInfo; } } if(iLockedDockLine!=-1) { if(this.Dock==DockStyle.Top && iDockLine<=iLockedDockLine) iDockLine=iLockedDockLine+1; else if(this.Dock==DockStyle.Bottom && iDockLine>=iLockedDockLine) iDockLine=iLockedDockLine-1; } // We have the docking line now, find right Docking offset for object to dock // First get the index of the docking line, default is at the end int iIndex=this.Controls.Count; for(int i=0;i<this.Controls.Count;i++) { Control objCtrl=this.Controls[i]; if(!objCtrl.Visible) continue; IDockInfo pCtrlDockInfo=objCtrl as IDockInfo; if(pCtrlDockInfo.DockLine>=iDockLine) { iIndex=i; break; } } // Find the right insertion point based on X coordinate for(int i=iIndex;i<this.Controls.Count;i++) { Control objCtrl=this.Controls[i]; if(!objCtrl.Visible) continue; IDockInfo pCtrlDockInfo=objCtrl as IDockInfo; if(pCtrlDockInfo.DockLine>iDockLine) { pInfo.InsertPosition=i; if(bDockedHere && i>0 && this.Controls.GetChildIndex(objCtrlToDock)<i) pInfo.InsertPosition=i-1; if(pInsertionPoint.Y+objDockSize.Height>this.Height) pInfo.DockOffset=this.Height-objDockSize.Height; else pInfo.DockOffset=pInsertionPoint.Y; pInfo.DockLine=iDockLine; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; bDocked=true; break; } if(objCtrl.Bounds.Contains(pInsertionPoint)) { if(objCtrl!=objCtrlToDock) { if(pInsertionPoint.Y>=objCtrl.Top && pInsertionPoint.Y<=objCtrl.Top+10) { // This is right position, insert before docked control pInfo.InsertPosition=i; if(bDockedHere && i>0 && this.Controls.GetChildIndex(objCtrlToDock)<i) pInfo.InsertPosition=i-1; pInfo.DockOffset=0; pInfo.DockLine=iDockLine; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; } else { // Insert after docked control int iTmp=getDockLineHeight(i,iDockLine,false); if(iTmp+objDockSize.Height>=this.Height || pInsertionPoint.Y<iTmp) pInfo.DockOffset=objCtrl.Bottom; else pInfo.DockOffset=pInsertionPoint.Y; pInfo.InsertPosition=i+1; if(pDock.Stretch) { //if(iDockLine<iMaxDockLine) // iDockLine++; pInfo.DockOffset=pDock.DockOffset; } if(bDockedHere && i>0 && this.Controls.GetChildIndex(objCtrlToDock)<i) pInfo.InsertPosition=i; pInfo.DockLine=iDockLine; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; } } else { // This just tries to move control to the right, insertion point is over the object that needs to be docked pInfo.InsertPosition=i; pInfo.DockLine=iDockLine; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; int iTmp=getDockLineHeight(i+1,pDock.DockLine,true); if(iTmp+objDockSize.Height+pInsertionPoint.Y>=this.Height) pInfo.DockOffset=this.Height-iTmp-objDockSize.Height; else pInfo.DockOffset=pInsertionPoint.Y; if(pInfo.DockOffset<0) pInfo.DockOffset=0; } bDocked=true; break; } else if(pInsertionPoint.Y<objCtrl.Top || pInsertionPoint.X<objCtrl.Left && iLockedDockLine<0) { // Dock it before this control, insertion point is in empty space before docked control pInfo.InsertPosition=i; if(bDockedHere && i>0 && this.Controls.GetChildIndex(objCtrlToDock)<i) pInfo.InsertPosition=i-1; if(pDock.Stretch) pInfo.DockOffset=pDock.DockOffset; else pInfo.DockOffset=pInsertionPoint.Y; pInfo.DockLine=iDockLine; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; bDocked=true; break; } } if(!bDocked) { // Add it to the end if(iDockLine>=0) { if(bDockedHere) pInfo.InsertPosition=this.Controls.Count-1; else pInfo.InsertPosition=this.Controls.Count; } else pInfo.InsertPosition=0; if(pInsertionPoint.Y+objDockSize.Height>this.Height) pInfo.DockOffset=this.Height-objDockSize.Height; else pInfo.DockOffset=pInsertionPoint.Y; if(iDockLine>=0) { pInfo.DockLine=iDockLine; } else pInfo.DockLine=-1; pInfo.DockSide=this.Dock; pInfo.objDockSite=this; } // Snap it to the left if(pInfo.DockOffset<10) pInfo.DockOffset=0; if(m_DockOrientation==eOrientation.Horizontal) { if(objDockSize.Width>this.Width) pInfo.DockedWidth=this.Width; else pInfo.DockedWidth=objDockSize.Width; pInfo.DockedHeight=objDockSize.Height; } else { if(objDockSize.Height>this.Height) pInfo.DockedHeight=this.Height; else pInfo.DockedHeight=objDockSize.Height; pInfo.DockedWidth=objDockSize.Width; } return pInfo; }
public BarDesigner():base() { m_DockInfo=new DockSiteInfo(); this.EnableItemDragDrop=true; }
protected override void OnMouseDragMove(int x, int y) { if(!this.IsDockableWindow || !m_DragDrop) { base.OnMouseDragMove(x,y); return; } Point screenPos=new Point(x,y); Bar bar=this.Control as Bar; if(bar==null) return; Point tabPos=bar.DockTabControl.PointToClient(screenPos); if(bar.DockTabControl!=null && bar.DockTabControl.ClientRectangle.Contains(tabPos)) { if(m_IsDocking) { EndBarOwnerDocking(bar); m_IsDocking=false; m_DockInfo=new DockSiteInfo(); } MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,tabPos.X,tabPos.Y,0); bar.DockTabControl.InternalOnMouseMove(e); } else { m_IsDocking=true; IOwnerBarSupport ownerDock=bar.Owner as IOwnerBarSupport; m_DockInfo=ownerDock.GetDockInfo(bar,screenPos.X,screenPos.Y); if(m_DockInfo.objDockSite==null) { if(m_OutlineForm!=null) m_OutlineForm.Hide(); } else { Rectangle r=m_DockInfo.objDockSite.GetBarDockRectangle(bar,ref m_DockInfo); if(!r.IsEmpty) { if(m_OutlineForm==null) m_OutlineForm=BarFunctions.CreateOutlineForm(); NativeFunctions.SetWindowPos(m_OutlineForm.Handle.ToInt32(),NativeFunctions.HWND_TOP,r.X,r.Y,r.Width,r.Height,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE); } else if(m_OutlineForm!=null) m_OutlineForm.Hide(); } } }
private void EndDocking(bool revertLast, Point mousePos) { if (this.Capture) this.Capture = false; this.Cursor = System.Windows.Forms.Cursors.Default; IOwnerBarSupport barsupport = this.Owner as IOwnerBarSupport; if (barsupport != null) barsupport.DockComplete(); if (m_DragDockInfo.IsEmpty()) { m_MoveWindow = false; return; } if (m_TempTabBar != null || m_DragDockInfo.TabDockContainer != null) { DisposeDockingPreview(); Bar targetBar = m_TempTabBar; if (targetBar == null) targetBar = m_DragDockInfo.TabDockContainer; RemoveTempTabBarItems(); if (m_DragDockInfo.TabDockContainer != this) { if (m_DockTabTearOffIndex == -1) { System.Collections.ArrayList list = new System.Collections.ArrayList(m_ItemContainer.SubItems.Count); m_ItemContainer.SubItems.CopyTo(list); DockContainerItem firstItem = null; Form f = targetBar.FindForm(); if (f != null) f.ActiveControl = targetBar; foreach (BaseItem item in list) { DockContainerItem dockitem = item as DockContainerItem; if (dockitem != null) { if (firstItem == null) firstItem = dockitem; dockitem.Displayed = false; if (dockitem.OriginalBarName == "") { dockitem.OriginalBarName = this.Name; dockitem.OriginalPosition = m_ItemContainer.SubItems.IndexOf(dockitem); } m_ItemContainer.SubItems.Remove(dockitem); targetBar.Items.Add(dockitem); } } targetBar.RecalcLayout(); if (firstItem != null) { targetBar.SelectedDockContainerItem = firstItem; //if (f != null && firstItem.Control!=null) f.ActiveControl = firstItem.Control; } targetBar.InvokeBarDockEvents(); DotNetBarManager manager = m_Owner as DotNetBarManager; if (manager != null) { m_MoveWindow = false; targetBar = null; if (this.CustomBar) { manager.Bars.Remove(this); this.Dispose(); } else { this.Visible = false; } if (manager.ParentForm != null) manager.ParentForm.Activate(); return; } } else { Form f = targetBar.FindForm(); if (f != null) f.ActiveControl = targetBar; DockContainerItem dockitem = m_ItemContainer.SubItems[m_DockTabTearOffIndex] as DockContainerItem; dockitem.Displayed = false; m_ItemContainer.SubItems.Remove(dockitem); targetBar.Items.Add(dockitem); targetBar.SelectedDockContainerItem = dockitem; targetBar.RecalcLayout(); //if (f != null && dockitem.Control != null) f.ActiveControl = dockitem.Control; targetBar.InvokeBarDockEvents(); } } m_TempTabBar = null; m_DockTabTearOffIndex = -1; m_MoveWindow = false; m_DragDockInfo = new DockSiteInfo(); return; } if (m_DockTabTearOffIndex != -1) { DisposeDockingPreview(); if (revertLast) DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y))); else { DockContainerItem dc = (DockContainerItem)this.Items[m_DockTabTearOffIndex]; Bar bar = TearOffDockContainerItem(dc, false); bar.DockingHandler(m_DragDockInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y))); Form f = this.FindForm(); if (f != null && dc != null && dc.Control != null) { f.ActiveControl = dc.Control; } } m_DragDockInfo = new DockSiteInfo(); m_DockTabTearOffIndex = -1; } else { if (!m_OldOutlineRectangle.IsEmpty || m_OutlineForm != null) { DisposeDockingPreview(); if (revertLast) { if (this.LayoutType == eLayoutType.Toolbar) DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y))); } else DockingHandler(m_DragDockInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y))); m_DragDockInfo = new DockSiteInfo(); } else if (revertLast) { DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y))); m_DragDockInfo = new DockSiteInfo(); } } m_MoveWindow = false; }
private void AutoHideStateChanged() { IOwner owner = m_Owner as IOwner; IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport; if (owner == null) return; Control parentControl = GetOwnerControl(); if (parentControl == null) return; if (m_AutoHideState) { if (m_BarState == eBarState.AutoHide) return; if (m_TabDockItems != null) m_TabDockItems.Visible = false; // Remember last docking info DockSiteInfo tempInfo = m_LastDockSiteInfo; m_LastDockSiteInfo = new DockSiteInfo(); // Preserve the relative last docked to bar in case the return to same docking position is needed m_LastDockSiteInfo.LastRelativeDocumentId = tempInfo.LastRelativeDocumentId; m_LastDockSiteInfo.LastRelativeDockToBar = tempInfo.LastRelativeDockToBar; if (!m_BarDefinitionLoading) { if (this.Height > 0) m_LastDockSiteInfo.DockedHeight = this.Height; else if (m_ItemContainer != null && m_ItemContainer.MinHeight > 0) m_LastDockSiteInfo.DockedHeight = m_ItemContainer.MinHeight + 22; if (this.Width > 0) m_LastDockSiteInfo.DockedWidth = this.Width; else if (m_ItemContainer != null && m_ItemContainer.MinWidth > 0) m_LastDockSiteInfo.DockedWidth = m_ItemContainer.MinWidth + 22; // This will force proper recalculation in SetAutoHideSize procedure System.Drawing.Size minSize = GetLargestMinSize(); if (minSize.Width > m_LastDockSiteInfo.DockedWidth) m_LastDockSiteInfo.DockedWidth = 0; if (minSize.Height > m_LastDockSiteInfo.DockedHeight) m_LastDockSiteInfo.DockedHeight = 0; } m_LastDockSiteInfo.DockLine = this.DockLine; m_LastDockSiteInfo.DockOffset = this.DockOffset; if (this.Parent != null && m_BarState == eBarState.Docked) m_LastDockSiteInfo.DockSide = this.Parent.Dock; else m_LastDockSiteInfo.DockSide = DockStyle.Left; if (this.Parent != null && this.Parent is DockSite) { m_LastDockSiteInfo.InsertPosition = ((DockSite)this.Parent).Controls.GetChildIndex(this); m_LastDockSiteInfo.objDockSite = (DockSite)this.DockedSite; } // Undock the window m_BarState = eBarState.AutoHide; ResetActiveControl(); parentControl.SuspendLayout(); try { // Check for parent since if bar is deserialized there is no parent and state is Docked by default base.Visible = false; if (this.Parent != null && this.Parent is DockSite) { DockSite ds = this.Parent as DockSite; if (ds.DocumentDockContainer != null) { // Remember the split view docking if it was in effect if (ds.Dock != DockStyle.Fill) { DocumentBarContainer dbr = ds.GetDocumentUIManager().GetDocumentFromBar(this) as DocumentBarContainer; if (dbr != null && dbr.Parent is DocumentDockContainer) { DocumentDockContainer ddc = dbr.Parent as DocumentDockContainer; if (ddc.Orientation == eOrientation.Horizontal && (ds.Dock == DockStyle.Top || ds.Dock == DockStyle.Bottom) || ddc.Orientation == eOrientation.Vertical && (ds.Dock == DockStyle.Left || ds.Dock == DockStyle.Right) && ddc.Documents.Count > 1) { for (int i = 0; i < ddc.Documents.Count; i++) { if (ddc.Documents[i] is DocumentBarContainer && ddc.Documents[i].Visible && ddc.Documents[i] != dbr) { m_LastDockSiteInfo.MouseOverBar = ((DocumentBarContainer)ddc.Documents[i]).Bar; if (i < ddc.Documents.IndexOf(dbr)) m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Left : eDockSide.Bottom); else m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Right : eDockSide.Top); break; } } } } } ds.GetDocumentUIManager().UnDock(this); } else ((DockSite)this.Parent).RemoveBar(this); } this.Parent = null; parentControl.Controls.Add(this); parentControl.Controls.SetChildIndex(this, 0); AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide); panel.AddBar(this); if (!m_BarDefinitionLoading) SetAutoHideSize(); if (!m_IgnoreAnimation && m_AutoHideAnimationTime != 0) this.Visible = true; } finally { parentControl.ResumeLayout(); } //this.RecalcSize(); if (!m_BarDefinitionLoading) { this.Update(); AnimateHide(); } } else { AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide); panel.RemoveBar(this); if (m_LastDockSiteInfo.objDockSite != null) { if (m_LastDockSiteInfo.MouseOverBar != null) { if (m_LastDockSiteInfo.objDockSite.GetDocumentUIManager() == null || m_LastDockSiteInfo.objDockSite.GetDocumentUIManager().GetDocumentFromBar(m_LastDockSiteInfo.MouseOverBar) == null) { m_LastDockSiteInfo.MouseOverBar = null; m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None; m_LastDockSiteInfo.NewLine = true; } } } else { m_LastDockSiteInfo.MouseOverBar = null; m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None; m_LastDockSiteInfo.NewLine = true; } //m_LastDockSiteInfo.NewLine = true; DockingHandler(m_LastDockSiteInfo, Point.Empty); if (!this.IsVisible) this.Visible = true; this.RefreshDockTab(true); this.ResizeDockTab(); m_ItemContainer.MinHeight = 0; m_ItemContainer.MinWidth = 0; } }
//private bool m_OutlineDrag=true; protected override void OnMouseMove(MouseEventArgs e) { if (m_InMouseMove) return; m_InMouseMove = true; // Start window dragging if (m_MoveWindow && m_BarState != eBarState.Popup && e.Button == System.Windows.Forms.MouseButtons.Left) { if (this.Cursor != System.Windows.Forms.Cursors.SizeAll) this.Cursor = System.Windows.Forms.Cursors.SizeAll; Point p = Control.MousePosition; Point p2 = this.PointToClient(p); IOwnerBarSupport ownerDock = m_Owner as IOwnerBarSupport; // Graceful exit if (ownerDock == null || Math.Abs(p2.X - m_MouseDownPt.X) <= 4 && Math.Abs(p2.Y - m_MouseDownPt.Y) <= 4) { base.OnMouseMove(e); m_InMouseMove = false; return; } DockSiteInfo pDockInfo = ownerDock.GetDockInfo(this, p.X, p.Y); if (pDockInfo.objDockSite == null && !m_CanUndock) { base.OnMouseMove(e); m_InMouseMove = false; return; } bool bPreview = true; if (!m_OldOutlineRectangle.IsEmpty) { NativeFunctions.DrawReversibleDesktopRect(m_OldOutlineRectangle, 3); m_OldOutlineRectangle = Rectangle.Empty; } if (pDockInfo.UseOutline && pDockInfo.objDockSite != null) { Rectangle r = pDockInfo.objDockSite.GetBarDockRectangle(this, ref pDockInfo); if (!r.IsEmpty) { bPreview = false; if (m_OutlineForm == null) m_OutlineForm = CreateOutlineForm(); NativeFunctions.SetWindowPos(m_OutlineForm.Handle, new IntPtr(NativeFunctions.HWND_TOP), r.X, r.Y, r.Width, r.Height, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE); } } if (bPreview && m_OutlineForm != null) { m_OutlineForm.Visible = false; } m_DragDockInfo = pDockInfo; if (bPreview) { //if(m_BarState==eBarState.Floating || this.LayoutType!=eLayoutType.DockContainer || pDockInfo.TabDockContainer!=null) DockingHandler(pDockInfo, p); } } else if (e.Button == System.Windows.Forms.MouseButtons.None) { if (m_BarState == eBarState.Floating) { if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && ((e.X <= 2 && e.Y <= 2) || (e.X >= this.Width - 4 && e.Y >= this.Height - 4))) this.Cursor = System.Windows.Forms.Cursors.SizeNWSE; else if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && ((e.X >= this.Width - 2 && e.Y <= 2) || (e.X <= 4 && e.Y >= this.Height - 4))) this.Cursor = System.Windows.Forms.Cursors.SizeNESW; else if (e.X >= 0 && e.X <= 2 || e.X >= this.Width - 3 && e.X <= this.Width) this.Cursor = System.Windows.Forms.Cursors.SizeWE; else if (e.Y >= 0 && e.Y <= 2 || e.Y >= this.Height - 3 && e.Y <= this.Height) this.Cursor = System.Windows.Forms.Cursors.SizeNS; else if (this.Cursor == System.Windows.Forms.Cursors.SizeWE || this.Cursor == System.Windows.Forms.Cursors.SizeNS || this.Cursor == System.Windows.Forms.Cursors.SizeNWSE || this.Cursor == System.Windows.Forms.Cursors.SizeNESW) this.Cursor = System.Windows.Forms.Cursors.Default; } //else if(m_BarState==eBarState.Docked && m_ItemContainer.LayoutType==eLayoutType.DockContainer && m_ItemContainer.Stretch) //{ // if((e.X<=2 && this.DockedSite.Dock==DockStyle.Right) || (e.X>=this.Width-2 && this.DockedSite.Dock==DockStyle.Left)) // this.Cursor=Cursors.VSplit; // else if((e.Y<=2 && this.DockedSite.Dock==DockStyle.Bottom) || (e.Y>=this.Height-2 && this.DockedSite.Dock==DockStyle.Top)) // this.Cursor=Cursors.HSplit; // else if(e.X<=2 && (this.DockedSite.Dock==DockStyle.Bottom || this.DockedSite.Dock==DockStyle.Top) && this.Left>0) // this.Cursor=Cursors.VSplit; // else if(e.Y<=2 && (this.DockedSite.Dock==DockStyle.Left || this.DockedSite.Dock==DockStyle.Right) && this.Top>0) // this.Cursor=Cursors.HSplit; // else if(this.Cursor==Cursors.HSplit || this.Cursor==Cursors.VSplit) // this.Cursor=Cursors.Default; //} else if (m_BarState == eBarState.AutoHide && m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_ItemContainer.Stretch) { if ((e.X <= 2 && m_LastDockSiteInfo.DockSide == DockStyle.Right) || (e.X >= this.Width - 2 && m_LastDockSiteInfo.DockSide == DockStyle.Left)) this.Cursor = Cursors.VSplit; else if ((e.Y <= 2 && m_LastDockSiteInfo.DockSide == DockStyle.Bottom) || (e.Y >= this.Height - 2 && m_LastDockSiteInfo.DockSide == DockStyle.Top)) this.Cursor = Cursors.HSplit; else if (e.X <= 2 && (m_LastDockSiteInfo.DockSide == DockStyle.Bottom || m_LastDockSiteInfo.DockSide == DockStyle.Top) && this.Left > 0) this.Cursor = Cursors.VSplit; else if (e.Y <= 2 && (m_LastDockSiteInfo.DockSide == DockStyle.Left || m_LastDockSiteInfo.DockSide == DockStyle.Right) && this.Top > 0) this.Cursor = Cursors.HSplit; else if (this.Cursor == Cursors.HSplit || this.Cursor == Cursors.VSplit) this.Cursor = Cursors.Default; } else if (m_BarState == eBarState.Docked && m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle) { if ((e.X > this.Location.X + this.Width - GrabHandleResizeWidth && this.RightToLeft == RightToLeft.No) || (e.X < this.Location.X + +GrabHandleResizeWidth && this.RightToLeft == RightToLeft.Yes)) { Form form = this.FindForm(); if (form != null && form.WindowState == FormWindowState.Maximized) { if (this.Cursor == Cursors.SizeNESW || this.Cursor == Cursors.SizeNWSE) this.Cursor = Cursors.Default; } else { if (this.RightToLeft == RightToLeft.Yes) this.Cursor = Cursors.SizeNESW; else this.Cursor = Cursors.SizeNWSE; } } else if (this.Cursor == Cursors.SizeNESW || this.Cursor == Cursors.SizeNWSE) this.Cursor = Cursors.Default; } if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.OfficeXP || m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2003 || m_ItemContainer.EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle)) { if (!m_SystemButtons.CloseButtonRect.IsEmpty && m_SystemButtons.CloseButtonRect.Contains(e.X, e.Y)) { if (!m_SystemButtons.MouseOverClose) { m_SystemButtons.MouseOverClose = true; PaintCloseButton(); } } else if (m_SystemButtons.MouseOverClose) { m_SystemButtons.MouseOverClose = false; PaintCloseButton(); } if (!m_SystemButtons.CaptionButtonRect.IsEmpty && m_SystemButtons.CaptionButtonRect.Contains(e.X, e.Y)) { if (!m_SystemButtons.MouseOverCaption) { m_SystemButtons.MouseOverCaption = true; PaintCaptionButton(); } } else if (m_SystemButtons.MouseOverCaption) { m_SystemButtons.MouseOverCaption = false; PaintCaptionButton(); } if (!m_SystemButtons.CustomizeButtonRect.IsEmpty && m_SystemButtons.CustomizeButtonRect.Contains(e.X, e.Y)) { if (!m_SystemButtons.MouseOverCustomize) { m_SystemButtons.MouseOverCustomize = true; PaintCustomizeButton(); } } else if (m_SystemButtons.MouseOverCustomize) { m_SystemButtons.MouseOverCustomize = false; PaintCustomizeButton(); } if (!m_SystemButtons.AutoHideButtonRect.IsEmpty && m_SystemButtons.AutoHideButtonRect.Contains(e.X, e.Y)) { if (!m_SystemButtons.MouseOverAutoHide) { m_SystemButtons.MouseOverAutoHide = true; PaintAutoHideButton(); } } else if (m_SystemButtons.MouseOverAutoHide) { m_SystemButtons.MouseOverAutoHide = false; PaintAutoHideButton(); } } } else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_SizeWindow != 0 && m_BarState == eBarState.Floating) { System.Drawing.Size oldSize = this.ClientSize; System.Drawing.Size newSize = System.Drawing.Size.Empty; System.Drawing.Size minSize = MinimumDockSize(m_ItemContainer.Orientation); if (m_SizeWindow == SIZE_NWN || m_SizeWindow == SIZE_NWS) { if (m_SizeWindow == SIZE_NWS) newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, e.Y)); else newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, this.Height - e.Y)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { if (m_SizeWindow == SIZE_NWS) this.ClientSize = newSize; else { m_Float.Location = new Point(m_Float.Left + (this.Width - newSize.Width), m_Float.Top + (this.Height - newSize.Height)); this.ClientSize = newSize; } RecalcSize(); this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } else if (m_SizeWindow == SIZE_NEN || m_SizeWindow == SIZE_NES) { if (m_SizeWindow == SIZE_NES) newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, e.Y)); else newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, this.Height - e.Y)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { if (m_SizeWindow == SIZE_NES) { m_Float.Location = new Point(m_Float.Left + (this.Width - newSize.Width), m_Float.Top); this.ClientSize = newSize; } else { m_Float.Location = new Point(m_Float.Left, m_Float.Top + (this.Height - newSize.Height)); this.ClientSize = newSize; } RecalcSize(); this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } else if (m_SizeWindow == SIZE_E) { newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, this.Height)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { this.ClientSize = newSize; RecalcSize(); this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } else if (m_SizeWindow == SIZE_W) { newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, this.Height)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { int iRight = m_Float.Right; this.ClientSize = newSize; RecalcSize(); m_Float.Left = m_Float.Left + iRight - m_Float.Right; this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } else if (m_SizeWindow == SIZE_S) { if (e.Y > 0) { if (m_ItemContainer.LayoutType == eLayoutType.TaskList || m_ItemContainer.LayoutType == eLayoutType.DockContainer) newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width, e.Y)); else newSize = RecalcSizeOnly(new System.Drawing.Size((int)(m_MouseDownSize.Width * ((float)m_MouseDownSize.Height / (float)e.Y)), this.Height)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { this.ClientSize = newSize; RecalcSize(); this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } } else if (m_SizeWindow == SIZE_N) { if (e.Y != 0) { if (m_ItemContainer.LayoutType == eLayoutType.TaskList || m_ItemContainer.LayoutType == eLayoutType.DockContainer) newSize = RecalcSizeOnly(new Size(this.Width, this.Height - e.Y)); else newSize = RecalcSizeOnly(new System.Drawing.Size((int)(m_MouseDownSize.Width * ((float)m_MouseDownSize.Height / (float)(this.Height - e.Y))), this.Height)); if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height) { int iBottom = m_Float.Bottom; this.ClientSize = newSize; RecalcSize(); m_Float.Top = m_Float.Top + iBottom - m_Float.Bottom; this.Update(); // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it. IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } } } m_FloatingRect = new Rectangle(this.Location, this.Size); } else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_SizeWindow != 0 && m_BarState == eBarState.AutoHide || m_SizeWindow == SIZE_PARENTRESIZE && m_BarState == eBarState.Docked) //(m_BarState == eBarState.Docked || m_BarState == eBarState.AutoHide)) { System.Drawing.Size oldSize = this.ClientSize; System.Drawing.Size newSize = System.Drawing.Size.Empty; if (m_SizeWindow == SIZE_PARENTRESIZE) { if (this.RightToLeft == RightToLeft.No) { if (this.Parent != null && this.Parent.Parent != null) { Point pScreen = this.PointToScreen(new Point(e.X, e.Y)); if (this.Parent.Parent.Parent != null) { Point pl = this.Parent.Parent.Parent.PointToScreen(this.Parent.Parent.Location); this.Parent.Parent.Size = new Size(pScreen.X - pl.X + m_ResizeOffset.X, pScreen.Y - pl.Y + m_ResizeOffset.Y); } else this.Parent.Parent.Size = new Size(pScreen.X - this.Parent.Parent.Location.X + m_ResizeOffset.X, pScreen.Y - this.Parent.Parent.Location.Y + m_ResizeOffset.Y); IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer)) { Form form = this.FindForm(); if (form != null) { Point pScreen = this.PointToScreen(new Point(e.X, e.Y)); form.Size = new Size(pScreen.X - form.Location.X + m_ResizeOffset.X, pScreen.Y - form.Location.Y + m_ResizeOffset.Y); form.Update(); } } } else { if (this.Parent != null && this.Parent.Parent != null) { Point pScreen = this.PointToScreen(new Point(e.X, e.Y)); if (this.Parent.Parent.Parent != null) { Point pl = this.Parent.Parent.Parent.PointToScreen(this.Parent.Parent.Location); Rectangle b = this.Parent.Parent.Bounds; b.X = pScreen.X - m_ResizeOffset.X; b.Width += this.Parent.Parent.Left - b.X; b.Height = pScreen.Y - pl.Y + m_ResizeOffset.Y; this.Parent.Parent.Bounds = b; } else { Rectangle b = this.Parent.Parent.Bounds; b.X = pScreen.X - m_ResizeOffset.X; b.Width += this.Parent.Parent.Left - b.X; b.Height = pScreen.Y - this.Parent.Parent.Location.Y + m_ResizeOffset.Y; this.Parent.Parent.Bounds = b; } IOwner owner = m_Owner as IOwner; if (owner != null && owner.ParentForm != null) owner.ParentForm.Update(); } else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer)) { Form form = this.FindForm(); if (form != null) { Point pScreen = this.PointToScreen(new Point(e.X, e.Y)); Rectangle b = form.Bounds; b.X = pScreen.X - m_ResizeOffset.X; b.Width += form.Left - b.X; b.Height = pScreen.Y - form.Location.Y + m_ResizeOffset.Y; form.Bounds = b; //Size = new Size(pScreen.X - form.Location.X + m_ResizeOffset.X, pScreen.Y - form.Location.Y + m_ResizeOffset.Y); form.Update(); } } } } else if (m_SizeWindow == SIZE_HSPLITRIGHT) { int formClientWidth = GetFormClientWidth(); int mouseX = e.X; int minClientSize = 32; if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Width; if (minClientSize > 0 && formClientWidth + mouseX < minClientSize) mouseX = minClientSize - formClientWidth; if (formClientWidth + mouseX >= minClientSize || minClientSize == 0) { int oldMinWidth = m_ItemContainer.MinWidth; m_ItemContainer.MinWidth = 0; newSize = RecalcSizeOnly(new Size(this.Width - mouseX, this.Height)); m_ItemContainer.MinWidth = oldMinWidth; if (!oldSize.Equals(newSize)) { if (m_BarState == eBarState.AutoHide) { Rectangle oldRect = this.Bounds; this.EnableRedraw = false; try { m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal - mouseX; this.Width = this.Width - mouseX; RecalcSize(); this.Left = this.Left + (oldSize.Width - this.Size.Width); } finally { this.EnableRedraw = true; } if (this.Parent != null) { this.Parent.Invalidate(oldRect, true); this.Parent.Invalidate(this.Bounds, true); this.Parent.Update(); } else this.Refresh(); } else { int iOldMinWidth = m_ItemContainer.MinWidth; m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal - mouseX; if (m_ItemContainer.MinWidth < iOldMinWidth) SyncLineMinWidth(); RecalcLayout(); } if (m_BarState == eBarState.AutoHide) m_LastDockSiteInfo.DockedWidth = this.Width; } } } else if (m_SizeWindow == SIZE_HSPLITLEFT) { int formClientWidth = GetFormClientWidth(); int mouseX = e.X; int minClientSize = 32; if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Width; if (minClientSize > 0 && formClientWidth - (mouseX - this.Width) < minClientSize) { mouseX = formClientWidth + this.Width - minClientSize; } if (formClientWidth - (mouseX - this.Width) >= minClientSize || minClientSize == 0) { int oldMinWidth = m_ItemContainer.MinWidth; m_ItemContainer.MinWidth = 0; newSize = RecalcSizeOnly(new Size(mouseX, this.Height)); m_ItemContainer.MinWidth = oldMinWidth; if (!oldSize.Equals(newSize)) { if (m_BarState == eBarState.AutoHide) { Rectangle oldRect = this.Bounds; this.EnableRedraw = false; try { m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal + (mouseX - this.Width); this.Width = this.Width + (mouseX - this.Width); RecalcSize(); } finally { this.EnableRedraw = true; } if (this.Parent != null) { this.Parent.Invalidate(oldRect, true); this.Parent.Invalidate(this.Bounds, true); this.Parent.Update(); } else this.Refresh(); } else { int iOldMinWidth = m_ItemContainer.MinWidth; m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal + (mouseX - this.Width); if (m_ItemContainer.MinWidth < iOldMinWidth) SyncLineMinWidth(); RecalcLayout(); } if (m_BarState == eBarState.AutoHide) m_LastDockSiteInfo.DockedWidth = this.Width; } } } else if (m_SizeWindow == SIZE_VSPLITBOTTOM) { int formClientHeight = GetFormClientHeight(); int mouseY = e.Y; int minClientSize = 32; if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Height; if (minClientSize > 0 && formClientHeight + mouseY < minClientSize) mouseY = minClientSize - formClientHeight; if (formClientHeight + mouseY >= minClientSize || minClientSize == 0) { int oldMinHeight = m_ItemContainer.MinHeight; m_ItemContainer.MinHeight = 0; newSize = RecalcSizeOnly(new Size(this.Width, this.Height - mouseY)); m_ItemContainer.MinHeight = oldMinHeight; if (!oldSize.Equals(newSize)) { if (m_BarState == eBarState.AutoHide) { Rectangle oldRect = this.Bounds; this.EnableRedraw = false; try { m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal - mouseY; this.Height = this.Height - mouseY; RecalcSize(); this.Top = this.Top + (oldSize.Height - this.Height); } finally { this.EnableRedraw = true; } if (this.Parent != null) { this.Parent.Invalidate(oldRect, true); this.Parent.Invalidate(this.Bounds, true); this.Parent.Update(); } else this.Refresh(); } else { int iOldMinHeight = m_ItemContainer.MinHeight; Size minSize = this.MinimumDockSize(m_ItemContainer.Orientation); if (m_ItemContainer.HeightInternal - mouseY >= minSize.Height) m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal - mouseY; if (m_ItemContainer.MinHeight < iOldMinHeight) SyncLineMinHeight(); RecalcLayout(); } if (m_BarState == eBarState.AutoHide) m_LastDockSiteInfo.DockedHeight = this.Height; } } } else if (m_SizeWindow == SIZE_VSPLITTOP) { int formClientHeight = GetFormClientHeight(); int mouseY = e.Y; int minClientSize = 32; if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Height; if (minClientSize > 0 && formClientHeight - (mouseY - this.Height) < minClientSize) mouseY = formClientHeight + this.Height - minClientSize; if (formClientHeight - (mouseY - this.Height) >= minClientSize || minClientSize == 0) { int oldMinHeight = m_ItemContainer.MinHeight; m_ItemContainer.MinHeight = 0; newSize = RecalcSizeOnly(new Size(this.Width, mouseY)); m_ItemContainer.MinHeight = oldMinHeight; if (!oldSize.Equals(newSize)) { if (m_BarState == eBarState.AutoHide) { Rectangle oldRect = this.Bounds; this.EnableRedraw = false; try { m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal + (mouseY - this.Height); this.Height = mouseY; this.RecalcSize(); } finally { this.EnableRedraw = true; } if (this.Parent != null) { this.Parent.Invalidate(oldRect, true); this.Parent.Invalidate(this.Bounds, true); this.Parent.Update(); } else this.Refresh(); } else { int iOldMinHeight = m_ItemContainer.MinHeight; m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal + (mouseY - this.Height); if (m_ItemContainer.MinHeight < iOldMinHeight) SyncLineMinHeight(); RecalcLayout(); } if (m_BarState == eBarState.AutoHide) m_LastDockSiteInfo.DockedHeight = this.Height; } } } else if (m_SizeWindow == SIZE_HSPLIT && this.Parent.Controls.IndexOf(this) > 0) { Bar barLeft = GetPreviousVisibleBar(this); //this.Parent.Controls[iIndex] as Bar; if (barLeft != null && barLeft.DockLine == this.DockLine) { System.Drawing.Size minLeftSize = GetAdjustedFullSize(barLeft.MinimumDockSize(eOrientation.Horizontal)); System.Drawing.Size minThisSize = GetAdjustedFullSize(this.MinimumDockSize(eOrientation.Horizontal)); int x = e.X; if (barLeft.Width + x < minLeftSize.Width) x += (minLeftSize.Width - (barLeft.Width + x)) - 1; if (this.Width - x < minThisSize.Width) x -= (minThisSize.Width - (this.Width - x)) + 1; if (barLeft.Width + x >= minLeftSize.Width && this.Width - x >= minThisSize.Width) { Size oldLeftBarSize = barLeft.Size; Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(barLeft.Width + x, this.Height)); newSize = this.RecalcSizeOnly(new Size(this.Width - x, this.Height)); if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize)) { this.SplitDockWidth = 0; barLeft.SplitDockWidth = barLeft.Width + x; foreach (Control c in this.Parent.Controls) { if (c != this && c != barLeft && c.Visible && c is Bar) { Bar b = c as Bar; if (b.DockLine == this.DockLine && b.SplitDockHeight == 0) b.SplitDockWidth = b.Width; } } RecalcLayout(); } } } } else if (m_SizeWindow == SIZE_VSPLIT && this.Parent.Controls.IndexOf(this) > 0) { // Resize two bars that are docked on the same line, this bar is always on the right side //int iIndex=this.Parent.Controls.IndexOf(this)-1; // Index of the control to the left Bar barLeft = GetPreviousVisibleBar(this); //this.Parent.Controls[iIndex] as Bar; if (barLeft != null && barLeft.DockLine == this.DockLine) { System.Drawing.Size minLeftSize = GetAdjustedFullSize(barLeft.MinimumDockSize(eOrientation.Horizontal)); System.Drawing.Size minThisSize = GetAdjustedFullSize(this.MinimumDockSize(eOrientation.Horizontal)); int y = e.Y; if (barLeft.Height + y < minLeftSize.Height) y += (minLeftSize.Height - (barLeft.Height + y)) - 1; if (this.Height - y < minThisSize.Height) y -= minThisSize.Height - (this.Height - y) + 1; if (barLeft.Height + y >= minLeftSize.Height && this.Height - y >= minThisSize.Height) { Size oldLeftBarSize = barLeft.Size; Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(barLeft.Width, this.Height + y)); newSize = this.RecalcSizeOnly(new Size(this.Width, this.Height - y)); if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize)) { this.SplitDockHeight = 0; barLeft.SplitDockHeight = barLeft.Height + y; foreach (Control c in this.Parent.Controls) { if (c != this && c != barLeft && c.Visible && c is Bar) { Bar b = c as Bar; if (b.DockLine == this.DockLine && b.SplitDockHeight == 0) b.SplitDockHeight = b.Height; } } RecalcLayout(); } } } } } if (m_BarState == eBarState.Popup && m_ParentItem != null && m_ParentItem.DesignMode && e.Button == System.Windows.Forms.MouseButtons.Left && (Math.Abs(e.X - m_MouseDownPt.X) >= 2 || Math.Abs(e.Y - m_MouseDownPt.Y) >= 2 || m_DragDropInProgress)) { BaseItem focus = m_FocusItem; if (m_Owner is IOwner) focus = ((IOwner)m_Owner).GetFocusItem(); ISite site = this.GetSite(); if (site != null && focus != null) { DesignTimeMouseMove(e); } } base.OnMouseMove(e); if (m_ItemContainer.SubItems.Count == 0) { m_InMouseMove = false; return; } if (!m_MoveWindow && m_SizeWindow == 0) m_ItemContainer.InternalMouseMove(e); m_InMouseMove = false; }
public void DockingHandler(DockSiteInfo pDockInfo, Point p) { IOwner owner = m_Owner as IOwner; if (m_TempTabBar != null && pDockInfo.TabDockContainer == m_TempTabBar) return; if (pDockInfo.objDockSite == null && (m_BarState != eBarState.Floating || m_Float == null)) { m_DockingInProgress = true; if (m_TempTabBar != null) { RemoveTempTabBarItems(); m_TempTabBar.RecalcLayout(); m_TempTabBar = null; } // Remember last docking info DockSiteInfo tempInfo = m_LastDockSiteInfo; m_LastDockSiteInfo = new DockSiteInfo(); // Preserve the relative last docked to bar in case the return to same docking position is needed m_LastDockSiteInfo.LastRelativeDocumentId = tempInfo.LastRelativeDocumentId; m_LastDockSiteInfo.LastRelativeDockToBar = tempInfo.LastRelativeDockToBar; m_LastDockSiteInfo.DockedHeight = this.Height; m_LastDockSiteInfo.DockedWidth = this.Width; m_LastDockSiteInfo.DockLine = this.DockLine; m_LastDockSiteInfo.DockOffset = this.DockOffset; if (this.Parent != null) m_LastDockSiteInfo.DockSide = this.Parent.Dock; else m_LastDockSiteInfo.DockSide = DockStyle.Left; if (this.Parent != null && this.Parent is DockSite) { m_LastDockSiteInfo.InsertPosition = ((DockSite)this.Parent).Controls.GetChildIndex(this); m_LastDockSiteInfo.objDockSite = (DockSite)this.DockedSite; } if (m_LastDockSiteInfo.objDockSite == null) { IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport; if (barSupp != null) { switch (m_LastDockSiteInfo.DockSide) { case DockStyle.Left: m_LastDockSiteInfo.objDockSite = barSupp.LeftDockSite; break; case DockStyle.Right: m_LastDockSiteInfo.objDockSite = barSupp.RightDockSite; break; case DockStyle.Top: m_LastDockSiteInfo.objDockSite = barSupp.TopDockSite; break; case DockStyle.Bottom: m_LastDockSiteInfo.objDockSite = barSupp.BottomDockSite; break; case DockStyle.Fill: m_LastDockSiteInfo.objDockSite = barSupp.FillDockSite; break; } } } // Undock the window m_BarState = eBarState.Floating; if (m_Float == null) { m_Float = new FloatingContainer(this); m_Float.CreateControl(); } // Must reset the ActiveControl to null because on MDI Forms if this was not done // MDI form could not be closed if bar that had ActiveControl is floating. if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this) { owner.ParentForm.ActiveControl = null; this.Focus(); // Fixes the problem on SDI forms } else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl)) { owner.ParentForm.ActiveControl = null; this.Focus(); } // Check for parent since if bar is deserialized there is no parent and state is Docked by default if (this.Parent != null && this.Parent is DockSite) { if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null) { ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this); } else ((DockSite)this.Parent).RemoveBar(this); } this.Parent = null; m_Float.Controls.Add(this); if (!this.Visible/* && !m_BarDefinitionLoading*/) base.Visible = true; // IMPORTANT SINCE WE OVERRIDE BASE LOCATION WE HAVE TO USE BASE HERE TO ACTUALLY MOVE IT base.Location = new Point(0, 0); m_FloatingRect = new Rectangle(m_FloatingRect.Location, GetFloatingSize()); this.Size = m_FloatingRect.Size; this.DockOrientation = eOrientation.Horizontal; if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_AlwaysDisplayDockTab) RefreshDockTab(true); this.RecalcSize(); m_FloatingRect.Size = this.Size; m_Float.Location = p; if (m_ItemContainer.LayoutType != eLayoutType.Toolbar) m_MouseDownPt = new Point(this.Width / 2, 8); else m_MouseDownPt = new Point(8, 8); if (m_LoadingHideFloating) m_Float.Visible = false; else m_Float.Show(); m_FloatingRect.Location = m_Float.Location; // TODO: Bug Width was sometimes not reflected properly if (m_Float.Width != m_FloatingRect.Width) m_Float.Width = m_FloatingRect.Width; if (owner.ParentForm != null) { bool activate = true; if (m_BarDefinitionLoading && owner is DotNetBarManager && !((DotNetBarManager)owner).ActivateOnLayoutLoad) activate = false; if (activate) owner.ParentForm.Activate(); } m_DockingInProgress = false; // Raise events if (BarUndock != null) BarUndock(this, new EventArgs()); IOwnerBarSupport ownerDockEvents = m_Owner as IOwnerBarSupport; if (ownerDockEvents != null) ownerDockEvents.InvokeBarUndock(this, new EventArgs()); OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.BarUndocked)); // Resize Docking Tab if it exists ResizeDockTab(); } else { // Change the Z-Order of the dock-site if needed if ((pDockInfo.FullSizeDock || pDockInfo.PartialSizeDock) && pDockInfo.DockSiteZOrderIndex >= 0 && pDockInfo.objDockSite != null && pDockInfo.objDockSite.Parent != null) pDockInfo.objDockSite.Parent.Controls.SetChildIndex(pDockInfo.objDockSite, pDockInfo.DockSiteZOrderIndex); if (m_Owner != null) { if (pDockInfo.TabDockContainer != null) { if (m_TempTabBar != null && pDockInfo.TabDockContainer != m_TempTabBar) { RemoveTempTabBarItems(); m_TempTabBar.RecalcLayout(); m_TempTabBar = null; } if (m_TempTabBar != pDockInfo.TabDockContainer) { m_DockingInProgress = true; if (m_DockTabTearOffIndex == -1) { if (m_Float != null && m_Float.Visible) { if (owner.ParentForm != null) owner.ParentForm.Activate(); // Remember undocked size m_FloatingRect = new Rectangle(m_Float.Location, this.Size); m_DockOffset = pDockInfo.DockOffset; m_DockLine = pDockInfo.DockLine; m_Float.Controls.Remove(this); m_Float.Hide(); m_Float.Dispose(); m_Float = null; } else if (this.Parent != null && this.Parent is DockSite) ((DockSite)this.Parent).RemoveBar(this); m_BarState = eBarState.Docked; if (!m_BarDefinitionLoading) base.Visible = false; foreach (BaseItem item in m_ItemContainer.SubItems) { DockContainerItem dockitem = item as DockContainerItem; if (dockitem != null) { DockContainerItem temp = new DockContainerItem(); temp.Displayed = false; temp.Text = item.Text; temp.Image = dockitem.Image; temp.ImageIndex = dockitem.ImageIndex; temp.Icon = dockitem.Icon; temp.Tag = "systempdockitem"; pDockInfo.TabDockContainer.Items.Add(temp); } m_TempTabBar = pDockInfo.TabDockContainer; m_TempTabBar.RecalcLayout(); m_TempTabBar.Refresh(); } } else { DockContainerItem dockitem = m_ItemContainer.SubItems[m_DockTabTearOffIndex] as DockContainerItem; if (dockitem != null) { DockContainerItem temp = new DockContainerItem(); temp.Displayed = false; temp.Text = dockitem.Text; temp.Image = dockitem.Image; temp.ImageIndex = dockitem.ImageIndex; temp.Icon = dockitem.Icon; temp.Tag = "systempdockitem"; pDockInfo.TabDockContainer.Items.Add(temp); } m_TempTabBar = pDockInfo.TabDockContainer; m_TempTabBar.RecalcLayout(); m_TempTabBar.Refresh(); } m_DockingInProgress = false; } } else { if (m_TempTabBar != null) { // Allow tabbed bar to change position only if it is going to different bar if (pDockInfo.objDockSite == m_TempTabBar.Parent) return; RemoveTempTabBarItems(); m_TempTabBar.RecalcLayout(); m_TempTabBar = null; } // If coming from the tabs if (!this.Visible && !m_BarDefinitionLoading) this.Visible = true; if (pDockInfo.LastRelativeDockToBar != null && pDockInfo.LastRelativeDockToBar.DockedSite != null && owner is DotNetBarManager) { DotNetBarManager manager = (DotNetBarManager)owner; if (pDockInfo.LastRelativeDockToBar.AutoHide) { if (pDockInfo.objDockSite != null) pDockInfo.objDockSite.GetDocumentUIManager().Dock(this); else manager.Dock(this, eDockSide.Right); } else if (!pDockInfo.LastRelativeDockToBar.Visible || pDockInfo.LastRelativeDockToBar.DockSide == eDockSide.None) // Closed or floating { manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide); } else if (pDockInfo.LastRelativeDockToBar.DockSide != eDockSide.None && m_LastDockSiteInfo.LastDockSiteSide != pDockInfo.LastRelativeDockToBar.DockSide) // Reference bar docked somewhere else { manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide); } else manager.Dock(this, pDockInfo.LastRelativeDockToBar, LastDockSide); if (this.IsDisposed) return; m_BarState = eBarState.Docked; pDockInfo.LastRelativeDockToBar = null; } else if (pDockInfo.objDockSite != null && m_BarState != eBarState.Docked) { m_DockingInProgress = true; if (m_Float != null && m_BarState == eBarState.Floating) { if (owner.ParentForm != null) owner.ParentForm.Activate(); // Remember undocked size m_FloatingRect = new Rectangle(m_Float.Location, this.Size); m_DockOffset = pDockInfo.DockOffset; m_DockLine = pDockInfo.DockLine; m_Float.Controls.Remove(this); m_Float.Hide(); m_Float.Dispose(); m_Float = null; } m_BarState = eBarState.Docked; if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null) { DockDocumentManager(pDockInfo); } else { if (pDockInfo.InsertPosition == -10) pDockInfo.objDockSite.AddBar(this); else pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition); } m_DockingInProgress = false; // // Raise events // if(BarDock!=null) // BarDock(this,new EventArgs()); // IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport; // if(ownerDockEvents!=null) // ownerDockEvents.InvokeBarDock(this,new EventArgs()); } else if (pDockInfo.objDockSite != null && pDockInfo.objDockSite != this.Parent) { m_DockingInProgress = true; // Must reset the ActiveControl to null becouse on MDI Forms if this was not done // MDI form could not be closed if bar that had ActiveControl is floating. if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this) { owner.ParentForm.ActiveControl = null; this.Focus(); // Fixes the problem on SDI forms } else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl)) { owner.ParentForm.ActiveControl = null; this.Focus(); } // It is docked somewhere else, we need to undockit and dockit on another site // If Bar is deserialized there is no parent if (this.Parent != null && this.Parent is DockSite) { if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null) ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this); else ((DockSite)this.Parent).RemoveBar(this); } // If coming from the tabs if (!this.Visible && !m_BarDefinitionLoading) this.Visible = true; m_DockOffset = pDockInfo.DockOffset; m_DockLine = pDockInfo.DockLine; if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null) { pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide); } else { if (pDockInfo.InsertPosition == -10) pDockInfo.objDockSite.AddBar(this); else pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition); } // Raise events // if(BarDock!=null) // BarDock(this,new EventArgs()); // IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport; // if(ownerDockEvents!=null) // ownerDockEvents.InvokeBarDock(this,new EventArgs()); m_DockingInProgress = false; } else if (this.Parent != null && pDockInfo.objDockSite == this.Parent) { if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null) { pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide); } else { if (m_DockLine != pDockInfo.DockLine || m_DockOffset != pDockInfo.DockOffset && !this.Stretch || pDockInfo.objDockSite.Controls.GetChildIndex(this) != pDockInfo.InsertPosition || pDockInfo.NewLine) { m_DockLine = pDockInfo.DockLine; m_DockOffset = pDockInfo.DockOffset; // If coming from the tabs if (!this.Visible && !m_BarDefinitionLoading) this.Visible = true; if (pDockInfo.NewLine) pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition, true); else if (pDockInfo.InsertPosition == -10) { pDockInfo.objDockSite.AdjustBarPosition(this); pDockInfo.objDockSite.RecalcLayout(); } else pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition); } } } else { Point newLocation = new Point(p.X - m_MouseDownPt.X, p.Y - m_MouseDownPt.Y); ScreenInformation screen = BarFunctions.ScreenFromControl(m_Float); if (screen != null) { if (newLocation.Y + 8 >= screen.WorkingArea.Bottom) newLocation.Y = screen.WorkingArea.Bottom - 8; } m_Float.Location = newLocation; if (((IOwner)m_Owner).ParentForm != null) ((IOwner)m_Owner).ParentForm.Update(); } } } if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && (m_TabDockItems == null || !m_TabDockItems.Visible)) { int iVisible = m_ItemContainer.VisibleSubItems; if (!(m_BarState == eBarState.Floating && iVisible <= 1) && (m_AlwaysDisplayDockTab || iVisible > 0)) { eBarState oldBarState = m_BarState; m_BarState = eBarState.Docked; RefreshDockTab(false); m_BarState = oldBarState; } } if (m_BarState != eBarState.Floating) InvokeBarDockEvents(); } }
public void DockDocumentManager(DockSiteInfo pDockInfo) { DocumentDockUIManager dm = pDockInfo.objDockSite.GetDocumentUIManager(); if (pDockInfo.objDockSite.Dock == DockStyle.Fill) dm.Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide); else if ((pDockInfo.DockLine == -1 || pDockInfo.DockLine == 999) && (pDockInfo.objDockSite.Dock == DockStyle.Left || pDockInfo.objDockSite.Dock == DockStyle.Right)) // Ajdust for edge case docking { dm.Dock(null, this, pDockInfo.DockLine == -1 ? eDockSide.Left : eDockSide.None); } else if ((pDockInfo.DockLine == -1 || pDockInfo.DockLine == 999) && (pDockInfo.objDockSite.Dock == DockStyle.Top || pDockInfo.objDockSite.Dock == DockStyle.Bottom)) // Ajdust for edge case docking { dm.Dock(null, this, pDockInfo.DockLine == -1 ? eDockSide.Top : eDockSide.None); } else dm.Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide); }
private bool DockingHintHandler(ref DockSiteInfo dockInfo, IDockInfo barDockInfo, int x, int y) { if(!m_DockingHintSetup) { m_DockingHintSetup=true; return true; } // Determine whether mouse is inside of any of our bars Bar barMouseOver=null; foreach(Bar bar in this.Bars) { if(bar.Visible && (bar!=barDockInfo || this.DesignMode || bar.DockSide==eDockSide.Document)) { Point p=bar.PointToClient(new Point(x,y)); if(bar.LayoutType==eLayoutType.DockContainer && bar.ClientRectangle.Contains(p) && bar.DockSide!=eDockSide.None && CanDockToBar(barDockInfo, bar)) { barMouseOver=bar; break; } } } // Setup Docking Hints Windows SetupDockingHintWindows(barMouseOver,barDockInfo); bool bMiddleDockHint=false; dockInfo.DockSiteZOrderIndex=-1; eMouseOverHintSide dockHintSide=eMouseOverHintSide.None; if(m_DockingHintLeft!=null) { dockHintSide=m_DockingHintLeft.ExMouseMove(x,y); } if(m_DockingHintRight!=null) { eMouseOverHintSide ds=m_DockingHintRight.ExMouseMove(x,y); if(dockHintSide==eMouseOverHintSide.None) dockHintSide=ds; } if(m_DockingHintTop!=null) { eMouseOverHintSide ds=m_DockingHintTop.ExMouseMove(x,y); if(dockHintSide==eMouseOverHintSide.None) dockHintSide=ds; } if(m_DockingHintBottom!=null) { eMouseOverHintSide ds=m_DockingHintBottom.ExMouseMove(x,y); if(dockHintSide==eMouseOverHintSide.None) dockHintSide=ds; } if(m_DockingHintMiddle!=null) { eMouseOverHintSide ds=m_DockingHintMiddle.ExMouseMove(x,y); if(dockHintSide==eMouseOverHintSide.None) { dockHintSide=ds; if(ds!=eMouseOverHintSide.None) bMiddleDockHint=true; if(bMiddleDockHint && this.IsDocumentDockingEnabled && barDockInfo.CanDockDocument && barMouseOver==null && barDockInfo.CanDockDocument) { if(!barDockInfo.CanDockTop && ds==eMouseOverHintSide.Top) dockHintSide=eMouseOverHintSide.DockTab; else if(!barDockInfo.CanDockBottom && ds==eMouseOverHintSide.Bottom) dockHintSide=eMouseOverHintSide.DockTab; else if(!barDockInfo.CanDockLeft && ds==eMouseOverHintSide.Left) dockHintSide=eMouseOverHintSide.DockTab; else if(!barDockInfo.CanDockRight && ds==eMouseOverHintSide.Right) dockHintSide=eMouseOverHintSide.DockTab; } } } dockInfo.MouseOverBar=barMouseOver; if(barMouseOver==null || !bMiddleDockHint) { if(m_EnableFullSizeDock) { dockInfo.FullSizeDock=!bMiddleDockHint; dockInfo.PartialSizeDock=bMiddleDockHint; } switch(dockHintSide) { case eMouseOverHintSide.Left: { dockInfo.MouseOverDockSide = eDockSide.Left; if(barDockInfo.DockSide!=eDockSide.Left) { dockInfo.DockSide=DockStyle.Left; if (bMiddleDockHint) { dockInfo.DockLine = 999; dockInfo.InsertPosition = 999; } else { dockInfo.DockLine = -1; dockInfo.InsertPosition = 0; } dockInfo.NewLine = true; } else { dockInfo.DockSide=DockStyle.Left; dockInfo.DockLine=barDockInfo.DockLine; dockInfo.DockOffset=barDockInfo.DockOffset; dockInfo.InsertPosition=m_LeftDockSite.Controls.IndexOf(barDockInfo as Control); } dockInfo.objDockSite=m_LeftDockSite; break; } case eMouseOverHintSide.Right: { dockInfo.MouseOverDockSide = eDockSide.Right; if(barDockInfo.DockSide!=eDockSide.Right) { dockInfo.DockSide=DockStyle.Right; if (bMiddleDockHint) { dockInfo.DockLine = -1; dockInfo.InsertPosition = 0; } else { dockInfo.DockLine = 999; dockInfo.InsertPosition = 999; } dockInfo.NewLine = true; } else { dockInfo.DockSide=DockStyle.Right; dockInfo.DockLine=barDockInfo.DockLine; dockInfo.DockOffset=barDockInfo.DockOffset; dockInfo.InsertPosition=m_RightDockSite.Controls.IndexOf(barDockInfo as Control); } dockInfo.objDockSite=m_RightDockSite; break; } case eMouseOverHintSide.Top: { dockInfo.MouseOverDockSide = eDockSide.Top; if(barDockInfo.DockSide!=eDockSide.Top) { dockInfo.DockSide=DockStyle.Top; if (bMiddleDockHint) { dockInfo.DockLine = 999; dockInfo.InsertPosition = 999; } else { dockInfo.DockLine = -1; dockInfo.InsertPosition = 0; } dockInfo.NewLine = true; } else { dockInfo.DockSide=DockStyle.Top; dockInfo.DockLine=barDockInfo.DockLine; dockInfo.DockOffset=barDockInfo.DockOffset; dockInfo.InsertPosition=m_TopDockSite.Controls.IndexOf(barDockInfo as Control); } dockInfo.objDockSite=m_TopDockSite; break; } case eMouseOverHintSide.Bottom: { dockInfo.MouseOverDockSide = eDockSide.Bottom; if(barDockInfo.DockSide!=eDockSide.Bottom) { dockInfo.DockSide=DockStyle.Bottom; if (bMiddleDockHint) { dockInfo.DockLine = -1; dockInfo.InsertPosition = 0; } else { dockInfo.DockLine = 999; dockInfo.InsertPosition = 999; } dockInfo.NewLine=true; } else { dockInfo.DockSide=DockStyle.Bottom; dockInfo.DockLine=barDockInfo.DockLine; dockInfo.DockOffset=barDockInfo.DockOffset; dockInfo.InsertPosition=m_BottomDockSite.Controls.IndexOf(barDockInfo as Control); } dockInfo.objDockSite=m_BottomDockSite; break; } case eMouseOverHintSide.DockTab: { if(this.IsDocumentDockingEnabled) { dockInfo.objDockSite=m_FillDockSite; dockInfo.DockSide=DockStyle.Fill; dockInfo.MouseOverDockSide=eDockSide.Document; } break; } } } else { switch(dockHintSide) { case eMouseOverHintSide.DockTab: { dockInfo.MouseOverDockSide=eDockSide.Document; if(barMouseOver!=null) { //if(((Bar)barDockInfo).TempTabBar==barMouseOver) { dockInfo.TabDockContainer=barMouseOver; dockInfo.DockSide=barMouseOver.Parent.Dock; dockInfo.objDockSite=barMouseOver.Parent as DockSite; } // else // { // if(barDockInfo.DockSide!=eDockSide.None) // { // dockInfo.DockSide=barMouseOver.Parent.Dock; // dockInfo.objDockSite=barMouseOver.Parent as DockSite; // dockInfo.DockLine=barDockInfo.DockLine; // dockInfo.DockOffset=barDockInfo.DockOffset; // } // else // { // dockInfo.TabDockContainer=barMouseOver; // } // } } break; } case eMouseOverHintSide.Right: { dockInfo.MouseOverDockSide=eDockSide.Right; dockInfo.DockSide=barMouseOver.Parent.Dock; dockInfo.objDockSite=barMouseOver.DockedSite as DockSite; switch(barMouseOver.DockSide) { case eDockSide.Top: case eDockSide.Bottom: { dockInfo.DockLine = 0; // barMouseOver.DockLine; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver)+1; dockInfo.DockOffset=barMouseOver.DockOffset+1; break; } default: { dockInfo.DockLine=barMouseOver.DockLine+1; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); dockInfo.InsertPosition++; dockInfo.NewLine=true; break; } } break; } case eMouseOverHintSide.Left: { dockInfo.MouseOverDockSide=eDockSide.Left; dockInfo.DockSide=barMouseOver.Parent.Dock; dockInfo.objDockSite=barMouseOver.DockedSite as DockSite; switch(barMouseOver.DockSide) { case eDockSide.Top: case eDockSide.Bottom: { dockInfo.DockLine = 0; // barMouseOver.DockLine; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); dockInfo.DockOffset=barMouseOver.DockOffset-1; break; } default: { dockInfo.DockLine = 0; // barMouseOver.DockLine - 1; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); dockInfo.NewLine=true; break; } } break; } case eMouseOverHintSide.Top: { dockInfo.MouseOverDockSide=eDockSide.Top; dockInfo.DockSide=barMouseOver.Parent.Dock; dockInfo.objDockSite=barMouseOver.DockedSite as DockSite; switch(barMouseOver.DockSide) { case eDockSide.Top: case eDockSide.Bottom: { dockInfo.DockLine = 0; // barMouseOver.DockLine - 1; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); dockInfo.NewLine=true; break; } default: { dockInfo.DockLine = 0;// barMouseOver.DockLine; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); dockInfo.DockOffset=barMouseOver.DockOffset-1; break; } } break; } case eMouseOverHintSide.Bottom: { dockInfo.MouseOverDockSide=eDockSide.Bottom; dockInfo.DockSide=barMouseOver.Parent.Dock; dockInfo.objDockSite=barMouseOver.DockedSite as DockSite; switch(barMouseOver.DockSide) { case eDockSide.Top: case eDockSide.Bottom: { dockInfo.DockLine=barMouseOver.DockLine+1; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver); if(barMouseOver.DockSide==eDockSide.Bottom) dockInfo.InsertPosition++; dockInfo.NewLine=true; break; } default: { dockInfo.DockLine = 0; // barMouseOver.DockLine; dockInfo.InsertPosition=barMouseOver.Parent.Controls.IndexOf(barMouseOver)+1; dockInfo.DockOffset=barMouseOver.DockOffset+1; break; } } break; } } } dockInfo.UseOutline=true; return true; }
DockSiteInfo IOwnerBarSupport.GetDockInfo(IDockInfo pDock, int x, int y) { DockSiteInfo objRet=new DockSiteInfo(); // Prevent Docking if Ctrl key is pressed if((Control.ModifierKeys & Keys.Control)!=0) return objRet; if(((Bar)pDock).LayoutType==eLayoutType.DockContainer) { if (pDock.CanDockBottom || pDock.CanDockLeft || pDock.CanDockRight || pDock.CanDockTop || pDock.CanDockDocument) { if (DockingHintHandler(ref objRet, pDock, x, y)) return objRet; } return objRet; } if(pDock.CanDockTop && m_ToolbarTopDockSite!=null) { objRet = m_ToolbarTopDockSite.GetDockSiteInfo(pDock, x, y); if(objRet.objDockSite!=null) return objRet; } if(pDock.CanDockBottom && m_ToolbarBottomDockSite!=null) { objRet = m_ToolbarBottomDockSite.GetDockSiteInfo(pDock, x, y); if(objRet.objDockSite!=null) return objRet; } if(pDock.CanDockLeft && m_ToolbarLeftDockSite!=null) { objRet = m_ToolbarLeftDockSite.GetDockSiteInfo(pDock, x, y); if(objRet.objDockSite!=null) return objRet; } if(pDock.CanDockRight && m_ToolbarRightDockSite!=null) { objRet = m_ToolbarRightDockSite.GetDockSiteInfo(pDock, x, y); if(objRet.objDockSite!=null) return objRet; } return objRet; }