/// <summary> /// Use this for initialization /// </summary> virtual protected void Start() { pointsAdded = new PointsAdded(); EventManager.AddPointsAddedInvoker(this); blockDestroyed = new BlockDestroyed(); EventManager.AddBlockDestroyedInvoker(this); }
public void AddPoints(IEnumerable <Position> points) { _routePoints.AddRange(points); PointsAdded?.Invoke(this, new PointsAddedEventArgs { NewPoints = new List <Position>(points) }); }
public void AddPoint(Position point) { _routePoints.Add(point); PointsAdded?.Invoke(this, new PointsAddedEventArgs { NewPoints = new List <Position>(new[] { point }) }); }
/// <summary> /// Use this for initialization /// </summary> virtual protected void Start() { // scoring support pointsAdded = new PointsAdded(); EventManager.AddPointsAddedInvoker(this); // destruction support blockDestroyed = new BlockDestroyed(); EventManager.AddBlockDestroyedInvoker(this); }
public override void OnMoved(UIElement uiElement, PointerRoutedEventArgs args) { InkBuilder.AddPointsFromEvent(Phase.Update, uiElement, args); Path = InkBuilder.GetPath(); PointsAdded?.Invoke(this, null); }
public override void OnPressed(UIElement uiElement, PointerRoutedEventArgs args) { InkBuilder.AddPointsFromEvent(Phase.Begin, uiElement, args); Polygons = InkBuilder.GetPolygons(); PointsAdded?.Invoke(this, null); }
// -->> Aquire data <<-- // Subscribes to the notifications for the specefied characteristic // thus enabling the data acquisition //_________________________________________________________________ private async void acquireButton_Click(object sender, RoutedEventArgs e) { acquireButton.IsEnabled = false; if (!IsValueChangedHandlerRegistered) {// Not registered to notifications try { GattCharacteristic characteristic = selectedCharacteristic.Last(); GattCommunicationStatus result = await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync( GattClientCharacteristicConfigurationDescriptorValue.Notify); if (result == GattCommunicationStatus.Success) { characteristic.ValueChanged += Characteristic_ValueChanged; OnNewDataEnqueued += new ElementEnqueued(OnNewDataEnqueuedFxn); OnNewPointsAdded += new PointsAdded(OnNewPointsAddedFxn); IsValueChangedHandlerRegistered = true; acquireButton.Label = "Stop"; acquireButton.Icon = new SymbolIcon(Symbol.Stop); stopwatch.Start(); } else { rootPage.notifyFlyout("Error acquiring! " + result.ToString(), acquireButton); } } catch (Exception ex) //(UnauthorizedAccessException ex) { rootPage.notifyFlyout("Can't subscribe to notifications: " + ex.Message, acquireButton); } } else {// Unregister for notifications GattCharacteristic characteristic = selectedCharacteristic.Last(); characteristic.ValueChanged -= Characteristic_ValueChanged; OnNewDataEnqueued -= OnNewDataEnqueuedFxn; OnNewPointsAdded -= OnNewPointsAddedFxn; IsValueChangedHandlerRegistered = false; acquireButton.Label = "Acquire"; acquireButton.Icon = new FontIcon { Glyph = "\uE9D9" }; } acquireButton.IsEnabled = true; #region //Code for direct reading /*GattReadResult result = null; * try * { * result = await selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached); * } * catch (Exception ex) * { * notifyFlyout("Acquiring failed! " + ex.Message); * } * * if (result.Status == GattCommunicationStatus.Success) * { * byte[] data; * CryptographicBuffer.CopyToByteArray(result.Value, out data); * dataTextBlock.Text = BitConverter.ToInt32(data, 0).ToString(); * } * else * { * notifyFlyout("Acquiring failed"); * }*/ #endregion }