private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { if (Object.ReferenceEquals(e.Command, DockManagerCommands.NewTab)) { var newPane = new ContentPane(); newPane.Header = "New Tab"; this.tabsPane.Items.Add(newPane); } }
/// <summary> /// Initializes a new object. /// </summary> /// <param name="content">The content of the ContentPane.</param> public ContentPaneProxy(object content, string name) { _contentPane = new ContentPane(); _contentPane.Name = name; _contentPane.Content = content; ContentPaneProxy.SetAssociatedProxy(_contentPane, this); base.DataContext = _contentPane; this.HookEvents(true); }
static ContentPaneFactory SetupPane(out WorkSurfaceContextViewModel workSurfaceContextViewModel, out ContentPane userControl, MessageBoxResult messageBoxResult) { var pane = new ContentPaneFactory(); var eventAggregator = new Mock<IEventAggregator>(); var workSurfaceViewModel = new Mock<ITestWorkSurfaceViewModel>(); workSurfaceViewModel.SetupGet(w => w.WorkSurfaceContext).Returns(WorkSurfaceContext.Workflow); workSurfaceViewModel.SetupGet(w => w.ResourceModel).Returns(new TestResourceModel { Authorized = true }); var localhost = new Mock<IEnvironmentModel>(); localhost.Setup(e => e.ID).Returns(Guid.Empty); localhost.Setup(e => e.IsConnected).Returns(true); var environmentRepository = new Mock<IEnvironmentRepository>(); environmentRepository.Setup(c => c.All()).Returns(new[] { localhost.Object }); environmentRepository.Setup(c => c.Source).Returns(localhost.Object); var eventPublisher = new Mock<IEventAggregator>(); var asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker(); var versionChecker = new Mock<IVersionChecker>(); var browserPopupController = new Mock<IBrowserPopupController>(); var savePopup = new Mock<IPopupController>(); savePopup.Setup(s => s.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>())).Returns(messageBoxResult); var mainViewModel = new MainViewModelMock(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object,new Mock<IStudioResourceRepository>().Object, new Mock<IConnectControlSingleton>().Object, new Mock<IConnectControlViewModel>().Object, false, browserPopupController.Object) { IsBusyDownloadingInstaller = () => false, PopupProvider = savePopup.Object }; workSurfaceContextViewModel = new WorkSurfaceContextViewModel(eventAggregator.Object, new WorkSurfaceKey { EnvironmentID = Guid.NewGuid(), ResourceID = Guid.NewGuid(), ServerID = Guid.NewGuid(), WorkSurfaceContext = WorkSurfaceContext.Workflow }, workSurfaceViewModel.Object, new Mock<IPopupController>().Object, (a, b) => { }) { Parent = mainViewModel }; pane.ItemsSource = new List<WorkSurfaceContextViewModel> { workSurfaceContextViewModel }; userControl = new ContentPane { DataContext = workSurfaceContextViewModel }; return pane; }
internal static void SetAssociatedProxy(ContentPane pane, ContentPaneProxy value) { pane.SetValue(AssociatedProxyPropertyKey, value); }
internal static ContentPaneProxy GetAssociatedProxy(ContentPane pane) { return (ContentPaneProxy)pane.GetValue(AssociatedProxyProperty); }
public void DockManager_OnPaneDragEnded_(object sender, PaneDragEndedEventArgs e) { var contentPane = e.Panes[0]; _contentPane = contentPane; UpdatePane(contentPane); var windows = Application.Current.Windows; foreach (var window in windows) { var actuallWindow = window as Window; if (actuallWindow != null) { var windowType = actuallWindow.GetType(); if (windowType.FullName == "Infragistics.Windows.Controls.ToolWindowHostWindow") { actuallWindow.Activated -= ActuallWindowOnActivated; actuallWindow.Activated += ActuallWindowOnActivated; } } } }
void DockManager_OnPaneDragStarting(object sender, PaneDragStartingEventArgs e) { _contentPane = e.Panes[0]; }
public void UpdatePane(ContentPane contentPane) { if(contentPane == null) throw new ArgumentNullException("contentPane"); WorkflowDesignerViewModel workflowDesignerViewModel = contentPane.TabHeader as WorkflowDesignerViewModel; if (workflowDesignerViewModel != null && contentPane.ContentVisibility == Visibility.Visible) { contentPane.CloseButtonVisibility = Visibility.Visible; } }
/// <summary> /// Initializes a new instance of the <see cref = "DockableWindowConductor" /> class. /// </summary> /// <param name = "viewModel">The view model.</param> /// <param name = "view">The view.</param> public DockableWindowConductor(object viewModel, ContentPane view) { _viewModel = viewModel; _view = view; var activatable = viewModel as IActivate; if(activatable != null) activatable.Activate(); var deactivatable = viewModel as IDeactivate; if(deactivatable != null) { _view.Closed += OnClosed; deactivatable.Deactivated += OnDeactivated; } var guard = viewModel as IGuardClose; if(guard != null) view.Closing += OnClosing; }
private static ContentPane EnsureDockWindow(object view) { var window = view as ContentPane; if(window == null) { window = new ContentPane { CloseAction = PaneCloseAction.RemovePane, Content = view as UIElement }; window.SetValue(View.IsGeneratedProperty, true); } return window; }
/// <summary> /// Initializes a new <see cref="InitializeContentPaneEventArgs"/> /// </summary> /// <param name="pane">The pane being initialized</param> public InitializeContentPaneEventArgs(ContentPane pane) { if (pane == null) { throw new ArgumentNullException("pane"); } _pane = pane; }
/// <summary> /// Invoked when a ContentPane for a given item is being removed. /// </summary> /// <param name="cp">The pane being removed</param> protected virtual void RemovePane(ContentPane cp) { // we need to temporarily change the close action while we close it DependencyProperty closeProp = ContentPane.CloseActionProperty; if(cp == null) { return; } object oldValue = cp.ReadLocalValue(closeProp); BindingExpressionBase oldExpression = cp.GetBindingExpression(closeProp); cp.CloseAction = PaneCloseAction.RemovePane; // restore the original close action if(oldExpression != null) { cp.SetBinding(closeProp, oldExpression.ParentBindingBase); } else if(oldValue == DependencyProperty.UnsetValue) { cp.ClearValue(closeProp); } else { cp.SetValue(closeProp, oldValue); } }
private void RaiseInitializeContentPane(ContentPane pane) { if(null == _target) { return; } var args = new InitializeContentPaneEventArgs(pane) { RoutedEvent = InitializeContentPaneEvent }; UiElementHelper.RaiseEvent(_target, args); }
/// <summary> /// Invoked when a new <see cref="ContentPane"/> has been created and needs to be added to the appropriate target collection. /// </summary> /// <param name="pane">The pane that was created and needs to be added to the appropriate collection</param> protected virtual void AddPane(ContentPane pane) { DocumentContentHost host = _target as DocumentContentHost; if(host != null) { ContentPane sibling = GetSiblingDocument(); TabGroupPane tgp = null; if(sibling != null) { tgp = LogicalTreeHelper.GetParent(sibling) as TabGroupPane; Debug.Assert(null != tgp, "Expected all documents to be within a tab group pane."); } if(null == tgp) { SplitPane sp = new SplitPane(); tgp = new TabGroupPane { Name = "Z" + Guid.NewGuid().ToString("N") }; sp.Panes.Add(tgp); DocumentContentHost dch = host; dch.Panes.Add(sp); } tgp.Items.Add(pane); RaiseInitializeContentPane(pane); } else { IList targetCollection = null; Debug.Assert(_target == null || !string.IsNullOrEmpty((string)_target.GetValue(FrameworkElement.NameProperty)), "The Name should be set so the container will not be removed when all the panes have been moved elsewhere. Otherwise new panes may not be displayed."); SplitPane splitPane = _target as SplitPane; if(splitPane != null) { targetCollection = splitPane.Panes; } else { TabGroupPane target = _target as TabGroupPane; if(target != null) { targetCollection = target.Items; } } if(null != targetCollection) { targetCollection.Add(pane); RaiseInitializeContentPane(pane); } } }
//Juries TODO improve (remove typing tied to contentfactory) private void SetTabName(ContentPane pane, object item) { WorkSurfaceContextViewModel model = item as WorkSurfaceContextViewModel; if(model != null) { var vm = model; pane.Name = vm.WorkSurfaceKey.ToString(); } else pane.Name = item.ToString(); }