Ejemplo n.º 1
0
        public async Task HistoryActivate()
        {
            using (_workflow.Plots.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                var plot1to10 = await GetExpectedImageAsync("bmp", 600, 500, 96, "plot1-10", "plot(1:10)");

                var plot2to10 = await GetExpectedImageAsync("bmp", 600, 500, 96, "plot2-10", "plot(2:10)");

                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(1:10)",
                    "plot(2:10)",
                });

                var deviceVC        = _workflow.Plots.GetPlotVisualComponent(_workflow.Plots.ActiveDevice);
                var historyVC       = _workflow.Plots.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                historyCommands.ActivatePlot.Should().BeDisabled();

                // Select and activate the first plot
                historyVC.SelectedPlot = _workflow.Plots.ActiveDevice.GetPlotAt(0);
                historyCommands.ActivatePlot.Should().BeEnabled();
                var plotReceivedTask = EventTaskSources.IRPlotDevice.PlotAddedOrUpdated.Create(_workflow.Plots.ActiveDevice);
                await historyCommands.ActivatePlot.InvokeAsync();

                await plotReceivedTask;
                _workflow.Plots.ActiveDevice.ActivePlot.Image.Should().HaveSamePixels(plot1to10);

                CoreShell.LastShownErrorMessage.Should().BeNullOrEmpty();
            }
        }
Ejemplo n.º 2
0
        public async Task HistoryRemove()
        {
            using (_workflow.Plots.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(1:10)",
                });

                var historyVC       = _workflow.Plots.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                var device1   = _workflow.Plots.ActiveDevice;
                var device1VC = _workflow.Plots.GetPlotVisualComponent(device1);
                var plot1     = device1.ActivePlot;

                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(2:10)",
                });

                var device2   = _workflow.Plots.ActiveDevice;
                var device2VC = _workflow.Plots.GetPlotVisualComponent(device2);
                var plot2     = device2.ActivePlot;

                historyVC.SelectedPlot = null;
                historyCommands.Remove.Should().BeDisabled();

                // Select the only plot in device 1 and remove it
                historyVC.SelectedPlot = plot1;
                historyCommands.Remove.Should().BeEnabled();
                var plotRemovedTask = EventTaskSources.IRPlotDevice.PlotRemoved.Create(device1);
                await historyCommands.Remove.InvokeAsync();

                await plotRemovedTask;

                device1.ActivePlot.Should().BeNull();
                device1.PlotCount.Should().Be(0);
                device1.ActiveIndex.Should().Be(-1);

                // Deleting the plot from device 1 should not have changed the active device
                _workflow.Plots.ActiveDevice.Should().Be(device2);

                // Select the only plot in device 2 and remove it
                historyVC.SelectedPlot = plot2;
                historyCommands.Remove.Should().BeEnabled();
                plotRemovedTask = EventTaskSources.IRPlotDevice.PlotRemoved.Create(device2);
                await historyCommands.Remove.InvokeAsync();

                await plotRemovedTask;

                device2.ActivePlot.Should().BeNull();
                device2.PlotCount.Should().Be(0);
                device2.ActiveIndex.Should().Be(-1);
            }
        }
Ejemplo n.º 3
0
        protected override void OnCreate()
        {
            var controller      = new AsyncCommandController();
            var visualComponent = new RPlotHistoryVisualComponent(_plotManager, controller, this, _coreShell);
            var commands        = new RPlotHistoryCommands(_plotManager.InteractiveWorkflow, visualComponent);

            controller.AddCommand(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Copy, commands.Copy);
            controller.AddCommand(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Cut, commands.Cut);
            controller.AddCommand(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Delete, commands.Remove);
            controller.AddCommand(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotHistoryActivatePlot, commands.ActivatePlot);
            controller.AddCommand(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotHistoryZoomIn, commands.ZoomIn);
            controller.AddCommand(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotHistoryZoomOut, commands.ZoomOut);
            controller.AddCommand(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotHistoryAutoHide, commands.AutoHide);
            Component      = visualComponent;
            _commandTarget = new CommandTargetToOleShim(null, Component.Controller);
            base.OnCreate();
        }
Ejemplo n.º 4
0
        public async Task HistoryZoom()
        {
            using (_workflow.Plots.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                var historyVC       = _workflow.Plots.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                // Default is 96, and minimum is 48, so we are able to zoom out once
                historyCommands.ZoomOut.Should().BeEnabled();
                await historyCommands.ZoomOut.InvokeAsync();

                historyCommands.ZoomOut.Should().BeDisabled();

                historyCommands.ZoomIn.Should().BeEnabled();
                await historyCommands.ZoomIn.InvokeAsync();

                historyCommands.ZoomOut.Should().BeEnabled();
            }
        }
Ejemplo n.º 5
0
        public async Task HistoryCopy()
        {
            using (_plotManager.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(1:10)",
                });

                var historyVC       = _plotManager.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                var device1   = _plotManager.ActiveDevice;
                var device1VC = _plotManager.GetPlotVisualComponent(device1);
                var plot1     = device1.ActivePlot;

                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(2:10)",
                });

                var device2         = _plotManager.ActiveDevice;
                var device2VC       = _plotManager.GetPlotVisualComponent(device2);
                var device2Commands = new RPlotDeviceCommands(_workflow, device2VC);
                var plot2           = device2.ActivePlot;

                historyVC.SelectedPlots = new[] { plot1 };

                historyCommands.Copy.Should().BeEnabled();
                await historyCommands.Copy.InvokeAsync();

                _ui.LastShownErrorMessage.Should().BeNullOrEmpty();

                device2Commands.Paste.Should().BeEnabled();
                var plotReceivedTask = EventTaskSources.IRPlotDevice.PlotAddedOrUpdated.Create(device2);
                await device2Commands.Paste.InvokeAsync();

                await plotReceivedTask;

                _ui.LastShownErrorMessage.Should().BeNullOrEmpty();

                var bs = device2.ActivePlot.Image as BitmapSource;
                bs.Should().HaveSamePixels(plot1.Image as BitmapSource);
            }
        }
Ejemplo n.º 6
0
        public async Task HistoryAutoHide()
        {
            using (_workflow.Plots.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                var historyVC       = _workflow.Plots.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                historyVC.AutoHide = false;
                historyCommands.AutoHide.Should().BeVisibleAndEnabled();
                historyCommands.AutoHide.Should().BeUnchecked();

                await historyCommands.AutoHide.InvokeAsync();

                historyVC.AutoHide.Should().BeTrue();
                historyCommands.AutoHide.Should().BeVisibleAndEnabled();
                historyCommands.AutoHide.Should().BeChecked();

                await historyCommands.AutoHide.InvokeAsync();

                historyVC.AutoHide.Should().BeFalse();
                historyCommands.AutoHide.Should().BeVisibleAndEnabled();
                historyCommands.AutoHide.Should().BeUnchecked();
            }
        }