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) { // do not allow this as Tabbed Document //anchorableToShow.CanDockAsTabbedDocument = false; toolsPane.Children.Add(anchorableToShow); return(true); } return(false); }
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); }
/// <summary> /// Ensure that tool panes are initially docked to their default positions. /// </summary> /// <param name="layout">The root of the docking layout.</param> /// <param name="anchorableToShow">The anchorable to show.</param> /// <param name="destinationContainer">The destination container.</param> /// <returns></returns> public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { if (anchorableToShow.Content is IPadContent padContent) { if (destinationContainer?.FindParent <LayoutFloatingWindow>() != null) { return(false); // we do not handle bringing pads in a floating layout } var defaultPosition = padContent.DefaultPosition; if (defaultPosition == DefaultPadPositions.Hidden) { layout.Hidden.Add(anchorableToShow); // Pads hidden by default are added to the hidden collection return(true); } // search for the appropriate LayoutAnchorablePane LayoutAnchorablePane destinationPane = null; AnchorSide?anchorSide = DefaultPadPosition_To_AnchorSide(defaultPosition); if (anchorSide.HasValue && (null != (destinationPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(p => p.GetSide() == anchorSide.Value)))) { destinationPane.Children.Add(anchorableToShow); return(true); } } return(false); // no special strategy here }
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; }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { var destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } if (anchorableToShow?.Content is TabViewModel) { var tabPane = layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); if (tabPane != null) { tabPane.Children.Add(anchorableToShow); return(true); } } else if (anchorableToShow?.Content is ToolViewModel) { var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane"); if (toolsPane != null) { toolsPane.Children.Add(anchorableToShow); return(true); } } return(false); }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { if (destinationContainer != null) { return(false); } // WARNING: tricky code, do not modify unless you know what you are doing // if the pane is floating let the manager go ahead if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } var panel = anchorableToShow.Content as PanelVM; if (panel == null) { return(false); } // find the pane with the same ContentId, which is loaded from the layout profile and has an empty content // we are going to replace it with the real content (anchorableToShow) var placeholder = layout.Descendents().OfType <LayoutAnchorable>().FirstOrDefault(x => x.ContentId == panel.ContentId); // placeholder not found, we will leave this pane to the manager (will be placed in the default location) if (placeholder == null) { return(false); } // this will happen once a hidden pane become visible again, the manager will insert it for us. if (placeholder == anchorableToShow) { return(false); } // sync visiblity panel.IsVisible = placeholder.IsVisible; // PreviousContainer and PreviousContainerIndex must be synchronized to anchorableToShow, otherwise if it is hidden, it // cannot be recovered (to its PreviousContainer) var previousContainerProperty = placeholder.GetType() .GetProperty("PreviousContainer", BindingFlags.NonPublic | BindingFlags.Instance); var previousContainer = previousContainerProperty.GetValue(placeholder, null); previousContainerProperty.SetValue(anchorableToShow, previousContainer, null); anchorableToShow.PreviousContainerIndex = placeholder.PreviousContainerIndex; // now we could replace the placeholder with anchorableToShow var parent = placeholder.Parent; parent.ReplaceChild(placeholder, anchorableToShow); return(true); }
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"); Type toolType = anchorableToShow.Content.GetType(); var docData = _dockViewmodel.Data.DocumentTypeData.FirstOrDefault(a => a.DocType == _dockViewmodel.Data.ActiveDocument.GetType()); var pos = docData.DicToolDockPosition[toolType]; LayoutAnchorSide side = GetAnchorSide(pos, layout); if (side.Children.Count == 0) { var group = new LayoutAnchorGroup(); group.Children.Add(anchorableToShow); side.Children.Add(group); SetToolPaneProperties(anchorableToShow); return(true); } else { side.Children[0].Children.Add(anchorableToShow); SetToolPaneProperties(anchorableToShow); return(true); } return(false); //return true; }
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 var destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } var tool = anchorableToShow.Content as ToolViewModel; if (tool != null) { var preferredLocation = tool.PreferredLocation; var paneName = GetPaneName(preferredLocation); var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName); if (toolsPane == null) { switch (preferredLocation) { case ToolLocation.Left: toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.Start); break; case ToolLocation.Right: toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.End); break; case ToolLocation.Bottom: toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.End); break; case ToolLocation.Top: toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.Start); break; default: throw new ArgumentOutOfRangeException(); } } toolsPane.Children.Add(anchorableToShow); return(true); } return(false); }
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 projectPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ProjectPane"); if (projectPane != null && anchorableToShow.Content is ProjectTreeViewModel) { projectPane.Children.Add(anchorableToShow); return(true); } else if (anchorableToShow.Content is ProjectTreeViewModel) { var pane = new LayoutAnchorablePane(anchorableToShow) { DockWidth = new System.Windows.GridLength(300) }; layout.RootPanel.Children.Insert(0, pane); return(true); } var pixelPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(x => x.Name == "PixelPane"); if (pixelPane != null && anchorableToShow.Content is ArrangerEditorViewModel) { pixelPane.Children.Add(anchorableToShow); return(true); } else if (anchorableToShow.Content is ArrangerEditorViewModel) { var pane = new LayoutAnchorablePane(anchorableToShow) { DockWidth = new System.Windows.GridLength(400) }; layout.RootPanel.Children.Add(pane); return(true); } return(false); }
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); } return(false); }
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; }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { if (destinationContainer?.FindParent <LayoutFloatingWindow>() != null) { return(false); } var documentPane = GetOrCreateDocumentPane(layout); if (documentPane == null) { return(false); } documentPane.Children.Add(anchorableToShow); return(true); }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { if (destinationContainer?.FindParent <LayoutFloatingWindow>() != null) { return(false); } var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "AnchorablePane"); if (toolsPane == null) { return(false); } toolsPane.Children.Add(anchorableToShow); return(true); }
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; }
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); }
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); }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { LayoutDocumentPane destPane = destinationContainer as LayoutDocumentPane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } if (((PanelViewModelBase)anchorableToShow.Content).DockLocation == altaik.baseapp.helper.PanelDockLocationEnum.DetailsDocument) { ((LayoutPanel)layout.Children.First()).Children.Add(new LayoutDocumentPane(anchorableToShow)); return(true); } return(false); }
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); }
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; }
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 if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } if (anchorableToShow.Content is IAnchorableWindow) { string paneToSearch = ""; switch ((anchorableToShow.Content as IAnchorableWindow).AnchorableDefaultPlacementEnum) { case PlacementEnum.Top: break; case PlacementEnum.Left: paneToSearch = "LeftAnchorablePane"; break; case PlacementEnum.Right: break; case PlacementEnum.Bottom: paneToSearch = "BottomAnchorablePane"; break; default: throw new ArgumentOutOfRangeException(); } var anchorablePaneToAddChild = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneToSearch); if (anchorablePaneToAddChild != null) { anchorablePaneToAddChild.Children.Add(anchorableToShow); return(true); } } return(false); }
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; }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { var destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent<LayoutFloatingWindow>() != null) return false; LayoutAnchorablePane toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault( d => d.GetType() == typeof (IContentView)); if (toolsPane != null) { toolsPane.Children.Add(anchorableToShow); return true; } return false; }
/// <summary> /// /// </summary> /// <param name="layout"></param> /// <param name="anchorableToShow">配置されようとしている LayoutAnchorable</param> /// <param name="destinationContainer"></param> /// <returns></returns> public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } var viewModel = anchorableToShow.Content; if (viewModel == null) { return(false); } var propInfo = viewModel.GetType().GetProperty("ContentId", BindingFlags.Public | BindingFlags.Instance); if (propInfo == null) { return(false); } var contentId = (string)propInfo.GetValue(viewModel); var target = Items.Find((t) => t.ContentId == contentId); if (target == null) { return(false); } // 選択した名前の領域を取得し、そこにドッキングウィンドウを追加する var pane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == target.TargetLayoutName); if (pane != null) { pane.Children.Add(anchorableToShow); return(true); } return(false); }
/// <summary> /// Befores the insert anchorable. /// </summary> /// <param name="layout">The layout.</param> /// <param name="anchorableToShow">The anchorable to show.</param> /// <param name="destinationContainer">The destination container.</param> /// <returns>The <see cref="bool" />.</returns> 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 // var destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => string.Equals(d.Name, "ToolsPane")); if (toolsPane != null) { toolsPane.Children.Add(anchorableToShow); return(true); } return(false); }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane; if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null) { return(false); } if (anchorableToShow.Content is ToolVM) { ToolVM tvm = (ToolVM)anchorableToShow.Content; var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == tvm.InitialPane); if (toolsPane != null) { toolsPane.Children.Add(anchorableToShow); return(true); } } return(false); }
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 != null) { var itemType = anchorableToShow.Content.GetType(); var defaultViewAttributes = itemType.GetCustomAttributes(typeof(DefaultViewAttribute), true); foreach (DefaultViewAttribute defaultViewAttribute in defaultViewAttributes) { string defaultLayoutAnchorablePaneName = defaultViewAttribute.DefaultLayoutAnchorablePaneName; LayoutAnchorablePane layoutAnchorablePane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name.Equals(defaultLayoutAnchorablePaneName)); if (layoutAnchorablePane != null) { layoutAnchorablePane.Children.Add(anchorableToShow); return(true); } } } var rightPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "rightPane"); if (rightPane != null) { rightPane.Children.Add(anchorableToShow); return(true); } return(false); }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { var container = destinationContainer as LayoutAnchorablePane; if (!(container is null)) { var parent = destinationContainer.FindParent <LayoutFloatingWindow>(); if (!(parent is null)) { return(false); } } var vm = anchorableToShow.Content as LayoutInsertTarget; if (vm is null) { return(false); } var target = Items.Find(x => x.ContentId == vm.ContentId); if (target is null) { return(false); } var pane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(x => x.Name == target.TargetLayoutName); if (pane is null) { return(false); } pane.Children.Add(anchorableToShow); return(true); }
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) { if (destinationContainer?.FindParent <LayoutFloatingWindow>() != null) { return(false); } PanePosition targetPosition = anchorableToShow.Content is PaneModel model ? model.DefaultPosition : PanePosition.Document; switch (targetPosition) { case PanePosition.Top: case PanePosition.Bottom: case PanePosition.Left: case PanePosition.Right: var pane = GetOrCreatePane(layout, targetPosition.ToString()); if (pane == null) { return(false); } anchorableToShow.CanDockAsTabbedDocument = false; pane.Children.Add(anchorableToShow); return(true); case PanePosition.Document: var documentPane = GetOrCreateDocumentPane(layout); if (documentPane == null) { return(false); } documentPane.Children.Add(anchorableToShow); return(true); default: throw new NotSupportedException($"Enum value {targetPosition} is not supported"); } }
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; }
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); } anchorableToShow.AutoHideWidth = 256; anchorableToShow.AutoHideHeight = 128; anchorableToShow.CanShowOnHover = false; if (anchorableToShow.Content is ExplorerViewModel) { var explorerPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ExplorerPane"); if (explorerPane != null) { explorerPane.Children.Add(anchorableToShow); return(true); } } if (anchorableToShow.Content is PropertiesViewModel) { var propertiesPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "PropertiesPane"); if (propertiesPane != null) { propertiesPane.Children.Add(anchorableToShow); return(true); } } if (anchorableToShow.Content is OutputViewModel) { var outputPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "OutputPane"); if (outputPane != null) { outputPane.Children.Add(anchorableToShow); return(true); } } if (anchorableToShow.Content is ToolboxViewModel) { var leftGroup = new LayoutAnchorGroup(); leftGroup.Children.Add(anchorableToShow); layout.LeftSide.Children.Add(leftGroup); return(true); } if (anchorableToShow.Content is GitChangesViewModel) { var rightGroup = new LayoutAnchorGroup(); rightGroup.Children.Add(anchorableToShow); layout.RightSide.Children.Add(rightGroup); return(true); } if (anchorableToShow.Content is ErrorViewModel) { var bottomGroup = new LayoutAnchorGroup(); bottomGroup.Children.Add(anchorableToShow); layout.BottomSide.Children.Add(bottomGroup); return(true); } return(false); }
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 content = anchorableToShow.Content; string destPaneName = ""; if(content is IdInfoTablePane2ViewModel) { destPaneName = "IdInfoTablePane"; ////layout.BottomSide.InsertChildAt(0, anchorableToShow); //layout.BottomSide.Children[0].Children.Add(anchorableToShow); //return true; } else if(content is CategoryTreePaneViewModel) { destPaneName = "CategoryTreePane"; } else if (content is WpfApplication1.Workspace.ParameterFileTreePaneViewModel) { destPaneName = "ParameterFileTreePane"; } else if(content is FileSharePaneViewModel) { destPaneName = "FileSharePane"; } else if(content is ParameterTab2ViewModel) { destPaneName = "ParameterTabPane"; } else { return false; } foreach(var pane in layout.Descendents().OfType<LayoutAnchorablePane>().Where(p=>p.ChildrenCount >= 1)) { for (int i = 0; i < pane.ChildrenCount; ++i) { var child = pane.Children[i]; if (child.Content == null) { child.IsVisible = false; --i; } } } var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == destPaneName); if (toolsPane != null) { toolsPane.Children.Add(anchorableToShow); return true; } return false; }