public void ClickPlot(int pixelX, int pixelY) { _shell.AssertIsOnMainThread(); if (LocatorMode) { var result = LocatorResult.CreateClicked(pixelX, pixelY); EndLocatorMode(result); } }
public void ClickPlot(int pixelX, int pixelY) { _mainThread.Assert(); if (LocatorMode) { var result = LocatorResult.CreateClicked(pixelX, pixelY); _plotManager.EndLocatorMode(_device, result); } }
public LocatorResult Next() { if (_index < _points.Length) { var res = LocatorResult.CreateClicked(_points[_index].X, _points[_index].Y); _index++; return(res); } return(LocatorResult.CreateNotClicked()); }
public void EndLocatorMode(IRPlotDevice device, LocatorResult result) { device.LocatorMode = false; var tcs = _locatorTcs; _locatorTcs = null; tcs?.TrySetResult(result); _locatorCancelTokenRegistration.Dispose(); }
public async Task <LocatorResult> Locator(CancellationToken ct) { var historyProvider = _coreShell.ExportProvider.GetExportedValue <IPlotHistoryProvider>(); var history = historyProvider.GetPlotHistory(_session); if (history.PlotContentProvider.Locator != null) { return(await history.PlotContentProvider.Locator.StartLocatorModeAsync(ct)); } return(LocatorResult.CreateNotClicked()); }
private void RootContainer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_locatorTcs != null) { var rootContainer = (FrameworkElement)sender; var pos = e.GetPosition(rootContainer); var pixelSize = WpfUnitsConversion.ToPixels(rootContainer as Visual, pos); var result = LocatorResult.CreateClicked((int)pixelSize.X, (int)pixelSize.Y); EndLocatorMode(result); } }
public void EndLocatorMode(LocatorResult result) { _shell.AssertIsOnMainThread(); var tcs = _locatorTcs; _locatorTcs = null; tcs?.SetResult(result); LocatorMode = false; LocatorModeChanged?.Invoke(this, EventArgs.Empty); _device.LocatorMode = LocatorMode; }
public Task <LocatorResult> Locator(Guid deviceId, CancellationToken ct) { LocatorCalls.Add(ct); return(LocatorHandler != null?LocatorHandler(deviceId, ct) : Task.FromResult(LocatorResult.CreateNotClicked())); }
Task <LocatorResult> IRCallbacks.Locator(Guid deviceId, CancellationToken ct) { var callback = _callback; return(callback != null?callback.Locator(deviceId, ct) : Task.FromResult(LocatorResult.CreateNotClicked())); }
public async Task LocatorCommand() { _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(360, 360, 96); await InitializeGraphicsDevice(); await ExecuteAndWaitForPlotsAsync(new[] { "plot(0:10)", }); var device = _plotManager.ActiveDevice; device.Should().NotBeNull(); var deviceVC = _plotManager.GetPlotVisualComponent(device); var deviceCommands = new RPlotDeviceCommands(_workflow, deviceVC); device.LocatorMode.Should().BeFalse(); deviceCommands.EndLocator.Should().BeInvisibleAndDisabled(); var firstLocatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device); var locatorTask = ExecuteAndDoNotWaitForPlotsAsync(new[] { "res <- locator()", }); await firstLocatorModeTask; var points = new Point[] { new Point(10, 10), new Point(100, 50), new Point(290, 90), }; // R's high-level locator() function enters a loop that calls into // the graphics device low-level locator() API, which calls back into VS // to set locator mode and waits for either: // - a result with a click point // - a not clicked result // The high-level locator() function stops its loop when it gets // the not clicked result. foreach (var point in points) { device.LocatorMode.Should().BeTrue(); deviceCommands.EndLocator.Should().BeEnabled(); // Send a result with a click point, which will causes // locator mode to end and immediately start again var locatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device); _plotManager.EndLocatorMode(device, LocatorResult.CreateClicked((int)point.X, (int)point.Y)); await locatorModeTask; device.LocatorMode.Should().BeFalse(); deviceCommands.EndLocator.Should().BeInvisibleAndDisabled(); locatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device); await locatorModeTask; } // Send a result with a not clicked result, which causes // locator mode to end, and the high-level locator() function // call will return. var lastLocatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device); await deviceCommands.EndLocator.InvokeAsync(); await lastLocatorModeTask; device.LocatorMode.Should().BeFalse(); deviceCommands.EndLocator.Should().BeInvisibleAndDisabled(); string outputFilePath = _testFiles.GetDestinationPath("LocatorResult.csv"); await ExecuteAndDoNotWaitForPlotsAsync(new[] { $"write.csv(res, {outputFilePath.ToRPath().ToRStringLiteral()})" }); var x = new double[] { -2.48008095952895, 1.55378525638498, 10.0697250455366 }; var y = new double[] { 14.4476461865435, 12.091623959219, 9.73560173189449 }; CheckLocatorResult(outputFilePath, x, y); await locatorTask; }
public void EndLocatorMode() { _shell.AssertIsOnMainThread(); EndLocatorMode(LocatorResult.CreateNotClicked()); }
public Task <LocatorResult> Locator(Guid deviceId, CancellationToken ct) => Task.FromResult(LocatorResult.CreateNotClicked());
public void EndLocatorMode() { EndLocatorMode(LocatorResult.CreateNotClicked()); }
public Task InvokeAsync() { InteractiveWorkflow.Plots.EndLocatorMode(VisualComponent.Device, LocatorResult.CreateNotClicked()); return(Task.CompletedTask); }
public Task <CommandResult> InvokeAsync() { InteractiveWorkflow.Plots.EndLocatorMode(VisualComponent.Device, LocatorResult.CreateNotClicked()); return(Task.FromResult(CommandResult.Executed)); }