private void AddOrUpdate(IRPlot plot, object plotImage) { _mainThread.Assert(); // Some error messages coming from the host may not have a plot id // associated with them. We never want to add a history entry in that case. if (plot.PlotId == Guid.Empty) { return; } var entry = Entries.SingleOrDefault(p => p.Plot.PlotId == plot.PlotId); if (entry != null) { // A null image means the plot couldn't be rendered. // This can happen if an existing plot was resized too small. // Don't overwrite the history image in this case, because the // existing image in history will be better than no image at all. if (plotImage != null) { entry.PlotImage = plotImage; } } else { Entries.Add(new RPlotHistoryEntryViewModel(_plotManager, _mainThread, plot, plotImage)); } OnPropertyChanged(nameof(ShowWatermark)); }
public void Remove(IRPlot plot) { _plots.Remove(plot); PlotCount = _plots.Count; if (ActiveIndex >= PlotCount) { ActiveIndex = PlotCount - 1; } PlotRemoved?.Invoke(this, new RPlotEventArgs(plot)); }
private async Task CopyPlotAsync(IRPlot sourcePlot, IRPlotDevice targetDevice) { await TaskUtilities.SwitchToBackgroundThread(); try { await InteractiveWorkflow.RSession.CopyPlotAsync(sourcePlot.ParentDevice.DeviceId, sourcePlot.PlotId, targetDevice.DeviceId); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
public async Task RemovePlotAsync(IRPlot plot) { await TaskUtilities.SwitchToBackgroundThread(); try { await _interactiveWorkflow.RSession.RemoveCurrentPlotAsync(plot.ParentDevice.DeviceId, plot.PlotId); plot.ParentDevice.Remove(plot); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
public void Remove(IRPlot plot) { _plots.Remove(plot); PlotCount = _plots.Count; if (ActiveIndex >= PlotCount) { ActiveIndex = PlotCount - 1; } PlotRemoved?.Invoke(this, new RPlotEventArgs(plot)); }
public void SelectEntry(IRPlot plot) { _mainThread.Assert(); foreach (var entry in Entries) { if (entry.Plot == plot) { SelectedPlot = entry; break; } } }
public RPlotHistoryEntryViewModel(IRPlotManager plotManager, IMainThread mainThread, IRPlot plot, object plotImage) { Check.ArgumentNull(nameof(plotManager), plotManager); Check.ArgumentNull(nameof(mainThread), mainThread); Check.ArgumentNull(nameof(plot), plot); Check.ArgumentNull(nameof(plotImage), plotImage); _plotManager = plotManager; _mainThread = mainThread; _plot = plot; _plotImage = plotImage; RefreshDeviceName(); }
public RPlotHistoryEntryViewModel(IRPlotManager plotManager, ICoreShell shell, IRPlot plot, BitmapImage plotImage) { if (plotManager == null) { throw new ArgumentNullException(nameof(plotManager)); } if (shell == null) { throw new ArgumentNullException(nameof(shell)); } if (plot == null) { throw new ArgumentNullException(nameof(plot)); } _plotManager = plotManager; _shell = shell; _plot = plot; _plotImage = plotImage; RefreshDeviceName(); }
public async Task ActivatePlotAsync(IRPlot plot) { InteractiveWorkflow.Shell.AssertIsOnMainThread(); if (HistoryVisualComponent != null) { if (HistoryVisualComponent.AutoHide) { HistoryVisualComponent.Container.Hide(); } } await TaskUtilities.SwitchToBackgroundThread(); try { await _interactiveWorkflow.RSession.SelectPlotAsync(plot.ParentDevice.DeviceId, plot.PlotId); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
private void Refresh(IRPlot plot) { _mainThread.Post(() => { if (plot != null) { PlotImage = plot.Image; ShowWatermark = false; ShowError = plot.Image == null; } else { PlotImage = null; ShowWatermark = true; ShowError = false; } DeviceNameChanged?.Invoke(this, EventArgs.Empty); PlotChanged?.Invoke(this, EventArgs.Empty); }); }
public RPlotHistoryEntryViewModel(IRPlotManager plotManager, ICoreShell shell, IRPlot plot, BitmapImage plotImage) { if (plotManager == null) { throw new ArgumentNullException(nameof(plotManager)); } if (shell == null) { throw new ArgumentNullException(nameof(shell)); } if (plot == null) { throw new ArgumentNullException(nameof(plot)); } _plotManager = plotManager; _shell = shell; _plot = plot; _plotImage = plotImage; RefreshDeviceName(); }
public Task ExportToBitmapAsync(IRPlot plot, string deviceName, string outputFilePath, int pixelWidth, int pixelHeight, int resolution) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportPlotToBitmapAsync(plot.ParentDevice.DeviceId, plot.PlotId, deviceName, outputFilePath, pixelWidth, pixelHeight, resolution));
public async Task ActivatePlotAsync(IRPlot plot) { InteractiveWorkflow.Shell.AssertIsOnMainThread(); if (HistoryVisualComponent != null) { if (HistoryVisualComponent.AutoHide) { HistoryVisualComponent.Container.Hide(); } } await TaskUtilities.SwitchToBackgroundThread(); try { await _interactiveWorkflow.RSession.SelectPlotAsync(plot.ParentDevice.DeviceId, plot.PlotId); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
public RPlotEventArgs(IRPlot plot) { Plot = plot; }
public Task ExportToMetafileAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight, int resolution) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportPlotToMetafileAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight, resolution));
public async Task RemovePlotAsync(IRPlot plot) { await TaskUtilities.SwitchToBackgroundThread(); try { await _interactiveWorkflow.RSession.RemoveCurrentPlotAsync(plot.ParentDevice.DeviceId, plot.PlotId); plot.ParentDevice.Remove(plot); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
public Task ExportToPdfAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportToPdfAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight));
private void Refresh(IRPlot plot) { _shell.DispatchOnUIThread(() => { if (plot != null) { PlotImage = plot.Image; ShowWatermark = false; ShowError = plot.Image == null; } else { PlotImage = null; ShowWatermark = true; ShowError = false; } DeviceNameChanged?.Invoke(this, EventArgs.Empty); PlotChanged?.Invoke(this, EventArgs.Empty); }); }
private void AddOrUpdate(IRPlot plot, BitmapImage plotImage) { _shell.AssertIsOnMainThread(); // Some error messages coming from the host may not have a plot id // associated with them. We never want to add a history entry in that case. if (plot.PlotId == Guid.Empty) { return; } var entry = Entries.SingleOrDefault(p => p.Plot.PlotId == plot.PlotId); if (entry != null) { // A null image means the plot couldn't be rendered. // This can happen if an existing plot was resized too small. // Don't overwrite the history image in this case, because the // existing image in history will be better than no image at all. if (plotImage != null) { entry.PlotImage = plotImage; } } else { Entries.Add(new RPlotHistoryEntryViewModel(_plotManager, _shell, plot, plotImage)); } OnPropertyChanged(nameof(ShowWatermark)); }
public void SelectEntry(IRPlot plot) { }
private async Task CopyPlotAsync(IRPlot sourcePlot, IRPlotDevice targetDevice) { await TaskUtilities.SwitchToBackgroundThread(); try { await InteractiveWorkflow.RSession.CopyPlotAsync(sourcePlot.ParentDevice.DeviceId, sourcePlot.PlotId, targetDevice.DeviceId); } catch (RException ex) { throw new RPlotManagerException(string.Format(CultureInfo.InvariantCulture, Resources.Plots_EvalError, ex.Message), ex); } }
public Task ExportToMetafileAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight, int resolution) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportPlotToMetafileAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight, resolution));
public Task ExportToBitmapAsync(IRPlot plot, string deviceName, string outputFilePath, int pixelWidth, int pixelHeight, int resolution) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportPlotToBitmapAsync(plot.ParentDevice.DeviceId, plot.PlotId, deviceName, outputFilePath, pixelWidth, pixelHeight, resolution));
public Task ExportToPdfAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight) => ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportToPdfAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight));
protected virtual Task InvokeAsync(IRPlot plot) => Task.CompletedTask;
public void SelectEntry(IRPlot plot) { _shell.AssertIsOnMainThread(); foreach (var entry in Entries) { if (entry.Plot == plot) { SelectedPlot = entry; break; } } }
public void SelectEntry(IRPlot plot) { }
protected override Task InvokeAsync(IRPlot plot) => InteractiveWorkflow.Plots.RemovePlotAsync(plot);
public RPlotEventArgs(IRPlot plot) { Plot = plot; }