Beispiel #1
0
        private void lbDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox   lbEvent = sender as ListBox;
            PenDevice dev     = lbEvent.SelectedItem as PenDevice;

            txtMacAddress.Text = dev.address;
        }
        // The PointerEnter event will get fired as soon as Pointer input is received.
        // This event handler implementation will query the device providing input to see if it's a pen and
        // then check to see the pen supports tactile feedback
        private void MainGrid_Entered(object sender, PointerRoutedEventArgs e)
        {
            // If the current Pointer device is not a pen, exit
            if (e.Pointer.PointerDeviceType != PointerDeviceType.Pen)
            {
                return;
            }

            // Attempt to retrieve the PenDevice from the current PointerId
            penDevice = PenDevice.GetFromPointerId(e.Pointer.PointerId);

            // If a PenDevice cannot be retrieved based on the PointerId, it does not support
            // advanced pen features, such as tactile feedback
            if (penDevice == null)
            {
                statusText.Text = "Advanced pen features not supported";
                return;
            }

            // Check to see if the current PenDevice supports tactile feedback by seeing if it
            // has a SimpleHapticsController
            hapticsController = penDevice.SimpleHapticsController;
            if (hapticsController == null)
            {
                statusText.Text = "This pen does not provide tactile feedback";
                return;
            }
        }
Beispiel #3
0
 public RazorViewTopLevelImpl(AvaloniaView avaloniaView)
 {
     _avaloniaView             = avaloniaView;
     TransparencyLevel         = WindowTransparencyLevel.None;
     AcrylicCompensationLevels = new AcrylicPlatformCompensationLevels(1, 1, 1);
     _touchDevice = new TouchDevice();
     _penDevice   = new PenDevice();
 }
Beispiel #4
0
 // Stop sending the tactile feedback and clear the current penDevice and hapticsController on PointerExit.
 // Stopping the feedback is important as it clears the tactile signal from the PenDevice's
 // SimpleHapticsController, ensuring that it has a clean state once it next enters range.
 private void MovableRect_Exited(object sender, PointerRoutedEventArgs e)
 {
     penDevice       = null;
     statusText.Text = "";
     if (hapticsController != null)
     {
         hapticsController.StopFeedback();
         hapticsController = null;
     }
 }
Beispiel #5
0
        // The PointerEnter event will get fired as soon as Pointer input is received.
        // This event handler implementation will query the device providing input to see if it's a pen and
        // then check to see the pen supports tactile feedback and, if so, configure the PenDevice
        // to send the appropriate tactile signal based on what is selected in the dropdown.
        private void HapticCanvas_Entered(object sender, PointerRoutedEventArgs e)
        {
            // If the current Pointer device is not a pen, exit
            if (e.Pointer.PointerDeviceType != PointerDeviceType.Pen)
            {
                return;
            }

            // Attempt to retrieve the PenDevice from the current PointerId
            penDevice = PenDevice.GetFromPointerId(e.Pointer.PointerId);

            // If a PenDevice cannot be retrieved based on the PointerId, it does not support
            // advanced pen features, such as tactile feedback
            if (penDevice == null)
            {
                statusText.Text = "Advanced pen features not supported";
                return;
            }

            // Check to see if the current PenDevice supports tactile feedback by seeing if it
            // has a SimpleHapticsController
            hapticsController = penDevice.SimpleHapticsController;
            if (hapticsController == null)
            {
                statusText.Text = "This pen does not provide tactile feedback";
                return;
            }

            // Get feedback based on the user's selected waveform
            currentFeedback = GetSelectedFeedbackOrFallback(out string message);

            // Send the current feedback to the PenDevice's SimpleHapticsController.
            // Once sent, inking tactile feedback will be triggered as soon as the pen tip touches
            // the screen and will be stopped once the pen tip is lifted from the screen.
            // Also, check to see if the current PenDevice's SimpleHapticsController supports
            // setting the intensity value of the tactile feedback.  If so, set it based
            // on the slider.  If not, send the waveform without custom intensity.
            if (hapticsController.IsIntensitySupported)
            {
                hapticsController.SendHapticFeedback(currentFeedback, intensitySlider.Value / 100);
                message += "\nIntensity set to " + intensitySlider.Value + "%";
            }
            else
            {
                hapticsController.SendHapticFeedback(currentFeedback);
                message += "\nSetting intensity is not supported by this pen";
            }
            statusText.Text = message;
        }
Beispiel #6
0
        // The PointerEnter event will get fired as soon as Pointer input is received in the movableRect.
        // This event handler implementation will query the device providing input to see if it's a pen and
        // then check to see the pen supports tactile feedback and, if so, configure the PenDevice
        // to send the InkContinuous tactile signal.
        private void MovableRect_Entered(object sender, PointerRoutedEventArgs e)
        {
            // If the current Pointer device is not a pen, exit
            if (e.Pointer.PointerDeviceType != PointerDeviceType.Pen)
            {
                return;
            }

            // Attempt to retrieve the PenDevice from the current PointerId
            penDevice = PenDevice.GetFromPointerId(e.Pointer.PointerId);

            // If a PenDevice cannot be retrieved based on the PointerId, it does not support
            // advanced pen features, such as tactile feedback
            if (penDevice == null)
            {
                statusText.Text = "Advanced pen features not supported";
                return;
            }

            // Check to see if the current PenDevice supports tactile feedback by seeing if it
            // has a SimpleHapticsController
            hapticsController = penDevice.SimpleHapticsController;
            if (hapticsController == null)
            {
                statusText.Text = "This pen does not provide tactile feedback";
                return;
            }

            // Send the InkContinuous waveform to the PenDevice's SimpleHapticsController.
            // Once sent, inking continuous tactile feedback will be triggered as soon as the pen tip touches
            // the screen and will be stopped once the pen tip is lifted from the screen.
            // Also, check to see if the current PenDevice's SimpleHapticsController supports
            // setting the intensity value of the tactile feedback.  If so, set it to 0.75.
            // If not, send the waveform with the default intensity.
            foreach (var waveform in hapticsController.SupportedFeedback)
            {
                if (waveform.Waveform == KnownSimpleHapticsControllerWaveforms.InkContinuous)
                {
                    if (hapticsController.IsIntensitySupported)
                    {
                        hapticsController.SendHapticFeedback(waveform, 0.75);
                    }
                    else
                    {
                        hapticsController.SendHapticFeedback(waveform);
                    }
                }
            }
        }
Beispiel #7
0
 /// <summary>
 /// 创建流程
 /// </summary>
 /// <param name="pen">学生设备</param>
 /// <param name="command">执行命令</param>
 public FlowItem(PenDevice pen, FlowCommand command)
 {
     this.StudentId = pen.StudentId;
     this.PenDevice = pen;
     this.Command   = command;
 }
        // The PointerEnter event will get fired as soon as Pointer input is received.
        // This event handler implementation will query the device providing input to see if it's a pen and
        // then check to see the pen supports tactile feedback and, if so, what features it supports
        private void Pointer_Entered(object sender, PointerRoutedEventArgs e)
        {
            // If the current Pointer device is not a pen, exit
            if (e.Pointer.PointerDeviceType != PointerDeviceType.Pen)
            {
                supportedFeatures.Text = "";
                supportedFeedback.Text = "";
                return;
            }

            // Attempt to retrieve the PenDevice from the current PointerId
            penDevice = PenDevice.GetFromPointerId(e.Pointer.PointerId);

            // If a PenDevice cannot be retrieved based on the PointerId, it does not support
            // advanced pen features, such as tactile feedback
            if (penDevice == null)
            {
                statusText.Text        = "Advanced pen features not supported";
                supportedFeatures.Text = "";
                supportedFeedback.Text = "";
                return;
            }

            // Check to see if the current PenDevice supports tactile feedback by seeing if it
            // has a SimpleHapticsController
            hapticsController = penDevice.SimpleHapticsController;
            if (hapticsController == null)
            {
                statusText.Text = "This pen does not provide tactile feedback";
                return;
            }

            // Check which tactile feedback features are supported
            supportedFeatures.Text = "Supported Haptics Features:\n";
            if (hapticsController.IsIntensitySupported)
            {
                supportedFeatures.Text += "Intensity\n";
            }
            if (hapticsController.IsPlayCountSupported)
            {
                supportedFeatures.Text += "PlayCount\n";
            }
            if (hapticsController.IsPlayDurationSupported)
            {
                supportedFeatures.Text += "PlayDuration\n";
            }
            if (hapticsController.IsReplayPauseIntervalSupported)
            {
                supportedFeatures.Text += "ReplayPauseInterval\n";
            }

            // Check which feedback waveforms are supported
            supportedFeedback.Text = "Supported Feedback:\n";
            foreach (SimpleHapticsControllerFeedback feedback in hapticsController.SupportedFeedback)
            {
                ushort waveform = feedback.Waveform;
                foreach (KeyValuePair <string, ushort> entry in MainPage.WaveformNamesMap)
                {
                    if (entry.Value == waveform)
                    {
                        supportedFeedback.Text += entry.Key + "\n";
                        break;
                    }
                }
            }
            statusText.Text = "";
        }
 // Clear the current penDevice and hapticsController on PointerExit
 private void Pointer_Exited(object sender, PointerRoutedEventArgs e)
 {
     penDevice         = null;
     hapticsController = null;
 }
Beispiel #10
0
        public UCTablet()
        {
            InitializeComponent();

            Loaded += (s, e) =>
            {
                drawingAttributes = new DrawingAttributes
                {
                    Color              = Colors.Black,
                    Width              = 0.9,
                    Height             = 0.9,
                    StylusTip          = StylusTip.Ellipse,
                    FitToCurve         = false,
                    StylusTipTransform = new Matrix(1, 1.5, 2.2, 1.0, 0.0, 0.0),
                    IsHighlighter      = false,
                    IgnorePressure     = false
                };
                inkPen.DefaultDrawingAttributes = drawingAttributes;

                mPen = PenController.Instance.GetPen(StudentId);
                if (mPen != null)
                {
                    mPen.HandlerWriteing += HandlerWriteing;
                    ShowHandwriting(mPen.GetPoints(), false);

                    mMainThread = new Thread(() =>
                    {
                        while (!App.IsExit)
                        {
                            List <PenPoint> points = new List <PenPoint>();
                            while (mRealtimeStacks.Count > 0)
                            {
                                try
                                {
                                    var point = mRealtimeStacks.Dequeue();
                                    if (point == null)
                                    {
                                        continue;
                                    }
                                    points.Add(point);
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                            if (points.Count > 0)
                            {
                                this.UICall(updateUI, points);
                            }
                            Thread.Sleep(1);
                        }
                    });
                    mMainThread.Start();
                }
                else
                {
                    PenLoaded?.Invoke(mPen, new EventArgs());
                }
            };
            Unloaded += (s, e) =>
            {
                Close();
            };
        }