/// <summary> /// Propogates a workspace cell list request down the hierarchy of docking elements. /// </summary> /// <param name="state">Request that should result in the cells collection being modified.</param> /// <param name="cells">Cells collection for modification by the docking elements.</param> public override void PropogateCellList(DockingPropogateCellList state, KryptonWorkspaceCellList cells) { switch (state) { case DockingPropogateCellList.All: case DockingPropogateCellList.Docked: case DockingPropogateCellList.Floating: case DockingPropogateCellList.Workspace: { // If the request relevant to this space control? if ((state == DockingPropogateCellList.All) || ((state == DockingPropogateCellList.Docked) && (ClearStoreAction == DockingPropogateAction.ClearDockedStoredPages)) || ((state == DockingPropogateCellList.Floating) && (ClearStoreAction == DockingPropogateAction.ClearFloatingStoredPages)) || ((state == DockingPropogateCellList.Workspace) && (ClearStoreAction == DockingPropogateAction.ClearFillerStoredPages))) { // Find each cell in turn KryptonWorkspaceCell cell = SpaceControl.FirstCell(); while (cell != null) { cells.Add(cell); cell = SpaceControl.NextCell(cell); } } } break; } // Let base class perform standard processing base.PropogateCellList(state, cells); }
/// <summary> /// Add a KryptonPage array into an existing cell. /// </summary> /// <param name="cell">Reference to existing workspace cell.</param> /// <param name="pages">Array of KryptonPage instances to be added.</param> public void CellAppend(KryptonWorkspaceCell cell, KryptonPage[] pages) { // Demand that pages are not already present DemandPagesNotBePresent(pages); // Cannot insert to a null cell if (cell == null) { throw new ArgumentNullException(nameof(cell)); } // Check that we actually contain the provided workspace cell KryptonWorkspaceCell checkCell = SpaceControl.FirstCell(); while (checkCell != null) { if (checkCell == cell) { break; } checkCell = SpaceControl.NextCell(checkCell); } if (cell != checkCell) { throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace"); } // Append all the pages to end of the cell pages collection if (pages != null) { cell.Pages.AddRange(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> /// Saves docking configuration information using a provider xml writer. /// </summary> /// <param name="xmlWriter">Xml writer object.</param> public override void SaveElementToXml(XmlWriter xmlWriter) { // Output workspace based docking element xmlWriter.WriteStartElement(XmlElementName); xmlWriter.WriteAttributeString("N", Name); xmlWriter.WriteAttributeString("O", Order.ToString()); xmlWriter.WriteAttributeString("S", CommonHelper.SizeToString(SpaceControl.Size)); // Output an xml for the contained workspace SpaceControl.PageSaving += OnSpaceControlPageSaving; SpaceControl.SaveLayoutToXml(xmlWriter); SpaceControl.PageSaving -= OnSpaceControlPageSaving; // Terminate the workspace element xmlWriter.WriteFullEndElement(); }
void Awake() { obj = this; xSize += 2; ySize += 2; //Configure action space for (int x = 0; x < xSize; ++x) { currentSpace.Add(new List<WorldObject>()); futureSpace.Add(new List<WorldObject>()); for (int y = 0; y < ySize; ++y) { currentSpace[x].Add (null); futureSpace[x].Add (null); } } }
/// <summary> /// Propogates a page request down the hierarchy of docking elements. /// </summary> /// <param name="state">Request that should result in a page reference if found.</param> /// <param name="uniqueName">Unique name of the page the request relates to.</param> /// <returns>Reference to page that matches the request; otherwise null.</returns> public override KryptonPage PropogatePageState(DockingPropogatePageState state, string uniqueName) { switch (state) { case DockingPropogatePageState.PageForUniqueName: { // If we have the requested name page and it is not a placeholder then we have found it KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if ((page != null) && !(page is KryptonStorePage)) { return(page); } } break; } // Let base class perform standard processing return(base.PropogatePageState(state, uniqueName)); }
/// <summary> /// Propogates a boolean state request down the hierarchy of docking elements. /// </summary> /// <param name="state">Boolean state that is requested to be recovered.</param> /// <param name="uniqueName">Unique name of the page the request relates to.</param> /// <returns>True/False if state is known; otherwise null indicating no information available.</returns> public override bool?PropogateBoolState(DockingPropogateBoolState state, string uniqueName) { switch (state) { case DockingPropogateBoolState.ContainsPage: { // Return the definitive answer 'true' if the control contains the named page KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if ((page != null) && !(page is KryptonStorePage)) { return(true); } } break; case DockingPropogateBoolState.ContainsStorePage: { // Return definitive answer 'true' if the group controls contains a store page for the unique name. KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if (page is KryptonStorePage) { return(true); } } break; case DockingPropogateBoolState.IsPageShowing: { // If we have the requested page then return the visible state of the page KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if ((page != null) && !(page is KryptonStorePage)) { return(page.LastVisibleSet); } } break; } // Let base class perform standard processing return(base.PropogateBoolState(state, uniqueName)); }
/// <summary> /// Return an array of the visible pages that are inside the cell that contains the provided unique name. /// </summary> /// <param name="uniqueName">Unique name of page that is inside the target cell.</param> /// <returns>Array of page references.</returns> public KryptonPage[] CellVisiblePages(string uniqueName) { List <KryptonPage> pages = new List <KryptonPage>(); // Grab the cell that contains the provided unique name KryptonWorkspaceCell cell = SpaceControl.CellForUniqueName(uniqueName); if (cell != null) { // Only interested in visible pages that are not placeholders foreach (KryptonPage page in cell.Pages) { if (!(page is KryptonStorePage) && page.LastVisibleSet) { pages.Add(page); } } } return(pages.ToArray()); }
/// <summary> /// Propogates an action request down the hierarchy of docking elements. /// </summary> /// <param name="action">Action that is requested to be performed.</param> /// <param name="pages">Array of pages the action relates to.</param> public override void PropogateAction(DockingPropogateAction action, KryptonPage[] pages) { switch (action) { case DockingPropogateAction.RestorePages: foreach (KryptonPage page in pages) { // Swap pages that are placeholders for the actual pages KryptonPage storePage = SpaceControl.PageForUniqueName(page.UniqueName); if (storePage is KryptonStorePage) { KryptonWorkspaceCell cell = SpaceControl.CellForPage(storePage); cell.Pages.Insert(cell.Pages.IndexOf(storePage), page); } } break; } // Let base class perform standard processing base.PropogateAction(action, 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> /// Add a KryptonPage array into an existing cell starting at the provided index. /// </summary> /// <param name="cell">Reference to existing workspace cell.</param> /// <param name="index">Index for inserting new pages.</param> /// <param name="pages">Array of KryptonPage instances to be added.</param> public void CellInsert(KryptonWorkspaceCell cell, int index, KryptonPage[] pages) { // Demand that pages are not already present DemandPagesNotBePresent(pages); // Cannot insert to a null cell if (cell == null) { throw new ArgumentNullException(nameof(cell)); } // Check that we actually contain the provided workspace cell KryptonWorkspaceCell checkCell = SpaceControl.FirstCell(); while (checkCell != null) { if (checkCell == cell) { break; } checkCell = SpaceControl.NextCell(checkCell); } if (cell != checkCell) { throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace"); } if (pages != null) { ObserveAutoHiddenSlideSize(pages); // Insert all the pages in sequence starting at the provided index foreach (KryptonPage page in pages) { cell.Pages.Insert(index++, page); } } }
/// <summary> /// Return the workspace cell that contains the named page. /// </summary> /// <param name="uniqueName">Unique name for search.</param> /// <returns>Reference to KryptonWorkspaceCell if match found; otherwise null.</returns> public KryptonWorkspaceCell CellForPage(string uniqueName) { return(SpaceControl.CellForUniqueName(uniqueName)); }
/// <summary> /// Propogates 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) { switch (action) { case DockingPropogateAction.Loading: // Force layout so that the correct number of pages is recognized SpaceControl.PerformLayout(); // Remove all the pages including store pages SpaceControl.ClearAllPages(); // Force layout so that the control will kill itself SpaceControl.PerformLayout(); break; case DockingPropogateAction.ShowPages: case DockingPropogateAction.HidePages: { bool newVisible = (action == DockingPropogateAction.ShowPages); foreach (string uniqueName in uniqueNames) { // Update visible state of pages that are not placeholders KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if ((page != null) && !(page is KryptonStorePage)) { page.Visible = newVisible; } } } break; case DockingPropogateAction.ShowAllPages: SpaceControl.ShowAllPages(typeof(KryptonStorePage)); break; case DockingPropogateAction.HideAllPages: SpaceControl.HideAllPages(typeof(KryptonStorePage)); break; case DockingPropogateAction.RemovePages: case DockingPropogateAction.RemoveAndDisposePages: foreach (string uniqueName in uniqueNames) { // If the named page exists and is not placeholder then remove it KryptonPage removePage = SpaceControl.PageForUniqueName(uniqueName); if ((removePage != null) && !(removePage is KryptonStorePage)) { // Find the cell that contains the target so we can remove the page KryptonWorkspaceCell cell = SpaceControl.CellForPage(removePage); if (cell != null) { cell.Pages.Remove(removePage); if (action == DockingPropogateAction.RemoveAndDisposePages) { removePage.Dispose(); } } } } break; case DockingPropogateAction.RemoveAllPages: case DockingPropogateAction.RemoveAndDisposeAllPages: { // 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 remove the actual page and not placeholders KryptonPage page = cell.Pages[i]; if ((page != null) && !(page is KryptonStorePage)) { cell.Pages.RemoveAt(i); if (action == DockingPropogateAction.RemoveAndDisposeAllPages) { page.Dispose(); } } } cell = SpaceControl.NextCell(cell); } // Force layout so that the control will kill itself SpaceControl.PerformLayout(); } break; case DockingPropogateAction.StorePages: foreach (string uniqueName in uniqueNames) { // Swap pages that are not placeholders to become placeholders KryptonPage page = SpaceControl.PageForUniqueName(uniqueName); if ((page != null) && !(page is KryptonStorePage)) { // Replace the existing page with a placeholder that has the same unique name KryptonWorkspaceCell cell = SpaceControl.CellForPage(page); KryptonStorePage placeholder = new KryptonStorePage(uniqueName, _storeName); cell.Pages.Insert(cell.Pages.IndexOf(page), placeholder); cell.Pages.Remove(page); } } break; case DockingPropogateAction.StoreAllPages: { // 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--) { // Swap pages that are not placeholders to become placeholders KryptonPage page = cell.Pages[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); cell.Pages.Insert(cell.Pages.IndexOf(page), placeholder); cell.Pages.Remove(page); } } cell = SpaceControl.NextCell(cell); } } break; case DockingPropogateAction.ClearFillerStoredPages: case DockingPropogateAction.ClearFloatingStoredPages: case DockingPropogateAction.ClearDockedStoredPages: case DockingPropogateAction.ClearStoredPages: // Only process an attempt to clear all pages or those related to this docking location if ((action == DockingPropogateAction.ClearStoredPages) || (action == ClearStoreAction)) { foreach (string uniqueName in uniqueNames) { // Only remove a matching unique name if it is a placeholder page KryptonPage removePage = SpaceControl.PageForUniqueName(uniqueName); if (removePage is KryptonStorePage) { // Check if the page is one marked to be ignored in this operation if (removePage != IgnoreStorePage) { // Find the cell that contains the target so we can remove the page KryptonWorkspaceCell cell = SpaceControl.CellForPage(removePage); cell?.Pages.Remove(removePage); } } } } break; case DockingPropogateAction.ClearAllStoredPages: { // 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--) { // Remove all placeholders KryptonPage page = cell.Pages[i]; if (page is KryptonStorePage) { cell.Pages.Remove(page); } } cell = SpaceControl.NextCell(cell); } } break; case DockingPropogateAction.StringChanged: UpdateStrings(); break; case DockingPropogateAction.DebugOutput: Console.WriteLine(SpaceControl.ToString()); SpaceControl.DebugOutput(); break; } // Let base class perform standard processing base.PropogateAction(action, uniqueNames); }