Пример #1
0
        private void EncodeCurrentStrokeCommon(string pointerDeviceType, InkBuilder inkBuilder, Style style)
        {
            // Create the ink input provider using the pointer device type
            InkInputProvider inkInputProvider = CreateAndAddInkProvider(pointerDeviceType);

            // Create the input device using EasClientDeviceInformation or any other class providing relevant info
            InputDevice inputDevice = CreateAndAddInputDevice();


            // Create the sensor context
            SensorContext sensorContext = CreateAndAddSensorContext(inkInputProvider, inputDevice);

            // Create the input context using the environment and the sensor context
            Identifier inputContextId = CreateAndAddInputContext(sensorContext.Id);

            // Create sensor data using the input context
            SensorData sensorData = new SensorData(
                Identifier.FromNewGuid(),
                inputContextId,
                Wacom.Ink.Serialization.InkState.Plane);

            // Get the sensor data from the ink builders
            List <PointerData> pointerDataList = inkBuilder.GetPointerDataList();

            // Fill the default channels with the sensor data
            FillDefaultChannels(sensorData, sensorContext, pointerDataList);

            InkDocument.SensorData.Add(sensorData);

            Spline spline = inkBuilder.SplineProducer.AllData;

            PathPointLayout layout = inkBuilder.Layout;

            Stroke stroke = new Stroke(
                Identifier.FromNewGuid(),
                spline.Clone(),
                style,
                layout,
                sensorData.Id);

            StrokeNode strokeNode = new StrokeNode(Identifier.FromNewGuid(), stroke);

            InkDocument.InkTree.Root.Add(strokeNode);
        }
 public override void OnReleased(UIElement uiElement, PointerRoutedEventArgs args)
 {
     InkBuilder.AddPointsFromEvent(Phase.End, uiElement, args);
     Path = InkBuilder.GetPath();
     DrawingFinished?.Invoke(this, BlendCurrentStroke);
 }
 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);
 }
 /// <summary>
 /// Passes pointer event to InkBuilder to finish building ink
 /// </summary>
 /// <param name="args">Arguments returned by pointer released event</param>
 /// <param name="uiElement">UI element associated with pointer event</param>
 public virtual void DoPointerReleased(PointerRoutedEventArgs args, UIElement uiElement)
 {
     InkBuilder.AddPointsFromEvent(Phase.End, uiElement, args);
 }