public override void OnDrop(DragItem source) { if (DropMode == DropMode.Left || DropMode == DropMode.Right || DropMode == DropMode.Top || DropMode == DropMode.Bottom) { IDockView child; if (source.RelativeObj is BaseFloatWindow) { child = (source.RelativeObj as BaseFloatWindow).Child; (source.RelativeObj as BaseFloatWindow).DetachChild(child); } else { child = source.RelativeObj as IDockView; } DockManager.ChangeDockMode(child, (Model as ILayoutGroup).Mode); //must to changside DockManager.ChangeSide(child, Model.Side); LayoutGroupPanel panel; if (DockViewParent == null) { var wnd = Parent as BaseFloatWindow; wnd.DetachChild(this); panel = new LayoutGroupPanel(Model.Side) { Direction = (DropMode == DropMode.Left || DropMode == DropMode.Right) ? Direction.Horizontal : Direction.Vertical, DesiredWidth = wnd.ActualWidth, DesiredHeight = wnd.ActualHeight, IsAnchorPanel = true }; wnd.DockManager = DockManager; wnd.AttachChild(panel, AttachMode.None, 0); panel._AttachChild(this, 0); } else { panel = DockViewParent as LayoutGroupPanel; } AttachTo(panel, child, DropMode); } else { base.OnDrop(source); } if (source.RelativeObj is BaseFloatWindow) { (source.RelativeObj as BaseFloatWindow).Close(); } }
public override void AttachChild(IDockView child, AttachMode mode, int index) { if (index < 0 || index > Count) { throw new ArgumentOutOfRangeException("index out of range!"); } if (!_AssertMode(mode)) { throw new ArgumentException("mode is illegal!"); } if (Count == 1 && ActualWidth > 0 && ActualHeight > 0) { ILayoutSize size = Children[0] as ILayoutSize; size.DesiredWidth = ActualWidth; size.DesiredHeight = ActualHeight; } if (child is LayoutDocumentGroupControl || child is LayoutGroupDocumentPanel || mode == AttachMode.Left_WithSplit || mode == AttachMode.Top_WithSplit || mode == AttachMode.Right_WithSplit || mode == AttachMode.Bottom_WithSplit) { _AttachWithSplit(child, mode, index); } else { if (IsRootPanel) { AttachToRootPanel(child, mode); } else { var parent = Parent as LayoutGroupPanel; switch (parent.Direction) { case Direction.LeftToRight: if (mode == AttachMode.Left || mode == AttachMode.Right) { if (child is LayoutGroupPanel) { _AttachSubPanel((child as LayoutGroupPanel), index); } else { _AttachChild(child, index); } } else { int _index = parent.IndexOf(this); parent._DetachChild(this); var pparent = new LayoutGroupPanel() { Direction = Direction.UpToDown }; parent._AttachChild(pparent, _index); pparent._AttachChild(this, 0); pparent._AttachChild(child, mode == AttachMode.Top ? 0 : 1); } break; case Direction.UpToDown: if (mode == AttachMode.Top || mode == AttachMode.Bottom) { if (child is LayoutGroupPanel) { _AttachSubPanel((child as LayoutGroupPanel), index); } else { _AttachChild(child, index); } } else { int _index = parent.IndexOf(this); parent._DetachChild(this); var pparent = new LayoutGroupPanel() { Direction = Direction.LeftToRight }; parent._AttachChild(pparent, _index); pparent._AttachChild(this, 0); pparent._AttachChild(child, mode == AttachMode.Left ? 0 : 1); } break; } } } }
public void AttachTo(LayoutGroupPanel panel, IDockView source, DropMode mode) { int index = panel.Children.IndexOf(this); switch (mode) { case DropMode.Left: if (panel.Direction == Direction.Vertical) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.Horizontal, DesiredWidth = Math.Max(ActualWidth, Constants.DockDefaultWidthLength), DesiredHeight = Math.Max(ActualHeight, Constants.DockDefaultHeightLength), IsAnchorPanel = true }; panel._DetachChild(this); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Left, 0); } else { panel._AttachChild(source, index); } break; case DropMode.Top: if (panel.Direction == Direction.Horizontal) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.Vertical, DesiredWidth = Math.Max(ActualWidth, Constants.DockDefaultWidthLength), DesiredHeight = Math.Max(ActualHeight, Constants.DockDefaultHeightLength), IsAnchorPanel = true }; panel._DetachChild(this); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Top, 0); } else { panel._AttachChild(source, index); } break; case DropMode.Right: if (panel.Direction == Direction.Vertical) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.Horizontal, DesiredWidth = Math.Max(ActualWidth, Constants.DockDefaultWidthLength), DesiredHeight = Math.Max(ActualHeight, Constants.DockDefaultHeightLength), IsAnchorPanel = true }; panel._DetachChild(this); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Right, 1); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); } else { panel._AttachChild(source, index + 1); } break; case DropMode.Bottom: if (panel.Direction == Direction.Horizontal) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.Vertical, DesiredWidth = Math.Max(ActualWidth, Constants.DockDefaultWidthLength), DesiredHeight = Math.Max(ActualHeight, Constants.DockDefaultHeightLength), IsAnchorPanel = true }; panel._DetachChild(this); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Bottom, 1); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); } else { panel._AttachChild(source, index + 1); } break; } }
public override void OnDrop(DragItem source) { if (DropMode == DropMode.Header || DropMode == DropMode.Center) { base.OnDrop(source); } else { IDockView child; if (source.RelativeObj is BaseFloatWindow) { child = (source.RelativeObj as BaseFloatWindow).Child; (source.RelativeObj as BaseFloatWindow).DetachChild(child); } else { child = source.RelativeObj as IDockView; } DockManager.ChangeDockMode(child, (Model as ILayoutGroup).Mode); if (_AssertSplitMode(DropMode)) { //must to changside DockManager.ChangeSide(child, Model.Side); if (DockViewParent == null) { var parent = Parent as BaseFloatWindow; parent.DetachChild(this, false); var panel = new LayoutGroupDocumentPanel() { DesiredWidth = Math.Max(parent.ActualWidth, Constants.DockDefaultWidthLength), DesiredHeight = Math.Max(parent.ActualHeight, Constants.DockDefaultHeightLength), Direction = (DropMode == DropMode.Left_WithSplit || DropMode == DropMode.Right_WithSplit) ? Direction.Horizontal : Direction.Vertical }; panel._AttachChild(this, 0); if (DropMode == DropMode.Left_WithSplit || DropMode == DropMode.Top_WithSplit) { panel.AttachChild(child, DropMode == DropMode.Left_WithSplit ? AttachMode.Left_WithSplit : AttachMode.Top_WithSplit, 0); } else { panel.AttachChild(child, DropMode == DropMode.Right_WithSplit ? AttachMode.Right_WithSplit : AttachMode.Bottom_WithSplit, 1); } parent.AttachChild(panel, AttachMode.None, 0); } else { var parent = Parent as LayoutGroupDocumentPanel; parent.Direction = (DropMode == DropMode.Left_WithSplit || DropMode == DropMode.Right_WithSplit) ? Direction.Horizontal : Direction.Vertical; int index = parent.IndexOf(this); switch (DropMode) { case DropMode.Left_WithSplit: parent.AttachChild(child, AttachMode.Left_WithSplit, index); break; case DropMode.Top_WithSplit: parent.AttachChild(child, AttachMode.Top_WithSplit, index); break; case DropMode.Right_WithSplit: parent.AttachChild(child, AttachMode.Right_WithSplit, index + 1); break; case DropMode.Bottom_WithSplit: parent.AttachChild(child, AttachMode.Bottom_WithSplit, index + 1); break; } } } else { DockManager.FormatChildSize(child as ILayoutSize, new Size(ActualWidth, ActualHeight)); var _parent = Parent as LayoutGroupDocumentPanel; var child_size = child as ILayoutSize; if (_parent.DockViewParent is LayoutRootPanel) { var rootPanel = _parent.DockViewParent as LayoutRootPanel; rootPanel.DetachChild(_parent, false); var pparent = new LayoutGroupPanel() { Direction = (DropMode == DropMode.Left || DropMode == DropMode.Right) ? Direction.Horizontal : Direction.Vertical }; pparent._AttachChild(_parent, 0); switch (DropMode) { case DropMode.Left: DockManager.ChangeSide(child, DockSide.Left); pparent.AttachChild(child, AttachMode.Left, 0); break; case DropMode.Top: DockManager.ChangeSide(child, DockSide.Top); pparent.AttachChild(child, AttachMode.Top, 0); break; case DropMode.Right: DockManager.ChangeSide(child, DockSide.Right); pparent.AttachChild(child, AttachMode.Right, 1); break; case DropMode.Bottom: DockManager.ChangeSide(child, DockSide.Bottom); pparent.AttachChild(child, AttachMode.Bottom, 1); break; } rootPanel.AttachChild(pparent, AttachMode.None, 0); } else { var panel = _parent.DockViewParent as LayoutGroupPanel; int index = panel.IndexOf(_parent); switch (DropMode) { case DropMode.Left: DockManager.ChangeSide(child, DockSide.Left); if (panel.Direction == Direction.Horizontal) { panel.AttachChild(child, AttachMode.Left, index); } else { panel._DetachChild(_parent); var pparent = new LayoutGroupPanel() { Direction = Direction.Horizontal }; pparent._AttachChild(_parent, 0); pparent._AttachChild(child, 0); panel._AttachChild(pparent, Math.Min(index, panel.Count)); } break; case DropMode.Top: DockManager.ChangeSide(child, DockSide.Top); if (panel.Direction == Direction.Vertical) { panel.AttachChild(child, AttachMode.Top, index); } else { panel._DetachChild(_parent); var pparent = new LayoutGroupPanel() { Direction = Direction.Vertical }; pparent._AttachChild(_parent, 0); pparent._AttachChild(child, 0); panel._AttachChild(pparent, Math.Min(index, panel.Count)); } break; case DropMode.Right: DockManager.ChangeSide(child, DockSide.Right); if (panel.Direction == Direction.Horizontal) { panel.AttachChild(child, AttachMode.Right, index + 1); } else { panel._DetachChild(_parent); var pparent = new LayoutGroupPanel() { Direction = Direction.Horizontal }; pparent._AttachChild(_parent, 0); pparent._AttachChild(child, 1); panel._AttachChild(pparent, Math.Min(index, panel.Count)); } break; case DropMode.Bottom: DockManager.ChangeSide(child, DockSide.Bottom); if (panel.Direction == Direction.Vertical) { panel.AttachChild(child, AttachMode.Bottom, index + 1); } else { panel._DetachChild(_parent); var pparent = new LayoutGroupPanel() { Direction = Direction.Vertical }; pparent._AttachChild(_parent, 0); pparent._AttachChild(child, 1); panel._AttachChild(pparent, Math.Min(index, panel.Count)); } break; } } } } if (source.RelativeObj is BaseFloatWindow) { (source.RelativeObj as BaseFloatWindow).Close(); } }
public void AttachTo(LayoutGroupPanel panel, IDockView source, DropMode mode) { int index = panel.Children.IndexOf(this); switch (mode) { case DropMode.Left: if (panel.Direction == Direction.UpToDown) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.LeftToRight, DesiredWidth = ActualWidth, DesiredHeight = ActualHeight, IsAnchorPanel = true }; panel._DetachChild(this); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Left, 0); } else { panel._AttachChild(source, index); } break; case DropMode.Top: if (panel.Direction == Direction.LeftToRight) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.UpToDown, DesiredWidth = ActualWidth, DesiredHeight = ActualHeight, IsAnchorPanel = true }; panel._DetachChild(this); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Top, 0); } else { panel._AttachChild(source, index); } break; case DropMode.Right: if (panel.Direction == Direction.UpToDown) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.LeftToRight, DesiredWidth = ActualWidth, DesiredHeight = ActualHeight, IsAnchorPanel = true }; panel._DetachChild(this); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Right, 1); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); } else { panel._AttachChild(source, index + 1); } break; case DropMode.Bottom: if (panel.Direction == Direction.LeftToRight) { var _subpanel = new LayoutGroupPanel(Model.Side) { Direction = Direction.UpToDown, DesiredWidth = ActualWidth, DesiredHeight = ActualHeight, IsAnchorPanel = true }; panel._DetachChild(this); _subpanel._AttachChild(this, 0); _subpanel.AttachChild(source, AttachMode.Bottom, 1); panel._AttachChild(_subpanel, Math.Min(index, panel.Count)); } else { panel._AttachChild(source, index + 1); } break; } }