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); }
void _application_OnShowDockableWindow(IDockableWindow window) { if (!_anchorables.ContainsKey(window)) return; LayoutAnchorable anchorable = _anchorables[window]; if (anchorable != null) { if (anchorable.IsAutoHidden) { anchorable.ToggleAutoHide(); } else { LayoutContent content = anchorable; while (content != null && content.Parent is ILayoutContentSelector) { ILayoutContentSelector selector = (ILayoutContentSelector)content.Parent; int index = selector.IndexOf(content); if (index != selector.SelectedContentIndex) selector.SelectedContentIndex = index; content = content.Parent as LayoutContent; } anchorable.Show(); if (anchorable.IsVisible == false) { //if (anchorable.CanFloat) // anchorable.Float(); //else anchorable.Dock(); } } } }
/// <summary> /// 初始化主要内容的容器控件 /// </summary> private void initMianContentControl() { mianContentControl = new DockingManager(); mianContentControl.BorderBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush; mianContentControl.Theme = new Xceed.Wpf.AvalonDock.Themes.MetroTheme(); mianContentControl.DocumentClosed += MianContentControl_DocumentClosed; var v = Utility.Windows.ResourceHelper.FindResource(@"DockDocumentHeaderTemplate"); DataTemplate dataTemplate = v as DataTemplate; mianContentControl.DocumentHeaderTemplate = dataTemplate; LayoutRoot layoutRoot = new LayoutRoot(); mianContentControl.Layout = layoutRoot; LayoutAnchorSide layoutAnchorSide = new LayoutAnchorSide(); layoutRoot.LeftSide = layoutAnchorSide; LayoutAnchorGroup layoutAnchorGroup = new LayoutAnchorGroup(); layoutAnchorSide.Children.Add(layoutAnchorGroup); LayoutAnchorable layoutAnchorable = new LayoutAnchorable(); layoutAnchorable.Title = Utility.Windows.ResourceHelper.FindResource(@"NavigationMenu").ToString(); layoutAnchorable.IconSource = Utility.Windows.BitmapImageHelper.GetBitmapImage("Images/Folder_32.png", 16, 16); layoutAnchorable.CanAutoHide = true; layoutAnchorable.CanClose = false; layoutAnchorable.CanFloat = false; layoutAnchorable.CanHide = false; layoutAnchorable.IsMaximized = false; layoutAnchorable.AutoHideMinWidth = (double)Utility.Windows.ResourceHelper.FindResource(@"LeftTreeAutoHideMinWidth"); layoutAnchorGroup.Children.Add(layoutAnchorable); layoutAnchorable.ToggleAutoHide(); //TreeView treeView = new TreeView(); //layoutAnchorable.Content = new ContentControl ()(Prism.Regions.RegionManager.SetRegionName (""); //Prism.Regions.RegionManager.GetRegionName(layoutAnchorable, "TreeMenuModule"); //treeView.ItemsSource = this.MenuItems; //layoutAnchorable.Content = //Style style = new Style(); ; //style.TargetType = typeof(TreeViewItem); //style.BasedOn = Utility.Windows.ResourceHelper.FindResource(@"MetroTreeViewItem") as Style; //treeView.ItemContainerStyle = style; var treeMenuContent = new ContentControl(); layoutAnchorable.Content = treeMenuContent; Prism.Regions.RegionManager.SetRegionName(treeMenuContent, "TreeMenuRegion"); //Prism.Regions.RegionManager.SetRegionName(layoutAnchorable, "TreeMenuModule"); //var regionManager = containerProvider.Resolve<IRegionManager>(); //regionManager.RegisterViewWithRegion("ShellContentRegion", typeof(ShellView)); LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); layoutRoot.RootPanel.Orientation = Orientation.Horizontal; layoutRoot.RootPanel.Children[1] = layoutDocumentPaneGroup; layoutDocumentPaneGroup.InsertChildAt(0, layoutDocumentPane); }
/// <summary> /// Add pane to JSharp window /// </summary> private void AddPane(Pane pane) { if (pane == null) { return; } var lA = new LayoutAnchorable { Title = pane._title, Content = pane._content }; pane._parentPaneHolder = lA; if (!dictionaryOfPanes.ContainsKey(pane._title)) { dictionaryOfPanes.Add(pane._title, pane); } else { dictionaryOfPanes[pane._title]._parentPaneHolder = pane._parentPaneHolder; pane._paneLocation = dictionaryOfPanes[pane._title]._paneLocation; pane._isAutoHide = dictionaryOfPanes[pane._title]._isAutoHide; pane._width = dictionaryOfPanes[pane._title]._width; pane._height = dictionaryOfPanes[pane._title]._height; } ((UserControl)pane._content).HorizontalAlignment = HorizontalAlignment.Stretch; ((UserControl)pane._content).VerticalAlignment = VerticalAlignment.Stretch; //panes[pane.paneLocation].Children.Add(lA); lA.CanDockAsTabbedDocument = false; lA.AddToLayout(DockManager, (AnchorableShowStrategy)pane._paneLocation); if (lA.Parent is LayoutAnchorablePane p) { p.DockWidth = new GridLength(pane._width); p.DockHeight = new GridLength(pane._height); } else if (lA.Parent is LayoutAnchorablePaneGroup pG) { pG.DockWidth = new GridLength(pane._width); pG.DockHeight = new GridLength(pane._height); } lA.AutoHideHeight = pane._height; lA.AutoHideWidth = pane._width; if (pane._isAutoHide) { lA.ToggleAutoHide(); } }
/// <summary> /// Provides derived classes an opportunity to handle changes to the IsAutoHidden property. /// </summary> protected virtual void OnIsAutoHiddenChanged(DependencyPropertyChangedEventArgs e) { if (_anchorable != null) { if (_anchorable.IsAutoHidden != (bool)e.NewValue) { _anchorable.ToggleAutoHide(); } } }
private void OnModelContentLoaded(object sender, RoutedEventArgs e) { if (!called_Show) { return; } called_Show = false; if (LayoutSetting.GetDefaultIsDockAnchorable(_model.Title)) { _model.ToggleAutoHide(); } }
/// <summary> /// 初始化主要内容的容器控件 /// </summary> private void initMianContentControl() { mianContentControl = new DockingManager(); mianContentControl.BorderBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush; mianContentControl.Theme = new Xceed.Wpf.AvalonDock.Themes.MetroTheme(); mianContentControl.DocumentClosed += MianContentControl_DocumentClosed; var v = Utility.Windows.ResourceHelper.FindResource(@"DockDocumentHeaderTemplate"); DataTemplate dataTemplate = v as DataTemplate; mianContentControl.DocumentHeaderTemplate = dataTemplate; mianContentControl.Background = Utility.Windows.ResourceHelper.FindResource(@"DesktopBackground") as System.Windows.Media.ImageBrush; LayoutRoot layoutRoot = new LayoutRoot(); mianContentControl.Layout = layoutRoot; LayoutAnchorSide layoutAnchorSide = new LayoutAnchorSide(); layoutRoot.LeftSide = layoutAnchorSide; LayoutAnchorGroup layoutAnchorGroup = new LayoutAnchorGroup(); layoutAnchorSide.Children.Add(layoutAnchorGroup); LayoutAnchorable layoutAnchorable = new LayoutAnchorable(); layoutAnchorable.Title = Utility.Windows.ResourceHelper.FindResource(@"NavigationMenu").ToString(); layoutAnchorable.IconSource = Utility.Windows.ResourceHelper.FindResource(@"Folder_32x32") as System.Windows.Media.ImageSource; layoutAnchorable.CanAutoHide = true; layoutAnchorable.CanClose = false; layoutAnchorable.CanFloat = false; layoutAnchorable.CanHide = false; layoutAnchorable.IsMaximized = false; layoutAnchorable.AutoHideMinWidth = (double)Utility.Windows.ResourceHelper.FindResource(@"LeftTreeAutoHideMinWidth"); layoutAnchorGroup.Children.Add(layoutAnchorable); layoutAnchorable.ToggleAutoHide(); TreeView treeView = new TreeView(); layoutAnchorable.Content = treeView; treeView.ItemsSource = this.MenuItems; Style style = new Style();; style.TargetType = typeof(TreeViewItem); style.BasedOn = Utility.Windows.ResourceHelper.FindResource(@"MetroTreeViewItem") as Style; treeView.ItemContainerStyle = style; LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); layoutRoot.RootPanel.Orientation = Orientation.Horizontal; layoutRoot.RootPanel.Children[1] = layoutDocumentPaneGroup; layoutDocumentPaneGroup.InsertChildAt(0, layoutDocumentPane); }
private static void SetToolPaneProperties(LayoutAnchorable anchorableToShow) { anchorableToShow.Show(); anchorableToShow.ToggleAutoHide(); var toolpanel = anchorableToShow.Content as Viewer.AdvancedTypes.DockingToolHelper.ToolViewModel; var layoutPane = anchorableToShow.Parent as LayoutAnchorablePane; layoutPane.DockMinWidth = toolpanel.MinWidth; layoutPane.DockMinHeight = toolpanel.MinHeight; }
private void initLayout(LayoutAnchorable la) { if (la.IsAutoHidden) { la.ToggleAutoHide(); } var parent = la.Parent as LayoutAnchorablePane; if (parent != null) { parent.DockWidth = new GridLength(la.AutoHideMinWidth); } }
public static void ShowPanel(System.Windows.FrameworkElement control) { DockingManager dman = control.Parent as DockingManager; if (dman != null) { LayoutAnchorable panel = dman.Layout.Descendents().OfType <LayoutAnchorable>() .FirstOrDefault <LayoutAnchorable>(lay => lay.Content == control); if (panel != null && panel.IsAutoHidden) { panel.ToggleAutoHide(); } } }
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 destinationPane = string.Empty; bool autoHide = false; anchorableToShow.AutoHideWidth = 400; anchorableToShow.AutoHideHeight = 300; if (anchorableToShow.Content is NeuronGraphViewModel) { destinationPane = "TopToolsPane"; } else if (anchorableToShow.Content is EditorToolViewModel) { destinationPane = "DocumentBottomPane"; } else if (anchorableToShow.Content is ServerExplorerToolViewModel) { destinationPane = "LeftToolsPane"; autoHide = true; } else { destinationPane = "BottomToolsPane"; } var success = AddAnchorableToPane(destinationPane, layout, anchorableToShow); if (autoHide) { anchorableToShow.ToggleAutoHide(); } return(success); }