コード例 #1
0
        private void SetOutline(DockContainer dockPanel, DockStyle dock, bool fullPanelEdge)
        {
            Rectangle rect = fullPanelEdge ? dockPanel.DockArea : dockPanel.DocumentWindowBounds;

            rect.Location = dockPanel.PointToScreen(rect.Location);
            if (dock == DockStyle.Top)
            {
                int height = (int)(rect.Height * dockPanel.DockBottomPortion);
                rect = new Rectangle(rect.X, rect.Y, rect.Width, height);
            }
            else if (dock == DockStyle.Bottom)
            {
                int height = (int)(rect.Height * dockPanel.DockBottomPortion);
                rect = new Rectangle(rect.X, rect.Bottom - height, rect.Width, height);
            }
            else if (dock == DockStyle.Left)
            {
                int width = (int)(rect.Width * dockPanel.DockLeftPortion);
                rect = new Rectangle(rect.X, rect.Y, width, rect.Height);
            }
            else if (dock == DockStyle.Right)
            {
                int width = (int)(rect.Width * dockPanel.DockRightPortion);
                rect = new Rectangle(rect.Right - width, rect.Y, width, rect.Height);
            }
            else if (dock == DockStyle.Fill)
            {
                rect          = dockPanel.DocumentWindowBounds;
                rect.Location = dockPanel.PointToScreen(rect.Location);
            }

            SetDragForm(rect);
        }
コード例 #2
0
ファイル: DragHandler.cs プロジェクト: psryland/rylogic_code
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            // Set the positions of the edge docking indicators
            var distance_from_edge = 15;
            var loc_ghost          = Point.Add(m_ss_start_pt, DraggeeOfs);
            var loc_top            = DockContainer.PointToScreen(new Point((DockContainer.Width - DimensionsFor(EIndicator.dock_site_top).Width) / 2, distance_from_edge));
            var loc_left           = DockContainer.PointToScreen(new Point(distance_from_edge, (DockContainer.Height - DimensionsFor(EIndicator.dock_site_left).Height) / 2));
            var loc_right          = DockContainer.PointToScreen(new Point(DockContainer.Width - distance_from_edge - DimensionsFor(EIndicator.dock_site_right).Width, (DockContainer.Height - DimensionsFor(EIndicator.dock_site_right).Height) / 2));
            var loc_bottom         = DockContainer.PointToScreen(new Point((DockContainer.Width - DimensionsFor(EIndicator.dock_site_bottom).Width) / 2, DockContainer.Height - distance_from_edge - DimensionsFor(EIndicator.dock_site_bottom).Height));

            // Create the semi-transparent non-modal window for the dragged item
            Ghost = new GhostPane(this, loc_ghost)
            {
                Visibility = Visibility.Visible
            };

            // Create the dock site indicators
            IndTop = new Indicator(this, EIndicator.dock_site_top, DockContainer.AutoHidePanels[EDockSite.Top].Root.DockPane(EDockSite.Centre), loc_top)
            {
                Visibility = Visibility.Visible
            };
            IndLeft = new Indicator(this, EIndicator.dock_site_left, DockContainer.AutoHidePanels[EDockSite.Left].Root.DockPane(EDockSite.Centre), loc_left)
            {
                Visibility = Visibility.Visible
            };
            IndRight = new Indicator(this, EIndicator.dock_site_right, DockContainer.AutoHidePanels[EDockSite.Right].Root.DockPane(EDockSite.Centre), loc_right)
            {
                Visibility = Visibility.Visible
            };
            IndBottom = new Indicator(this, EIndicator.dock_site_bottom, DockContainer.AutoHidePanels[EDockSite.Bottom].Root.DockPane(EDockSite.Centre), loc_bottom)
            {
                Visibility = Visibility.Visible
            };
            IndCrossLg = new Indicator(this, EIndicator.dock_site_cross_lg)
            {
                Visibility = Visibility.Collapsed
            };
            IndCrossSm = new Indicator(this, EIndicator.dock_site_cross_sm)
            {
                Visibility = Visibility.Collapsed
            };

            // The dock handler deals with the mouse
            CaptureMouse();
        }