예제 #1
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");
            }
        }
예제 #2
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;
            }
        }