/// <summary> /// Changes the active document of the panel. If reaches the border, delegates the navigation request to the parent dock, if any. /// </summary> /// <param name="dockPanel">The panel itself</param> /// <param name="direction">Direction of the navigation</param> public static void NavigateDocument(this DockPanel dockPanel, Direction direction) { DockPanelDocumentInfo info = dockPanel.GetDocumentInfo(); if (info.SelectedDockContent != null) { var newIndex = info.SelectedDockContentIndex + (int)direction; if ((newIndex > -1) && (newIndex < info.DockContents.Length)) { // the desired new index belongs to the current dock panel, we can navigate internally. info.DockContents[newIndex].DockHandler.Activate(); return; } } }
/// <summary> /// Helper method to retrieve the array representation of the currently docked documents. /// </summary> /// <param name="dockPanel">The panel itself</param> /// <returns>DockPanelDocumentInfo about the docks and the selected index</returns> public static DockPanelDocumentInfo GetDocumentInfo(this DockPanel dockPanel) { DockPanelDocumentInfo re = new DockPanelDocumentInfo(); re.DockContents = new IDockContent[dockPanel.DocumentsCount]; re.SelectedDockContentIndex = -1; var i = 0; foreach (var idc in dockPanel.Documents) { if (idc == dockPanel.ActiveDocument) { re.SelectedDockContentIndex = i; re.SelectedDockContent = idc; } re.DockContents[i++] = idc; } return(re); }