Beispiel #1
0
        /// <summary>
        /// Set logical dock
        /// </summary>
        /// <param name="hostContainerDock">host container dock</param>
        /// <param name="dock">dock</param>
        /// <param name="mode">mode</param>
        public void SetDock(DockStyle hostContainerDock, DockStyle dock, DockableMode mode)
        {
            if (_hostContainerDock != hostContainerDock)
            {
                if (AllowedDock != DockAllowed.Unknown)
                {
                    bool isAllowed = false;
                    switch (hostContainerDock)
                    {
                    case DockStyle.Left:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.Left);
                        break;

                    case DockStyle.Right:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.Right);
                        break;

                    case DockStyle.Top:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.Top);
                        break;

                    case DockStyle.Bottom:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.Bottom);
                        break;

                    case DockStyle.None:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.None);
                        break;

                    case DockStyle.Fill:
                        isAllowed = EnumUtility.Contains(AllowedDock, DockAllowed.Fill);
                        break;

                    case Globals.DockAutoHide:
                        isAllowed = _hostContainerDock == DockStyle.Left ||
                                    _hostContainerDock == DockStyle.Right ||
                                    _hostContainerDock == DockStyle.Top ||
                                    _hostContainerDock == DockStyle.Bottom;
                        break;
                    }

                    if (isAllowed == false)
                    {
                        throw new NotSupportedException("Err");
                    }
                }

                _hostContainerDock = hostContainerDock;

                IsDocked = hostContainerDock != DockStyle.None && hostContainerDock != Globals.DockAutoHide;

                PagesPanel.ShowAutohideButton = (hostContainerDock != DockStyle.None && hostContainerDock != DockStyle.Fill);
            }

            _dock     = dock;
            _dockMode = mode;

            foreach (DockableFormInfo info in _cachedInfos)
            {
                info.HostContainerDock = _hostContainerDock;
                info.Dock     = _dock;
                info.DockMode = _dockMode;
            }
        }