Exemple #1
0
        private void _ToRoot(DockManager dockManager)
        {
            Mode = DockMode.Normal;
            var group = new LayoutGroup(Side, Mode, dockManager);

            group.Attach(this);
            var groupctrl = new AnchorSideGroupControl(group)
            {
                DesiredHeight = DesiredHeight, DesiredWidth = DesiredWidth
            };

            switch (Side)
            {
            case DockSide.Left:
                dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(groupctrl, AttachMode.Left, 0);
                break;

            case DockSide.Right:
                dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(groupctrl, AttachMode.Right, dockManager.LayoutRootPanel.RootGroupPanel.Count);
                break;

            case DockSide.Top:
                dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(groupctrl, AttachMode.Top, 0);
                break;

            case DockSide.Bottom:
                dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(groupctrl, AttachMode.Bottom, dockManager.LayoutRootPanel.RootGroupPanel.Count);
                break;
            }
        }
Exemple #2
0
        public void ToFloat(bool isActive = true)
        {
            if (!CanFloat && isActive)
            {
                _dockControl.SetActive();
                return;
            }
            if (_container != null)
            {
                CanSelect = true;
                //注意切换模式
                Mode = DockMode.Float;
                var dockManager = DockManager;
                _container.Detach(this);
                _container = null;
                BaseFloatWindow  wnd;
                BaseGroupControl groupctrl;
                if (!IsDocument)
                {
                    var group = new LayoutGroup(Side, Mode, dockManager);
                    group.Attach(this);
                    groupctrl = new AnchorSideGroupControl(group)
                    {
                        DesiredHeight = DesiredHeight, DesiredWidth = DesiredWidth
                    };
                    wnd = new AnchorGroupWindow(dockManager)
                    {
                        Height = DesiredHeight,
                        Width  = DesiredWidth,
                        Left   = FloatLeft,
                        Top    = FloatTop
                    };
                }
                else
                {
                    var group = new LayoutDocumentGroup(Mode, dockManager);
                    group.Attach(this);
                    groupctrl = new LayoutDocumentGroupControl(group)
                    {
                        DesiredHeight = DesiredHeight, DesiredWidth = DesiredWidth
                    };
                    wnd = new DocumentGroupWindow(dockManager)
                    {
                        Height = DesiredHeight,
                        Width  = DesiredWidth,
                        Left   = FloatLeft,
                        Top    = FloatTop
                    };
                }
                wnd.AttachChild(groupctrl, AttachMode.None, 0);
                wnd.Show();

                if (isActive)
                {
                    _dockControl.SetActive();
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// attach source to target by <see cref="AttachMode"/>
 /// </summary>
 /// <param name="source">源</param>
 /// <param name="target">目标</param>
 /// <param name="mode">附加模式</param>
 public void AttachTo(IDockControl source, IDockControl target, AttachMode mode)
 {
     if (target.Container.View == null)
     {
         throw new InvalidOperationException("target must be visible!");
     }
     if (target.IsDisposed)
     {
         throw new InvalidOperationException("target is disposed!");
     }
     if (source == target)
     {
         throw new InvalidOperationException("source can not be target!");
     }
     if (source == null || target == null)
     {
         throw new ArgumentNullException("source or target is null!");
     }
     if (source.Container.View != target.Container.View && source.CanSelect)
     {
         source.SetActive();
     }
     else if (source.Container != null)
     {
         source.Container.Detach(source.ProtoType);
         BaseLayoutGroup  group;
         BaseGroupControl ctrl;
         if (source.IsDocument)
         {
             group = new LayoutDocumentGroup(DockMode.Normal, this);
             ctrl  = new LayoutDocumentGroupControl(group, (target.Container.View as ILayoutViewWithSize).DesiredWidth, (target.Container.View as ILayoutViewWithSize).DesiredHeight);
         }
         else
         {
             group = new LayoutGroup(source.Side, DockMode.Normal, this);
             ctrl  = new AnchorSideGroupControl(group, (target.Container.View as ILayoutViewWithSize).DesiredWidth, (target.Container.View as ILayoutViewWithSize).DesiredHeight);
         }
         group.Attach(source.ProtoType);
         var _atsource = target.ProtoType.Container.View as IAttcah;
         _atsource.AttachWith(ctrl, mode);
         source.SetActive();
     }
     else
     {
         throw new ArgumentNullException("the container of source is null!");
     }
 }
Exemple #4
0
        public override void ShowWithActive(IDockElement element, bool toActice = true)
        {
            base.ShowWithActive(element, toActice);
            if (_view != null)
            {
                (_view as TabControl).SelectedIndex = IndexOf(element);
            }
            else//_view不存在则要创建新的_view
            {
                if (_attachObj == null || !_attachObj.AttachTo())
                {
                    if (this is LayoutDocumentGroup)
                    {
                        var _children = Children.ToList();
                        _children.Reverse();
                        var dockManager = _dockManager;
                        Dispose();
                        foreach (var child in _children)
                        {
                            dockManager.Root.DocumentModels[0].Attach(child);
                        }
                    }
                    else
                    {
                        var ctrl = new AnchorSideGroupControl(this);
                        switch (Side)
                        {
                        case DockSide.Left:
                            _dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(ctrl, AttachMode.Left, 0);
                            break;

                        case DockSide.Right:
                            _dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(ctrl, AttachMode.Right, _dockManager.LayoutRootPanel.RootGroupPanel.Count);
                            break;

                        case DockSide.Top:
                            _dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(ctrl, AttachMode.Top, 0);
                            break;

                        case DockSide.Bottom:
                            _dockManager.LayoutRootPanel.RootGroupPanel.AttachChild(ctrl, AttachMode.Bottom, _dockManager.LayoutRootPanel.RootGroupPanel.Count);
                            break;
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// attach source to target by <see cref="AttachMode"/>
        /// </summary>
        /// <param name="source">源</param>
        /// <param name="target">目标</param>
        /// <param name="mode">附加模式</param>
        public void AttachTo(IDockControl source, IDockControl target, AttachMode mode, double ratio = -1)
        {
            if (target.Container.View == null)
            {
                throw new InvalidOperationException("target must be visible!");
            }
            if (target.IsDisposed)
            {
                throw new InvalidOperationException("target is disposed!");
            }
            if (source == target)
            {
                throw new InvalidOperationException("source can not be target!");
            }
            if (source == null || target == null)
            {
                throw new ArgumentNullException("source or target is null!");
            }
            if (target.Mode == DockMode.DockBar)
            {
                throw new ArgumentNullException("target is DockBar Mode!");
            }
            if (source.Container != null)
            {
                //DockBar模式下无法合并,故先转换为Normal模式
                //if (target.Mode == DockMode.DockBar)
                //    target.ToDock();

                source.Container.Detach(source.ProtoType);


                double width = (target.Container.View as ILayoutViewWithSize).DesiredWidth
                , height     = (target.Container.View as ILayoutViewWithSize).DesiredHeight;

                if (ratio > 0)
                {
                    if (mode == AttachMode.Right ||
                        mode == AttachMode.Left ||
                        mode == AttachMode.Left_WithSplit ||
                        mode == AttachMode.Right_WithSplit)
                    {
                        width = (target.Container.View as ILayoutViewWithSize).DesiredWidth * ratio;
                    }

                    if (mode == AttachMode.Top ||
                        mode == AttachMode.Bottom ||
                        mode == AttachMode.Top_WithSplit ||
                        mode == AttachMode.Bottom_WithSplit)
                    {
                        height = (target.Container.View as ILayoutViewWithSize).DesiredHeight * ratio;
                    }
                }

                BaseLayoutGroup  group;
                BaseGroupControl ctrl;
                if (source.IsDocument)
                {
                    group = new LayoutDocumentGroup(DockMode.Normal, this);
                    ctrl  = new LayoutDocumentGroupControl(group, ratio > 0 ? width : source.DesiredWidth, ratio > 0 ? height : source.DesiredHeight);
                }
                else
                {
                    group = new LayoutGroup(source.Side, DockMode.Normal, this);
                    ctrl  = new AnchorSideGroupControl(group, ratio > 0 ? width : source.DesiredWidth, ratio > 0 ? height : source.DesiredHeight);
                }
                group.Attach(source.ProtoType);
                var _atsource = target.ProtoType.Container.View as IAttcah;
                _atsource.AttachWith(ctrl, mode);
                source.SetActive();
            }
            else
            {
                throw new ArgumentNullException("the container of source is null!");
            }
        }
Exemple #6
0
        public override void ToFloat()
        {
            BaseFloatWindow  wnd;
            BaseGroupControl ctrl;
            BaseLayoutGroup  group;
            var dockManager = _dockManager;
            var children    = _children.ToList();
            var ele         = children.First();

            //hide all first
            foreach (var child in children)
            {
                Detach(child);
            }

            if (this is LayoutDocumentGroup)
            {
                group = new LayoutDocumentGroup(DockMode.Float, dockManager);
                foreach (var child in children)
                {
                    group.Attach(child);
                }

                ctrl = new LayoutDocumentGroupControl(group)
                {
                    DesiredHeight = ele.DesiredHeight, DesiredWidth = ele.DesiredWidth
                };
                wnd = new DocumentGroupWindow(dockManager)
                {
                    Height = ele.DesiredHeight,
                    Width  = ele.DesiredWidth,
                    Left   = ele.FloatLeft,
                    Top    = ele.FloatTop
                };
            }
            else
            {
                group = new LayoutGroup(_side, DockMode.Float, dockManager);
                foreach (var child in children)
                {
                    group.Attach(child);
                }

                ctrl = new AnchorSideGroupControl(group)
                {
                    DesiredHeight = ele.DesiredHeight, DesiredWidth = ele.DesiredWidth
                };
                wnd = new AnchorGroupWindow(dockManager)
                {
                    Height = ele.DesiredHeight,
                    Width  = ele.DesiredWidth,
                    Left   = ele.FloatLeft,
                    Top    = ele.FloatTop
                };
            }

            wnd.AttachChild(ctrl, AttachMode.None, 0);
            wnd.Show();

            dockManager.ActiveControl.SetActive();
        }