本文整理汇总了C#中Xceed.Wpf.AvalonDock.Layout.LayoutRoot.Descendents方法的典型用法代码示例。如果您正苦于以下问题:C# LayoutRoot.Descendents方法的具体用法?C# LayoutRoot.Descendents怎么用?C# LayoutRoot.Descendents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xceed.Wpf.AvalonDock.Layout.LayoutRoot
的用法示例。
在下文中一共展示了LayoutRoot.Descendents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
//Determine panel name for given view model type
string destPaneName = string.Empty;
if (anchorableToShow.Content is JadeControls.Workspace.ViewModel.WorkspaceViewModel ||
anchorableToShow.Content is JadeControls.SymbolInspector.SymbolInspectorPaneViewModel ||
anchorableToShow.Content is JadeControls.CursorInspector.CursorInspectorPaneViewModel)
{
destPaneName = "LeftToolPanel";
}
else if (anchorableToShow.Content is JadeControls.OutputControl.ViewModel.OutputViewModel ||
anchorableToShow.Content is JadeControls.SearchResultsControl.ViewModel.SearchResultsPaneViewModel)
{
destPaneName = "LowerToolPanel";
}
else if (anchorableToShow.Content is JadeControls.ContextTool.ContextPaneViewModel)
{
destPaneName = "RightToolPanel";
}
else
{
return false;
}
//Find pane
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == destPaneName);
if (toolsPane != null)
{
//Add
toolsPane.Children.Add(anchorableToShow);
return true;
}
return false;
}
示例2: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
if (destinationContainer != null &&
destinationContainer.FindParent<LayoutFloatingWindow>() != null)
{
return false;
}
foreach (var viewModelPane in ViewModelPanes)
{
if (viewModelPane.Item1.IsInstanceOfType(anchorableToShow.Content))
{
var pane = layout
.Descendents()
.OfType<LayoutAnchorablePane>()
.SingleOrDefault(p => p.Name == viewModelPane.Item2);
if (pane != null)
{
pane.Children.Add(anchorableToShow);
if (viewModelPane.Item3)
{
anchorableToShow.ToggleAutoHide();
}
return true;
}
}
}
return false;
}
示例3: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
var tool = anchorableToShow.Content as ITool;
if (tool != null)
{
var preferredLocation = tool.PreferredLocation;
string paneName = GetPaneName(preferredLocation);
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
if (toolsPane == null)
{
switch (preferredLocation)
{
case PaneLocation.Left:
toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.Start);
break;
case PaneLocation.Right:
toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.End);
break;
case PaneLocation.Bottom:
toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.End);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
toolsPane.Children.Add(anchorableToShow);
return true;
}
return false;
}
示例4: CreateAnchorablePane
private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation,
string paneName, InsertPosition position)
{
var layoutPanels = layout.Descendents().OfType<LayoutPanel>().ToArray();
var parent = layoutPanels.FirstOrDefault(d => d != null && d.Orientation == orientation);
if (parent == null)
{
parent = layoutPanels.FirstOrDefault();
position = InsertPosition.Start;
}
var toolsPane = new LayoutAnchorablePane { Name = paneName };
if (parent != null)
{
if (position == InsertPosition.Start)
parent.InsertChildAt(0, toolsPane);
else
parent.Children.Add(toolsPane);
}
else
{
var layoutAnchorableFloatingWindow = new LayoutAnchorableFloatingWindow();
toolsPane.Parent = layoutAnchorableFloatingWindow;
}
return toolsPane;
}
示例5: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
//AD wants to add the anchorable into destinationContainer
//just for test provide a new anchorablepane
//if the pane is floating let the manager go ahead
LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;
if (destinationContainer != null &&
destinationContainer.FindParent<LayoutFloatingWindow>() != null)
return false;
if (anchorableToShow.Content is SectionBrowserViewModel)
{
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "SectionBrowserPane");
if (toolsPane != null)
{
// anchorableToShow.CanHide = false;
toolsPane.Children.Add(anchorableToShow);
return true;
}
}
if (anchorableToShow.Content is BlockGroupBrowserViewModel)
{
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "BlockGroupBrowserPane");
if (toolsPane != null)
{
// anchorableToShow.CanHide = false;
toolsPane.Children.Add(anchorableToShow);
return true;
}
}
if (anchorableToShow.Content is BlockOutputPreviewViewModel)
{
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "BlockOutputPreviewPane");
if (toolsPane != null)
{
toolsPane.Children.Add(anchorableToShow);
return true;
}
}
return false;
}
示例6: BeforeInsertAnchorable
//http://avalondock.codeplex.com/wikipage?title=AvalonDock%202.0%20Getting%20Start%20Guide&referringTitle=Documentation
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
if (anchorableToShow.Content is ITool)
{
var preferredLocation = ((ITool) anchorableToShow.Content).PreferredLocation;
string paneName = GetPaneName(preferredLocation);
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
if (toolsPane == null)
{
switch (preferredLocation)
{
case PaneLocation.Left:
{
//TODO: this should use two steps: first, try to add to existing "LayoutAnchorablePane" if not create layoutAnchorGroup like below
var layoutAnchorSide = layout.Descendents().OfType<LayoutAnchorSide>().First(side => side.Side == AnchorSide.Left);
var layoutAnchorGroup = new LayoutAnchorGroup();
layoutAnchorGroup.InsertChildAt(0, anchorableToShow);
layoutAnchorSide.InsertChildAt(0, layoutAnchorGroup);
anchorableToShow.AutoHideWidth = 200;
//var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
//toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
}
break;
case PaneLocation.Right:
{
var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
parent.Children.Add(toolsPane);
}
break;
case PaneLocation.Bottom:
{
var ds = layout.Descendents().ToList();
var items = layout.Descendents().OfType<LayoutPanel>().ToList();
var items2 = layout.Descendents().OfType<LayoutAnchorGroup>().ToList();
//var parent = items2.First();
var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(300, GridUnitType.Pixel) };
parent.Children.Add(toolsPane);
}
break;
default:
throw new ArgumentOutOfRangeException();
}
}
if(toolsPane != null)
toolsPane.Children.Add(anchorableToShow);
return true;
}
return false;
}
示例7: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
if (destinationContainer != null &&
destinationContainer.FindParent<LayoutFloatingWindow>() != null)
return false;
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");
if (toolsPane != null)
{
toolsPane.Children.Add(anchorableToShow);
return true;
}
return false;
}
示例8: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorable, ILayoutContainer destination)
{
LayoutAnchorablePane pane = destination as LayoutAnchorablePane;
if (destination != null && destination.FindParent<LayoutFloatingWindow>() != null)
{
return false;
}
LayoutAnchorablePane files = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "pnFiles");
if (files != null)
{
files.Children.Add(anchorable);
return true;
}
return false;
}
示例9: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
var myViewModel = anchorableToShow.Content as IToolWindow;
if (myViewModel != null)
{
var lap = layout.Descendents();
var pane = lap.OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == myViewModel.DefaultDockingPane);
if (pane != null)
{
pane.Children.Add(anchorableToShow);
return true;
}
}
return false;
}
示例10: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
//AD wants to add the anchorable into destinationContainer
//just for test provide a new anchorablepane
//if the pane is floating let the manager go ahead
LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;
if (destinationContainer != null &&
destinationContainer.FindParent<LayoutFloatingWindow>() != null)
return false;
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");
if (toolsPane != null)
{
toolsPane.Children.Add(anchorableToShow);
return true;
}
return false;
}
示例11: BeforeInsertContent
private bool BeforeInsertContent(LayoutRoot layout, LayoutContent anchorableToShow)
{
var viewModel = (ViewModelBase) anchorableToShow.Content;
var layoutContent =
layout.Descendents().OfType<LayoutContent>().FirstOrDefault(x => x.ContentId == viewModel.ContextId);
if (layoutContent == null)
return false;
layoutContent.Content = anchorableToShow.Content;
// Add layoutContent to it's previous container
var layoutContainer =
layoutContent.GetType()
.GetProperty("PreviousContainer", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(layoutContent, null) as ILayoutContainer;
if (layoutContainer is LayoutAnchorablePane)
(layoutContainer as LayoutAnchorablePane).Children.Add(layoutContent as LayoutAnchorable);
else if (layoutContainer is LayoutDocumentPane)
(layoutContainer as LayoutDocumentPane).Children.Add(layoutContent);
else
throw new NotSupportedException();
return true;
}
示例12: BeforeInsertAnchorable
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
ILayoutContainer destinationContainer)
{
var destPane = destinationContainer as LayoutAnchorablePane;
if (destinationContainer != null &&
destinationContainer.FindParent<LayoutFloatingWindow>() != null)
return false;
var content = anchorableToShow.Content;
bool result;
if (destinationContainer != null && destinationContainer.FindParent<LayoutFloatingWindow>() != null)
{
result = false;
}
else
{
var layoutAnchorablePane =
layout.Descendents()
.OfType<LayoutAnchorablePane>()
.FirstOrDefault(d => d.Name == "BottomPane");
var layoutAnchorablePane2 =
layout.Descendents()
.OfType<LayoutAnchorablePane>()
.FirstOrDefault(d => d.Name == "LeftPane");
var layoutAnchorablePane3 =
layout.Descendents()
.OfType<LayoutAnchorablePane>()
.FirstOrDefault(d => d.Name == "RightPane");
switch (((ToolViewModel) content).DefaultPane)
{
case DefaultToolPane.Left:
if (layoutAnchorablePane2 != null)
{
layoutAnchorablePane2.Children.Add(anchorableToShow);
result = true;
return result;
}
break;
case DefaultToolPane.Right:
if (layoutAnchorablePane3 != null)
{
layoutAnchorablePane3.Children.Add(anchorableToShow);
result = true;
return result;
}
break;
case DefaultToolPane.Bottom:
if (layoutAnchorablePane != null)
{
layoutAnchorablePane.Children.Add(anchorableToShow);
result = true;
return result;
}
break;
}
var layoutAnchorablePane4 =
layout.Descendents()
.OfType<LayoutAnchorablePane>()
.FirstOrDefault((LayoutAnchorablePane d) => d.Name == "ToolsPane");
if (layoutAnchorablePane4 != null)
{
layoutAnchorablePane4.Children.Add(anchorableToShow);
result = true;
}
else
{
result = false;
}
}
return result;
}
示例13: DetachDocumentsSource
void DetachDocumentsSource(LayoutRoot layout, IEnumerable documentsSource)
{
if (documentsSource == null)
return;
if (layout == null)
return;
var documentsToRemove = layout.Descendents().OfType<LayoutDocument>()
.Where(d => documentsSource.Contains(d.Content)).ToArray();
foreach (var documentToRemove in documentsToRemove)
{
(documentToRemove.Parent as ILayoutContainer).RemoveChild(
documentToRemove);
}
var documentsSourceAsNotifier = documentsSource as INotifyCollectionChanged;
if (documentsSourceAsNotifier != null)
documentsSourceAsNotifier.CollectionChanged -= new NotifyCollectionChangedEventHandler(documentsSourceElementsChanged);
}
示例14: DetachAnchorablesSource
void DetachAnchorablesSource(LayoutRoot layout, IEnumerable anchorablesSource)
{
if (anchorablesSource == null)
return;
if (layout == null)
return;
var anchorablesToRemove = layout.Descendents().OfType<LayoutAnchorable>()
.Where(d => anchorablesSource.Contains(d.Content)).ToArray();
foreach (var anchorableToRemove in anchorablesToRemove)
{
(anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
anchorableToRemove);
}
var anchorablesSourceAsNotifier = anchorablesSource as INotifyCollectionChanged;
if (anchorablesSourceAsNotifier != null)
anchorablesSourceAsNotifier.CollectionChanged -= new NotifyCollectionChangedEventHandler(anchorablesSourceElementsChanged);
}
示例15: AttachDocumentsSource
void AttachDocumentsSource(LayoutRoot layout, IEnumerable documentsSource)
{
if (documentsSource == null)
return;
if (layout == null)
return;
//if (layout.Descendents().OfType<LayoutDocument>().Any())
// throw new InvalidOperationException("Unable to set the DocumentsSource property if LayoutDocument objects are already present in the model");
var documentsImported = layout.Descendents().OfType<LayoutDocument>().Select(d => d.Content).ToArray();
var documents = documentsSource as IEnumerable;
var listOfDocumentsToImport = new List<object>(documents.OfType<object>());
foreach (var document in listOfDocumentsToImport.ToArray())
{
if (documentsImported.Contains(document))
listOfDocumentsToImport.Remove(document);
}
LayoutDocumentPane documentPane = null;
if (layout.LastFocusedDocument != null)
{
documentPane = layout.LastFocusedDocument.Parent as LayoutDocumentPane;
}
if (documentPane == null)
{
documentPane = layout.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault();
}
//if (documentPane == null)
// throw new InvalidOperationException("Layout must contains at least one LayoutDocumentPane in order to host documents");
_suspendLayoutItemCreation = true;
foreach (var documentContentToImport in listOfDocumentsToImport)
{
//documentPane.Children.Add(new LayoutDocument() { Content = documentToImport });
var documentToImport = new LayoutDocument()
{
Content = documentContentToImport
};
bool added = false;
if (LayoutUpdateStrategy != null)
{
added = LayoutUpdateStrategy.BeforeInsertDocument(layout, documentToImport, documentPane);
}
if (!added)
{
if (documentPane == null)
throw new InvalidOperationException("Layout must contains at least one LayoutDocumentPane in order to host documents");
documentPane.Children.Add(documentToImport);
added = true;
}
if (LayoutUpdateStrategy != null)
LayoutUpdateStrategy.AfterInsertDocument(layout, documentToImport);
CreateDocumentLayoutItem(documentToImport);
}
_suspendLayoutItemCreation = true;
var documentsSourceAsNotifier = documentsSource as INotifyCollectionChanged;
if (documentsSourceAsNotifier != null)
documentsSourceAsNotifier.CollectionChanged += new NotifyCollectionChangedEventHandler(documentsSourceElementsChanged);
}