예제 #1
0
        /// <summary>
        /// Shows the buttons to dock in the center of the view rectangle
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="viewScreenRectangle">view rectangle in which the buttons to dock will be shown (in screen coordinates)</param>
        public void Show(zAllowedDock allowedDockMode)
        {
            UpdateButtonsBounds();

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

            if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Left))
            {
                _dockLeftGuider.Visible = true;;
            }
            if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
            {
                _dockRightGuider.Visible = true;
            }
            if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
            {
                _dockTopGuider.Visible = true;
            }
            if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
            {
                _dockBottomGuider.Visible = true;;
            }
        }
        /// <summary>
        /// Load form
        /// </summary>
        /// <param name="xmlForm">xml form</param>
        /// <param name="formsFactory">forms factory</param>
        /// <param name="autoHide">list of autohide forms</param>
        /// <param name="selected">selected info</param>
        private ControlSizeInfo AddForm(XmlNode xmlForm, FormFactoryHandler formsFactory, List <DockableFormInfo> autoHide, out DockableFormInfo selected)
        {
            selected = null;

            XmlNode xmlGuid        = xmlForm.SelectSingleNode(XmlTags.TagGuid);
            XmlNode xmlParentGuid  = xmlForm.SelectSingleNode(XmlTags.TagParentGuid);
            XmlNode xmlAllowedDock = xmlForm.SelectSingleNode(XmlTags.TagAllowedDock);
            XmlNode xmlCurrentDock = xmlForm.SelectSingleNode(XmlTags.TagCurrentDock);
            XmlNode xmlCurrentMode = xmlForm.SelectSingleNode(XmlTags.TagCurrentMode);
            XmlNode xmlIsSelected  = xmlForm.SelectSingleNode(XmlTags.TagIsSelected);
            XmlNode xmlIsAutoHide  = xmlForm.SelectSingleNode(XmlTags.TagIsAutoHide);
            XmlNode xmlWidth       = xmlForm.SelectSingleNode(XmlTags.TagWidth);
            XmlNode xmlHeight      = xmlForm.SelectSingleNode(XmlTags.TagHeight);

            Guid         identifier  = new Guid(xmlGuid.InnerText);
            zAllowedDock allowedDock = (zAllowedDock)Enum.Parse(typeof(zAllowedDock), xmlAllowedDock.InnerText);
            Form         form        = formsFactory(identifier);
            int          width       = Convert.ToInt32(xmlWidth.InnerText);
            int          height      = Convert.ToInt32(xmlHeight.InnerText);

            form.Width  = width;
            form.Height = height;

            DockableFormInfo info = _container.Add(form, allowedDock, identifier);

            if (PanelAdded != null)
            {
                PanelAdded(this, new PanelAddedEventArgs(info));
            }

            if (Convert.ToBoolean(xmlIsSelected.InnerText))
            {
                selected = info;
            }

            if (Convert.ToBoolean(xmlIsAutoHide.InnerText))
            {
                autoHide.Add(info);
            }


            DockStyle currentDock = (DockStyle)Enum.Parse(typeof(DockStyle), xmlCurrentDock.InnerText);
            zDockMode currentMode = (zDockMode)Enum.Parse(typeof(zDockMode), xmlCurrentMode.InnerText);

            if (currentDock != DockStyle.None)
            {
                if (xmlParentGuid == null)
                {
                    _container.DockForm(info, currentDock, currentMode);
                }
                else
                {
                    Guid             parentGuid = new Guid(xmlParentGuid.InnerText);
                    DockableFormInfo parentInfo = _container.GetFormInfo(parentGuid);
                    _container.DockForm(info, parentInfo, currentDock, currentMode);
                }
            }

            return(new ControlSizeInfo(form, width, height));
        }
예제 #3
0
        /// <summary>
        /// Add form to guider
        /// </summary>
        /// <param name="form">form to guide</param>
        /// <param name="allowedDock">allowed dock</param>
        /// <param name="formIdentifier">identifier of the form added</param>
        /// <returns>object that encapsulates relevant information for the guided form</returns>
        public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier)
        {
            if (GetFormInfo(form) != null)
            {
                throw new ArgumentException("Err");
            }

            // Should set the border as None to prevent Microsoft bug in TextBox:
            // TextBox on Form with TopLevel = False and FormBorderStyle != None doesn't process Click event
            form.FormBorderStyle = FormBorderStyle.None;

            Rectangle bounds = form.Bounds;

            DockableFormInfo info = new DockableFormInfo(form, allowedDock, formIdentifier);

            info.ExplicitDisposing += OnInfoDisposing;
            info.SelectedChanged   += OnFormSelectedChanged;
            info.ShowAutoPanel     += OnShowFormAutoPanel;

            _dockableForms.Add(info);

            FormsTabbedView view = CreateFormsTabbedView(bounds.Size, null);

            view.Add(info);

            _layout.CreateFloatingContainer(view, bounds);

            return(info);
        }
        public DockableFormInfo AddForm(Control c, zAllowedDock allowDock, string guid, Size size, string caption)
        {
            Form             frm = CreateForm(size, c, caption);
            DockableFormInfo dfi = this.Add(frm, allowDock, new Guid(guid));

            return(dfi);
        }
예제 #5
0
        /// <summary>
        /// End window movement
        /// </summary>
        public void EndWindowMovement()
        {
            if (_movedWindow == null)
            {
                return;
            }

            Point        screenLocation = Control.MousePosition;
            zAllowedDock allowedDock    = _allowedDock;

            if (GetContainerUnderMouse(screenLocation) != null)
            {
                allowedDock = zAllowedDock.All;
            }

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

            StopMovement();

            _movedWindow = null;

            EventHandler <DockControlEventArgs> handler = ApplyDock;

            if (handler != null && result.Dock != DockStyle.None)
            {
                DockControlEventArgs args = new DockControlEventArgs(movedControl, result.Dock, result.DockMode);
                handler(this, args);
            }
        }
예제 #6
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();
            }
        }
예제 #7
0
        /// <summary>
        /// Gets the dock result for given screen location
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="screenLocation">screen location</param>
        /// <returns>dock result</returns>
        public GuidedDockResult GetDockResult(zAllowedDock allowedDockMode, Point screenLocation)
        {
            ValidateNotDisposed();

             _dockResult.Dock     = DockStyle.None;
             _dockResult.DockMode = zDockMode.Outer;

             Point clientLocation = _host.PointToClient(screenLocation);

             if (_marginGuiders.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Left) )
             {
            _dockResult.Dock = DockStyle.Left;
             }
             else if (_marginGuiders.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
             {
            _dockResult.Dock = DockStyle.Right;
             }
             else if (_marginGuiders.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
             {
            _dockResult.Dock = DockStyle.Top;
             }
             else if (_marginGuiders.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
             {
            _dockResult.Dock = DockStyle.Bottom;
             }
             else if (_centerGuider.IsVisible)
             {
            _dockResult.DockMode = zDockMode.Inner;

            if (_centerGuider.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Left))
            {
               _dockResult.Dock = DockStyle.Left;
            }
            else if (_centerGuider.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
            {
               _dockResult.Dock = DockStyle.Top;
            }
            else if (_centerGuider.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
            {
               _dockResult.Dock = DockStyle.Right;
            }
            else if (_centerGuider.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
            {
               _dockResult.Dock = DockStyle.Bottom;
            }
            else if (_centerGuider.FillButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Fill))
            {
               _dockResult.Dock = DockStyle.Fill;
            }
             }

             return _dockResult;
        }
        /// <summary>
        /// Gets the dock result for given screen location
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="screenLocation">screen location</param>
        /// <returns>dock result</returns>
        public GuidedDockResult GetDockResult(zAllowedDock allowedDockMode, Point screenLocation)
        {
            ValidateNotDisposed();

            _dockResult.Dock     = DockStyle.None;
            _dockResult.DockMode = zDockMode.Outer;

            Point clientLocation = _host.PointToClient(screenLocation);

            if (_marginGuiders.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Left))
            {
                _dockResult.Dock = DockStyle.Left;
            }
            else if (_marginGuiders.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
            {
                _dockResult.Dock = DockStyle.Right;
            }
            else if (_marginGuiders.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
            {
                _dockResult.Dock = DockStyle.Top;
            }
            else if (_marginGuiders.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
            {
                _dockResult.Dock = DockStyle.Bottom;
            }
            else if (_centerGuider.IsVisible)
            {
                _dockResult.DockMode = zDockMode.Inner;

                if (_centerGuider.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Left))
                {
                    _dockResult.Dock = DockStyle.Left;
                }
                else if (_centerGuider.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
                {
                    _dockResult.Dock = DockStyle.Top;
                }
                else if (_centerGuider.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
                {
                    _dockResult.Dock = DockStyle.Right;
                }
                else if (_centerGuider.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
                {
                    _dockResult.Dock = DockStyle.Bottom;
                }
                else if (_centerGuider.FillButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, zAllowedDock.Fill))
                {
                    _dockResult.Dock = DockStyle.Fill;
                }
            }

            return(_dockResult);
        }
예제 #9
0
        /// <summary>
        /// Begin the movement of a window
        /// </summary>
        /// <param name="window">moved window</param>
        /// <param name="allowedDock">allowed dock for the window</param>
        public void BeginWindowMovement(Control window, zAllowedDock allowedDock)
        {
            if (_movedWindow != null)
            {
                throw new InvalidOperationException("Err001");
            }

            _movedWindow = window;
            _allowedDock = allowedDock;

            GuideForm();
        }
예제 #10
0
파일: DockGuider.cs 프로젝트: Remurr/nDbg
        /// <summary>
        /// Begin the movement of a window
        /// </summary>
        /// <param name="window">moved window</param>
        /// <param name="allowedDock">allowed dock for the window</param>
        public void BeginWindowMovement(Control window, zAllowedDock allowedDock)
        {
            if (_movedWindow != null)
             {
            throw new InvalidOperationException("Err001");
             }

             _movedWindow = window;
             _allowedDock = allowedDock;

             GuideForm();
        }
예제 #11
0
        /// <summary>
        /// Shows the buttons to dock in the center of the view rectangle
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="viewScreenRectangle">view rectanlge in the center of which the buttons to dock will be shown (in screen coordinates)</param>
        public void Show(zAllowedDock allowedDockMode, Rectangle viewScreenRectangle)
        {
            ValidateNotDisposed();

            UpdateGuiderBounds(allowedDockMode, viewScreenRectangle);

            _dockLeftGuider.Visible   = EnumUtility.Contains(allowedDockMode, zAllowedDock.Left);
            _dockRightGuider.Visible  = EnumUtility.Contains(allowedDockMode, zAllowedDock.Right);
            _dockTopGuider.Visible    = EnumUtility.Contains(allowedDockMode, zAllowedDock.Top);
            _dockBottomGuider.Visible = EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom);

            _dockFillGuider.Visible         = true;
            _dockFillGuider.ShowFillPreview = EnumUtility.Contains(allowedDockMode, zAllowedDock.Fill);
        }
예제 #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="form">form</param>
        /// <param name="allowedDock">allowed dock mode</param>
        /// <param name="identifier">identifier of the form info</param>
        internal DockableFormInfo(Form form, zAllowedDock allowedDock, Guid identifier)
        {
            if (identifier == Guid.Empty)
            {
                throw new ArgumentException("Err");
            }

            _identifier                = identifier;
            _dockableForm              = form;
            _allowedDock               = allowedDock;
            _button                    = new TabButton(form);
            _button.ExplicitDisposing += OnButtonDisposing;

            form.GotFocus += OnFormGotFocus;
        }
예제 #13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="form">form</param>
        /// <param name="allowedDock">allowed dock mode</param>
        /// <param name="identifier">identifier of the form info</param>
        internal DockableFormInfo(Form form, zAllowedDock allowedDock, Guid identifier)
        {
            if (identifier == Guid.Empty)
             {
            throw new ArgumentException("Err");
             }

             _identifier    = identifier;
             _dockableForm  = form;
             _allowedDock   = allowedDock;
             _button        = new TabButton(form);
             _button.ExplicitDisposing += OnButtonDisposing;

             form.GotFocus += OnFormGotFocus;
        }
예제 #14
0
      /// <summary>
      /// Add form to guider
      /// </summary>
      /// <param name="form">form to guide</param>
      /// <param name="allowedDock">allowed dock</param>
      /// <param name="formIdentifier">identifier of the form added</param>
      /// <returns>object that encapsulates relevant information for the guided form</returns>
      public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier)
      {
         if (GetFormInfo(form) != null)
         {
            throw new ArgumentException("Err");
         }

         // Should set the border as None to prevent Microsoft bug in TextBox:
         // TextBox on Form with TopLevel = False and FormBorderStyle != None doesn't process Click event
         form.FormBorderStyle = FormBorderStyle.None;

         Rectangle bounds = form.Bounds;

         DockableFormInfo info = new DockableFormInfo(form, allowedDock, formIdentifier);
         info.ExplicitDisposing  += OnInfoDisposing;
         info.SelectedChanged    += OnFormSelectedChanged;
         info.ShowAutoPanel      += OnShowFormAutoPanel;

         _dockableForms.Add(info);

         FormsTabbedView view  = CreateFormsTabbedView(bounds.Size, null);
         view.Add(info);

         _layout.CreateFloatingContainer(view, bounds);

         return info;
      }
예제 #15
0
      /// <summary>
      /// Shows the center guider
      /// </summary>
      /// <param name="allowedDockMode">allowed dock</param>
      /// <param name="screenBounds">screen bounds where to center the guider</param>
      public void ShowCenterGuider(zAllowedDock allowedDockMode, Rectangle screenBounds)
      {
         ValidateNotDisposed();

         _centerGuider.Show(allowedDockMode, screenBounds);
      }
        /// <summary>
        /// Show margin guider
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="screenBounds">screen bounds where to show the margins guider</param>
        public void ShowMarginsGuider(zAllowedDock allowedDockMode, Rectangle screenBounds)
        {
            ValidateNotDisposed();

            _marginGuiders.Show(allowedDockMode);
        }
        /// <summary>
        /// Shows the center guider
        /// </summary>
        /// <param name="allowedDockMode">allowed dock</param>
        /// <param name="screenBounds">screen bounds where to center the guider</param>
        public void ShowCenterGuider(zAllowedDock allowedDockMode, Rectangle screenBounds)
        {
            ValidateNotDisposed();

            _centerGuider.Show(allowedDockMode, screenBounds);
        }
예제 #18
0
 private DockableFormInfo Add(Control c, zAllowedDock allowedDock, string guid)
 {
     return(base.Add(CreateForm(c), allowedDock, new Guid(guid)));
 }
예제 #19
0
 /// <summary>
 /// Add form to guider
 /// </summary>
 /// <param name="form">form to guide</param>
 /// <param name="allowedDock">allowed dock</param>
 /// <param name="formIdentifier">identifier of the form added</param>
 /// <returns>object that encapsulates relevant information for the guided form</returns>
 public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier)
 {
     return _docker.Add(form, allowedDock, formIdentifier);
 }
예제 #20
0
 /// <summary>
 /// Add form to guider
 /// </summary>
 /// <param name="form">form to guide</param>
 /// <param name="allowedDock">allowed dock</param>
 /// <param name="formIdentifier">identifier of the form added</param>
 /// <returns>object that encapsulates relevant information for the guided form</returns>
 public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier)
 {
     return(_docker.Add(form, allowedDock, formIdentifier));
 }
예제 #21
0
      /// <summary>
      /// Update the bounds of the buttons
      /// </summary>
      /// <param name="allowedDockMode">allowed dock mode</param>
      /// <param name="viewScreenRectangle">view rectanlge in the center of which the buttons to dock will be shown (in screen coordinates)</param>
      public void UpdateGuiderBounds(zAllowedDock allowedDockMode, Rectangle viewScreenRectangle)
      {
         ValidateNotDisposed();

         Rectangle viewRectangle = _host.RectangleToClient(viewScreenRectangle);

         if (_lastAllowedDockMode == allowedDockMode && _lastViewRectangle == viewRectangle)
         {
            return;
         }

         _lastViewRectangle   = viewRectangle;
         _lastAllowedDockMode = allowedDockMode;

         int width    = viewRectangle.Width;
         int height   = viewRectangle.Height;
         Point center = new Point(width / 2, height / 2);
         Point offset = viewRectangle.Location;

         Point fillPosition      = new Point(center.X       - _dockFillGuider.Width / 2,        center.Y       - _dockFillGuider.Height / 2);

         Point leftPosition      = new Point(fillPosition.X - _dockLeftGuider.Width + 7,        center.Y       - _dockLeftGuider.Height / 2);
         Point topPosition       = new Point(center.X       - _dockTopGuider.Width / 2 - 1,     fillPosition.Y - _dockTopGuider.Height + 7);
         Point rightPosition     = new Point(fillPosition.X + _dockFillGuider.Width - 7,        center.Y       - _dockRightGuider.Height / 2);
         Point bottomPosition    = new Point(center.X       - _dockBottomGuider.Width / 2,      fillPosition.Y + _dockBottomGuider.Height + 7);

         fillPosition.Offset  (offset);
         leftPosition.Offset  (offset);
         rightPosition.Offset (offset);
         topPosition.Offset   (offset);
         bottomPosition.Offset(offset);

         _dockLeftGuider.Location      = leftPosition;
         _dockRightGuider.Location     = rightPosition;
         _dockTopGuider.Location       = topPosition;
         _dockBottomGuider.Location    = bottomPosition;
         _dockFillGuider.Location      = fillPosition;

         bool dockLeftGuiderVisible          = EnumUtility.Contains (allowedDockMode, zAllowedDock.Left);
         bool dockRightGuiderVisible         = EnumUtility.Contains (allowedDockMode, zAllowedDock.Right);
         bool dockTopGuiderVisible           = EnumUtility.Contains (allowedDockMode, zAllowedDock.Top);
         bool dockBottomGuiderVisible        = EnumUtility.Contains (allowedDockMode, zAllowedDock.Bottom);
         bool dockFillGuiderShowFillPreview  = EnumUtility.Contains (allowedDockMode, zAllowedDock.Fill);


         _guiderBounds.X = _dockFillGuider.Left;
         if (dockLeftGuiderVisible)
         {
            _guiderBounds.X = _dockLeftGuider.Left;
         }

         _guiderBounds.Y = _dockFillGuider.Top;
         if (dockTopGuiderVisible)
         {
            _guiderBounds.Y = _dockTopGuider.Top;
         }

         int right = _dockFillGuider.Right;
         if (dockRightGuiderVisible)
         {
            right = _dockRightGuider.Right;
         }
         _guiderBounds.Width = right - _guiderBounds.Left;

         int bottom = _dockFillGuider.Bottom;
         if (dockBottomGuiderVisible)
         {
            bottom = _dockBottomGuider.Bottom;
         }
         _guiderBounds.Height = bottom - _guiderBounds.Top;


         _leftButtonBounds.Location    = leftPosition;
         _rightButtonBounds.Location   = rightPosition;
         _topButtonBounds.Location     = topPosition;
         _bottomButtonBounds.Location  = bottomPosition;

         _fillButtonBounds = _dockFillGuider.FillBounds;
         _fillButtonBounds.X += _dockFillGuider.Left;
         _fillButtonBounds.Y += _dockFillGuider.Top;
      }
예제 #22
0
        /// <summary>
        /// Shows the buttons to dock in the center of the view rectangle
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="viewScreenRectangle">view rectangle in which the buttons to dock will be shown (in screen coordinates)</param>
        public void Show(zAllowedDock allowedDockMode)
        {
            UpdateButtonsBounds();

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

             if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Left))
             {
            _dockLeftGuider.Visible = true;;
             }
             if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Right))
             {
            _dockRightGuider.Visible = true;
             }
             if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Top))
             {
            _dockTopGuider.Visible = true;
             }
             if (EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom))
             {
            _dockBottomGuider.Visible = true;;
             }
        }
예제 #23
0
      /// <summary>
      /// Shows the buttons to dock in the center of the view rectangle
      /// </summary>
      /// <param name="allowedDockMode">allowed dock mode</param>
      /// <param name="viewScreenRectangle">view rectanlge in the center of which the buttons to dock will be shown (in screen coordinates)</param>
      public void Show(zAllowedDock allowedDockMode, Rectangle viewScreenRectangle)
      {
         ValidateNotDisposed();

         UpdateGuiderBounds(allowedDockMode, viewScreenRectangle);

         _dockLeftGuider.Visible    = EnumUtility.Contains(allowedDockMode, zAllowedDock.Left);
         _dockRightGuider.Visible   = EnumUtility.Contains(allowedDockMode, zAllowedDock.Right);
         _dockTopGuider.Visible     = EnumUtility.Contains(allowedDockMode, zAllowedDock.Top);
         _dockBottomGuider.Visible  = EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom);

         _dockFillGuider.Visible    = true;
         _dockFillGuider.ShowFillPreview = EnumUtility.Contains(allowedDockMode, zAllowedDock.Fill);
      }
예제 #24
0
파일: FormsDocker.cs 프로젝트: Remurr/nDbg
        /// <summary>
        /// Add form to guider
        /// </summary>
        /// <param name="form">form to guide</param>
        /// <param name="allowedDock">allowed dock</param>
        /// <param name="formIdentifier">identifier of the form added</param>
        /// <returns>object that encapsulates relevant information for the guided form</returns>
        public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier)
        {
            if (GetFormInfo(form) != null)
             {
            throw new ArgumentException("Err");
             }

             Rectangle bounds = form.Bounds;

             // @matt - force right values
             form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
             form.TopLevel = false;

             DockableFormInfo info = new DockableFormInfo(form, allowedDock, formIdentifier);
             info.ExplicitDisposing  += OnInfoDisposing;
             info.SelectedChanged    += OnFormSelectedChanged;
             info.ShowAutoPanel      += OnShowFormAutoPanel;

             _dockableForms.Add(info);

             FormsTabbedView view  = CreateFormsTabbedView(bounds.Size, null);
             view.Add(info);

             _layout.CreateFloatingContainer(view, bounds);

             return info;
        }
예제 #25
0
      /// <summary>
      /// Show margin guider
      /// </summary>
      /// <param name="allowedDockMode">allowed dock mode</param>
      /// <param name="screenBounds">screen bounds where to show the margins guider</param>
      public void ShowMarginsGuider(zAllowedDock allowedDockMode, Rectangle screenBounds)
      {
         ValidateNotDisposed();

         _marginGuiders.Show(allowedDockMode);
      }
예제 #26
0
        /// <summary>
        /// Update the bounds of the buttons
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="viewScreenRectangle">view rectanlge in the center of which the buttons to dock will be shown (in screen coordinates)</param>
        public void UpdateGuiderBounds(zAllowedDock allowedDockMode, Rectangle viewScreenRectangle)
        {
            ValidateNotDisposed();

            Rectangle viewRectangle = _host.RectangleToClient(viewScreenRectangle);

            if (_lastAllowedDockMode == allowedDockMode && _lastViewRectangle == viewRectangle)
            {
                return;
            }

            _lastViewRectangle   = viewRectangle;
            _lastAllowedDockMode = allowedDockMode;

            int   width  = viewRectangle.Width;
            int   height = viewRectangle.Height;
            Point center = new Point(width / 2, height / 2);
            Point offset = viewRectangle.Location;

            Point fillPosition = new Point(center.X - _dockFillGuider.Width / 2, center.Y - _dockFillGuider.Height / 2);

            Point leftPosition   = new Point(fillPosition.X - _dockLeftGuider.Width + 7, center.Y - _dockLeftGuider.Height / 2);
            Point topPosition    = new Point(center.X - _dockTopGuider.Width / 2 - 1, fillPosition.Y - _dockTopGuider.Height + 7);
            Point rightPosition  = new Point(fillPosition.X + _dockFillGuider.Width - 7, center.Y - _dockRightGuider.Height / 2);
            Point bottomPosition = new Point(center.X - _dockBottomGuider.Width / 2, fillPosition.Y + _dockBottomGuider.Height + 7);

            fillPosition.Offset(offset);
            leftPosition.Offset(offset);
            rightPosition.Offset(offset);
            topPosition.Offset(offset);
            bottomPosition.Offset(offset);

            _dockLeftGuider.Location   = leftPosition;
            _dockRightGuider.Location  = rightPosition;
            _dockTopGuider.Location    = topPosition;
            _dockBottomGuider.Location = bottomPosition;
            _dockFillGuider.Location   = fillPosition;

            bool dockLeftGuiderVisible         = EnumUtility.Contains(allowedDockMode, zAllowedDock.Left);
            bool dockRightGuiderVisible        = EnumUtility.Contains(allowedDockMode, zAllowedDock.Right);
            bool dockTopGuiderVisible          = EnumUtility.Contains(allowedDockMode, zAllowedDock.Top);
            bool dockBottomGuiderVisible       = EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom);
            bool dockFillGuiderShowFillPreview = EnumUtility.Contains(allowedDockMode, zAllowedDock.Fill);


            _guiderBounds.X = _dockFillGuider.Left;
            if (dockLeftGuiderVisible)
            {
                _guiderBounds.X = _dockLeftGuider.Left;
            }

            _guiderBounds.Y = _dockFillGuider.Top;
            if (dockTopGuiderVisible)
            {
                _guiderBounds.Y = _dockTopGuider.Top;
            }

            int right = _dockFillGuider.Right;

            if (dockRightGuiderVisible)
            {
                right = _dockRightGuider.Right;
            }
            _guiderBounds.Width = right - _guiderBounds.Left;

            int bottom = _dockFillGuider.Bottom;

            if (dockBottomGuiderVisible)
            {
                bottom = _dockBottomGuider.Bottom;
            }
            _guiderBounds.Height = bottom - _guiderBounds.Top;


            _leftButtonBounds.Location   = leftPosition;
            _rightButtonBounds.Location  = rightPosition;
            _topButtonBounds.Location    = topPosition;
            _bottomButtonBounds.Location = bottomPosition;

            _fillButtonBounds    = _dockFillGuider.FillBounds;
            _fillButtonBounds.X += _dockFillGuider.Left;
            _fillButtonBounds.Y += _dockFillGuider.Top;
        }