예제 #1
0
파일: ViewDockGrid.cs 프로젝트: Kuzq/gitter
        /// <summary>Initializes a new instance of the <see cref="ViewDockGrid"/> class.</summary>
        public ViewDockGrid()
        {
            _dockMarkers = new GridDockMarkers(this);
            var bounds = ClientRectangle;
            bounds.X += ViewConstants.Spacing;
            bounds.Y += ViewConstants.Spacing;
            bounds.Width -= ViewConstants.Spacing * 2;
            bounds.Height -= ViewConstants.Spacing * 2;
            _rootHost = new ViewHost(this, true, true, null)
            {
                Bounds = bounds,
                Anchor = ViewConstants.AnchorAll,
            };
            _rootControl = _rootHost;
            _floatingViewForms = new LinkedList<FloatingViewForm>();
            _popupsStack = new PopupNotificationsStack();

            SetStyle(ControlStyles.ContainerControl, true);

            SuspendLayout();
            _rootHost.Parent = this;
            ResumeLayout(true);

            lock(_grids)
            {
                _grids.AddLast(this);
            }

            BackColor = ViewManager.Renderer.BackgroundColor;
        }
예제 #2
0
        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;
        }
예제 #3
0
        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()));
        }
예제 #4
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;
        }
예제 #5
0
        internal ViewHostFooter(ViewHost viewHost)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            _viewHost = viewHost;
            SetStyle(
                ControlStyles.ContainerControl |
                ControlStyles.Selectable |
                ControlStyles.SupportsTransparentBackColor,
                false);
            SetStyle(
                ControlStyles.UserPaint |
                ControlStyles.ResizeRedraw |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.OptimizedDoubleBuffer,
                true);
        }
예제 #6
0
        /// <summary>Initializes a new instance of the <see cref="FloatingViewForm"/> class.</summary>
        /// <param name="viewHost">Floating <see cref="ViewHost"/>.</param>
        public FloatingViewForm(ViewDockGrid dockGrid, ViewHost viewHost)
        {
            Verify.Argument.IsNotNull(dockGrid, "dockGrid");
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            Font			= GitterApplication.FontManager.UIFont;
            Text			= viewHost.Text;
            FormBorderStyle	= FormBorderStyle.None;
            BackColor		= Renderer.BackgroundColor;
            StartPosition	= FormStartPosition.Manual;
            Padding			= new Padding(Renderer.FloatBorderSize);
            Bounds			= GetBoundsForControl(viewHost);
            if(viewHost.Width < ViewConstants.MinimumHostWidth)
            {
                if(viewHost.Height < ViewConstants.MinimumHostHeight)
                {
                    viewHost.Size = new Size(ViewConstants.MinimumHostWidth, ViewConstants.MinimumHostHeight);
                }
                else
                {
                    viewHost.Width = ViewConstants.MinimumHostWidth;
                }
            }
            else if(viewHost.Height < ViewConstants.MinimumHostHeight)
            {
                viewHost.Height = ViewConstants.MinimumHostHeight;
            };
            MinimumSize		= new Size(
                ViewConstants.MinimumHostWidth + Renderer.FloatBorderSize * 2,
                ViewConstants.MinimumHostHeight + Renderer.FloatBorderSize * 2);
            ShowInTaskbar	= false;
            ShowIcon		= false;
            ControlBox		= false;
            MinimizeBox		= false;
            MaximizeBox		= true;
            _rootControl	= viewHost;
            _dockGrid		= dockGrid;

            _dockGrid.AddFloatingForm(this);
        }
예제 #7
0
파일: ViewHost.cs 프로젝트: Kuzq/gitter
        /// <summary>Get bounding rectangle for docked view.</summary>
        /// <param name="viewHost">Tested <see cref="ViewHost"/>.</param>
        /// <param name="dockResult">Position for docking.</param>
        /// <returns>Bounding rectangle for docked view.</returns>
        public Rectangle GetDockBounds(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            Rectangle bounds;
            var size = Size;
            switch(dockResult)
            {
                case DockResult.Left:
                case DockResult.DocumentLeft:
                    {
                        var w1 = viewHost.Width;
                        var w2 = size.Width;
                        ViewSplit.OptimalSizes(w2, ViewConstants.MinimumHostWidth, ref w1, ref w2);
                        bounds = new Rectangle(0, 0, w1, size.Height);
                    }
                    break;
                case DockResult.Top:
                case DockResult.DocumentTop:
                    {
                        var h1 = viewHost.Height;
                        var h2 = size.Height;
                        ViewSplit.OptimalSizes(h2, ViewConstants.MinimumHostHeight, ref h1, ref h2);
                        bounds = new Rectangle(0, 0, size.Width, h1);
                    }
                    break;
                case DockResult.Right:
                case DockResult.DocumentRight:
                    {
                        var w1 = size.Width;
                        var w2 = viewHost.Width;
                        ViewSplit.OptimalSizes(w1, ViewConstants.MinimumHostWidth, ref w1, ref w2);
                        bounds = new Rectangle(size.Width - w2, 0, w2, size.Height);
                    }
                    break;
                case DockResult.Bottom:
                case DockResult.DocumentBottom:
                    {
                        var h1 = size.Height;
                        var h2 = viewHost.Height;
                        ViewSplit.OptimalSizes(h1, ViewConstants.MinimumHostHeight, ref h1, ref h2);
                        bounds = new Rectangle(0, size.Height - h2, size.Width, h2);
                    }
                    break;
                case DockResult.Fill:
                    bounds = new Rectangle(0, 0, size.Width, size.Height);
                    bounds.Intersect(_viewContainer.Bounds);
                    break;
                default:
                    throw new ArgumentException(
                        "Unsupported DockResult value: {0}".UseAsFormat(dockResult),
                        "dockResult");
            }
            return RectangleToScreen(bounds);
        }
예제 #8
0
        public void Cancel()
        {
            Verify.State.IsTrue(IsActive);

            _isActive = false;
            if(_hoveredGrid != null)
            {
                _hoveredGrid.DockMarkers.Hide();
                _hoveredGrid = null;
            }
            if(_hoveredHost != null)
            {
                _hoveredHost.DockMarkers.Hide();
                _hoveredHost = null;
            }
        }
예제 #9
0
        public ViewHostDockingProcess(ViewHost viewHost)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            _viewHost = viewHost;
        }
예제 #10
0
        public void Update(Point location)
        {
            Verify.State.IsTrue(IsActive);

            bool gridHit = false;
            location = _viewHost.PointToScreen(location);
            var grid = HitTestGrid(location);
            if(grid != null)
            {
                if(_hoveredGrid != null)
                {
                    if(_hoveredGrid != grid)
                    {
                        _hoveredGrid.DockMarkers.Hide();
                        _hoveredGrid = grid;
                        grid.DockMarkers.Show(_viewHost);
                    }
                }
                else
                {
                    _hoveredGrid = grid;
                    grid.DockMarkers.Show(_viewHost);
                }
                gridHit = grid.DockMarkers.UpdateHover(location);
            }
            else
            {
                if(_hoveredGrid != null)
                {
                    _hoveredGrid.DockMarkers.Hide();
                    _hoveredGrid = null;
                }
            }
            var host = HitTestViewHost(location);
            if(host != null)
            {
                if(_hoveredHost != null)
                {
                    if(_hoveredHost != host)
                    {
                        _hoveredHost.DockMarkers.Hide();
                        _hoveredHost = host;
                        host.DockMarkers.Show(_viewHost);
                    }
                }
                else
                {
                    _hoveredHost = host;
                    host.DockMarkers.Show(_viewHost);
                }
                if(!gridHit)
                {
                    host.DockMarkers.UpdateHover(location);
                }
                else
                {
                    host.DockMarkers.Unhover();
                }
            }
            else
            {
                if(_hoveredHost != null)
                {
                    _hoveredHost.DockMarkers.Hide();
                    _hoveredHost = null;
                }
            }
        }
예제 #11
0
        public bool Start(Point location)
        {
            Verify.State.IsFalse(IsActive);

            _isActive = true;
            location = _viewHost.PointToScreen(location);
            var grid = HitTestGrid(location);
            if(grid != null)
            {
                _hoveredGrid = grid;
                grid.DockMarkers.Show(_viewHost);
                grid.DockMarkers.UpdateHover(location);
            }
            var host = HitTestViewHost(location);
            if(host != null)
            {
                _hoveredHost = host;
                host.DockMarkers.Show(_viewHost);
                host.DockMarkers.UpdateHover(location);
            }
            return true;
        }
예제 #12
0
 public void Dispose()
 {
     if(_hoveredGrid != null)
     {
         _hoveredGrid.DockMarkers.Hide();
         _hoveredGrid = null;
     }
     if(_hoveredHost != null)
     {
         _hoveredHost.DockMarkers.Hide();
         _hoveredHost = null;
     }
     _isActive = false;
 }
예제 #13
0
파일: ViewDockGrid.cs 프로젝트: Kuzq/gitter
        /// <summary>Docks <paramref name="viewHost"/> into this <see cref="IDockHost"/>.</summary>
        /// <param name="viewHost"><see cref="ViewHost"/> to dock.</param>
        /// <param name="dockResult">Position for docking.</param>
        public void PerformDock(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");
            Verify.Argument.IsFalse(viewHost.IsDocumentWell, "viewHost");
            Verify.Argument.IsFalse(viewHost.ViewsCount == 1 && viewHost.GetView(0).IsDocument, "viewHost");

            switch(dockResult)
            {
                case DockResult.Left:
                    DockSide(AnchorStyles.Left, viewHost, false);
                    viewHost.Status = ViewHostStatus.Docked;
                    break;
                case DockResult.Top:
                    DockSide(AnchorStyles.Top, viewHost, false);
                    viewHost.Status = ViewHostStatus.Docked;
                    break;
                case DockResult.Right:
                    DockSide(AnchorStyles.Right, viewHost, false);
                    viewHost.Status = ViewHostStatus.Docked;
                    break;
                case DockResult.Bottom:
                    DockSide(AnchorStyles.Bottom, viewHost, false);
                    viewHost.Status = ViewHostStatus.Docked;
                    break;
                case DockResult.AutoHideLeft:
                    GetCreateDockSide(AnchorStyles.Left).AddHost(viewHost);
                    break;
                case DockResult.AutoHideTop:
                    GetCreateDockSide(AnchorStyles.Top).AddHost(viewHost);
                    break;
                case DockResult.AutoHideRight:
                    GetCreateDockSide(AnchorStyles.Right).AddHost(viewHost);
                    break;
                case DockResult.AutoHideBottom:
                    GetCreateDockSide(AnchorStyles.Bottom).AddHost(viewHost);
                    break;
                default:
                    throw new ArgumentException(
                        "Unsupported DockResult value: {0}".UseAsFormat(dockResult),
                        "dockResult");
            }
        }
예제 #14
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;
        }
예제 #15
0
파일: ViewDockGrid.cs 프로젝트: Kuzq/gitter
        /// <summary>Get bounding rectangle for docked view.</summary>
        /// <param name="viewHost">Tested <see cref="ViewHost"/>.</param>
        /// <param name="dockResult">Position for docking.</param>
        /// <returns>Bounding rectangle for docked view.</returns>
        public Rectangle GetDockBounds(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            var rootBounds = RootControl.Bounds;
            Rectangle bounds;
            switch(dockResult)
            {
                case DockResult.Left:
                    {
                        var w1 = viewHost.Width;
                        var w2 = rootBounds.Width;
                        ViewSplit.OptimalSizes(w2, ViewConstants.MinimumHostWidth, ref w1, ref w2);
                        bounds = new Rectangle(0, 0, w1, rootBounds.Height);
                    }
                    break;
                case DockResult.Top:
                    {
                        var h1 = viewHost.Height;
                        var h2 = rootBounds.Height;
                        ViewSplit.OptimalSizes(h2, ViewConstants.MinimumHostHeight, ref h1, ref h2);
                        bounds = new Rectangle(0, 0, rootBounds.Width, h1);
                    }
                    break;
                case DockResult.Right:
                    {
                        var w1 = rootBounds.Width;
                        var w2 = viewHost.Width;
                        ViewSplit.OptimalSizes(w1, ViewConstants.MinimumHostWidth, ref w1, ref w2);
                        bounds = new Rectangle(rootBounds.Width - w2, 0, w2, rootBounds.Height);
                    }
                    break;
                case DockResult.Bottom:
                    {
                        var h1 = rootBounds.Height;
                        var h2 = viewHost.Height;
                        ViewSplit.OptimalSizes(h1, ViewConstants.MinimumHostHeight, ref h1, ref h2);
                        bounds = new Rectangle(0, rootBounds.Height - h2, rootBounds.Width, h2);
                    }
                    break;
                default:
                    throw new ArgumentException(
                        "Unsuported DockResult value: {0}".UseAsFormat(dockResult),
                        "dockResult");
            }
            bounds.Offset(rootBounds.X, rootBounds.Y);
            return RectangleToScreen(bounds);
        }
예제 #16
0
파일: ViewDockGrid.cs 프로젝트: Kuzq/gitter
 internal void DockSide(AnchorStyles side, ViewHost host, bool autoHide)
 {
     host.DockToSide(RootControl, side);
 }
예제 #17
0
파일: ViewHost.cs 프로젝트: Kuzq/gitter
        /// <summary>
        /// Determines if <see cref="ViewHost"/> cn be docked into this <see cref="IDockHost"/>.
        /// </summary>
        /// <param name="viewHost"><see cref="ViewHost"/> to dock.</param>
        /// <param name="dockResult">Position for docking.</param>
        /// <returns>true if docking is possible.</returns>
        public bool CanDock(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            switch(dockResult)
            {
                case DockResult.Left:
                case DockResult.Top:
                case DockResult.Right:
                case DockResult.Bottom:
                case DockResult.Fill:
                    return true;
                case DockResult.DocumentLeft:
                case DockResult.DocumentTop:
                case DockResult.DocumentRight:
                case DockResult.DocumentBottom:
                    return _isDocumentWell;
                default:
                    return false;
            }
        }
예제 #18
0
 public GridDockMarker(ViewDockGrid grid, ViewHost viewHost, AnchorStyles side)
     : base(grid, viewHost, new[] { GetButton(side) }, Border, GetPositionBounds(grid, side))
 {
     _grid = grid;
     _side = side;
 }
예제 #19
0
파일: ViewLayout.cs 프로젝트: Kuzq/gitter
            public HostEntry(ViewHost viewHost)
                : this()
            {
                Verify.Argument.IsNotNull(viewHost, "viewHost");

                _isRoot = viewHost.IsRoot;
                _isDocumentWell = viewHost.IsDocumentWell;
                foreach(var view in viewHost.Views)
                {
                    _views.Add(new ViewEntry(view));
                }
            }
예제 #20
0
파일: ViewHost.cs 프로젝트: Kuzq/gitter
        /// <summary>
        /// Docks <paramref name="viewHost"/> into this <see cref="IDockHost"/>.
        /// </summary>
        /// <param name="viewHost"><see cref="ViewHost"/> to dock.</param>
        /// <param name="dockResult">Position for docking.</param>
        public void PerformDock(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            switch(dockResult)
            {
                case DockResult.Left:
                    viewHost.DockToSide(this, AnchorStyles.Left);
                    if(_status == ViewHostStatus.DockedOnFloat || _status == ViewHostStatus.Floating)
                    {
                        viewHost.Status = ViewHostStatus.DockedOnFloat;
                    }
                    break;
                case DockResult.Top:
                    viewHost.DockToSide(this, AnchorStyles.Top);
                    if(_status == ViewHostStatus.DockedOnFloat || _status == ViewHostStatus.Floating)
                    {
                        viewHost.Status = ViewHostStatus.DockedOnFloat;
                    }
                    break;
                case DockResult.Right:
                    viewHost.DockToSide(this, AnchorStyles.Right);
                    if(_status == ViewHostStatus.DockedOnFloat || _status == ViewHostStatus.Floating)
                    {
                        viewHost.Status = ViewHostStatus.DockedOnFloat;
                    }
                    break;
                case DockResult.Bottom:
                    viewHost.DockToSide(this, AnchorStyles.Bottom);
                    if(_status == ViewHostStatus.DockedOnFloat || _status == ViewHostStatus.Floating)
                    {
                        viewHost.Status = ViewHostStatus.DockedOnFloat;
                    }
                    break;
                case DockResult.DocumentLeft:
                    viewHost.DockToSideAsDocument(this, AnchorStyles.Left);
                    break;
                case DockResult.DocumentTop:
                    viewHost.DockToSideAsDocument(this, AnchorStyles.Top);
                    break;
                case DockResult.DocumentRight:
                    viewHost.DockToSideAsDocument(this, AnchorStyles.Right);
                    break;
                case DockResult.DocumentBottom:
                    viewHost.DockToSideAsDocument(this, AnchorStyles.Bottom);
                    break;
                case DockResult.Fill:
                    viewHost.DockInto(this);
                    Activate();
                    break;
                default:
                    throw new ArgumentException(
                        "Unsupported DockResult value: {0}".UseAsFormat(dockResult),
                        "dockResult");
            }
        }
예제 #21
0
파일: ViewDockGrid.cs 프로젝트: Kuzq/gitter
        /// <summary>Determines if <see cref="ViewHost"/> cn be docked into this <see cref="IDockHost"/>.</summary>
        /// <param name="viewHost"><see cref="ViewHost"/> to dock.</param>
        /// <param name="dockResult">Position for docking.</param>
        /// <returns>true if docking is possible.</returns>
        public bool CanDock(ViewHost viewHost, DockResult dockResult)
        {
            Verify.Argument.IsNotNull(viewHost, "viewHost");

            if(viewHost.IsDocumentWell || (viewHost.ViewsCount == 1 && viewHost.GetView(0).IsDocument))
            {
                return false;
            }
            switch(dockResult)
            {
                case DockResult.Left:
                case DockResult.Top:
                case DockResult.Right:
                case DockResult.Bottom:
                    return true;
                default:
                    return false;
            }
        }