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 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; } }