Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public void Remove(IRPlot plot) {
            _plots.Remove(plot);

            PlotCount = _plots.Count;
            if (ActiveIndex >= PlotCount) {
                ActiveIndex = PlotCount - 1;
            }

            PlotRemoved?.Invoke(this, new RPlotEventArgs(plot));
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        public void Remove(IRPlot plot)
        {
            _plots.Remove(plot);

            PlotCount = _plots.Count;
            if (ActiveIndex >= PlotCount)
            {
                ActiveIndex = PlotCount - 1;
            }

            PlotRemoved?.Invoke(this, new RPlotEventArgs(plot));
        }
Ejemplo n.º 6
0
        public void SelectEntry(IRPlot plot)
        {
            _mainThread.Assert();

            foreach (var entry in Entries)
            {
                if (entry.Plot == plot)
                {
                    SelectedPlot = entry;
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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);
            });
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
 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));
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
 public RPlotEventArgs(IRPlot plot) {
     Plot = plot;
 }
Ejemplo n.º 15
0
 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));
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
 public Task ExportToPdfAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight) =>
     ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportToPdfAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight));
Ejemplo n.º 18
0
        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);
            });
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
 public void SelectEntry(IRPlot plot)
 {
 }
Ejemplo n.º 21
0
 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);
     }
 }
Ejemplo n.º 22
0
 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));
Ejemplo n.º 23
0
 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));
Ejemplo n.º 24
0
 public Task ExportToPdfAsync(IRPlot plot, string outputFilePath, double inchWidth, double inchHeight) =>
 ExportAsync(outputFilePath, _interactiveWorkflow.RSession.ExportToPdfAsync(plot.ParentDevice.DeviceId, plot.PlotId, outputFilePath, inchWidth, inchHeight));
Ejemplo n.º 25
0
 protected virtual Task InvokeAsync(IRPlot plot) => Task.CompletedTask;
Ejemplo n.º 26
0
        public void SelectEntry(IRPlot plot) {
            _shell.AssertIsOnMainThread();

            foreach (var entry in Entries) {
                if (entry.Plot == plot) {
                    SelectedPlot = entry;
                    break;
                }
            }
        }
 public void SelectEntry(IRPlot plot) {
 }
Ejemplo n.º 28
0
 protected override Task InvokeAsync(IRPlot plot) => InteractiveWorkflow.Plots.RemovePlotAsync(plot);
Ejemplo n.º 29
0
 public RPlotEventArgs(IRPlot plot)
 {
     Plot = plot;
 }