/// <summary> /// Initialize a new instance of the PageDragEndData class. /// </summary> /// <param name="source">Source object for the drag data..</param> /// <param name="navigator">Navigator associated with pages.</param> /// <param name="pages">Collection of pages.</param> public PageDragEndData(object source, KryptonNavigator navigator, KryptonPageCollection pages) { _source = source; _navigator = navigator; _pages = pages; }
/// <summary> /// Initialize a new instance of the DragTargetNull class. /// </summary> /// <param name="manager">Reference to docking manager.</param> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="pages">Reference to collection of pages to drag.</param> public DockingDragTargetProvider(KryptonDockingManager manager, KryptonFloatingWindow floatingWindow, KryptonPageCollection pages) { _manager = manager; _floatingWindow = floatingWindow; _pages = pages; }
/// <summary> /// Initialize a new instance of the PageDragEndEventArgs class. /// </summary> /// <param name="dropped">True if a drop was performed; otherwise false.</param> /// <param name="pages">Array of event associated pages.</param> public PageDragEndEventArgs(bool dropped, KryptonPage[] pages) { _dropped = dropped; _pages = new KryptonPageCollection(); if (pages != null) _pages.AddRange(pages); }
/// <summary> /// Initialize a new instance of the KryptonPageDragEventArgs class. /// </summary> /// <param name="screenPoint">Screen point of the mouse.</param> /// <param name="pages">Array of event associated pages.</param> public PageDragEventArgs(Point screenPoint, KryptonPage[] pages) { _screenPoint = screenPoint; _pages = new KryptonPageCollection(); if (pages != null) _pages.AddRange(pages); }
/// <summary> /// Initialize a new instance of the PageDragCancelEventArgs class. /// </summary> /// <param name="screenPoint">Screen point of the mouse.</param> /// <param name="elementOffset">Offset from the top left of the element.</param> /// <param name="c">Control that started the drag operation.</param> /// <param name="pages">Collection of event associated pages.</param> public PageDragCancelEventArgs(Point screenPoint, Point elementOffset, Control c, KryptonPageCollection pages) { _screenPoint = screenPoint; _elementOffset = elementOffset; _c = c; _pages = pages; }
/// <summary> /// Initialize a new instance of the PageDragCancelEventArgs class. /// </summary> /// <param name="elementOffset">Offset from the top left of the element.</param> /// <param name="screenPoint">Screen point of the mouse.</param> /// <param name="c">Control that started the drag operation.</param> /// <param name="pages">Array of event associated pages.</param> public PageDragCancelEventArgs(Point screenPoint, Point elementOffset, Control c, KryptonPage[] pages) { _screenPoint = screenPoint; _elementOffset = elementOffset; _c = c; _pages = new KryptonPageCollection(); if (pages != null) _pages.AddRange(pages); }
/// <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> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Let base class perform loading of all docking elements base.LoadElementFromXml(xmlReader, pages); // Find the largest ordering value for all dockspace controls int largestOrder = -1; PropogateIntState(DockingPropogateIntState.DockspaceOrder, ref largestOrder); if (largestOrder > 0) { // Use upper limit to prevent crazy values causing long delays largestOrder = Math.Min(largestOrder, 30); // Request each dockspace in ordering sequence reposition itself for (int i = 0; i <= largestOrder; i++) PropogateAction(DockingPropogateAction.RepositionDockspace, i); } }
/// <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="pages">Set of pages requested to be dragged.</param> public virtual void DoDragDrop(Point screenPoint, Point elementOffset, Control c, KryptonPageCollection pages) { // Cannot drag a null reference if (pages == null) throw new ArgumentNullException("pages"); // Cannot drag an empty collection if (pages.Count == 0) throw new ArgumentOutOfRangeException("pages", "collection cannot be empry"); // Create docking specific drag manager for moving the pages around DockingDragManager dragManager = new DockingDragManager(this, c); dragManager.FloatingWindowOffset = elementOffset; bool atLeastOneFloating = false; KryptonPage firstFloatingPage = null; foreach (KryptonPage page in pages) { // You cannot drag a store page if (!(page is KryptonStorePage)) { // Cannot drag a null page reference if (page == null) throw new ArgumentNullException("pages collection contains a null page reference"); // Remember the first page that is allowed to be made floating if (!atLeastOneFloating && page.AreFlagsSet(KryptonPageFlags.DockingAllowFloating)) { // Use event to indicate the page is becoming floating and allow it to be cancelled CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(page.UniqueName, false); OnPageFloatingRequest(args); if (!args.Cancel) { firstFloatingPage = page; atLeastOneFloating = true; } } } } // If we have at least one page that is allowed to be floating if (atLeastOneFloating) { // Can we find an existing floating store page... KryptonDockingFloatspace floatspace = FindStorePageElement(DockingLocation.Floating, firstFloatingPage) as KryptonDockingFloatspace; if (floatspace != null) { KryptonDockingFloatingWindow floatingWindow = floatspace.GetParentType(typeof(KryptonDockingFloatingWindow)) as KryptonDockingFloatingWindow; if (floatingWindow != null) { // If the floating window is not currently visible... if (!floatingWindow.FloatingWindow.Visible) { using (DockingMultiUpdate update = new DockingMultiUpdate(this)) { //...then we can use it for dragging. We want the floating window to become visible and show just the set of pages // that are allowed to be floating from the set of pages passed into this function. As the window is not currently // visible it means all the contained pages are hidden and so we can make only the pages we are interested in visible // and it will have the appearance we need. dragManager.FloatingWindow = floatingWindow.FloatingWindow; // Convert the existing page loaction, if any, to store and restore it in this floating window KryptonPage[] firstFloatingPages = new KryptonPage[] { firstFloatingPage }; PropogateAction(DockingPropogateAction.StorePages, firstFloatingPages); floatingWindow.PropogateAction(DockingPropogateAction.RestorePages, firstFloatingPages); // Make a list of all pages that should be appended to the floating window List<string> appendUniqueNames = new List<string>(); List<KryptonPage> appendPages = new List<KryptonPage>(); foreach (KryptonPage page in pages) if (!(page is KryptonStorePage) && (page != firstFloatingPage) && page.AreFlagsSet(KryptonPageFlags.DockingAllowFloating)) { appendUniqueNames.Add(page.UniqueName); appendPages.Add(page); } // 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); // Convert the append pages to store pages and then append to the same cell as the just restore page above PropogateAction(DockingPropogateAction.StorePages, appendUniqueNames.ToArray()); KryptonWorkspaceCell cell = floatingWindow.CellForPage(firstFloatingPage.UniqueName); cell.Pages.AddRange(appendPages.ToArray()); } } } } // Do we need to create a new floating window? if (dragManager.FloatingWindow == null) { // Get access to a floating element that allows a new floating window to be created KryptonDockingFloating floating = FindDockingFloating(firstFloatingPage.UniqueName); if (floating != null) { KryptonDockingFloatingWindow floatingWindow = floating.AddFloatingWindow(); if (floatingWindow != null) { using (DockingMultiUpdate update = new DockingMultiUpdate(this)) { // This is the window that will be moved during the drag operation dragManager.FloatingWindow = floatingWindow.FloatingWindow; // Make a list of all pages that should be appended to the floating window List<string> appendUniqueNames = new List<string>(); List<KryptonPage> appendPages = new List<KryptonPage>(); foreach (KryptonPage page in pages) if (!(page is KryptonStorePage) && page.AreFlagsSet(KryptonPageFlags.DockingAllowFloating)) { appendUniqueNames.Add(page.UniqueName); appendPages.Add(page); } // 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); // Append the pages inside the new window, storing the current locations for later use PropogateAction(DockingPropogateAction.StorePages, appendUniqueNames.ToArray()); floatingWindow.FloatspaceElement.Append(appendPages.ToArray()); floatingWindow.FloatingWindow.Show(); } } } } } // Alow workspace controls to compact and update based on changes from above Application.DoEvents(); // 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)); }
/// <summary> /// Initialize a new instance of the KryptonPageDragEventArgs class. /// </summary> /// <param name="screenPoint">Screen point of the mouse.</param> /// <param name="pages">Collection of event associated pages.</param> public PageDragEventArgs(Point screenPoint, KryptonPageCollection pages) { _screenPoint = screenPoint; _pages = pages; }
/// <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; } }
/// <summary> /// Initialize a new instance of the PageDragEndData class. /// </summary> /// <param name="source">Source object for the drag data..</param> /// <param name="pages">Collection of pages.</param> public PageDragEndData(object source, KryptonPageCollection pages) : this(source, null, pages) { }
/// <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> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Let base class load the pages into the floatspace base.LoadElementFromXml(xmlReader, pages); // If loading did not create any pages then kill ourself as not needed if (FloatspaceControl.PageCount == 0) FloatspaceControl.Dispose(); }
/// <summary> /// Perform docking element specific actions based on the loading xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> protected override void LoadDockingElement(XmlReader xmlReader, KryptonPageCollection pages) { // Grab the requested size and location Point location = CommonHelper.StringToPoint(xmlReader.GetAttribute("L")); Size clientSize = CommonHelper.StringToSize(xmlReader.GetAttribute("S")); // Find the size of the floating window borders int hBorders = FloatingWindow.Width - FloatingWindow.ClientSize.Width; int vBorders = FloatingWindow.Height - FloatingWindow.ClientSize.Height; // Find the monitor that has the window Rectangle workingArea = Screen.GetWorkingArea(new Rectangle(location, clientSize)); // Limit client size to that which will fit inside the working area if (clientSize.Width > (workingArea.Width - hBorders)) clientSize.Width = workingArea.Width - hBorders; if (clientSize.Height > (workingArea.Height - vBorders)) clientSize.Height = workingArea.Height - vBorders; // Ensure floating window is positioned inside the working area if (location.X < workingArea.X) location.X = workingArea.X; else if ((location.X + clientSize.Width + hBorders) > workingArea.Right) location.X = workingArea.Right - clientSize.Width - hBorders; if (location.Y < workingArea.Y) location.Y = workingArea.Y; else if ((location.Y + clientSize.Height + vBorders) > workingArea.Bottom) location.Y = workingArea.Bottom - clientSize.Height - vBorders; // Update floating window with loaded size/position FloatingWindow.Location = location; FloatingWindow.ClientSize = clientSize; }
/// <summary> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Is it the expected xml element name? if (xmlReader.Name != XmlElementName) throw new ArgumentException("Element name '" + XmlElementName + "' was expected but found '" + xmlReader.Name + "' instead."); // Grab the element attributes string elementName = xmlReader.GetAttribute("N"); string elementOrder = xmlReader.GetAttribute("O"); string elementSize = xmlReader.GetAttribute("S"); // Check the name matches up if (elementName != Name) throw new ArgumentException("Attribute 'N' value '" + Name + "' was expected but found '" + elementName + "' instead."); // Check for the optional element order value if (!string.IsNullOrEmpty(elementOrder)) Order = int.Parse(elementOrder); else Order = -1; // Check for the optional element size value if (!string.IsNullOrEmpty(elementSize)) LoadSize = CommonHelper.StringToSize(elementSize); else LoadSize = Size.Empty; // Read to the expect child element if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); // This should always be a workspace definition if (xmlReader.Name != "KW") throw new ArgumentException("Element name 'KW' was expected but found '" + xmlReader.Name + "' instead."); // Let derived class perform element specific persistence LoadDockingElement(xmlReader, pages); // Read past this element to the end element if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); }
/// <summary> /// Initialize a new instance of the PagesEventArgs class. /// </summary> /// <param name="pages">Collection of pages.</param> public PagesEventArgs(KryptonPageCollection pages) { _pages = pages; }
private void CreatePageCollection() { // Create page collection and monitor changes _pages = new KryptonPageCollection(); _pages.Inserted += new TypedHandler<KryptonPage>(OnPageInserted); _pages.Removing += new TypedHandler<KryptonPage>(OnPageRemoving); _pages.Removed += new TypedHandler<KryptonPage>(OnPageRemoved); _pages.Clearing += new EventHandler(OnPageClearing); _pages.Cleared += new EventHandler(OnPageCleared); // Init fields used to notice a change in the page/page visible counts _cachePageCount = 0; _cachePageVisibleCount = 0; }
/// <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> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Let base class load the pages into the dockspace base.LoadElementFromXml(xmlReader, pages); // If a size was found during loading then apply it now if (!LoadSize.IsEmpty) { switch (DockspaceControl.Dock) { case DockStyle.Left: case DockStyle.Right: DockspaceControl.Width = LoadSize.Width; break; case DockStyle.Top: case DockStyle.Bottom: DockspaceControl.Height = LoadSize.Height; break; } } // Determine the correct visible state of the control if (DockspaceControl.CellVisibleCount == 0) { _cacheCellVisibleCount = 0; OnHasNoVisibleCells(EventArgs.Empty); } else { _cacheCellVisibleCount = 1; OnHasVisibleCells(EventArgs.Empty); } // If loading did not create any pages then kill ourself as not needed if (DockspaceControl.PageCount == 0) DockspaceControl.Dispose(); }
/// <summary> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Is it the expected xml element name? if (xmlReader.Name != XmlElementName) { throw new ArgumentException($@"Element name '{XmlElementName}' was expected but found '{xmlReader.Name}' instead."); } // Grab the element attributes string elementName = xmlReader.GetAttribute(@"N"); string elementCount = xmlReader.GetAttribute(@"C"); // Check the name matches up if (elementName != Name) { throw new ArgumentException($@"Attribute 'N' value '{Name}' was expected but found '{elementName}' instead."); } // Remove any existing pages in the navigator DockableNavigatorControl.Pages.Clear(); // If there are children then load them int count = int.Parse(elementCount); if (count > 0) { KryptonDockingManager manager = DockingManager; for (int i = 0; i < count; i++) { // Read past this element if (!xmlReader.Read()) { throw new ArgumentException(@"An element was expected but could not be read in."); } // 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 = CommonHelper.XmlAttributeToText(xmlReader, @"UN"); bool boolStore = CommonHelper.StringToBool(CommonHelper.XmlAttributeToText(xmlReader, @"S")); bool boolVisible = CommonHelper.StringToBool(CommonHelper.XmlAttributeToText(xmlReader, @"V", @"True")); // If the entry is for just a placeholder... KryptonPage page; if (boolStore) { // Recreate the requested store page and append page = new KryptonStorePage(uniqueName, _storeName); DockableNavigatorControl.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 && (args.Page != null)) { page = args.Page; } } if (page != null) { // Use the loaded visible state page.Visible = boolVisible; // Remove from provided collection as we can only add it once to the docking hierarchy pages.Remove(page); // Add into the navigator DockableNavigatorControl.Pages.Add(page); } } 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."); } } } // Read past this element to the end element 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> /// 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) { //!!!!betauser //hack. unhide the page to load it correctly. after loading the page will hided if (!CommonHelper.StringToBool(boolVisible)) { page.needHideAfterLoading = true; } page.Visible = true; //// 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> /// 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) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { // Create a new auto hidden group and then reload it KryptonDockingAutoHiddenGroup autoHiddenGroup = AppendAutoHiddenGroup(xmlReader.GetAttribute("N")); autoHiddenGroup.LoadElementFromXml(xmlReader, pages); } }
/// <summary> /// Initialize a new instance of the KryptonPageDragEventArgs class. /// </summary> /// <param name="screenPoint">Screen point of the mouse.</param> /// <param name="pages">Collection of event associated pages.</param> public PageDragEventArgs(Point screenPoint, KryptonPageCollection pages) { ScreenPoint = screenPoint; Pages = pages; }
/// <summary> /// Perform docking element specific actions based on the loading xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> protected override void LoadDockingElement(XmlReader xmlReader, KryptonPageCollection pages) { // Load layout information and use any matching pages in the provided collection SpaceControl.PageLoading += new EventHandler<PageLoadingEventArgs>(OnSpaceControlPageLoading); SpaceControl.RecreateLoadingPage += new EventHandler<RecreateLoadingPageEventArgs>(OnSpaceControlRecreateLoadingPage); SpaceControl.LoadLayoutFromXml(xmlReader, pages); SpaceControl.PageLoading -= new EventHandler<PageLoadingEventArgs>(OnSpaceControlPageLoading); SpaceControl.RecreateLoadingPage -= new EventHandler<RecreateLoadingPageEventArgs>(OnSpaceControlRecreateLoadingPage); }
/// <summary> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Let base class load the pages into the group base.LoadElementFromXml(xmlReader, pages); // Determine the correct visible state of the control if (AutoHiddenGroupControl.Pages.VisibleCount == 0) { _cacheCellVisibleCount = 0; AutoHiddenGroupControl.Visible = false; } else { _cacheCellVisibleCount = 1; AutoHiddenGroupControl.Visible = true; } // If loading did not create any pages then kill ourself as not needed if (AutoHiddenGroupControl.Pages.Count == 0) AutoHiddenGroupControl.Dispose(); }
/// <summary> /// Propagates an action request down the hierarchy of docking elements. /// </summary> /// <param name="action">Action that is requested to be performed.</param> /// <param name="uniqueNames">Array of unique names of the pages the action relates to.</param> public override void PropogateAction(DockingPropogateAction action, string[] uniqueNames) { KryptonPageCollection pageCollection = DockableNavigatorControl.Pages; switch (action) { case DockingPropogateAction.Loading: // Remove all pages including store pages pageCollection.Clear(); return; case DockingPropogateAction.ShowAllPages: case DockingPropogateAction.HideAllPages: case DockingPropogateAction.RemoveAllPages: case DockingPropogateAction.RemoveAndDisposeAllPages: // Ignore some global actions return; case DockingPropogateAction.StorePages: foreach (string uniqueName in uniqueNames) { // Swap pages that are not placeholders to become placeholders KryptonPage page = pageCollection[uniqueName]; if ((page != null) && !(page is KryptonStorePage)) { // Replace the existing page with a placeholder that has the same unique name KryptonStorePage placeholder = new KryptonStorePage(uniqueName, _storeName); pageCollection.Insert(pageCollection.IndexOf(page), placeholder); pageCollection.Remove(page); } } break; case DockingPropogateAction.StoreAllPages: // Process each page inside the cell for (int i = pageCollection.Count - 1; i >= 0; i--) { // Swap pages that are not placeholders to become placeholders KryptonPage page = pageCollection[i]; if ((page != null) && !(page is KryptonStorePage)) { // Replace the existing page with a placeholder that has the same unique name KryptonStorePage placeholder = new KryptonStorePage(page.UniqueName, _storeName); pageCollection.Insert(pageCollection.IndexOf(page), placeholder); pageCollection.Remove(page); } } break; case DockingPropogateAction.ClearFillerStoredPages: case DockingPropogateAction.ClearStoredPages: foreach (string uniqueName in uniqueNames) { // Only remove a matching unique name if it is a placeholder page KryptonPage removePage = pageCollection[uniqueName]; if (removePage is KryptonStorePage) { pageCollection.Remove(removePage); } } break; case DockingPropogateAction.ClearAllStoredPages: { // Process each page inside the cell for (int i = pageCollection.Count - 1; i >= 0; i--) { // Remove all placeholders KryptonPage page = pageCollection[i]; if (page is KryptonStorePage) { pageCollection.Remove(page); } } } break; case DockingPropogateAction.DebugOutput: Console.WriteLine(GetType().ToString()); DockableNavigatorControl.DebugOutput(); break; } // Let base class perform standard processing base.PropogateAction(action, uniqueNames); }
/// <summary> /// Perform docking element specific actions based on the loading xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> protected virtual void LoadDockingElement(XmlReader xmlReader, KryptonPageCollection pages) { }
/// <summary> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public virtual void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Is it the expected xml element name? if (xmlReader.Name != XmlElementName) throw new ArgumentException("Element name '" + XmlElementName + "' was expected but found '" + xmlReader.Name + "' instead."); // Grab the element attributes string elementName = xmlReader.GetAttribute("N"); string elementCount = xmlReader.GetAttribute("C"); // Check the name matches up if (elementName != Name) throw new ArgumentException("Attribute 'N' value '" + Name + "' was expected but found '" + elementName + "' instead."); // Let derived class perform element specific persistence LoadDockingElement(xmlReader, pages); // If there are children then move over them int count = int.Parse(elementCount); if (count > 0) { for (int i = 0; i < count; i++) { // Read to the next element if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); // Find a child docking element with the matching name IDockingElement child = this[xmlReader.GetAttribute("N")]; // Let derived class perform child element specific processing LoadChildDockingElement(xmlReader, pages, child); } } // Read past this element to the end element 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 virtual void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages) { // Propogate the action request to all the child elements // (use reverse order so if element removes itself we still have a valid loop) for (int i = Count - 1; i >= 0; i--) this[i].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 virtual void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { string nodeName = xmlReader.Name; do { // Read past this element if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); // Finished when we hit the end element matching the incoming one if ((xmlReader.NodeType == XmlNodeType.EndElement) && (xmlReader.Name == nodeName)) break; } while (true); } }
/// <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) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { // Create a new floating window and then reload it KryptonDockingFloatingWindow floatingWindow = AddFloatingWindow(xmlReader.GetAttribute("N")); floatingWindow.LoadElementFromXml(xmlReader, pages); } }
private KryptonPage[] ArrayFromCollection(KryptonPageCollection pages) { // Convert collection to array KryptonPage[] array = new KryptonPage[pages.Count]; for (int i = 0; i < array.Length; i++) array[i] = pages[i]; return array; }