Class used to generate ContentPane instances based on a given source collection of items (ContainerFactoryBase.ItemsSource).
Inheritance: ContainerFactory
示例#1
0
        private static void OnPaneFactoryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is DocumentContentHost || d is TabGroupPane || d is SplitPane)
            {
                ContentPaneFactory oldFactory = (ContentPaneFactory)e.OldValue;
                ContentPaneFactory newFactory = (ContentPaneFactory)e.NewValue;

                if (oldFactory != null && oldFactory.Equals(newFactory))
                {
                    return;
                }

                if (oldFactory != null)
                {
                    oldFactory._target = null;

                    foreach (var o in oldFactory.GetElements())
                    {
                        var cp = (ContentPane)o;
                        oldFactory.RemovePane(cp);
                    }
                }

                if (newFactory != null)
                {
                    newFactory._target = d;

                    foreach (var o in newFactory.GetElements())
                    {
                        var cp = (ContentPane)o;
                        newFactory.AddPane(cp);
                    }
                }
            }
        }
        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;
        }
示例#3
0
 /// <summary>
 /// Sets the object that will create ContentPane instances based on the items in the associate <see cref="ContainerFactoryBase.ItemsSource"/>
 /// </summary>
 public static void SetPaneFactory(DependencyObject d, ContentPaneFactory value)
 {
     d.SetValue(PaneFactoryProperty, value);
 }
示例#4
0
 /// <summary>
 /// Sets the object that will create ContentPane instances based on the items in the associate <see cref="ContainerFactoryBase.ItemsSource"/>
 /// </summary>
 public static void SetPaneFactory(DependencyObject d, ContentPaneFactory value)
 {
     d.SetValue(PaneFactoryProperty, value);
 }