Exemple #1
0
        /// <summary>
        /// Propagates a page list request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="state">Request that should result in pages collection being modified.</param>
        /// <param name="pages">Pages collection for modification by the docking elements.</param>
        public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
        {
            switch (state)
            {
            case DockingPropogatePageList.All:
            case DockingPropogatePageList.Docked:
            case DockingPropogatePageList.Floating:
            case DockingPropogatePageList.Filler:
            {
                // If the request relevant to this space control?
                if ((state == DockingPropogatePageList.All) || (state == DockingPropogatePageList.Filler))
                {
                    // Process each page inside the navigator
                    for (int i = DockableNavigatorControl.Pages.Count - 1; i >= 0; i--)
                    {
                        // Only add real pages and not placeholders
                        KryptonPage page = DockableNavigatorControl.Pages[i];
                        if ((page != null) && !(page is KryptonStorePage))
                        {
                            pages.Add(page);
                        }
                    }
                }
            }
            break;
            }

            // Let base class perform standard processing
            base.PropogatePageList(state, pages);
        }
Exemple #2
0
        /// <summary>
        /// Is this target a match for the provided screen position.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="dragEndData">Data to be dropped at destination.</param>
        /// <returns>True if a match; otherwise false.</returns>
        public override bool IsMatch(Point screenPt, PageDragEndData dragEndData)
        {
            // First time around...
            if (_visibleNotDraggedPages == -1)
            {
                // If pages are being dragged from this cell
                if (dragEndData.Navigator == Cell)
                {
                    // Create list of all the visible pages in the cell
                    KryptonPageCollection visiblePages = new KryptonPageCollection();
                    foreach (KryptonPage page in Cell.Pages)
                    {
                        if (page.LastVisibleSet)
                        {
                            visiblePages.Add(page);
                        }
                    }

                    // Remove all those that are being dragged
                    foreach (KryptonPage page in dragEndData.Pages)
                    {
                        visiblePages.Remove(page);
                    }

                    // Cache number of visible pages in target that are not part of the dragging set
                    _visibleNotDraggedPages = visiblePages.Count;
                }
                else
                {
                    // Pages not coming from this cell so we always allow the cell edge targets
                    _visibleNotDraggedPages = int.MaxValue;
                }
            }

            // If the drop leaves at least 1 page in the navigator then allow drag to edge
            if (_visibleNotDraggedPages >= 1)
            {
                return(base.IsMatch(screenPt, dragEndData));
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Propagates a page list request down the hierarchy of docking elements.
 /// </summary>
 /// <param name="state">Request that should result in pages collection being modified.</param>
 /// <param name="pages">Pages collection for modification by the docking elements.</param>
 public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
 {
     switch (state)
     {
         case DockingPropogatePageList.All:
         case DockingPropogatePageList.AutoHidden:
             for (int i = AutoHiddenGroupControl.Pages.Count - 1; i >= 0; i--)
             {
                 // Only add real pages and not just placeholders
                 KryptonPage page = AutoHiddenGroupControl.Pages[i];
                 if ((page != null) && !(page is KryptonStorePage))
                 {
                     // Remember the real page is inside a proxy!
                     KryptonAutoHiddenProxyPage proxyPage = (KryptonAutoHiddenProxyPage)page;
                     pages.Add(proxyPage.Page);
                 }
             }
             break;
     }
 }
Exemple #4
0
        /// <summary>
        /// Propogates a page list request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="state">Request that should result in pages collection being modified.</param>
        /// <param name="pages">Pages collection for modification by the docking elements.</param>
        public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
        {
            switch (state)
            {
            case DockingPropogatePageList.All:
            case DockingPropogatePageList.Docked:
            case DockingPropogatePageList.Floating:
            case DockingPropogatePageList.Filler:
            {
                // If the request relevant to this space control?
                if ((state == DockingPropogatePageList.All) ||
                    ((state == DockingPropogatePageList.Docked) && (ClearStoreAction == DockingPropogateAction.ClearDockedStoredPages)) ||
                    ((state == DockingPropogatePageList.Floating) && (ClearStoreAction == DockingPropogateAction.ClearFloatingStoredPages)) ||
                    ((state == DockingPropogatePageList.Filler) && (ClearStoreAction == DockingPropogateAction.ClearFillerStoredPages)))
                {
                    // Process each cell in turn
                    KryptonWorkspaceCell cell = SpaceControl.FirstCell();
                    while (cell != null)
                    {
                        // Process each page inside the cell
                        for (int i = cell.Pages.Count - 1; i >= 0; i--)
                        {
                            // Only add real pages and not placeholders
                            KryptonPage page = cell.Pages[i];
                            if ((page != null) && !(page is KryptonStorePage))
                            {
                                pages.Add(page);
                            }
                        }

                        cell = SpaceControl.NextCell(cell);
                    }
                }
            }
            break;
            }

            // Let base class perform standard processing
            base.PropogatePageList(state, pages);
        }
        /// <summary>
        /// Propagates a request for drag targets down the hierarchy of docking elements.
        /// </summary>
        /// <param name="floatingWindow">Reference to window being dragged.</param>
        /// <param name="dragData">Set of pages being dragged.</param>
        /// <param name="targets">Collection of drag targets.</param>
        public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow,
                                                  PageDragEndData dragData,
                                                  DragTargetList targets)
        {
            // Create list of the pages that are allowed to be dropped into this workspace
            KryptonPageCollection pages = new KryptonPageCollection();

            foreach (KryptonPage page in dragData.Pages)
            {
                if (page.AreFlagsSet(KryptonPageFlags.DockingAllowWorkspace))
                {
                    pages.Add(page);
                }
            }

            // Do we have any pages left for dragging?
            if (pages.Count > 0)
            {
                DragTargetList workspaceTargets = DockableWorkspaceControl.GenerateDragTargets(new PageDragEndData(this, pages), KryptonPageFlags.DockingAllowWorkspace);
                targets.AddRange(workspaceTargets.ToArray());
            }
        }
        /// <summary>
        /// Perform docking element specific actions for loading a child xml.
        /// </summary>
        /// <param name="xmlReader">Xml reader object.</param>
        /// <param name="pages">Collection of available pages.</param>
        /// <param name="child">Optional reference to existing child docking element.</param>
        protected override void LoadChildDockingElement(XmlReader xmlReader,
                                                        KryptonPageCollection pages,
                                                        IDockingElement child)
        {
            KryptonDockingManager manager = DockingManager;

            // Is it the expected xml element name?
            if (xmlReader.Name != "KP")
            {
                throw new ArgumentException("Element name 'KP' was expected but found '" + xmlReader.Name + "' instead.");
            }

            // Get the unique name of the page
            string uniqueName = xmlReader.GetAttribute("UN");
            string boolStore = xmlReader.GetAttribute("S");
            string boolVisible = xmlReader.GetAttribute("V");

            KryptonPage page;

            // If the entry is for just a placeholder...
            if (CommonHelper.StringToBool(boolStore))
            {
                // Recreate the requested store page and append
                page = new KryptonStorePage(uniqueName, "AutoHiddenGroup");
                AutoHiddenGroupControl.Pages.Add(page);
            }
            else
            {
                // Can we find a provided page to match the incoming layout?
                page = pages[uniqueName];
                if (page == null)
                {
                    // Generate event so developer can create and supply the page now
                    RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName);
                    manager.RaiseRecreateLoadingPage(args);
                    if (!args.Cancel)
                    {
                        page = args.Page;

                        // Add recreated page to the looking dictionary
                        if ((page != null) && (pages[page.UniqueName] == null))
                        {
                            pages.Add(page);
                        }
                    }
                }

                if (page != null)
                {
                    // Use the loaded visible state
                    page.Visible = CommonHelper.StringToBool(boolVisible);

                    // Create a proxy around the page and append it
                    KryptonAutoHiddenProxyPage proxyPage = new KryptonAutoHiddenProxyPage(page);
                    AutoHiddenGroupControl.Pages.Add(proxyPage);
                }
            }

            if (!xmlReader.Read())
            {
                throw new ArgumentException("An element was expected but could not be read in.");
            }

            if (xmlReader.Name != "CPD")
            {
                throw new ArgumentException("Expected 'CPD' element was not found");
            }

            bool finished = xmlReader.IsEmptyElement;

            // Generate event so custom data can be loaded and/or the page to be added can be modified
            DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page);
            manager.RaisePageLoading(pageLoading);

            // Read everything until we get the end of custom data marker
            while (!finished)
            {
                // Check it has the expected name
                if (xmlReader.NodeType == XmlNodeType.EndElement)
                {
                    finished = (xmlReader.Name == "CPD");
                }

                if (!finished)
                {
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }
                }
            }

            if (!xmlReader.Read())
            {
                throw new ArgumentException("An element was expected but could not be read in.");
            }
        }
        /// <summary>
        /// Propogates a request for drag targets down the hierarchy of docking elements.
        /// </summary>
        /// <param name="floatingWindow">Reference to window being dragged.</param>
        /// <param name="dragData">Set of pages being dragged.</param>
        /// <param name="targets">Collection of drag targets.</param>
        public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow,
            PageDragEndData dragData,
            DragTargetList targets)
        {
            if (DockspaceControl.CellVisibleCount > 0)
            {
                // Create list of the pages that are allowed to be dropped into this dockspace
                KryptonPageCollection pages = new KryptonPageCollection();
                foreach (KryptonPage page in dragData.Pages)
                    if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked))
                        pages.Add(page);

                // Do we have any pages left for dragging?
                if (pages.Count > 0)
                {
                    DragTargetList dockspaceTargets = DockspaceControl.GenerateDragTargets(new PageDragEndData(this, pages), KryptonPageFlags.DockingAllowDocked);
                    targets.AddRange(dockspaceTargets.ToArray());
                }
            }
        }
        /// <summary>
        /// Is this target a match for the provided screen position.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="dragEndData">Data to be dropped at destination.</param>
        /// <returns>True if a match; otherwise false.</returns>
        public override bool IsMatch(Point screenPt, PageDragEndData dragEndData)
        {
            // First time around...
            if (_visibleNotDraggedPages == -1)
            {
                // If pages are being dragged from this cell
                if (dragEndData.Navigator == _cell)
                {
                    // Create list of all the visible pages in the cell
                    KryptonPageCollection visiblePages = new KryptonPageCollection();
                    foreach (KryptonPage page in _cell.Pages)
                        if (page.LastVisibleSet)
                            visiblePages.Add(page);

                    // Remove all those that are being dragged
                    foreach (KryptonPage page in dragEndData.Pages)
                        visiblePages.Remove(page);

                    // Cache number of visible pages in target that are not part of the dragging set
                    _visibleNotDraggedPages = visiblePages.Count;
                }
                else
                {
                    // Pages not coming from this cell so we always allow the cell edge targets
                    _visibleNotDraggedPages = int.MaxValue;
                }
            }

            // If the drop leaves at least 1 page in the navigator then allow drag to edge
            if (_visibleNotDraggedPages >= 1)
                return base.IsMatch(screenPt, dragEndData);
            else
                return false;
        }
        /// <summary>
        /// Propogates a page list request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="state">Request that should result in pages collection being modified.</param>
        /// <param name="pages">Pages collection for modification by the docking elements.</param>
        public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
        {
            switch (state)
            {
                case DockingPropogatePageList.All:
                case DockingPropogatePageList.Docked:
                case DockingPropogatePageList.Floating:
                case DockingPropogatePageList.Filler:
                    {
                        // If the request relevant to this space control?
                        if ((state == DockingPropogatePageList.All) ||
                            ((state == DockingPropogatePageList.Docked) && (ClearStoreAction == DockingPropogateAction.ClearDockedStoredPages)) ||
                            ((state == DockingPropogatePageList.Floating) && (ClearStoreAction == DockingPropogateAction.ClearFloatingStoredPages)) ||
                            ((state == DockingPropogatePageList.Filler) && (ClearStoreAction == DockingPropogateAction.ClearFillerStoredPages)))
                        {
                            // Process each cell in turn
                            KryptonWorkspaceCell cell = SpaceControl.FirstCell();
                            while (cell != null)
                            {
                                // Process each page inside the cell
                                for (int i = cell.Pages.Count - 1; i >= 0; i--)
                                {
                                    // Only add real pages and not placeholders
                                    KryptonPage page = cell.Pages[i];
                                    if ((page != null) && !(page is KryptonStorePage))
                                        pages.Add(page);
                                }

                                cell = SpaceControl.NextCell(cell);
                            }
                        }
                    }
                    break;
            }

            // Let base class perform standard processing
            base.PropogatePageList(state, pages);
        }
        /// <summary>
        /// Perform docking element specific actions for loading a child xml.
        /// </summary>
        /// <param name="xmlReader">Xml reader object.</param>
        /// <param name="pages">Collection of available pages.</param>
        /// <param name="child">Optional reference to existing child docking element.</param>
        protected override void LoadChildDockingElement(XmlReader xmlReader,
                                                        KryptonPageCollection pages,
                                                        IDockingElement child)
        {
            KryptonDockingManager manager = DockingManager;

            // Is it the expected xml element name?
            if (xmlReader.Name != "KP")
                throw new ArgumentException("Element name 'KP' was expected but found '" + xmlReader.Name + "' instead.");

            // Get the unique name of the page
            string uniqueName = xmlReader.GetAttribute("UN");
            string boolStore = xmlReader.GetAttribute("S");
            string boolVisible = xmlReader.GetAttribute("V");

            KryptonPage page = null;

            // If the entry is for just a placeholder...
            if (CommonHelper.StringToBool(boolStore))
            {
                // Recreate the requested store page and append
                page = new KryptonStorePage(uniqueName, "AutoHiddenGroup");
                AutoHiddenGroupControl.Pages.Add(page);
            }
            else
            {
                // Can we find a provided page to match the incoming layout?
                page = pages[uniqueName];
                if (page == null)
                {
                    // Generate event so developer can create and supply the page now
                    RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName);
                    manager.RaiseRecreateLoadingPage(args);
                    if (!args.Cancel)
                    {
                        page = args.Page;

                        // Add recreated page to the looking dictionary
                        if ((page != null) && (pages[page.UniqueName] == null))
                            pages.Add(page);
                    }
                }

                if (page != null)
                {
                    // Use the loaded visible state
                    page.Visible = CommonHelper.StringToBool(boolVisible);

                    // Create a proxy around the page and append it
                    KryptonAutoHiddenProxyPage proxyPage = new KryptonAutoHiddenProxyPage(page);
                    AutoHiddenGroupControl.Pages.Add(proxyPage);
                }
            }

            if (!xmlReader.Read())
                throw new ArgumentException("An element was expected but could not be read in.");

            if (xmlReader.Name != "CPD")
                throw new ArgumentException("Expected 'CPD' element was not found");

            bool finished = xmlReader.IsEmptyElement;

            // Generate event so custom data can be loaded and/or the page to be added can be modified
            DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page);
            manager.RaisePageLoading(pageLoading);

            // Read everything until we get the end of custom data marker
            while (!finished)
            {
                // Check it has the expected name
                if (xmlReader.NodeType == XmlNodeType.EndElement)
                    finished = (xmlReader.Name == "CPD");

                if (!finished)
                {
                    if (!xmlReader.Read())
                        throw new ArgumentException("An element was expected but could not be read in.");
                }
            }

            if (!xmlReader.Read())
                throw new ArgumentException("An element was expected but could not be read in.");
        }
 /// <summary>
 /// Propogates a page list request down the hierarchy of docking elements.
 /// </summary>
 /// <param name="state">Request that should result in pages collection being modified.</param>
 /// <param name="pages">Pages collection for modification by the docking elements.</param>
 public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
 {
     switch (state)
     {
         case DockingPropogatePageList.All:
         case DockingPropogatePageList.AutoHidden:
             for (int i = AutoHiddenGroupControl.Pages.Count - 1; i >= 0; i--)
             {
                 // Only add real pages and not just placeholders
                 KryptonPage page = AutoHiddenGroupControl.Pages[i];
                 if ((page != null) && !(page is KryptonStorePage))
                 {
                     // Remember the real page is inside a proxy!
                     KryptonAutoHiddenProxyPage proxyPage = (KryptonAutoHiddenProxyPage)page;
                     pages.Add(proxyPage.Page);
                 }
             }
             break;
     }
 }
Exemple #12
0
        /// <summary>
        /// Generate an implementation of the IDragPageNotify class that will be used to handle the drag/drop operation.
        /// </summary>
        /// <param name="screenPoint">Screen point of the mouse for the drag operation.</param>
        /// <param name="elementOffset">Offset from top left of element causing the drag.</param>
        /// <param name="c">Control that started the drag operation.</param>
        /// <param name="window">Reference to floating window element that should be dragged.</param>
        public virtual void DoDragDrop(Point screenPoint, Point elementOffset, Control c, KryptonDockingFloatingWindow window)
        {
            // Cannot drag a null reference
            if (window == null)
                throw new ArgumentNullException("window");

            // Create a list of all the visible pages inside the floating window
            KryptonPageCollection pages = new KryptonPageCollection();
            KryptonWorkspaceCell cell = window.FloatspaceElement.FloatspaceControl.FirstVisibleCell();
            while (cell != null)
            {
                foreach (KryptonPage page in cell.Pages)
                    if (!(page is KryptonStorePage) && page.LastVisibleSet)
                        pages.Add(page);

                cell = window.FloatspaceElement.FloatspaceControl.NextVisibleCell(cell);
            }

            // If it actually has any visible contents to be moved
            if (pages.Count > 0)
            {
                // Create docking specific drag manager for moving the pages around
                DockingDragManager dragManager = new DockingDragManager(this, null);
                dragManager.FloatingWindow = window.FloatingWindow;
                dragManager.FloatingWindowOffset = elementOffset;

                // Set the window location before it is shown otherwise we see a brief flash as it appears at the
                // existing location and then it moves to the correct location based on the screen mouse position
                dragManager.FloatingWindow.Location = new Point(screenPoint.X - elementOffset.X, screenPoint.Y - elementOffset.Y);

                // Add ourself as a source of drag targets and then begin the dragging process
                dragManager.DragTargetProviders.Add(new DockingDragTargetProvider(this, dragManager.FloatingWindow, pages));
                dragManager.DragStart(screenPoint, new PageDragEndData(this, pages));
            }
        }