Beispiel #1
0
 public abstract int MeasureViewDockSideTabLength(ViewDockSideTab tab, Graphics graphics);
Beispiel #2
0
 private void SpawnPanel(ViewDockSideTab tab)
 {
     SpawnPanel(tab, false);
 }
Beispiel #3
0
        private void SpawnPanel(ViewDockSideTab tab, bool activate)
        {
            _grid.SuspendLayout();
            if (_visibleHost == tab.ViewHost)
            {
                if (activate)
                {
                    _visibleHost.Activate(tab.View);
                }
                else
                {
                    _visibleHost.SetActiveView(tab.View);
                }
            }
            else
            {
                DespawnPanel();
                Rectangle    bounds;
                AnchorStyles anchor;
                _visibleHost = tab.ViewHost;
                switch (_side)
                {
                case AnchorStyles.Left:
                {
                    var w = _visibleHost.Width;
                    bounds = new Rectangle(Renderer.SideTabHeight, Top, w, _grid.VerticalClientSpace);
                    anchor = ViewConstants.AnchorDockLeft;
                }
                break;

                case AnchorStyles.Top:
                {
                    var h = _visibleHost.Height;
                    bounds = new Rectangle(Left, Renderer.SideTabHeight, _grid.HorizontalClientSpace, h);
                    anchor = ViewConstants.AnchorDockTop;
                }
                break;

                case AnchorStyles.Right:
                {
                    var w = _visibleHost.Width;
                    bounds = new Rectangle(Left - w, Top, w, _grid.VerticalClientSpace);
                    anchor = ViewConstants.AnchorDockRight;
                }
                break;

                case AnchorStyles.Bottom:
                {
                    var h = _visibleHost.Height;
                    bounds = new Rectangle(Left, Top - h, _grid.HorizontalClientSpace, h);
                    anchor = ViewConstants.AnchorDockBottom;
                }
                break;

                default:
                    _visibleHost = null;
                    throw new ApplicationException(string.Format(
                                                       CultureInfo.InvariantCulture,
                                                       "Unexpected {0}.Side: {1}", GetType().Name, Side));
                }
                if (_side != AnchorStyles.Left && _grid.LeftSide != null)
                {
                    _grid.LeftSide.DespawnPanel();
                }
                if (_side != AnchorStyles.Top && _grid.TopSide != null)
                {
                    _grid.TopSide.DespawnPanel();
                }
                if (_side != AnchorStyles.Right && _grid.RightSide != null)
                {
                    _grid.RightSide.DespawnPanel();
                }
                if (_side != AnchorStyles.Bottom && _grid.BottomSide != null)
                {
                    _grid.BottomSide.DespawnPanel();
                }
                _visibleHost.SetActiveView(tab.View);
                _visibleHost.Bounds = bounds;
                _visibleHost.Anchor = anchor;
                _visibleHost.Parent = _grid;
                _visibleHost.BringToFront();
                _grid.ResumeLayout(true);
                if (activate)
                {
                    _visibleHost.Activate();
                }
            }
            _autoHideTimer.Enabled = true;
        }
Beispiel #4
0
        /// <summary>Adds <see cref="ViewHost"/> to this <see cref="ViewDockSide"/>.</summary>
        /// <param name="viewHost"><see cref="ViewHost"/> to add.</param>
        public void AddHost(ViewHost viewHost)
        {
            Verify.Argument.IsNotNull(viewHost, nameof(viewHost));

            _dockedHosts.Add(viewHost);
            viewHost.DockSide = this;
            viewHost.Status   = ViewHostStatus.AutoHide;
            int size = 0;

            using (var graphics = CreateGraphics())
            {
                if (viewHost.ViewsCount != 0)
                {
                    foreach (var view in viewHost.Views)
                    {
                        var tab = new ViewDockSideTab(this, viewHost, view);
                        tab.ResetLength(graphics);
                        size += tab.Length;
                        _tabs.Add(tab);
                        view.TextChanged += OnViewTextChanged;
                    }
                }
            }
            switch (Orientation)
            {
            case Orientation.Vertical:
            {
                var space  = _grid.VerticalClientSpace;
                var height = _size + size;
                _size   = height;
                height += _tabs.Count * Renderer.SideTabSpacing;
                if (height > space)
                {
                    height = space;
                }
                Height = height;
            }
            break;

            case Orientation.Horizontal:
            {
                var space = _grid.HorizontalClientSpace;
                var width = _size + size;
                _size  = width;
                width += _tabs.Count * Renderer.SideTabSpacing;
                if (width > space)
                {
                    width = space;
                }
                Width = width;
            }
            break;

            default:
                throw new ApplicationException(string.Format(
                                                   CultureInfo.InvariantCulture,
                                                   "Unexpected {0}.Orientation: {1}", GetType().Name, Orientation));
            }
            viewHost.ViewAdded   += OnViewAdded;
            viewHost.ViewRemoved += OnViewRemoved;
        }
Beispiel #5
0
        private void OnViewAdded(object sender, ViewEventArgs e)
        {
            var host = (ViewHost)sender;
            int i    = _tabs.Count - 1;

            for (; i >= 0; --i)
            {
                if (_tabs[i].ViewHost == host)
                {
                    break;
                }
            }
            var tab = new ViewDockSideTab(this, host, e.View);

            tab.ResetLength();
            var size = tab.Length;

            _tabs.Insert(i, tab);
            switch (_orientation)
            {
            case Orientation.Vertical:
            {
                var space  = _grid.VerticalClientSpace;
                var height = _size + size;
                _size = height;
                if (_tabs.Count != 1)
                {
                    height += Renderer.SideTabSpacing;
                }
                if (height > space)
                {
                    height = space;
                }
                Height = height;
            }
            break;

            case Orientation.Horizontal:
            {
                var space = _grid.HorizontalClientSpace;
                var width = _size + size;
                _size = width;
                if (_tabs.Count != 1)
                {
                    width += Renderer.SideTabSpacing;
                }
                if (width > space)
                {
                    width = space;
                }
                Width = width;
            }
            break;

            default:
                throw new ApplicationException(string.Format(
                                                   CultureInfo.InvariantCulture,
                                                   "Unexpected {0}.Orientation: {1}", GetType().Name, Orientation));
            }
            e.View.TextChanged += OnViewTextChanged;
            Invalidate();
        }
 public override void RenderViewDockSideTabBackground(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     RenderTabBackground(tab, bounds, graphics);
 }
 public override void RenderViewDockSideTabContent(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     RenderTabContent(tab, bounds, graphics);
 }
 public override void RenderViewDockSideTabContent(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     switch(tab.Side.Side)
     {
         case AnchorStyles.Left:
             bounds.X += Constants.SideTabOutline;
             bounds.Width -= Constants.SideTabOutline;
             break;
         case AnchorStyles.Top:
             bounds.Y += Constants.SideTabOutline;
             bounds.Height -= Constants.SideTabOutline;
             break;
         case AnchorStyles.Right:
             bounds.Width -= Constants.SideTabOutline;
             break;
         case AnchorStyles.Bottom:
             bounds.Height -= Constants.SideTabOutline;
             break;
         default:
             throw new ApplicationException(
                 string.Format("Unexpected DockSide.Side value: {0}", tab.Side.Anchor));
     }
     var color = tab.IsMouseOver ?
         ColorTable.DockSideTabForegroundHover :
         ColorTable.DockSideTabForeground;
     RenderTabContent(tab, bounds, graphics, color);
 }
 public override int MeasureViewDockSideTabLength(ViewDockSideTab tab, Graphics graphics)
 {
     return MeasureTabLength(tab, graphics);
 }
Beispiel #10
0
 public abstract void RenderViewDockSideTabContent(ViewDockSideTab tab, Graphics graphics, Rectangle bounds);
 public override void RenderViewDockSideTabBackground(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     var rcOutline = bounds;
     switch(tab.Side.Side)
     {
         case AnchorStyles.Left:
             rcOutline.Width = Constants.SideTabOutline;
             break;
         case AnchorStyles.Top:
             rcOutline.Height = Constants.SideTabOutline;
             break;
         case AnchorStyles.Right:
             rcOutline.X = rcOutline.Right - Constants.SideTabOutline;
             rcOutline.Width = Constants.SideTabOutline;
             break;
         case AnchorStyles.Bottom:
             rcOutline.Y = rcOutline.Bottom - Constants.SideTabOutline;
             rcOutline.Height  = Constants.SideTabOutline;
             break;
         default:
             throw new ApplicationException(
                 string.Format("Unexpected DockSide.Side value: {0}", tab.Side.Anchor));
     }
     var color = tab.IsMouseOver ?
         ColorTable.DockSideTabOutlineHover :
         ColorTable.DockSideTabOutline;
     using(var brush = new SolidBrush(color))
     {
         graphics.FillRectangle(brush, rcOutline);
     }
 }
Beispiel #12
0
 public abstract void RenderViewDockSideTabBackground(ViewDockSideTab tab, Graphics graphics, Rectangle bounds);
Beispiel #13
0
 public abstract int MeasureViewDockSideTabLength(ViewDockSideTab tab, Graphics graphics);
 public override void RenderViewDockSideTabContent(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     RenderTabContent(tab, bounds, graphics);
 }
Beispiel #15
0
 public abstract void RenderViewDockSideTabBackground(ViewDockSideTab tab, Graphics graphics, Rectangle bounds);
 public override void RenderViewDockSideTabBackground(ViewDockSideTab tab, Graphics graphics, Rectangle bounds)
 {
     RenderTabBackground(tab, bounds, graphics);
 }
Beispiel #17
0
 public abstract void RenderViewDockSideTabContent(ViewDockSideTab tab, Graphics graphics, Rectangle bounds);
 public override int MeasureViewDockSideTabLength(ViewDockSideTab tab, Graphics graphics)
 {
     return(MeasureTabLength(tab, graphics));
 }