本文整理汇总了C#中AvalonDock.DockableContent.SetStateToDock方法的典型用法代码示例。如果您正苦于以下问题:C# DockableContent.SetStateToDock方法的具体用法?C# DockableContent.SetStateToDock怎么用?C# DockableContent.SetStateToDock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvalonDock.DockableContent
的用法示例。
在下文中一共展示了DockableContent.SetStateToDock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
/// <summary>
/// Show a dockable content in its container with a desidered state
/// </summary>
/// <param name="content">Content to show</param>
/// <param name="desideredState">State desidered</param>
/// <param name="desideredAnchor">Border to which anchor the newly created container pane</param>
/// <remarks></remarks>
internal void Show(DockableContent content, DockableContentState desideredState, AnchorStyle desideredAnchor)
{
Debug.WriteLine(string.Format("Show Content={0}, desideredState={1}, desideredAnchor={2}", content.Name, desideredState, desideredAnchor));
#region Dockable content
if (desideredState == DockableContentState.Hidden)//??!!show hidden?
Hide(content);
if (content.State == DockableContentState.AutoHide)
{
//first redock the content
(content.ContainerPane as DockablePane).ToggleAutoHide();
//then show it as desidered
Show(content, desideredState, desideredAnchor);
}
else if (content.State == DockableContentState.Docked ||
content.State == DockableContentState.Document ||
content.State == DockableContentState.None)
{
if (content.ContainerPane == null ||
content.State == DockableContentState.None)
{
//Problem!? try to rescue
if (content.State == DockableContentState.Docked ||
content.State == DockableContentState.None)
{
//find the the pane which the desidered anchor style
//DockablePane foundPane = this.FindChildDockablePane(desideredAnchor != AnchorStyle.None ? desideredAnchor : AnchorStyle.Right);
//first search for a pane with other contents (avoiding empty panes which are containers for hidden contents)
ILinqToTree<DependencyObject> itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).IsDocked);
if (itemFound == null)//search for all panes (even empty)
itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).Items.Count == 0);
DockablePane foundPane = itemFound != null ? itemFound.Item as DockablePane : null;
if (foundPane != null)
{
content.SetStateToDock();
foundPane.Items.Add(content);
var containerPanel = foundPane.Parent as ResizingPanel;
if (containerPanel != null)
containerPanel.InvalidateMeasure();
}
else
{
//if no suitable pane was found create e new one on the fly
if (content.ContainerPane != null)
{
content.ContainerPane.RemoveContent(content);
}
DockablePane pane = new DockablePane();
pane.Items.Add(content);
Anchor(pane, desideredAnchor);
}
}
else
{
//add to main document pane
MainDocumentPane.Items.Add(content);
}
}
if (content.ContainerPane.GetManager() == null)
{
//disconnect the parent pane from previous panel
//((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
if (content.ContainerPane.Parent != null)
{
((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
}
Anchor(content.ContainerPane as DockablePane, desideredAnchor);
}
if (desideredState == DockableContentState.DockableWindow ||
desideredState == DockableContentState.FloatingWindow)
{
var floatingWindow = new DockableFloatingWindow(this);
floatingWindow.Content = content;
var mainWindow = Window.GetWindow(this);
if (mainWindow.IsVisible)
floatingWindow.Owner = mainWindow;
//floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
//if (content.Content != null)
//{
// floatingWindow.Width = Math.Min(((FrameworkElement)content.Content).ActualWidth, ResizingPanel.GetResizeWidth(content.ContainerPane));
// floatingWindow.Height = Math.Min(((FrameworkElement)content.Content).ActualHeight, ResizingPanel.GetResizeHeight(content.ContainerPane));
//.........这里部分代码省略.........