Esempio n. 1
0
 public void DetachChild(IDockView child, bool force = true)
 {
     if (child == RootGroupPanel)
     {
         RootGroupPanel = null;
     }
 }
Esempio n. 2
0
 public override void AttachChild(IDockView child, AttachMode mode, int index)
 {
     //后面的2是border Thickness
     _widthEceeed  += Constants.DocumentWindowPadding * 2 + 2;
     _heightEceeed += Constants.DocumentWindowPadding * 2 + Constants.FloatWindowHeaderHeight + 2;
     base.AttachChild(child, mode, index);
 }
Esempio n. 3
0
 public void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (child is LayoutGroupPanel)
     {
         RootGroupPanel = child as LayoutGroupPanel;
     }
 }
 public override void DetachChild(IDockView child, bool force = true)
 {
     if (!(child is LayoutDocumentGroupControl))
     {
         throw new InvalidOperationException("not support Operation!");
     }
     else
     {
         _DetachChild(child);
         if (DockViewParent != null)
         {
             DockManager.Root.DocumentModels.Remove(child.Model as BaseLayoutGroup);
         }
         if (Count < 2)
         {
             Direction = Direction.None;
         }
         if (Count == 1)
         {
             if (DockViewParent == null)
             {
                 var _child = Children[0];
                 var wnd    = Parent as ILayoutViewParent;
                 wnd.DetachChild(this, false);
                 _Dispose();
                 wnd.AttachChild(_child as IDockView, AttachMode.None, 0);
             }
         }
     }
 }
Esempio n. 5
0
 public void SetUp( )
 {
     mockery     = new MockRepository( );
     mockView    = mockery.DynamicMock <IDockView>( );
     mockTask    = mockery.DynamicMock <ICatalogTasks>( );
     mockRequest = mockery.DynamicMock <IHttpRequest>( );
 }
Esempio n. 6
0
 public DockPresenter(IDockView view)
     : this(
         view,
         Resolve.DependencyFor <IHttpRequest>( ),
         Resolve.DependencyFor <ICatalogTasks>( )
         )
 {
 }
Esempio n. 7
0
 public virtual void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (Content != child)
     {
         Content = child;
         DockManager.AddFloatWindow(this);
         Height = (child as ILayoutSize).DesiredHeight + _heightEceeed;
         Width  = (child as ILayoutSize).DesiredWidth + _widthEceeed;
     }
 }
Esempio n. 8
0
 public int IndexOf(IDockView child)
 {
     if (child == RootGroupPanel)
     {
         return(0);
     }
     else
     {
         return(-1);
     }
 }
Esempio n. 9
0
 public int IndexOf(IDockView child)
 {
     if (child == Child)
     {
         return(0);
     }
     else
     {
         return(-1);
     }
 }
Esempio n. 10
0
 public override void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (child is ILayoutPanel)
     {
         _heightEceeed += Constants.FloatWindowHeaderHeight;
     }
     Owner = DockManager.MainWindow;
     base.AttachChild(child, mode, index);
     if (child is BaseGroupControl)
     {
         (((child as BaseGroupControl).Model as BaseLayoutGroup).Children as ObservableCollection <IDockElement>).CollectionChanged += OnCollectionChanged;
     }
 }
Esempio n. 11
0
 public virtual void Dispose()
 {
     _children.CollectionChanged -= OnChildrenCollectionChanged;
     foreach (var child in _children)
     {
         child.PropertyChanged           -= OnChildrenPropertyChanged;
         (child as DockElement).Container = null;
     }
     _children.Clear();
     _children       = null;
     PropertyChanged = null;
     _view?.Dispose();
     _view = null;
 }
Esempio n. 12
0
 internal static void ChangeDockMode(IDockView view, DockMode mode)
 {
     if (view is BaseGroupControl)
     {
         (view.Model as BaseLayoutGroup).Mode = mode;
     }
     if (view is LayoutGroupPanel)
     {
         foreach (var _view in (view as LayoutGroupPanel).Children.OfType <IDockView>())
         {
             ChangeDockMode(_view, mode);
         }
     }
 }
Esempio n. 13
0
        public void AttachWith(IDockView source, AttachMode mode = AttachMode.Center)
        {
            switch (mode)
            {
            case AttachMode.Left:
                _dropMode = DropMode.Left;
                break;

            case AttachMode.Top:
                _dropMode = DropMode.Top;
                break;

            case AttachMode.Right:
                _dropMode = DropMode.Right;
                break;

            case AttachMode.Bottom:
                _dropMode = DropMode.Bottom;
                break;

            case AttachMode.Left_WithSplit:
                _dropMode = DropMode.Left_WithSplit;
                break;

            case AttachMode.Top_WithSplit:
                _dropMode = DropMode.Top_WithSplit;
                break;

            case AttachMode.Right_WithSplit:
                _dropMode = DropMode.Right_WithSplit;
                break;

            case AttachMode.Bottom_WithSplit:
                _dropMode = DropMode.Bottom_WithSplit;
                break;

            case AttachMode.Center:
                _dropMode = DropMode.Center;
                break;

            default:
                _dropMode = DropMode.None;
                break;
            }
            DragItem item = new DragItem(source, DockMode.Normal, DragMode.None, new Point(), Rect.Empty, Size.Empty);

            OnDrop(item);
            _dropMode = DropMode.None;
        }
Esempio n. 14
0
        public override void DetachChild(IDockView child, bool force = true)
        {
            if (child is BaseGroupControl)
            {
                (((child as BaseGroupControl).Model as BaseLayoutGroup).Children as ObservableCollection <IDockElement>).CollectionChanged -= OnCollectionChanged;
            }

            if (force)
            {
                Owner = null;
            }

            base.DetachChild(child, force);
            UpdateSize();
        }
Esempio n. 15
0
        internal static void ClearAttachObj(IDockView view)
        {
            if (view is AnchorSideGroupControl)
            {
                (view.Model as LayoutGroup).AttachObj?.Dispose();
            }

            if (view is LayoutGroupPanel)
            {
                foreach (var _view in (view as LayoutGroupPanel).Children.OfType <IDockView>())
                {
                    ClearAttachObj(_view);
                }
            }
        }
Esempio n. 16
0
 internal static void ChangeSide(IDockView view, DockSide side)
 {
     if (view.Model != null && view.Model.Side == side)
     {
         return;
     }
     if (view is BaseGroupControl)
     {
         (view.Model as BaseLayoutGroup).Side = side;
     }
     if (view is LayoutGroupPanel)
     {
         (view as LayoutGroupPanel).Side = side;
     }
 }
        private void _AttachWithSplit(IDockView child, AttachMode mode, int index)
        {
            if (child is LayoutDocumentGroupControl)
            {
                if (Direction == Direction.None)
                {
                    Direction = (mode == AttachMode.Left_WithSplit || mode == AttachMode.Right_WithSplit) ? Direction.LeftToRight : Direction.UpToDown;
                }
                _AttachChild(child, index);

                if (DockViewParent != null)
                {
                    DockManager.Root.DocumentModels.Add(child.Model as BaseLayoutGroup);
                }
            }

            if (child is AnchorSideGroupControl)
            {
                var model     = (child as AnchorSideGroupControl).Model as LayoutGroup;
                var _children = new List <IDockElement>(model.Children);
                model.Dispose();
                var group = new LayoutDocumentGroup(DockViewParent == null ? DockMode.Float : DockMode.Normal, DockManager);
                foreach (var _child in _children)
                {
                    group.Attach(_child);
                }
                var ctrl = new LayoutDocumentGroupControl(group);
                _AttachChild(ctrl, index);
                (child as IDisposable).Dispose();
            }

            if (child is LayoutGroupDocumentPanel ||
                child is LayoutGroupPanel)
            {
                var _children = new List <IDockView>((child as LayoutGroupPanel).Children.OfType <IDockView>());
                _children.Reverse();
                (child as LayoutGroupPanel).Children.Clear();
                foreach (var _child in _children)
                {
                    _AttachWithSplit(_child as IDockView, mode, index);
                }
                (child as IDisposable).Dispose();
            }

            //if (child is IDisposable)
            //    (child as IDisposable).Dispose();
        }
Esempio n. 18
0
 public virtual void DetachChild(IDockView child, bool force = true)
 {
     if (child == Content)
     {
         DockManager.RemoveFloatWindow(this);
         SaveSize();
         if (child is BaseGroupControl)
         {
             (child as BaseGroupControl).IsDraggingFromDock = false;
         }
         Content = null;
         if (force)
         {
             _dockManager = null;
         }
     }
 }
Esempio n. 19
0
 public virtual void DetachChild(IDockView child, bool force = true)
 {
     if (child == Content)
     {
         DockManager.RemoveFloatWindow(this);
         //保存Size信息
         if (child is ILayoutSize)
         {
             var _child = child as ILayoutSize;
             _child.DesiredWidth  = Math.Max(ActualWidth - _widthEceeed, Constants.SideLength);
             _child.DesiredHeight = Math.Max(ActualHeight - _heightEceeed, Constants.SideLength);
         }
         if (child is BaseGroupControl)
         {
             (child as BaseGroupControl).IsDraggingFromDock = false;
         }
         Content = null;
         if (force)
         {
             _dockManager = null;
         }
     }
 }
        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;
                    }
                }
            }
        }
Esempio n. 21
0
        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;
            }
        }
Esempio n. 22
0
 internal DockBarItemControl(IDockView dockViewParent)
 {
     _dockViewParent = dockViewParent;
 }
Esempio n. 23
0
        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;
            }
        }
Esempio n. 24
0
 public void Dispose()
 {
     _dockViewParent = null;
 }
Esempio n. 25
0
        internal IDockView FindChildByLevel(int level, DockSide side)
        {
            IDockView view = _rootGroupPanel;

            while (level > 0)
            {
                level--;
                if (view is BaseGroupControl)
                {
                    break;
                }
                if (view is LayoutGroupPanel)
                {
                    var panel = (view as LayoutGroupPanel);
                    if (panel.Direction == Direction.None)
                    {
                        break;
                    }
                    if (panel.Direction == Direction.LeftToRight)
                    {
                        if (side == DockSide.Top || side == DockSide.Bottom)
                        {
                            break;
                        }
                        if (side == DockSide.Left)
                        {
                            var child = panel.Children[0];
                            if (child is LayoutDocumentGroupControl)
                            {
                                break;
                            }
                            view = child as IDockView;
                        }
                        if (side == DockSide.Right)
                        {
                            var child = panel.Children[panel.Count - 1];
                            if (child is LayoutDocumentGroupControl)
                            {
                                break;
                            }
                            view = child as IDockView;
                        }
                    }
                    else
                    {
                        if (side == DockSide.Left || side == DockSide.Right)
                        {
                            break;
                        }
                        if (side == DockSide.Top)
                        {
                            var child = panel.Children[0];
                            if (child is LayoutDocumentGroupControl)
                            {
                                break;
                            }
                            view = child as IDockView;
                        }
                        if (side == DockSide.Bottom)
                        {
                            var child = panel.Children[panel.Count - 1];
                            if (child is LayoutDocumentGroupControl)
                            {
                                break;
                            }
                            view = child as IDockView;
                        }
                    }
                }
            }
            return(view);
        }
Esempio n. 26
0
 public DockPresenter(IDockView view, IHttpRequest request, ICatalogTasks task)
 {
     _request = request;
     _view    = view;
     _task    = task;
 }