Example #1
0
        public Task LoadPlotAsync(PlotMessage plot)
        {
            if (VisualComponent != null)
            {
                if (plot.IsClearAll)
                {
                    VisualComponent.Clear();
                }
                else if (plot.IsPlot)
                {
                    try {
                        VisualComponent.LoadPlot(plot.ToBitmapImage());
                    } catch (Exception e) when(!e.IsCriticalException())
                    {
                        VisualComponent.Error();
                    }
                }
                else if (plot.IsError)
                {
                    VisualComponent.Error();
                }
            }

            ActivePlotIndex = plot.ActivePlotIndex;
            PlotCount       = plot.PlotCount;
            _interactiveWorkflow.ActiveWindow?.Container.UpdateCommandStatus(false);

            PlotChanged?.Invoke(this, null);

            return(Task.CompletedTask);
        }
Example #2
0
 public virtual Task Plot(PlotMessage plot, CancellationToken ct) {
     if (PlotHandler != null) {
         PlotHandler(plot);
         return Task.CompletedTask;
     }
     throw new NotImplementedException();
 }
Example #3
0
 public virtual Task Plot(PlotMessage plot, CancellationToken ct)
 {
     if (PlotHandler != null)
     {
         PlotHandler(plot);
         return(Task.CompletedTask);
     }
     throw new NotImplementedException();
 }
Example #4
0
        /// <summary>
        /// Displays R plot in the host app-provided window
        /// </summary>
        public async Task Plot(PlotMessage plot, CancellationToken ct)
        {
            var containerFactory = _coreShell.ExportProvider.GetExportedValue <IRPlotManagerVisualComponentContainerFactory>();
            var provider         = _coreShell.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>();
            var workflow         = provider.GetOrCreate();

            await _coreShell.SwitchToMainThreadAsync();

            workflow.Plots.GetOrCreateVisualComponent(containerFactory, 0).Container.Show(false);

            await workflow.Plots.LoadPlotAsync(plot);
        }
Example #5
0
        private void OnPlot(PlotMessage plot)
        {
            // We also store the original plot messages, so we can
            // validate that the files have been deleted when the host goes away
            OriginalPlotMessages.Add(plot);

            if (plot.FilePath.Length <= 0)
            {
                return;
            }

            // Make a copy of the plot file, and store the path to the copy
            // When the R code finishes executing, the graphics device is destructed,
            // which destructs all the plots which deletes the original plot files
            int index = PlotFilePaths.Count;

            PlotFilePaths.Add(SavePlotFile(plot.FilePath, index));
        }
Example #6
0
        public async Task LoadPlotAsync(PlotMessage plot, CancellationToken cancellationToken)
        {
            await _shell.SwitchToMainThreadAsync(cancellationToken);

            var device = FindDevice(plot.DeviceId);

            device.DeviceNum = plot.DeviceNum;

            if (plot.IsClearAll)
            {
                device.Clear();
            }
            else if (plot.IsPlot)
            {
                try {
                    var img = plot.ToBitmapImage();

                    // Remember the size of the last plot.
                    // We'll use that when exporting the plot to image/pdf.
                    device.PixelWidth  = img.PixelWidth;
                    device.PixelHeight = img.PixelHeight;
                    device.Resolution  = (int)Math.Round(img.DpiX);

                    device.AddOrUpdate(plot.PlotId, img);
                } catch (Exception e) when(!e.IsCriticalException())
                {
                }
            }
            else if (plot.IsError)
            {
                device.AddOrUpdate(plot.PlotId, null);
            }

            var visualComponent = GetVisualComponentForDevice(plot.DeviceId);

            if (visualComponent != null)
            {
                visualComponent.Container.Show(focus: false, immediate: false);
                visualComponent.Container.UpdateCommandStatus(false);
            }
        }
Example #7
0
        Task IRCallbacks.Plot(PlotMessage plot, CancellationToken ct)
        {
            var callback = _callback;

            return(callback != null?callback.Plot(plot, ct) : Task.CompletedTask);
        }
Example #8
0
 public Task Plot(PlotMessage plot, CancellationToken ct)
 {
     PlotResult = plot.Data;
     return(Task.CompletedTask);
 }
Example #9
0
 public Task Plot(PlotMessage plot, CancellationToken ct) => Task.CompletedTask;
Example #10
0
 public static BitmapImage ToBitmapImage(this PlotMessage plot)
 {
     return(BitmapImageFactory.Load(plot.FilePath));
 }
Example #11
0
 public Task Plot(PlotMessage plot, CancellationToken ct) => Task.CompletedTask;
Example #12
0
 public static BitmapImage ToBitmapImage(this PlotMessage plot)
 {
     return(BitmapImageFactory.Load(new MemoryStream(plot.Data)));
 }
Example #13
0
 public Task Plot(PlotMessage plot, CancellationToken ct) {
     PlotCalls.Add(new Tuple<PlotMessage, CancellationToken>(plot, ct));
     return PlotHandler != null ? PlotHandler(plot, ct) : Task.CompletedTask;
 }
Example #14
0
        private void OnPlot(PlotMessage plot) {
            // We also store the original plot messages, so we can 
            // validate that the files have been deleted when the host goes away
            OriginalPlotMessages.Add(plot);

            if (plot.FilePath.Length <= 0) {
                return;
            }

            // Make a copy of the plot file, and store the path to the copy
            // When the R code finishes executing, the graphics device is destructed,
            // which destructs all the plots which deletes the original plot files
            int index = PlotFilePaths.Count;
            PlotFilePaths.Add(SavePlotFile(plot.FilePath, index));
        }
Example #15
0
 public Task Plot(PlotMessage plot, CancellationToken ct)
 {
     PlotCalls.Add(new Tuple <PlotMessage, CancellationToken>(plot, ct));
     return(Task.CompletedTask);
 }
Example #16
0
 /// <summary>
 /// Displays R plot in the host app-provided window
 /// </summary>
 public Task Plot(PlotMessage plot, CancellationToken ct)
 => _workflow.Plots.LoadPlotAsync(plot, ct);
Example #17
0
        /// <summary>
        /// Displays R plot in the host app-provided window
        /// </summary>
        public async Task Plot(PlotMessage plot, CancellationToken ct)
        {
            await _coreShell.SwitchToMainThreadAsync();

            await _workflow.Plots.LoadPlotAsync(plot);
        }