コード例 #1
0
ファイル: ViewDockSideTab.cs プロジェクト: Kuzq/gitter
        public ViewDockSideTab(ViewDockSide side, ViewHost viewHost, ViewBase view)
            : base(view, Utility.InvertAnchor(side.Side))
        {
            Verify.Argument.IsNotNull(side, "side");
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            _side = side;
            _viewHost = viewHost;
        }
コード例 #2
0
ファイル: ViewHeaderMenu.cs プロジェクト: Kuzq/gitter
        public ViewHeaderMenu(ViewHost viewHost, ViewBase view)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");
            Verify.Argument.IsNotNull(view, "view");

            _host = viewHost;
            _view = view;

            Items.Add(new ToolStripMenuItem(Resources.StrClose, null, (s, e) => _view.Close()));
        }
コード例 #3
0
ファイル: ViewHostTab.cs プロジェクト: Kuzq/gitter
        public ViewHostTab(ViewHostTabs tabs, ViewBase view)
            : base(view, tabs.Side)
        {
            Verify.Argument.IsNotNull(tabs, "tabs");

            _tabs = tabs;
            _viewHost = tabs.ViewHost;
            _buttons = new ViewButtons(tabs);
            if(_viewHost.IsDocumentWell)
            {
                _buttons.SetAvailableButtons(ViewButtonType.Close);
            }
            _buttons.Height = Renderer.TabHeight + Renderer.TabFooterHeight;
            _buttons.ButtonClick += OnButtonClick;
        }
コード例 #4
0
ファイル: ViewTabBase.cs プロジェクト: Kuzq/gitter
        /// <summary>Initializes a new instance of the <see cref="ViewTabBase"/> class.</summary>
        /// <param name="view">Represented <see cref="ViewBase"/>.</param>
        /// <param name="anchor">Tab anchor.</param>
        protected ViewTabBase(ViewBase view, AnchorStyles anchor)
        {
            Verify.Argument.IsNotNull(view, "view");

            switch(anchor)
            {
                case AnchorStyles.Left:
                case AnchorStyles.Right:
                    _orientation = Orientation.Vertical;
                    break;
                case AnchorStyles.Top:
                case AnchorStyles.Bottom:
                    _orientation = Orientation.Horizontal;
                    break;
                default:
                    throw new ArgumentException("Invalid anchor value.", "anchor");
            }
            _anchor = anchor;
            _view = view;
        }
コード例 #5
0
ファイル: ViewEventArgs.cs プロジェクト: Kuzq/gitter
 public ViewEventArgs(ViewBase view)
 {
     _view = view;
 }
コード例 #6
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        /// <summary>Remove view from host.</summary>
        /// <param name="view">View to remove.</param>
        /// <remarks>
        /// Removing last view from non-host control destroys host.
        /// Host container gets updated and sibling hosts resize accordingly.
        /// </remarks>
        internal void RemoveView(ViewBase view)
        {
            Verify.Argument.IsNotNull(view, "view");
            Verify.Argument.IsTrue(view.Host == this, "view", "View is not hosted in this ViewHost.");
            int index = _views.IndexOf(view);
            Assert.AreNotEqual(index, -1);

            _views.RemoveAt(index);
            view.TextChanged -= OnViewTextChanged;
            view.Host = null;
            if(_isDocumentWell)
            {
                if(_views.Count == 0)
                {
                    if(view == _activeView)
                    {
                        view.Parent = null;
                    }
                    if(!_isRoot)
                    {
                        Undock();
                        Dispose();
                        Status = ViewHostStatus.Disposed;
                    }
                    else
                    {
                        SuspendLayout();
                        RemoveTabs();
                        RemoveFooter();
                        ResumeLayout(true);
                        UpdateContentPanelBounds();
                    }
                }
                else
                {
                    _tabs.RemoveView(view);
                    if(_activeView == view)
                    {
                        bool focused = view.ContainsFocus;
                        if(index >= _views.Count)
                        {
                            index = _views.Count - 1;
                        }
                        if(focused)
                        {
                            Activate(_views[index]);
                        }
                        else
                        {
                            SetActiveView(_views[index]);
                        }
                        view.Parent = null;
                    }
                }
            }
            else
            {
                if(_views.Count == 0)
                {
                    if(view == _activeView)
                    {
                        view.Parent = null;
                    }
                    if(!_isRoot)
                    {
                        Undock();
                        Dispose();
                        Status = ViewHostStatus.Disposed;
                    }
                    else
                    {
                        RemoveHeader();
                        UpdateContentPanelBounds();
                    }
                }
                else
                {
                    if(_status != ViewHostStatus.AutoHide)
                    {
                        if(_views.Count == 1)
                        {
                            RemoveTabs();
                            UpdateContentPanelBounds();
                        }
                        else
                        {
                            _tabs.RemoveView(view);
                        }
                    }
                    if(_activeView == view)
                    {
                        bool focused = view.ContainsFocus;
                        if(index >= _views.Count)
                        {
                            index = _views.Count - 1;
                        }
                        if(focused)
                        {
                            Activate(_views[index]);
                        }
                        else
                        {
                            SetActiveView(_views[index]);
                        }
                        view.Parent = null;
                    }
                }
            }
            Events.Raise(ViewRemovedEvent, this, new ViewEventArgs(view));
        }
コード例 #7
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        /// <summary>Initializes a new instance of the <see cref="ViewHost"/> class.</summary>
        /// <param name="grid">Host grid.</param>
        /// <param name="isRoot">if set to <c>true</c> disables host auto-destruction on losing all hosted views.</param>
        /// <param name="isDocumentWell">if set to <c>true</c> uses advanced layout features for hosting variable size documents.</param>
        /// <param name="views">Hosted views.</param>
        internal ViewHost(ViewDockGrid grid, bool isRoot, bool isDocumentWell, IEnumerable<ViewBase> views)
        {
            Verify.Argument.IsNotNull(grid, "grid");

            SetStyle(ControlStyles.ContainerControl, true);
            SetStyle(
                ControlStyles.SupportsTransparentBackColor |
                ControlStyles.Selectable,
                false);

            _grid = grid;
            _isRoot = isRoot;
            _isDocumentWell = isDocumentWell;
            _views = new List<ViewBase>();
            var size = new Size(ViewConstants.MinimumHostWidth, ViewConstants.MinimumHostHeight);
            if(views != null)
            {
                foreach(var view in views)
                {
                    Verify.Argument.IsTrue(view != null, "views", "List of views contains invalid arguments.");

                    _views.Add(view);
                    view.TextChanged += OnViewTextChanged;
                    view.Host = this;
                    var ts = view.Size;
                    if(ts.Width > size.Width)
                    {
                        size.Width = ts.Width;
                    }
                    if(ts.Height > size.Height)
                    {
                        size.Height = ts.Height;
                    }
                }
            }
            if(_views.Count > 0)
            {
                if(isDocumentWell)
                {
                    size.Height += Renderer.TabHeight +
                                   Renderer.TabFooterHeight +
                                   Renderer.FooterHeight;
                }
                else
                {
                    size.Height += Renderer.HeaderHeight;
                    if(_views.Count > 1)
                    {
                        size.Height += Renderer.TabHeight;
                    }
                }
            }

            _dockMarkers = new ViewHostDockMarkers(this);
            _dockingProcess = new ViewHostDockingProcess(this);
            _resizingProcess = new ViewHostResizingProcess(this);

            BackColor = Renderer.BackgroundColor;

            SuspendLayout();

            int bottomOffset;
            int topOffset;
            if(_views.Count != 0)
            {
                _activeView = _views[0];
                if(isDocumentWell)
                {
                    SpawnTabs(size);
                    topOffset = _tabs.Height;
                    SpawnFooter(size);
                    bottomOffset = Renderer.FooterHeight;
                }
                else
                {
                    SpawnHeader(size);
                    topOffset = _header.Height;
                    if(_views.Count > 1)
                    {
                        SpawnTabs(size);
                        bottomOffset = _tabs.Height;
                    }
                    else
                    {
                        bottomOffset = 0;
                    }
                }
            }
            else
            {
                topOffset = 0;
                bottomOffset = 0;
            }

            _viewContainer = new Panel()
            {
                Bounds = new Rectangle(0, topOffset, size.Width, size.Height - topOffset - bottomOffset),
                Anchor = ViewConstants.AnchorAll,
            };

            if(_activeView != null)
            {
                _activeView.Bounds = new Rectangle(Point.Empty, _viewContainer.Size);
                _activeView.Anchor = ViewConstants.AnchorAll;
                _activeView.Parent = _viewContainer;
            }

            Size = size;

            _viewContainer.Parent = this;

            ResumeLayout(true);

            lock(_viewHosts)
            {
                _viewHosts.AddLast(this);
            }
        }
コード例 #8
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        /// <summary>Dock inside another host as tabbed views.</summary>
        /// <param name="viewHost">Host to dock into.</param>
        /// <remarks>
        /// This ViewHost will be destroyed in the process of docking.
        /// </remarks>
        internal void DockInto(ViewHost viewHost)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");
            Verify.Argument.IsTrue(viewHost != this, "viewHost", "Cannot dock to itself.");

            ReturnFromFloatingMode();
            PreventActiveViewDispose();
            foreach(var view in Views)
            {
                view.Host = null;
                viewHost.AddView(view);
            }
            if(ActiveView != null)
            {
                viewHost.SetActiveView(_activeView);
                _activeView = null;
            }
            Dispose();
            Status = ViewHostStatus.Disposed;
        }
コード例 #9
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        /// <summary>Set active view.</summary>
        /// <param name="view">View to activate.</param>
        public void SetActiveView(ViewBase view)
        {
            Verify.Argument.IsNotNull(view, "view");
            Verify.Argument.IsTrue(view.Host == this, "view", "View is hosted in another host.");

            if(_activeView != view)
            {
                var old = _activeView;
                _activeView = view;
                _activeView.Bounds = new Rectangle(Point.Empty, _viewContainer.Size);
                _activeView.Anchor = ViewConstants.AnchorAll;
                _activeView.Parent = _viewContainer;
                if(old != null)
                {
                    old.Parent = null;
                }
                if(_header != null)
                {
                    _header.Invalidate();
                }
                if(_tabs != null)
                {
                    _tabs.EnsureVisible(view);
                    _tabs.Invalidate();
                }
                Events.Raise(ActiveViewChangedEvent, this);
            }
        }
コード例 #10
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
 public int IndexOf(ViewBase view)
 {
     return _views.IndexOf(view);
 }
コード例 #11
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
 public bool Contains(ViewBase view)
 {
     return _views.Contains(view);
 }
コード例 #12
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        /// <summary>Host specified view.</summary>
        /// <param name="view">View to host.</param>
        public void AddView(ViewBase view)
        {
            Verify.Argument.IsNotNull(view, "view");
            Verify.Argument.IsTrue(view.Host == null, "view", "View is already hosted.");

            _views.Add(view);
            view.Host = this;
            if(_isDocumentWell)
            {
                if(_views.Count == 1)
                {
                    var size = Size;
                    SuspendLayout();
                    SpawnTabs(size);
                    SpawnFooter(size);
                    UpdateContentPanelBounds();
                    _activeView = view;
                    _activeView.Bounds = new Rectangle(Point.Empty, _viewContainer.Size);
                    _activeView.Anchor = ViewConstants.AnchorAll;
                    _activeView.Parent = _viewContainer;
                    ResumeLayout(true);
                    Events.Raise(ActiveViewChangedEvent, this);
                }
                else
                {
                    _tabs.AddView(view);
                }
            }
            else
            {
                if(_views.Count == 1)
                {
                    var size = Size;
                    SuspendLayout();
                    SpawnHeader(size);
                    UpdateContentPanelBounds();
                    _activeView = view;
                    _activeView.Bounds = new Rectangle(Point.Empty, _viewContainer.Size);
                    _activeView.Anchor = ViewConstants.AnchorAll;
                    _activeView.Parent = _viewContainer;
                    ResumeLayout(true);
                    Events.Raise(ActiveViewChangedEvent, this);
                }
                else if(_views.Count == 2)
                {
                    var size = Size;
                    SuspendLayout();
                    SpawnTabs(size);
                    UpdateContentPanelBounds();
                    ResumeLayout(true);
                }
                else
                {
                    _tabs.AddView(view);
                }
            }
            view.TextChanged += OnViewTextChanged;
            Events.Raise(ViewAddedEvent, this, new ViewEventArgs(view));
        }
コード例 #13
0
ファイル: ViewHost.cs プロジェクト: Kuzq/gitter
        public void Activate(ViewBase view)
        {
            Verify.Argument.IsNotNull(view, "view");
            Verify.Argument.IsTrue(view.Host == this, "view", "View is not hosted in this ViewHost.");

            SetActiveView(view);
            _activeView.Focus();
        }
コード例 #14
0
ファイル: ViewLayout.cs プロジェクト: Kuzq/gitter
            public ViewEntry(ViewBase view)
            {
                Verify.Argument.IsNotNull(view, "view");

                _guid = view.Guid;
            }
コード例 #15
0
ファイル: ViewDockGrid.cs プロジェクト: Kuzq/gitter
 public void DockSide(AnchorStyles side, ViewBase view, bool autoHide)
 {
     DockSide(side, new ViewHost(this, false, false, new[] { view }), autoHide);
 }
コード例 #16
0
ファイル: ViewDockGrid.cs プロジェクト: Kuzq/gitter
 public void DockRoot(ViewBase view)
 {
     _rootHost.AddView(view);
 }