本文整理汇总了C#中AvalonDock.DocumentPane类的典型用法代码示例。如果您正苦于以下问题:C# DocumentPane类的具体用法?C# DocumentPane怎么用?C# DocumentPane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentPane类属于AvalonDock命名空间,在下文中一共展示了DocumentPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitialized
protected override void OnInitialized(EventArgs e)
{
//setup window size
_floatingWindow.Width = _documentToTransfer.ContainerPane.ActualWidth;
_floatingWindow.Height = _documentToTransfer.ContainerPane.ActualHeight;
//save current content position in container pane
_previousPane = _documentToTransfer.ContainerPane as DocumentPane;
_arrayIndexPreviousPane = _previousPane.Items.IndexOf(_documentToTransfer);
SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty));
SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty));
//Style = _previousPane.Style;
AttachStyleFromPane(_previousPane);
//remove content from container pane
_previousPane.RemoveContent(_arrayIndexPreviousPane);
//add content to my temporary pane
Items.Add(_documentToTransfer);
_documentToTransfer.SetIsFloating(true);
base.OnInitialized(e);
}
示例2: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.DocumentManager = ((AvalonDock.DocumentPane)(target));
return;
}
this._contentLoaded = true;
}
示例3: AdapterAssociatesDocumentPaneWithRegion
public void AdapterAssociatesDocumentPaneWithRegion()
{
var documentPane = new DocumentPane();
IRegionAdapter adapter = new DocumentPaneRegionAdapter(null);
IRegion region = adapter.Initialize(documentPane, "Region1");
Assert.IsNotNull(region);
}
示例4: AttachStyleFromPane
void AttachStyleFromPane(DocumentPane copyFromPane)
{
if (copyFromPane == null)
return;
//Binding bnd = new Binding("Style");
//bnd.Source = copyFromPane;
//bnd.Mode = BindingMode.OneWay;
//SetBinding(StyleProperty, bnd);
}
示例5: OnInitialized
protected override void OnInitialized(EventArgs e)
{
_previousPane = _documentToTransfer.ContainerPane as DocumentPane;
if (_documentToTransfer != null && _documentToTransfer.FloatingWindowSize.IsEmpty)
{
if (_previousPane != null)
_documentToTransfer.FloatingWindowSize = new Size(_previousPane.ActualWidth, _previousPane.ActualHeight);
else
_documentToTransfer.FloatingWindowSize = new Size(400.0, 400.0);
}
if (_documentToTransfer != null && !_documentToTransfer.FloatingWindowSize.IsEmpty)
{
_floatingWindow.Width = _documentToTransfer.FloatingWindowSize.Width;
_floatingWindow.Height = _documentToTransfer.FloatingWindowSize.Height;
}
if (_previousPane != null)
{
//setup window size
_floatingWindow.Width = _documentToTransfer.ContainerPane.ActualWidth;
_floatingWindow.Height = _documentToTransfer.ContainerPane.ActualHeight;
//save current content position in container pane
_arrayIndexPreviousPane = _previousPane.Items.IndexOf(_documentToTransfer);
SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty));
SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty));
//Style = _previousPane.Style;
AttachStyleFromPane(_previousPane);
//remove content from container pane
_previousPane.RemoveContent(_arrayIndexPreviousPane);
}
//add content to my temporary pane
Items.Add(_documentToTransfer);
_documentToTransfer.SetIsFloating(true);
LayoutTransform = (MatrixTransform)_documentToTransfer.TansformToAncestor();
base.OnInitialized(e);
}
示例6: ClonePane
public override Pane ClonePane()
{
DocumentPane paneToAnchor = new DocumentPane();
ResizingPanel.SetEffectiveSize(paneToAnchor, new Size(Width, Height));
//transfer contents from hosted pane in the floating window and
//the new created dockable pane
while (HostedPane.Items.Count > 0)
{
paneToAnchor.Items.Add(
HostedPane.RemoveContent(0));
}
paneToAnchor.ApplyTemplate();
return paneToAnchor;
}
示例7: RestoreLayout
/// <summary>
/// Restore from xml a resizing panel or a documentpane
/// </summary>
/// <param name="mainElement"></param>
/// <param name="actualContents"></param>
/// <returns></returns>
object RestoreLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments, ref DocumentPane mainDocumentPane)
{
if (mainElement == null)
throw new ArgumentNullException("mainElement");
if (mainElement.Name == "ResizingPanel" ||
mainElement.Name == "DocumentPaneResizingPanel")
{
return RestoreResizingPanel(mainElement, actualContents, actualDocuments, ref mainDocumentPane);
}
else if (mainElement.Name == "DocumentPane")
{
mainDocumentPane = RestoreDocumentPaneLayout(mainElement, actualContents, actualDocuments);
return mainDocumentPane;
}
throw new InvalidOperationException(string.Format("Unable to deserialize '{0}' element", mainElement.Name));
}
示例8: RestoreDocumentPaneLayout
///// <summary>
///// Restore from xml a document pane
///// </summary>
///// <param name="childElement"></param>
///// <param name="mainExistingDocumentPane"></param>
///// <param name="existingDocumentPanel"></param>
///// <param name="dockableContents"></param>
//void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents)
//{
// mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel);
// if (mainExistingDocumentPane != null)
// {
// existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel();
// }
// else
// {
// existingDocumentPanel = null;
// }
// if (existingDocumentPanel != null)
// {
// if (existingDocumentPanel.Parent is ResizingPanel)
// {
// ((ResizingPanel)existingDocumentPanel.Parent).RemoveChild(existingDocumentPanel);
// }
// else if (existingDocumentPanel.Parent is DockingManager)
// {
// ((DockingManager)existingDocumentPanel.Parent).Content = null;
// }
// }
// else if (mainExistingDocumentPane != null)
// {
// if (mainExistingDocumentPane.Parent is ResizingPanel)
// {
// ((ResizingPanel)mainExistingDocumentPane.Parent).RemoveChild(mainExistingDocumentPane);
// }
// else if (mainExistingDocumentPane.Parent is DockingManager)
// {
// ((DockingManager)mainExistingDocumentPane.Parent).Content = null;
// }
// }
// foreach (XmlElement contentElement in childElement.ChildNodes)
// {
// if (contentElement.HasAttribute("Name"))
// {
// DockableContent foundContent = null;
// string contentName = contentElement.GetAttribute("Name");
// foreach (DockableContent content in dockableContents)
// {
// if (content.Name == contentName)
// {
// foundContent = content;
// break;
// }
// }
// if (foundContent == null &&
// DeserializationCallback != null)
// {
// DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
// DeserializationCallback(this, e);
// foundContent = e.Content as DockableContent;
// }
// if (foundContent != null)
// {
// DetachContentFromDockingManager(foundContent);
// mainExistingDocumentPane.Items.Add(foundContent);
// foundContent.SetStateToDocument();
// //call custom layout persistence method
// foundContent.RestoreLayout(contentElement);
// }
// }
// }
//}
DocumentPane RestoreDocumentPaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments)
{
var documentPane = new DocumentPane();
if (mainElement.HasAttribute("ResizeWidth"))
ResizingPanel.SetResizeWidth(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth")));
if (mainElement.HasAttribute("ResizeHeight"))
ResizingPanel.SetResizeHeight(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight")));
if (mainElement.HasAttribute("EffectiveSize"))
ResizingPanel.SetEffectiveSize(documentPane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize")));
foreach (XmlElement contentElement in mainElement.ChildNodes)
{
if (contentElement.Name == "DockableContent" &&
contentElement.HasAttribute("Name"))
{
DockableContent foundContent = null;
string contentName = contentElement.GetAttribute("Name");
foundContent = actualContents.FirstOrDefault(c => c.Name == contentName);
if (foundContent == null &&
DeserializationCallback != null)
{
DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
DeserializationCallback(this, e);
foundContent = e.Content as DockableContent;
//.........这里部分代码省略.........
示例9: EnsureContentNotEmpty
/// <summary>
/// This method ensure that content of this <see cref="DockingManager"/> is not empty
/// </summary>
void EnsureContentNotEmpty()
{
if (RestoringLayout)
return;
if (Content == null)
{
Content = new DocumentPane();
RefreshContents();
}
}
示例10: EnsurePanePositionIsValid
internal void EnsurePanePositionIsValid(DocumentPane pane)
{
if (pane == MainDocumentPane)
return;
//A document pane must be at maindocument pane level or deeper
if (MainDocumentPane.Parent == this)
{
throw new InvalidOperationException("A document pane can't be positioned at this level!");
}
}
示例11: DropInto
internal void DropInto(DockablePane paneDragged, DocumentPane paneToDropInto)
{
//if (paneToDropInto != MainDocumentPane)
// paneToDropInto = MainDocumentPane;
//transfer contents of dragged pane (contained in a FloatingWindow)
//to the pane which user select, taking care of setting contents state
//to Dock (using Dock() method of class DockablePane).
while (paneDragged.Items.Count > 0)
{
var contentToTransfer = paneDragged.RemoveContent(0);
paneToDropInto.Items.Add(contentToTransfer);
var dockContentToTransfer = contentToTransfer as DockableContent;
if (dockContentToTransfer != null)
dockContentToTransfer.SetStateToDocument();
contentToTransfer.Activate();
}
//paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1;
//paneToDropInto.Focus();
}
示例12: NewVerticalTabGroup
void NewVerticalTabGroup()
{
ManagedContent activeContent = SelectedItem as ManagedContent;
DocumentPane newContainerPane = new DocumentPane();
int indexOfDocumentInItsContainer = activeContent.ContainerPane.Items.IndexOf(activeContent);
activeContent.ContainerPane.RemoveContent(indexOfDocumentInItsContainer);
newContainerPane.Items.Add(activeContent);
GetManager().Anchor(newContainerPane, this, AnchorStyle.Right);
}
示例13: SetVisibilityOfMenuItems
private void SetVisibilityOfMenuItems(DocumentPane dp)
{
if (dp.Visibility == Visibility.Visible) // the value is set in ConvertBack of AvalonDockVisibilityConverter!!!
{
dp.Visibility = System.Windows.Visibility.Visible;
}
else
{
dp.Visibility = System.Windows.Visibility.Hidden;
}
foreach (DocumentContent dc in dockingManager.Documents)
{
if (dp.Visibility == Visibility.Visible)
{
dc.Show();
}
else
{
dc.Hide();
}
}
}
示例14: Anchor
/// <summary>
/// Anchor a dockable pane (<see cref="DockablePane"/>) to a border of a document pane
/// </summary>
/// <param name="paneToAnchor">Pane to anchor</param>
/// <param name="relativePane">Pane relative</param>
/// <param name="anchor"></param>
public void Anchor(DockablePane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor)
{
//ensure that content property is not empty
EnsureContentNotEmpty();
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//get a reference to the resizingpanel container of relativePane
ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel;
DocumentPaneResizingPanel relativeDocumentPaneContainer = relativePane.GetParentDocumentPaneResizingPanel();
Orientation requestedOrientation =
(anchor == AnchorStyle.Bottom || anchor == AnchorStyle.Top) ? Orientation.Vertical : Orientation.Horizontal;
if (relativePaneContainer == null)
{
Debug.Assert(relativePane.Parent == this);
this.Content = null;
relativeDocumentPaneContainer = new DocumentPaneResizingPanel();
relativeDocumentPaneContainer.Children.Add(relativePane);
relativePaneContainer = new ResizingPanel();
relativePaneContainer.Orientation = requestedOrientation;
this.Content = relativePaneContainer;
relativePaneContainer.Children.Add(relativeDocumentPaneContainer);
}
if (relativeDocumentPaneContainer == null)
{
relativeDocumentPaneContainer = new DocumentPaneResizingPanel();
relativeDocumentPaneContainer.Orientation = requestedOrientation;
int indexOfPaneToReplace = relativePaneContainer.Children.IndexOf(relativePane);
relativePaneContainer.Children.RemoveAt(indexOfPaneToReplace);
relativeDocumentPaneContainer.Children.Add(relativePane);
relativePaneContainer.Children.Insert(indexOfPaneToReplace, relativeDocumentPaneContainer);
}
relativePaneContainer = LogicalTreeHelper.GetParent(relativeDocumentPaneContainer) as ResizingPanel;
//Debug.Assert(relativePaneContainer is DocumentPaneResizingPanel, "By now we can't have a pane without a resizing panel containing it");
if (relativePaneContainer == null)
{
Debug.Assert(relativeDocumentPaneContainer.Parent == this);
this.Content = null;
relativePaneContainer = new ResizingPanel();
relativePaneContainer.Orientation = requestedOrientation;
this.Content = relativePaneContainer;
relativePaneContainer.Children.Add(relativeDocumentPaneContainer);
}
#region Create and setup container panel
if (relativePaneContainer != null)
{
//check if orientation is right
if (relativePaneContainer.Orientation != requestedOrientation)
{
//if the existing panel is not oriented as we want
//create a new one
ResizingPanel newPanel = new ResizingPanel();
newPanel.Orientation = requestedOrientation;
if (newPanel.Orientation == Orientation.Horizontal)
ResizingPanel.SetResizeHeight(newPanel, ResizingPanel.GetResizeHeight(relativePane));
else
ResizingPanel.SetResizeWidth(newPanel, ResizingPanel.GetResizeWidth(relativePane));
//replace relative pane in its' container panel
//with this new panel
int indexofRelativePane = relativePaneContainer.Children.IndexOf(relativeDocumentPaneContainer);
relativePaneContainer.Children.Remove(relativeDocumentPaneContainer);
relativePaneContainer.Children.Insert(indexofRelativePane, newPanel);
//now we have a panel correctly placed in the tree
newPanel.Children.Add(relativeDocumentPaneContainer);
//use InsertChildRelativeTo function to add a resizingsplitter between
//the two children
newPanel.InsertChildRelativeTo(
paneToAnchor, relativeDocumentPaneContainer, anchor == AnchorStyle.Right || anchor == AnchorStyle.Bottom);
}
else
{
//.........这里部分代码省略.........
示例15: RestoreResizingPanel
ResizingPanel RestoreResizingPanel(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments, ref DocumentPane mainDocumentPane)
{
ResizingPanel panel = null;
if (mainElement.Name == "DocumentPaneResizingPanel")
panel = new DocumentPaneResizingPanel();
else
panel = new ResizingPanel();
if (mainElement.HasAttribute("Orientation"))
panel.Orientation = (Orientation)Enum.Parse(typeof(Orientation), mainElement.GetAttribute("Orientation"));
if (mainElement.HasAttribute("ResizeWidth"))
ResizingPanel.SetResizeWidth(panel, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth")));
if (mainElement.HasAttribute("ResizeHeight"))
ResizingPanel.SetResizeHeight(panel, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight")));
if (mainElement.HasAttribute("EffectiveSize"))
ResizingPanel.SetEffectiveSize(panel, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize")));
foreach (XmlElement childElement in mainElement.ChildNodes)
{
if (childElement.Name == "ResizingPanel" ||
childElement.Name == "DocumentPaneResizingPanel")
{
var childPanel = RestoreResizingPanel(childElement, actualContents, actualDocuments, ref mainDocumentPane);
if (childPanel.Children.Count > 0)
{
panel.Children.Add(childPanel);
}
else
{
Debug.WriteLine("Found empty ResizingPanel in stored layout, it will be discarded.");
}
}
#region Restore DockablePane
else if (childElement.Name == "DockablePane")
{
var pane = RestoreDockablePaneLayout(childElement, actualContents, actualDocuments);
//restore dockable panes even if no contents are inside (an hidden content could refer this pane in SaveStateAndPosition)
panel.Children.Add(pane);
}
#endregion
#region Restore Contents inside a DocumentPane
else if (childElement.Name == "DocumentPane")
{
var documentPane = RestoreDocumentPaneLayout(childElement, actualContents, actualDocuments);
bool isMainDocumentPane = false;
if (childElement.HasAttribute("IsMain"))
isMainDocumentPane = XmlConvert.ToBoolean(childElement.GetAttribute("IsMain"));
if (documentPane.Items.Count > 0 ||
isMainDocumentPane)
panel.Children.Add(documentPane);
if (isMainDocumentPane)
{
if (mainDocumentPane != null)
throw new InvalidOperationException("Main document pane is set more than one time");
mainDocumentPane = documentPane;
}
}
#endregion
}
return panel;
}