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 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); } }