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); }
public virtual Task Plot(PlotMessage plot, CancellationToken ct) { if (PlotHandler != null) { PlotHandler(plot); return Task.CompletedTask; } throw new NotImplementedException(); }
public virtual Task Plot(PlotMessage plot, CancellationToken ct) { if (PlotHandler != null) { PlotHandler(plot); return(Task.CompletedTask); } throw new NotImplementedException(); }
/// <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); }
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)); }
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); } }
Task IRCallbacks.Plot(PlotMessage plot, CancellationToken ct) { var callback = _callback; return(callback != null?callback.Plot(plot, ct) : Task.CompletedTask); }
public Task Plot(PlotMessage plot, CancellationToken ct) { PlotResult = plot.Data; return(Task.CompletedTask); }
public Task Plot(PlotMessage plot, CancellationToken ct) => Task.CompletedTask;
public static BitmapImage ToBitmapImage(this PlotMessage plot) { return(BitmapImageFactory.Load(plot.FilePath)); }
public Task Plot(PlotMessage plot, CancellationToken ct) => Task.CompletedTask;
public static BitmapImage ToBitmapImage(this PlotMessage plot) { return(BitmapImageFactory.Load(new MemoryStream(plot.Data))); }
public Task Plot(PlotMessage plot, CancellationToken ct) { PlotCalls.Add(new Tuple<PlotMessage, CancellationToken>(plot, ct)); return PlotHandler != null ? PlotHandler(plot, ct) : Task.CompletedTask; }
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)); }
public Task Plot(PlotMessage plot, CancellationToken ct) { PlotCalls.Add(new Tuple <PlotMessage, CancellationToken>(plot, ct)); return(Task.CompletedTask); }
/// <summary> /// Displays R plot in the host app-provided window /// </summary> public Task Plot(PlotMessage plot, CancellationToken ct) => _workflow.Plots.LoadPlotAsync(plot, ct);
/// <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); }