첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형

▶ 컨텐트 ID로 LayoutContent 찾기 예제

using Xceed.Wpf.AvalonDock;
using Xceed.Wpf.AvalonDock.Layout;

...

private DockingManager dockingManager;

...

LayoutContent layoutContent = FindLayoutContent(this.dockingManager, "document1");

if(layoutContent != null)
{
    MessageBox.Show(layoutContent.ContentId + " found.");
}

 

728x90

 

▶ 컨텐트 ID로 LayoutContent 찾기

using Xceed.Wpf.AvalonDock;
using Xceed.Wpf.AvalonDock.Layout;

#region LayoutContent 찾기 - FindLayoutContent(layoutDocumentPane, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutDocumentPane">LayoutDocumentPane</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutDocumentPane layoutDocumentPane, string contentID)
{
    foreach(LayoutContent layoutContent in layoutDocumentPane.Children)
    {
        if(layoutContent.ContentId.Equals(contentID))
        {
            return layoutContent;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutDocumentPaneGroup, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutDocumentPaneGroup">LayoutDocumentPaneGroup</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutDocumentPaneGroup layoutDocumentPaneGroup, string contentID)
{
    LayoutContent layoutContent = null;

    foreach(ILayoutDocumentPane layoutDocumentPaneInterface in layoutDocumentPaneGroup.Children)
    {
        if(layoutDocumentPaneInterface is LayoutDocumentPane)
        {
            layoutContent = FindLayoutContent(layoutDocumentPaneInterface as LayoutDocumentPane, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }

        if(layoutDocumentPaneInterface is LayoutDocumentPaneGroup)
        {
            layoutContent = FindLayoutContent(layoutDocumentPaneInterface as LayoutDocumentPaneGroup, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutAnchorablePane, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutAnchorablePane">LayoutAnchorablePane</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutAnchorablePane layoutAnchorablePane, string contentID)
{
    foreach(LayoutAnchorable layoutAnchorable in layoutAnchorablePane.Children)
    {
        if(layoutAnchorable.ContentId.Equals(contentID))
        {
            return layoutAnchorable;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutAnchorablePaneGroup, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutAnchorablePaneGroup">LayoutAnchorablePaneGroup</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutAnchorablePaneGroup layoutAnchorablePaneGroup, string contentID)
{
    LayoutContent layoutContent = null;

    foreach(ILayoutAnchorablePane layoutAnchorablePaneInterface in layoutAnchorablePaneGroup.Children)
    {
        if(layoutAnchorablePaneInterface is LayoutAnchorablePane)
        {
            layoutContent = FindLayoutContent(layoutAnchorablePaneInterface as LayoutAnchorablePane, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }

        if(layoutAnchorablePaneInterface is LayoutAnchorablePaneGroup)
        {
            layoutContent = FindLayoutContent(layoutAnchorablePaneInterface as LayoutAnchorablePaneGroup, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutPanel, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutPanel">LayoutPanel</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutPanel layoutPanel, string contentID)
{
    LayoutContent layoutContent = null;

    foreach(ILayoutPanelElement layoutPanelElementInterface in layoutPanel.Children)
    {
        if(layoutPanelElementInterface is LayoutDocumentPane)
        {
            layoutContent = FindLayoutContent(layoutPanelElementInterface as LayoutDocumentPane, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }

        if(layoutPanelElementInterface is LayoutAnchorablePane)
        {
            layoutContent = FindLayoutContent(layoutPanelElementInterface as LayoutAnchorablePane, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }

        if(layoutPanelElementInterface is LayoutDocumentPaneGroup)
        {
            layoutContent = FindLayoutContent(layoutPanelElementInterface as LayoutDocumentPaneGroup, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }

        if(layoutPanelElementInterface is LayoutAnchorablePaneGroup)
        {
            layoutContent = FindLayoutContent(layoutPanelElementInterface as LayoutAnchorablePaneGroup, contentID);

            if(layoutContent != null)
            {
                return layoutContent;
            }

            continue;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutAnchorGroup, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutAnchorGroup">LayoutAnchorGroup</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutAnchorGroup layoutAnchorGroup, string contentID)
{
    foreach(LayoutAnchorable layoutAnchorable in layoutAnchorGroup.Children)
    {
        if(layoutAnchorable.ContentId.Equals(contentID))
        {
            return layoutAnchorable;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(layoutAnchorSide, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="layoutAnchorGroup">LayoutAnchorSide</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(LayoutAnchorSide layoutAnchorSide, string contentID)
{
    LayoutContent layoutContent = null;

    foreach(LayoutAnchorGroup layoutAnchorGroup in layoutAnchorSide.Children)
    {
        layoutContent = FindLayoutContent(layoutAnchorGroup, contentID);

        if(layoutContent != null)
        {
            return layoutContent;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(floatingWindows, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="floatingWindows">플로팅 윈도우 리스트</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(IEnumerable<LayoutFloatingWindowControl> floatingWindows, string contentID)
{
    LayoutContent layoutContent = null;

    foreach(LayoutFloatingWindowControl layoutFloatingWindowControl in floatingWindows)
    {
        if(layoutFloatingWindowControl.Model is LayoutDocumentFloatingWindow)
        {
            LayoutDocumentFloatingWindow layoutDocumentFloatingWindow = layoutFloatingWindowControl.Model as LayoutDocumentFloatingWindow;

            foreach(ILayoutElement layoutElementInterface in layoutDocumentFloatingWindow.Children)
            {
                if(layoutElementInterface is LayoutDocument)
                {
                    layoutContent = layoutElementInterface as LayoutDocument;

                    if(layoutContent.ContentId.Equals(contentID))
                    {
                        return layoutContent;
                    }

                    continue;
                }

                if(layoutElementInterface is LayoutDocumentPane)
                {
                    layoutContent = FindLayoutContent(layoutElementInterface as LayoutDocumentPane, contentID);

                    if(layoutContent != null)
                    {
                        return layoutContent;
                    }

                    continue;
                }

                if(layoutElementInterface is LayoutDocumentPaneGroup)
                {
                    layoutContent = FindLayoutContent(layoutElementInterface as LayoutDocumentPaneGroup, contentID);

                    if(layoutContent != null)
                    {
                        return layoutContent;
                    }

                    continue;
                }
            }

            continue;
        }

        if(layoutFloatingWindowControl.Model is LayoutAnchorableFloatingWindow)
        {
            LayoutAnchorableFloatingWindow layoutAnchorableFloatingWindow = layoutFloatingWindowControl.Model as LayoutAnchorableFloatingWindow;

            foreach(ILayoutElement layoutElementInterface in layoutAnchorableFloatingWindow.Children)
            {
                if(layoutElementInterface is LayoutAnchorable)
                {
                    layoutContent = layoutElementInterface as LayoutAnchorable;

                    if(layoutContent.ContentId.Equals(contentID))
                    {
                        return layoutContent;
                    }
                }

                if(layoutElementInterface is LayoutAnchorablePane)
                {
                    layoutContent = FindLayoutContent(layoutElementInterface as LayoutAnchorablePane, contentID);

                    if(layoutContent != null)
                    {
                        return layoutContent;
                    }

                    continue;
                }

                if(layoutElementInterface is LayoutAnchorablePaneGroup)
                {
                    layoutContent = FindLayoutContent(layoutElementInterface as LayoutAnchorablePaneGroup, contentID);

                    if(layoutContent != null)
                    {
                        return layoutContent;
                    }

                    continue;
                }
            }

            continue;
        }
    }

    return null;
}

#endregion

#region LayoutContent 찾기 - FindLayoutContent(dockingManager, contentID)

/// <summary>
/// LayoutContent 찾기
/// </summary>
/// <param name="dockingManager">DockingManager</param>
/// <param name="contentID">컨텐트 ID</param>
/// <returns>LayoutContent</returns>
public LayoutContent FindLayoutContent(DockingManager dockingManager, string contentID)
{
    LayoutContent layoutContent;

    layoutContent = FindLayoutContent(dockingManager.Layout.RootPanel, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    layoutContent = FindLayoutContent(dockingManager.Layout.LeftSide, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    layoutContent = FindLayoutContent(dockingManager.Layout.TopSide, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    layoutContent = FindLayoutContent(dockingManager.Layout.RightSide, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    layoutContent = FindLayoutContent(dockingManager.Layout.BottomSide, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    layoutContent = FindLayoutContent(dockingManager.FloatingWindows, contentID);

    if(layoutContent != null)
    {
        return layoutContent;
    }

    return null;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , , ,

댓글을 달아 주세요