public Overlay(OverlayViewModel viewModel) { InitializeComponent(); DataContext = viewModel; IsVisibleChanged += Overlay_IsVisibleChanged; }
public OverlayView() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { DataContext = new OverlayViewModel(new EventAggregator()); } }
private void ShowOverlay(OverlayViewModel vm) { var view = new OverlayView { DataContext = vm }; vm.CloseOverlay = () => view.Close(); view.ShowDialog(); }
public void shows_overlay() { // ARRANGE var viewModel = new ChromeViewModel(_mainViewModel, _overlayService.Object); var contentViewModel = new Mock <BaseViewModel>(); var overlayViewModel = new OverlayViewModel("header 1", contentViewModel.Object, Disposable.Empty); // ACT _show.OnNext(overlayViewModel); // ASSERT Assert.That(viewModel.HasOverlay, Is.True); Assert.That(viewModel.OverlayHeader, Is.EqualTo("header 1")); Assert.That(viewModel.Overlay, Is.EqualTo(contentViewModel.Object)); }
public void clears_overlay() { // ARRANGE var viewModel = new ChromeViewModel(_mainViewModel, _overlayService.Object); var contentViewModel = new Mock <BaseViewModel>(); var overlayViewModel = new OverlayViewModel("header 1", contentViewModel.Object, Disposable.Empty); _show.OnNext(overlayViewModel); // ACT viewModel.CloseOverlayCommand.Execute(null); // ASSERT Assert.That(viewModel.HasOverlay, Is.False); Assert.That(viewModel.OverlayHeader, Is.Empty); Assert.That(viewModel.Overlay, Is.Null); }
public void TestGeneralFunctions() { IOverlayType noOverlay = new NoOverlay(); IOverlayType blockOverlay = new BlocksOverlay(); IoC.GetAllInstances = nope => new List <object> { noOverlay, blockOverlay }; IoC.GetInstance = IoCAggregator; OverlayNode node = new OverlayNode(); OverlayViewModel vm = new OverlayViewModel(node); var inputNodeMock = new Mock <InputNode>(1); inputNodeMock.SetupGet(i => i.OutputHasLogfile).Returns(true); inputNodeMock.SetupGet(i => i.InputIsValid).Returns(true); //Test the available Types node.Inputs[0].Source = inputNodeMock.Object.Outputs[0]; Assert.Equal("No Overlay", vm.TypeTuples.First().Item1); //Test altering the chosen Type node.Type = blockOverlay; Assert.Equal("Macroblock-Overlay", vm.ChosenType.Item1); ColorInputNode color = new ColorInputNode(); color.Size = new Size(512, 512); node.Inputs[0].Source = color.Outputs[0]; vm.ChosenType = new System.Tuple <string, IOverlayType>("No Overlay", noOverlay); Assert.Equal("No Overlay", vm.ChosenType.Item1); //Test "Handling" a message(The result has be inspected manually) node.Type = noOverlay; Frame[] input = { new Frame(new Size(512, 512)) }; node.ProcessCore(input, 0); vm.Handle(null); using (var fileStream = new FileStream(@"..\..\..\..\output\thisIsBlack.png", FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(vm.RenderedImage)); encoder.Save(fileStream); } }
public void posts_overlay_without_lifetime() { // ARRANGE var contentViewModel = new Mock <BaseViewModel>(); var service = new OverlayService(); OverlayViewModel overlayViewModel = null; service.Show.Subscribe(x => overlayViewModel = x); // ACT service.Post("header 1", contentViewModel.Object, null); // ASSERT Assert.That(overlayViewModel.HasLifetime, Is.False); Assert.That(overlayViewModel.Lifetime, Is.Null); Assert.That(overlayViewModel.Header, Is.EqualTo("header 1")); Assert.That(overlayViewModel.ViewModel, Is.EqualTo(contentViewModel.Object)); }
public OverlayWindow(Forms.Screen screen) { InitializeComponent(); log.Trace("Initializing Overlay"); screenRect = screen.WorkingArea; vm = new OverlayViewModel(); this.DataContext = vm; this.SourceInitialized += OverlayWindow_SourceInitialized; this.Loaded += OverlayWindow_Loaded; this.Activated += OverlayWindow_Activated; AppService.Instance.OnToggleOverlayVisibility += AppService_OnToggleOverlayVisibility; AppService.Instance.OnResetDefaultOverlay += AppService_OnResetDefaultOverlay; }
public OverlayGroupControl(OverlayViewModel overlayViewModel) { _overlayViewModel = overlayViewModel; CheckCaptureItems = new DelegateCommand(() => ManageCXEntries(true)); CheckSystemInfo = new DelegateCommand(() => ManageSystemInfoEntries(true)); CheckOnlineMetrics = new DelegateCommand(() => ManageOnlineMetricEntries(true)); CheckGpuBasics = new DelegateCommand(() => ManageGpuBasicEntries(true)); CheckCpuLoads = new DelegateCommand(() => ManageCPULoadEntries(true)); CheckCpuClocks = new DelegateCommand(() => ManageCPUClockEntries(true)); CheckCpuTemps = new DelegateCommand(() => ManageCPUTemperatureEntries(true)); CheckRamItems = new DelegateCommand(() => ManageRAMEntries(true)); UncheckCaptureItems = new DelegateCommand(() => ManageCXEntries(false)); UncheckSystemInfo = new DelegateCommand(() => ManageSystemInfoEntries(false)); UncheckOnlineMetrics = new DelegateCommand(() => ManageOnlineMetricEntries(false)); UncheckGpuBasics = new DelegateCommand(() => ManageGpuBasicEntries(false)); UncheckCpuLoads = new DelegateCommand(() => ManageCPULoadEntries(false)); UncheckCpuClocks = new DelegateCommand(() => ManageCPUClockEntries(false)); UncheckCpuTemps = new DelegateCommand(() => ManageCPUTemperatureEntries(false)); UncheckRamItems = new DelegateCommand(() => ManageRAMEntries(false)); }
public void TestGeneralFunctions() { IOverlayType noOverlay = new NoOverlay(); IOverlayType blockOverlay = new BlocksOverlay(); IoC.GetAllInstances = nope => new List<object> { noOverlay, blockOverlay }; IoC.GetInstance = IoCAggregator; OverlayNode node = new OverlayNode(); OverlayViewModel vm = new OverlayViewModel(node); var inputNodeMock = new Mock<InputNode>(1); inputNodeMock.SetupGet(i => i.OutputHasLogfile).Returns(true); inputNodeMock.SetupGet(i => i.InputIsValid).Returns(true); //Test the available Types node.Inputs[0].Source = inputNodeMock.Object.Outputs[0]; Assert.Equal("No Overlay", vm.TypeTuples.First().Item1); //Test altering the chosen Type node.Type = blockOverlay; Assert.Equal("Macroblock-Overlay", vm.ChosenType.Item1); ColorInputNode color = new ColorInputNode(); color.Size = new Size(512, 512); node.Inputs[0].Source = color.Outputs[0]; vm.ChosenType = new System.Tuple<string, IOverlayType>("No Overlay", noOverlay); Assert.Equal("No Overlay", vm.ChosenType.Item1); //Test "Handling" a message(The result has be inspected manually) node.Type = noOverlay; Frame[] input = { new Frame(new Size(512, 512)) }; node.ProcessCore(input, 0); vm.Handle(null); using (var fileStream = new FileStream(@"..\..\..\..\output\thisIsBlack.png", FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(vm.RenderedImage)); encoder.Save(fileStream); } }
public MainWindow() { InitializeComponent(); DataContext = new OverlayViewModel(); }
private void OnInitialized(object sender, EventArgs args) { DataContext = new OverlayViewModel(); }
public OverlayGroupControl(OverlayViewModel overlayViewModel) { _overlayViewModel = overlayViewModel; }
public void Test50() { // Some necessary initializations. MainViewModel mvm = MainViewModelTest.GetInstance(); var windowManMock = new Mock <IWindowManagerEx>(); var vm = MainViewModelTest.GetInstance(cont => cont.ComposeExportedValue <IWindowManagerEx>(windowManMock.Object)); var conductorMock = new Mock <IConductor>(); // Step 1: Create simple pipeline. // // [color]---[overlay] // \ / // X // / \ // [noise]---[diagram] NoiseInputNode noise = new NoiseInputNode(); mvm.Model.Graph.AddNode(noise); ColorInputNode color = new ColorInputNode(); mvm.Model.Graph.AddNode(color); DiagramNode diagram = new DiagramNode(); diagram.Inputs.Add(new Node.Input()); diagram.Inputs.Add(new Node.Input()); mvm.Model.Graph.AddNode(diagram); OverlayNode overlay = new OverlayNode(); mvm.Model.Graph.AddNode(overlay); Assert.Contains(noise, mvm.Model.Graph.Nodes); Assert.Contains(color, mvm.Model.Graph.Nodes); Assert.Contains(diagram, mvm.Model.Graph.Nodes); Assert.Contains(overlay, mvm.Model.Graph.Nodes); mvm.Model.Graph.AddEdge(noise.Outputs[0], overlay.Inputs[0]); mvm.Model.Graph.AddEdge(noise.Outputs[0], diagram.Inputs[0]); mvm.Model.Graph.AddEdge(color.Outputs[0], overlay.Inputs[1]); mvm.Model.Graph.AddEdge(color.Outputs[0], diagram.Inputs[1]); Assert.Equal(noise.Outputs[0], overlay.Inputs[0].Source); Assert.Equal(noise.Outputs[0], diagram.Inputs[0].Source); Assert.Equal(color.Outputs[0], overlay.Inputs[1].Source); Assert.Equal(color.Outputs[0], diagram.Inputs[1].Source); // Step 2: Disable diagram node and open overlay node. diagram.IsEnabled = false; IGraphType pixelDiff = new PixelDiff(); IGraphType psnr = new PeakSignalNoiseRatio(); IoC.GetAllInstances = type => new List <IGraphType> { pixelDiff, psnr }; var overlayWindow = new OverlayViewModel(overlay) { Parent = conductorMock.Object }; var diagramWindow = new DiagramViewModel(diagram) { Parent = conductorMock.Object }; ((IActivate)overlayWindow).Activate(); conductorMock.Setup(c => c.DeactivateItem(overlayWindow, true)) .Callback(() => ((IDeactivate)overlayWindow).Deactivate(close: true)) .Verifiable(); mvm.OpenWindow(overlayWindow); Assert.Contains(overlayWindow, mvm.OpenWindows); // Step 3: Start pipeline and add an overlay in the overlay node. mvm.Model.Start(mvm.Model.Graph.Nodes); overlay.Type = new ArtifactsOverlay(); // Step 4: Remove selected overlay. overlay.Type = new NoOverlay(); // Step 5: Stop pipeline and close overlay node. mvm.Model.Stop(); mvm.CloseWindows(overlay); Assert.DoesNotContain(overlayWindow, mvm.OpenWindows); // Step 6: Re-enable diagram node and open it. diagram.IsEnabled = true; mvm.OpenWindow(diagramWindow); Assert.Contains(diagramWindow, mvm.OpenWindows); // Step 7: Choose a reference video and add a diagram graph. diagramWindow.Reference = new Tuple <string, Node.Input>(diagramWindow.GetVideoName(diagram.Inputs[0]), diagram.Inputs[0]); diagramWindow.ChosenVideo = new Tuple <string, Node.Input>(diagramWindow.GetVideoName(diagram.Inputs[1]), diagram.Inputs[1]); diagramWindow.AddGraph(); diagramWindow.Graphs.ElementAt(0).CurrentType = new GraphTypeViewModel(pixelDiff); // Step 8: Start pipeline again and change diagram graph type. mvm.Model.Start(mvm.Model.Graph.Nodes); diagramWindow.Graphs.ElementAt(0).CurrentType = new GraphTypeViewModel(psnr); // Step 9: Remove the diagram graph. DiagramGraphViewModel dgvm = diagramWindow.Graphs.ElementAt(0); diagramWindow.DeleteGraph(dgvm); Assert.DoesNotContain(dgvm, diagramWindow.Graphs); }