internal UIElement CreateUIElementForModel(ILayoutElement model) { if (model is LayoutPanel) return new LayoutPanelControl(model as LayoutPanel); if (model is LayoutAnchorablePaneGroup) return new LayoutAnchorablePaneGroupControl(model as LayoutAnchorablePaneGroup); if (model is LayoutDocumentPaneGroup) return new LayoutDocumentPaneGroupControl(model as LayoutDocumentPaneGroup); if (model is LayoutAnchorSide) { var templateModelView = new LayoutAnchorSideControl(model as LayoutAnchorSide); templateModelView.SetBinding(LayoutAnchorSideControl.TemplateProperty, new Binding("AnchorSideTemplate") { Source = this }); return templateModelView; } if (model is LayoutAnchorGroup) { var templateModelView = new LayoutAnchorGroupControl(model as LayoutAnchorGroup); templateModelView.SetBinding(LayoutAnchorGroupControl.TemplateProperty, new Binding("AnchorGroupTemplate") { Source = this }); return templateModelView; } if (model is LayoutDocumentPane) { var templateModelView = new LayoutDocumentPaneControl(model as LayoutDocumentPane); templateModelView.SetBinding(LayoutDocumentPaneControl.StyleProperty, new Binding("DocumentPaneControlStyle") { Source = this }); return templateModelView; } if (model is LayoutAnchorablePane) { var templateModelView = new LayoutAnchorablePaneControl(model as LayoutAnchorablePane); templateModelView.SetBinding(LayoutAnchorablePaneControl.StyleProperty, new Binding("AnchorablePaneControlStyle") { Source = this }); return templateModelView; } if (model is LayoutAnchorableFloatingWindow) { if (DesignerProperties.GetIsInDesignMode(this)) return null; var modelFW = model as LayoutAnchorableFloatingWindow; var newFW = new LayoutAnchorableFloatingWindowControl(modelFW) { //Owner = Window.GetWindow(this) }; newFW.SetParentToMainWindowOf(this); var paneForExtensions = modelFW.RootPanel.Children.OfType<LayoutAnchorablePane>().FirstOrDefault(); if (paneForExtensions != null) { //ensure that floating window position is inside current (or nearest) monitor paneForExtensions.KeepInsideNearestMonitor(); newFW.Left = paneForExtensions.FloatingLeft; newFW.Top = paneForExtensions.FloatingTop; newFW.Width = paneForExtensions.FloatingWidth; newFW.Height = paneForExtensions.FloatingHeight; } newFW.ShowInTaskbar = false; newFW.Show(); return newFW; } if (model is LayoutDocumentFloatingWindow) { if (DesignerProperties.GetIsInDesignMode(this)) return null; var modelFW = model as LayoutDocumentFloatingWindow; var newFW = new LayoutDocumentFloatingWindowControl(modelFW) { //Owner = Window.GetWindow(this) }; newFW.SetParentToMainWindowOf(this); var paneForExtensions = modelFW.RootDocument; if (paneForExtensions != null) { //ensure that floating window position is inside current (or nearest) monitor paneForExtensions.KeepInsideNearestMonitor(); newFW.Left = paneForExtensions.FloatingLeft; newFW.Top = paneForExtensions.FloatingTop; newFW.Width = paneForExtensions.FloatingWidth; newFW.Height = paneForExtensions.FloatingHeight; } newFW.ShowInTaskbar = false; newFW.Show(); return newFW; } if (model is LayoutDocument) { var templateModelView = new LayoutDocumentControl() { Model = model as LayoutDocument }; return templateModelView; } return null; }
// ReSharper disable once InconsistentNaming internal UIElement CreateUIElementForModel(ILayoutElement model) { var panel = model as LayoutPanel; if (panel != null) return new LayoutPanelControl(panel); var @group = model as LayoutAnchorablePaneGroup; if (@group != null) return new LayoutAnchorablePaneGroupControl(@group); var paneGroup = model as LayoutDocumentPaneGroup; if (paneGroup != null) return new LayoutDocumentPaneGroupControl(paneGroup); var side = model as LayoutAnchorSide; if (side != null) { var templateModelView = new LayoutAnchorSideControl(side); templateModelView.SetBinding(TemplateProperty, new Binding("AnchorSideTemplate") { Source = this }); return templateModelView; } var anchorGroup = model as LayoutAnchorGroup; if (anchorGroup != null) { var templateModelView = new LayoutAnchorGroupControl(anchorGroup); templateModelView.SetBinding(TemplateProperty, new Binding("AnchorGroupTemplate") { Source = this }); return templateModelView; } var documentPane = model as LayoutDocumentPane; if (documentPane != null) { var templateModelView = new LayoutDocumentPaneControl(documentPane); templateModelView.SetBinding(StyleProperty, new Binding("DocumentPaneControlStyle") { Source = this }); return templateModelView; } var pane = model as LayoutAnchorablePane; if (pane != null) { var templateModelView = new LayoutAnchorablePaneControl(pane); templateModelView.SetBinding(StyleProperty, new Binding("AnchorablePaneControlStyle") { Source = this }); return templateModelView; } var fw = model as LayoutAnchorableFloatingWindow; if (fw != null) { if (DesignerProperties.GetIsInDesignMode(this)) return null; var modelFw = fw; var newFw = new LayoutAnchorableFloatingWindowControl(modelFw); newFw.SetParentToMainWindowOf(this); var paneForExtensions = modelFw.RootPanel.Children.OfType<LayoutAnchorablePane>().FirstOrDefault(); if (paneForExtensions != null) { //ensure that floating window position is inside current (or nearest) monitor paneForExtensions.KeepInsideNearestMonitor(); newFw.Left = paneForExtensions.FloatingLeft; newFw.Top = paneForExtensions.FloatingTop; newFw.Width = paneForExtensions.FloatingWidth; newFw.Height = paneForExtensions.FloatingHeight; } newFw.ShowInTaskbar = false; newFw.Show(); // Do not set the WindowState before showing or it will be lost if (paneForExtensions != null && paneForExtensions.IsMaximized) { newFw.WindowState = WindowState.Maximized; } return newFw; } var window = model as LayoutDocumentFloatingWindow; if (window != null) { if (DesignerProperties.GetIsInDesignMode(this)) return null; var modelFw = window; var newFw = new LayoutDocumentFloatingWindowControl(modelFw); newFw.SetParentToMainWindowOf(this); var paneForExtensions = modelFw.RootDocument; if (paneForExtensions != null) { //ensure that floating window position is inside current (or nearest) monitor paneForExtensions.KeepInsideNearestMonitor(); newFw.Left = paneForExtensions.FloatingLeft; newFw.Top = paneForExtensions.FloatingTop; newFw.Width = paneForExtensions.FloatingWidth; newFw.Height = paneForExtensions.FloatingHeight; } newFw.ShowInTaskbar = true; newFw.Show(); // Do not set the WindowState before showing or it will be lost if (paneForExtensions != null && paneForExtensions.IsMaximized) { newFw.WindowState = WindowState.Maximized; } return newFw; } var document = model as LayoutDocument; if (document != null) { var templateModelView = new LayoutDocumentControl { Model = document }; return templateModelView; } return null; }