Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host window</param>
        public FormsDocker(IWin32Window host)
        {
            _host      = new FormWrapper(host, 14, 4);
             _guider    = new DockGuider (_host);
             _layout    = new DockLayout (_host);
             _autohide  = new Autohide   (_host, 9, _animationCommand);

             _layout.BeginMoveByMouse        += OnPositionerBeginMoveByMouse;
             _layout.MoveByMouse             += OnPositionerMoveByMouse;
             _layout.EndMoveByMouse          += OnPositionerEndMoveByMouse;
             _layout.DestroyFormsTabbedView  += OnDestroyFormsTabbedView;
             _layout.ShowFloatingWindows     += OnShowFloatingWindows;

             _autohide.SetHostContainerDock  += OnSetHostContainerDock;

             _guider.ApplyDock     += OnApplyDock;
             _animationTimer.Tick  += OnTimedAnimation;

             _animationTimer.Interval = 50;
             _animationTimer.Enabled  = true;

             _focusDetector.ControlGotFocus += OnControlGotFocus;
             _focusDetector.MessageFiltered += OnMessageFiltered;
             Application.AddMessageFilter(_focusDetector);
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        public MarginDockButtons(FormWrapper host)
        {
            _host = host;

            _leftButtonBounds.Size   = _dockLeftGuider.Size;
            _rightButtonBounds.Size  = _dockRightGuider.Size;
            _topButtonBounds.Size    = _dockTopGuider.Size;
            _bottomButtonBounds.Size = _dockBottomGuider.Size;

            _dockLeftGuider.Visible   = false;
            _dockRightGuider.Visible  = false;
            _dockTopGuider.Visible    = false;
            _dockBottomGuider.Visible = false;

            _dockLeftGuider.Text   = "outer left button";
            _dockRightGuider.Text  = "outer right button";
            _dockTopGuider.Text    = "outer top button";
            _dockBottomGuider.Text = "outer bottom button";

            _host.AddFirst(_dockLeftGuider);
            _host.AddFirst(_dockRightGuider);
            _host.AddFirst(_dockTopGuider);
            _host.AddFirst(_dockBottomGuider);

            _host.KeepFirst[0] = _dockLeftGuider;
            _host.KeepFirst[1] = _dockRightGuider;
            _host.KeepFirst[2] = _dockTopGuider;
            _host.KeepFirst[3] = _dockBottomGuider;

            _host.AddToIgnoreOnGetChildFromPoint(_dockLeftGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockRightGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockTopGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockBottomGuider);
        }
Example #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        public MarginDockButtons(FormWrapper host)
        {
            _host = host;

             _leftButtonBounds.Size     = _dockLeftGuider.Size;
             _rightButtonBounds.Size    = _dockRightGuider.Size;
             _topButtonBounds.Size      = _dockTopGuider.Size;
             _bottomButtonBounds.Size   = _dockBottomGuider.Size;

             _dockLeftGuider.Visible    = false;
             _dockRightGuider.Visible   = false;
             _dockTopGuider.Visible     = false;
             _dockBottomGuider.Visible  = false;

             _dockLeftGuider.Text       = "outer left button";
             _dockRightGuider.Text      = "outer right button";
             _dockTopGuider.Text        = "outer top button";
             _dockBottomGuider.Text     = "outer bottom button";

             _host.AddFirst(_dockLeftGuider);
             _host.AddFirst(_dockRightGuider);
             _host.AddFirst(_dockTopGuider);
             _host.AddFirst(_dockBottomGuider);

             _host.KeepFirst[0] = _dockLeftGuider;
             _host.KeepFirst[1] = _dockRightGuider;
             _host.KeepFirst[2] = _dockTopGuider;
             _host.KeepFirst[3] = _dockBottomGuider;

             _host.AddToIgnoreOnGetChildFromPoint(_dockLeftGuider);
             _host.AddToIgnoreOnGetChildFromPoint(_dockRightGuider);
             _host.AddToIgnoreOnGetChildFromPoint(_dockTopGuider);
             _host.AddToIgnoreOnGetChildFromPoint(_dockBottomGuider);
        }
Example #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host window</param>
        public FormsDocker(IWin32Window host)
        {
            _host     = new FormWrapper(host, 14, 4);
            _guider   = new DockGuider(_host);
            _layout   = new DockLayout(_host);
            _autohide = new Autohide(_host, 9, _animationCommand);

            _layout.BeginMoveByMouse       += OnPositionerBeginMoveByMouse;
            _layout.MoveByMouse            += OnPositionerMoveByMouse;
            _layout.EndMoveByMouse         += OnPositionerEndMoveByMouse;
            _layout.DestroyFormsTabbedView += OnDestroyFormsTabbedView;
            _layout.ShowFloatingWindows    += OnShowFloatingWindows;

            _autohide.SetHostContainerDock += OnSetHostContainerDock;

            _guider.ApplyDock    += OnApplyDock;
            _animationTimer.Tick += OnTimedAnimation;

            _animationTimer.Interval = 50;
            _animationTimer.Enabled  = true;

            _focusDetector.ControlGotFocus += OnControlGotFocus;
            _focusDetector.MessageFiltered += OnMessageFiltered;
            Application.AddMessageFilter(_focusDetector);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        public DockGuiderWrapper(FormWrapper host)
        {
            _host = host;

            _marginGuiders = new MarginDockButtons(host);
            _centerGuider  = new CenterDockButtons(host);
        }
Example #6
0
        ///// <summary>
        ///// Gets the child leaf window found at given screen location
        ///// </summary>
        ///// <param name="screenPoint">point in screen coordinates</param>
        ///// <param name="parent">parent inside which the child is searched</param>
        ///// <param name="validate">handler to validate if child is included in search</param>
        ///// <param name="containedExcluded">flag indicating that parent contained excluded</param>
        ///// <returns>rectangle from point</returns>
        //private static Control ChildLeafFromPoint(Point screenPoint, FormWrapper parent, ExtractControlHandler validate, out bool containedExcluded)
        //{
        //   containedExcluded = false;

        //   if (parent == null)
        //   {
        //      return null;
        //   }

        //   for (int childIndex = 0; childIndex < parent.ControlsCount; childIndex++)
        //   {
        //      Control child = parent.GetControlAt(childIndex);
        //      if (IgnoreOnGetFromPoint(parent, child))
        //      {
        //         continue;
        //      }

        //      if (child.RectangleToScreen(child.ClientRectangle).Contains(screenPoint) == false)
        //      {
        //         continue;
        //      }

        //      if (validate(child) == false)
        //      {
        //         containedExcluded = true;
        //         continue;
        //      }

        //      FormWrapper childWrapper    = new FormWrapper(child);
        //      bool childContainedExcluded = false;
        //      Control found = ChildLeafFromPoint(screenPoint, childWrapper, validate, out childContainedExcluded);
        //      if (childContainedExcluded)
        //      {
        //         continue;
        //      }

        //      if (found != null)
        //      {
        //         return found;
        //      }

        //      return child;
        //   }

        //   return null;
        //}

        /// <summary>
        /// Check if should ignore the child on get from point
        /// </summary>
        /// <param name="parent">parent</param>
        /// <param name="child">child</param>
        /// <returns></returns>
        private static bool IgnoreOnGetFromPoint(FormWrapper parent, Control child)
        {
            if (child == null)
            {
                return(true);
            }

            if (child.Visible == false)
            {
                return(true);
            }

            Control control = child;

            while (control != null)
            {
                if (parent._ignoreOnGetFromPoint.Contains(control))
                {
                    return(true);
                }

                control = control.Parent;
            }

            return(false);
        }
      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="host">host</param>
      public DockGuiderWrapper(FormWrapper host)
      {
         _host = host;

         _marginGuiders = new MarginDockButtons(host);
         _centerGuider  = new CenterDockButtons(host);
      }
Example #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="container">container</param>
 public DockStateSerializer(DockContainer container)
 {
     _container     = container;
      _host          = new FormWrapper(container, 0, 0);
      string appName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
      _savePath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appName);
      _savePath      = Path.Combine(_savePath, Resources.StateFileName);
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host window</param>
        public DockGuider(FormWrapper host)
        {
            _host                 = host;
            _host.SizeChanged    += OnHostSizeChanged;
            _host.Move           += OnHostMoved;
            _host.VisibleChanged += OnHostVisibleChanged;

            _guider = new DockGuiderWrapper(_host);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="container">container</param>
        public DockStateSerializer(DockContainer container)
        {
            _container = container;
            _host      = new FormWrapper(container, 0, 0);
            string appName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);

            _savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appName);
            _savePath = Path.Combine(_savePath, Resources.StateFileName);
        }
Example #11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host window</param>
        public DockGuider(FormWrapper host)
        {
            _host = host;
             _host.SizeChanged    += OnHostSizeChanged;
             _host.Move           += OnHostMoved;
             _host.VisibleChanged += OnHostVisibleChanged;

             _guider = new DockGuiderWrapper(_host);
        }
Example #12
0
        /// <summary>
        /// Move a window using mouse
        /// </summary>
        public void MoveWindowByMouse()
        {
            if (_movedWindow == null)
            {
                return;
            }

            zAllowedDock      allowedDock         = _allowedDock;
            Point             screenLocation      = Control.MousePosition;
            DockableContainer containerUnderMouse = GetContainerUnderMouse(screenLocation);

            Rectangle fillRectangle = FormWrapper.GetFillRectangleFromPoint(screenLocation, containerUnderMouse, _host);

            if (fillRectangle.IsEmpty)
            {
                _guider.HideCenterGuider();
            }
            else
            {
                if (containerUnderMouse == null)
                {
                    _guider.ShowCenterGuider(allowedDock, fillRectangle);
                }
                else
                {
                    allowedDock = zAllowedDock.All;
                    _guider.ShowCenterGuider(allowedDock, fillRectangle);
                }
            }


            GuidedDockResult result = _guider.GetDockResult(allowedDock, screenLocation);

            if (result.DockMode == zDockMode.Outer && result.Dock != DockStyle.None)
            {
                Rectangle bounds = OuterDockPreviewEngine.GetPreviewBounds(result.Dock, _host, _movedWindow);
                _guider.ShowPreviewPanel(bounds);
            }
            else if (result.DockMode == zDockMode.Inner && result.Dock != DockStyle.None)
            {
                Rectangle freeBounds = FormWrapper.GetFillScreenRectangle(_host);
                Rectangle bounds     = InnerDockPreviewEngine.GetPreviewBounds(result.Dock, _movedWindow, containerUnderMouse, freeBounds);
                if (bounds.IsEmpty)
                {
                    _guider.HidePreviewPanel();
                }
                else
                {
                    _guider.ShowPreviewPanel(bounds);
                }
            }
            else
            {
                _guider.HidePreviewPanel();
            }
        }
      /// <summary>
      /// Get outer bottom preview bounds
      /// </summary>
      /// <param name="host">host</param>
      /// <param name="movedPanel">moved panel</param>
      /// <returns>outer bottom preview bounds</returns>
      private static Rectangle GetOuterBottomPreviewBounds(FormWrapper host, Control movedPanel)
      {
         Rectangle marginBounds = host.ScreenClientRectangle;
         if (marginBounds.IsEmpty == false)
         {
            int size = GetPreviewSize(movedPanel, DockStyle.Bottom);

            return new Rectangle(marginBounds.Left, marginBounds.Bottom - size, marginBounds.Width, size);
         }

         return new Rectangle();
      }
      /// <summary>
      /// Get outer right preview bounds
      /// </summary>
      /// <param name="host">host</param>
      /// <param name="movedPanel">moved panel</param>
      /// <returns>outer right preview bounds</returns>
      private static Rectangle GetOuterRightPreviewBounds(FormWrapper host, Control movedPanel)
      {
         Rectangle marginBounds = host.ScreenClientRectangle;
         if (marginBounds.IsEmpty == false)
         {
            int size = GetPreviewSize(movedPanel, DockStyle.Right);

            return new Rectangle(marginBounds.Right - size, marginBounds.Top, size, marginBounds.Height);
         }

         return new Rectangle();
      }
Example #15
0
        /// <summary>
        /// GEt fill screen rectangle
        /// </summary>
        /// <param name="wrapper">wrapper</param>
        /// <returns></returns>
        public static Rectangle GetFillScreenRectangle(FormWrapper wrapper)
        {
            Rectangle clientArea = wrapper.RectangleToClient(GetScreenClientRectangle(wrapper._host));

            int x1 = clientArea.Left;
            int x2 = clientArea.Right;
            int y1 = clientArea.Top;
            int y2 = clientArea.Bottom;

            for (int index = 0; index < wrapper.ControlsCount; index++)
            {
                Control control = wrapper.GetControlAt(index);
                if (control.Dock == DockStyle.None || control.Visible == false)
                {
                    continue;
                }

                if (control.Dock == DockStyle.Left)
                {
                    x1 = Math.Max(x1, control.Right);
                }
                else if (control.Dock == DockStyle.Right)
                {
                    x2 = Math.Min(x2, control.Left);
                }
                else if (control.Dock == DockStyle.Top)
                {
                    y1 = Math.Max(y1, control.Bottom);
                }
                else if (control.Dock == DockStyle.Bottom)
                {
                    y2 = Math.Min(y2, control.Top);
                }
            }

            if (x2 <= x1 || y2 <= y1)
            {
                return(new Rectangle());
            }

            Rectangle result = new Rectangle(x1, y1, x2 - x1, y2 - y1);

            return(wrapper.RectangleToScreen(result));
        }
Example #16
0
        /// <summary>
        /// Get preview bounds
        /// </summary>
        /// <param name="dock">dock for which to get the preview bounds</param>
        /// <param name="host">host</param>
        /// <param name="movedPanel">moved panel</param>
        /// <returns>preview bounds</returns>
        public static Rectangle GetPreviewBounds(DockStyle dock, FormWrapper host, Control movedPanel)
        {
            switch (dock)
             {
            case DockStyle.Left:
               return GetOuterLeftPreviewBounds(host, movedPanel);

            case DockStyle.Right:
               return GetOuterRightPreviewBounds(host, movedPanel);

            case DockStyle.Top:
               return GetOuterTopPreviewBounds(host, movedPanel);

            case DockStyle.Bottom:
               return GetOuterBottomPreviewBounds(host, movedPanel);

            default:
               throw new InvalidOperationException();
             }
        }
Example #17
0
        /// <summary>
        /// Get preview bounds
        /// </summary>
        /// <param name="dock">dock for which to get the preview bounds</param>
        /// <param name="host">host</param>
        /// <param name="movedPanel">moved panel</param>
        /// <returns>preview bounds</returns>
        public static Rectangle GetPreviewBounds(DockStyle dock, FormWrapper host, Control movedPanel)
        {
            switch (dock)
            {
            case DockStyle.Left:
                return(GetOuterLeftPreviewBounds(host, movedPanel));

            case DockStyle.Right:
                return(GetOuterRightPreviewBounds(host, movedPanel));

            case DockStyle.Top:
                return(GetOuterTopPreviewBounds(host, movedPanel));

            case DockStyle.Bottom:
                return(GetOuterBottomPreviewBounds(host, movedPanel));

            default:
                throw new InvalidOperationException();
            }
        }
Example #18
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        /// <param name="firstControlOffset">offset for first control</param>
        /// <param name="animationCommand">animation command</param>
        public Autohide(FormWrapper host, int firstControlOffset, Command animationCommand)
        {
            _host = host;
             _animationCommand    = animationCommand;
             _firstControlOffset  = firstControlOffset;

             _previewPane.Visible = false;
             _host.AddFirst(_previewPane);
             _host.KeepFirst[4 + _firstControlOffset] = _previewPane;

             _previewPane.BackColor = Color.Black;

             _host.SizeChanged    += OnHostSizeChanged;
             _host.VisibleChanged += OnHostVisibleChanged;

             LeftAutohideButtons.Visible   = false;
             RightAutohideButtons.Visible  = false;
             TopAutohideButtons.Visible    = false;
             BottomAutohideButtons.Visible = false;
             ArrangeAutoButtonsPanels();
        }
Example #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        /// <param name="firstControlOffset">offset for first control</param>
        /// <param name="animationCommand">animation command</param>
        public Autohide(FormWrapper host, int firstControlOffset, Command animationCommand)
        {
            _host               = host;
            _animationCommand   = animationCommand;
            _firstControlOffset = firstControlOffset;

            _previewPane.Visible = false;
            _host.AddFirst(_previewPane);
            _host.KeepFirst[4 + _firstControlOffset] = _previewPane;

            _previewPane.BackColor = Color.FromArgb(45, 45, 48);

            _host.SizeChanged    += OnHostSizeChanged;
            _host.VisibleChanged += OnHostVisibleChanged;

            LeftAutohideButtons.Visible   = false;
            RightAutohideButtons.Visible  = false;
            TopAutohideButtons.Visible    = false;
            BottomAutohideButtons.Visible = false;
            ArrangeAutoButtonsPanels();
        }
Example #20
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host</param>
        public CenterDockButtons(FormWrapper host)
        {
            _host = host;

            _leftButtonBounds.Size   = _dockLeftGuider.Size;
            _rightButtonBounds.Size  = _dockRightGuider.Size;
            _topButtonBounds.Size    = _dockTopGuider.Size;
            _bottomButtonBounds.Size = _dockBottomGuider.Size;
            _fillButtonBounds.Size   = _dockFillGuider.FillSize;

            _dockLeftGuider.Visible   = false;
            _dockRightGuider.Visible  = false;
            _dockTopGuider.Visible    = false;
            _dockBottomGuider.Visible = false;
            _dockFillGuider.Visible   = false;

            _dockLeftGuider.Text   = "inner left button";
            _dockRightGuider.Text  = "inner right button";
            _dockTopGuider.Text    = "inner top button";
            _dockBottomGuider.Text = "inner bottom button";
            _dockFillGuider.Text   = "inner fill button";

            _host.AddFirst(_dockLeftGuider);
            _host.AddFirst(_dockRightGuider);
            _host.AddFirst(_dockTopGuider);
            _host.AddFirst(_dockBottomGuider);
            _host.AddFirst(_dockFillGuider);

            _host.KeepFirst[4] = _dockLeftGuider;
            _host.KeepFirst[5] = _dockRightGuider;
            _host.KeepFirst[6] = _dockTopGuider;
            _host.KeepFirst[7] = _dockBottomGuider;
            _host.KeepFirst[8] = _dockFillGuider;

            _host.AddToIgnoreOnGetChildFromPoint(_dockLeftGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockRightGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockTopGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockBottomGuider);
            _host.AddToIgnoreOnGetChildFromPoint(_dockFillGuider);
        }
      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="host">host</param>
      public CenterDockButtons(FormWrapper host)
      {
         _host = host;

         _leftButtonBounds.Size     = _dockLeftGuider.Size;
         _rightButtonBounds.Size    = _dockRightGuider.Size;
         _topButtonBounds.Size      = _dockTopGuider.Size;
         _bottomButtonBounds.Size   = _dockBottomGuider.Size;
         _fillButtonBounds.Size     = _dockFillGuider.FillSize;

         _dockLeftGuider.Visible    = false;
         _dockRightGuider.Visible   = false;
         _dockTopGuider.Visible     = false;
         _dockBottomGuider.Visible  = false;
         _dockFillGuider.Visible    = false;

         _dockLeftGuider.Text       = "inner left button";
         _dockRightGuider.Text      = "inner right button";
         _dockTopGuider.Text        = "inner top button";
         _dockBottomGuider.Text     = "inner bottom button";
         _dockFillGuider.Text       = "inner fill button";

         _host.AddFirst(_dockLeftGuider);
         _host.AddFirst(_dockRightGuider);
         _host.AddFirst(_dockTopGuider);
         _host.AddFirst(_dockBottomGuider);
         _host.AddFirst(_dockFillGuider);

         _host.KeepFirst[4] = _dockLeftGuider;
         _host.KeepFirst[5] = _dockRightGuider;
         _host.KeepFirst[6] = _dockTopGuider;
         _host.KeepFirst[7] = _dockBottomGuider;
         _host.KeepFirst[8] = _dockFillGuider;

         _host.AddToIgnoreOnGetChildFromPoint(_dockLeftGuider);
         _host.AddToIgnoreOnGetChildFromPoint(_dockRightGuider);
         _host.AddToIgnoreOnGetChildFromPoint(_dockTopGuider);
         _host.AddToIgnoreOnGetChildFromPoint(_dockBottomGuider);
         _host.AddToIgnoreOnGetChildFromPoint(_dockFillGuider);
      }
        /// <summary>
        /// Gets the margins for the top form
        /// </summary>
        /// <param name="topOffset">top offset (title height when border style is none or zero when border style is provided)</param>
        /// <returns>margins</returns>
        private Margins GetMargins(out int topOffset)
        {
            FormsContainerControlCollection forms = (FormsContainerControlCollection)FormsPanel.Controls;

            Margins margins = FormWrapper.GetMargins(forms.TopControl);

            topOffset = 0;
            Form topForm = forms.TopControl as Form;

            if (topForm != null)
            {
                if (topForm.FormBorderStyle == FormBorderStyle.None)
                {
                    margins.Top    = DefaultTopMargin + DefaultTitleHeight;
                    margins.Left   = DefaultLeftMargin;
                    margins.Right  = DefaultRightMargin;
                    margins.Bottom = DefaultBottomMargin;

                    topOffset = DefaultTitleHeight;
                }
            }

            return(margins);
        }
Example #23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="host">host window</param>
 public DockLayout(FormWrapper host)
 {
    _host = host;
 }
Example #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="host">host window</param>
 public DockLayout(FormWrapper host)
 {
     _host = host;
 }
Example #25
0
        /// <summary>
        /// Dock the form in host
        /// </summary>
        /// <param name="containerToDock">container to dock</param>
        /// <param name="dock">dock</param>
        /// <param name="mode">mode</param>
        private void DockInHost(DockableContainer container, DockStyle dock, zDockMode mode)
        {
            Rectangle availableBounds = FormWrapper.GetFillScreenRectangle(_host);

            container.SingleChild.SaveFloatingSize();
            container.Splitter.Visible = false;

            if (_host.Contains(container.Splitter) == false && dock != DockStyle.Fill)
            {
                _host.AddLast(container.Splitter);
            }

            if (mode == zDockMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            container.Dock = dock;

            if (dock != DockStyle.Fill)
            {
                container.Splitter.Dock    = dock;
                container.Splitter.Visible = true;
            }
            else
            {
                container.SingleChild.ButtonsRenderer = new TopTabButtonRenderer();
            }

            // Must call this again after splitter is docked and made visible, to have proper splitter.
            // Must have this if/else block also before making the splitter visible to prevent flickering
            if (mode == zDockMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);

                    if (availableBounds.IsEmpty == false)
                    {
                        if (dock == DockStyle.Left || dock == DockStyle.Right)
                        {
                            if (container.Width >= availableBounds.Width - MinAvailableSize)
                            {
                                container.Width = availableBounds.Width - MinAvailableSize;
                            }
                        }
                        else if (dock == DockStyle.Top || dock == DockStyle.Bottom)
                        {
                            if (container.Height >= availableBounds.Height - MinAvailableSize)
                            {
                                container.Height = availableBounds.Height - MinAvailableSize;
                            }
                        }
                    }
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            SetViewDock(container.SingleChild, dock, dock, mode);
        }
Example #26
0
      ///// <summary>
      ///// Gets the child leaf window found at given screen location
      ///// </summary>
      ///// <param name="screenPoint">point in screen coordinates</param>
      ///// <param name="parent">parent inside which the child is searched</param>
      ///// <param name="validate">handler to validate if child is included in search</param>
      ///// <param name="containedExcluded">flag indicating that parent contained excluded</param>
      ///// <returns>rectangle from point</returns>
      //private static Control ChildLeafFromPoint(Point screenPoint, FormWrapper parent, ExtractControlHandler validate, out bool containedExcluded)
      //{
      //   containedExcluded = false;

      //   if (parent == null)
      //   {
      //      return null;
      //   }

      //   for (int childIndex = 0; childIndex < parent.ControlsCount; childIndex++)
      //   {
      //      Control child = parent.GetControlAt(childIndex);
      //      if (IgnoreOnGetFromPoint(parent, child))
      //      {
      //         continue;
      //      }

      //      if (child.RectangleToScreen(child.ClientRectangle).Contains(screenPoint) == false)
      //      {
      //         continue;
      //      }

      //      if (validate(child) == false)
      //      {
      //         containedExcluded = true;
      //         continue;
      //      }

      //      FormWrapper childWrapper    = new FormWrapper(child);
      //      bool childContainedExcluded = false;
      //      Control found = ChildLeafFromPoint(screenPoint, childWrapper, validate, out childContainedExcluded);
      //      if (childContainedExcluded)
      //      {
      //         continue;
      //      }

      //      if (found != null)
      //      {
      //         return found;
      //      }

      //      return child;
      //   }

      //   return null;
      //}

      /// <summary>
      /// Check if should ignore the child on get from point
      /// </summary>
      /// <param name="parent">parent</param>
      /// <param name="child">child</param>
      /// <returns></returns>
      private static bool IgnoreOnGetFromPoint(FormWrapper parent, Control child)
      {
         if (child == null)
         {
            return true;
         }

         if (child.Visible == false)
         {
            return true;
         }

         Control control = child;
         while (control != null)
         {
            if (parent._ignoreOnGetFromPoint.Contains(control))
            {
               return true;
            }

            control = control.Parent;
         }

         return false;
      }
Example #27
0
 /// <summary>
 /// Get the fill rectangle of the control in screen coordinates
 /// </summary>
 /// <param name="window">window</param>
 /// <returns>fill screen rectangle</returns>
 public static Rectangle GetFillScreenRectangle(Control window)
 {
    FormWrapper wrapper = new FormWrapper(window);
    return GetFillScreenRectangle(wrapper);
 }
Example #28
0
      /// <summary>
      /// GEt fill screen rectangle
      /// </summary>
      /// <param name="wrapper">wrapper</param>
      /// <returns></returns>
      public static Rectangle GetFillScreenRectangle(FormWrapper wrapper)
      {
         Rectangle clientArea  = wrapper.RectangleToClient(GetScreenClientRectangle(wrapper._host));

         int x1 = clientArea.Left;
         int x2 = clientArea.Right;
         int y1 = clientArea.Top;
         int y2 = clientArea.Bottom;

         for (int index = 0; index < wrapper.ControlsCount; index++)
         {
            Control control  = wrapper.GetControlAt(index);
            if (control.Dock == DockStyle.None || control.Visible == false)
            {
               continue;
            }

            if (control.Dock == DockStyle.Left)
            {
               x1 = Math.Max(x1, control.Right);
            }
            else if (control.Dock == DockStyle.Right)
            {
               x2 = Math.Min(x2, control.Left);
            }
            else if (control.Dock == DockStyle.Top)
            {
               y1 = Math.Max(y1, control.Bottom);
            }
            else if (control.Dock == DockStyle.Bottom)
            {
               y2 = Math.Min(y2, control.Top);
            }
         }

         if (x2 <= x1 || y2 <= y1)
         {
            return new Rectangle();
         }

         Rectangle result = new Rectangle(x1, y1, x2 - x1, y2 - y1);

         return wrapper.RectangleToScreen(result);
      }
Example #29
0
        /// <summary>
        /// Gets the fill rectangle based on a point
        /// </summary>
        /// <param name="screenPoint">point in screen coordinates</param>
        /// <returns>rectangle from point</returns>
        public static Rectangle GetFillRectangleFromPoint(Point screenPoint, Control underPoint, FormWrapper host)
        {
            if (underPoint == null)
            {
                if (host != null)
                {
                    return(GetFillScreenRectangle(host));
                }

                return(new Rectangle());
            }

            Rectangle result = GetFillScreenRectangle(underPoint);

            if (result.Contains(screenPoint) == false)
            {
                return(new Rectangle());
            }

            return(result);
        }
Example #30
0
        /// <summary>
        /// Get outer bottom preview bounds
        /// </summary>
        /// <param name="host">host</param>
        /// <param name="movedPanel">moved panel</param>
        /// <returns>outer bottom preview bounds</returns>
        private static Rectangle GetOuterBottomPreviewBounds(FormWrapper host, Control movedPanel)
        {
            Rectangle marginBounds = host.ScreenClientRectangle;
             if (marginBounds.IsEmpty == false)
             {
            int size = GetPreviewSize(movedPanel, DockStyle.Bottom);

            return new Rectangle(marginBounds.Left, marginBounds.Bottom - size, marginBounds.Width, size);
             }

             return new Rectangle();
        }
Example #31
0
        /// <summary>
        /// Get outer right preview bounds
        /// </summary>
        /// <param name="host">host</param>
        /// <param name="movedPanel">moved panel</param>
        /// <returns>outer right preview bounds</returns>
        private static Rectangle GetOuterRightPreviewBounds(FormWrapper host, Control movedPanel)
        {
            Rectangle marginBounds = host.ScreenClientRectangle;
             if (marginBounds.IsEmpty == false)
             {
            int size = GetPreviewSize(movedPanel, DockStyle.Right);

            return new Rectangle(marginBounds.Right - size, marginBounds.Top, size, marginBounds.Height);
             }

             return new Rectangle();
        }
Example #32
0
      /// <summary>
      /// Gets the fill rectangle based on a point
      /// </summary>
      /// <param name="screenPoint">point in screen coordinates</param>
      /// <returns>rectangle from point</returns>
      public static Rectangle GetFillRectangleFromPoint(Point screenPoint, Control underPoint, FormWrapper host)
      {
         if (underPoint == null)
         {
            if (host != null)
            {
               return GetFillScreenRectangle(host);
            }

            return new Rectangle();
         }

         Rectangle result  = GetFillScreenRectangle(underPoint);
         if (result.Contains(screenPoint) == false)
         {
            return new Rectangle();
         }

         return result;
      }
Example #33
0
        /// <summary>
        /// Get the fill rectangle of the control in screen coordinates
        /// </summary>
        /// <param name="window">window</param>
        /// <returns>fill screen rectangle</returns>
        public static Rectangle GetFillScreenRectangle(Control window)
        {
            FormWrapper wrapper = new FormWrapper(window);

            return(GetFillScreenRectangle(wrapper));
        }