Exemple #1
0
 public IPlotHistory GetPlotHistory(IRSession session)
 {
     if (_instance == null)
     {
         _instance = new PlotHistory(session);
     }
     return(_instance);
 }
        public void CopyPlotAsMetafile() {
            var history = new PlotHistory();
            var cmd = new CopyPlotAsMetafileCommand(history);

            cmd.CommandID.ID.Should().Be(RPackageCommandId.icmdCopyPlotAsMetafile);
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 1;
            cmd.Should().BeEnabled();
        }
        public void HistoryPrevious() {
            var history = new PlotHistory();
            var cmd = new HistoryPreviousPlotCommand(history);

            cmd.CommandID.ID.Should().Be(RPackageCommandId.icmdPrevPlot);
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 1;
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 2;
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 1;
            history.PlotCount = 2;
            cmd.Should().BeEnabled();
        }
        public async Task PlotALot() {
            var sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
            var app = new RHostClientPlotTestApp();
            using (var script = new RHostScript(sessionProvider, app)) {
                var history = new PlotHistory(script.Session);
                app.History = history;

                foreach (var c in _commands) {
                    using (var interaction = await script.Session.BeginInteractionAsync()) {
                        try {
                            await interaction.RespondAsync(c + Environment.NewLine);
                            EventsPump.DoEvents(100);
                        } catch (RException) { }
                    }
                }

                for (int i = _commands.Length - 1; i >= 0; i--) {
                    try {
                        await history.PlotContentProvider.PreviousPlotAsync();
                        EventsPump.DoEvents(100);
                    } catch (RException) { }
                }

                for (int i = 0; i < _commands.Length; i++) {
                    try {
                        await history.PlotContentProvider.NextPlotAsync();
                        EventsPump.DoEvents(500);
                    } catch (RException) { }
                }

                EventsPump.DoEvents(1000);
            }
        }
 public IPlotHistory GetPlotHistory(IRSession session) {
     if(_instance == null) {
         _instance = new PlotHistory(session);
     }
     return _instance;
 }
        public void ExportPlotAsImage() {
            var history = new PlotHistory();
            var cmd = new ExportPlotAsImageCommand(history);

            cmd.CommandID.ID.Should().Be(RPackageCommandId.icmdExportPlotAsImage);
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 1;
            cmd.Should().BeEnabled();
        }
        public void RemovePlot() {
            var history = new PlotHistory();
            var cmd = new RemovePlotCommand(history);

            cmd.CommandID.ID.Should().Be(RPackageCommandId.icmdRemovePlot);
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 1;
            cmd.Should().BeEnabled();
        }
        public void ClearAllPlots() {
            var history = new PlotHistory();
            var cmd = new ClearPlotsCommand(history);

            cmd.CommandID.ID.Should().Be(RPackageCommandId.icmdClearPlots);
            cmd.Should().BeDisabled();

            history.ActivePlotIndex = 0;
            history.PlotCount = 1;
            cmd.Should().BeEnabled();
        }