private void UpdateMQTT(Grid parentGrid, TouchDevice touchDevice)
        {
            Point  position               = touchDevice.GetPosition(parentGrid);
            Rect   touchDeviceRect        = touchDevice.GetBounds(this);
            double?touchDeviceOrientation = touchDevice.GetOrientation(parentGrid);

            var message = new MQTT_SUR40_Message
            {
                Id   = touchDevice.Id,
                Type = GetTouchDeviceTypeString(touchDevice),

                X           = Math.Round(position.X, 2),
                Y           = Math.Round(position.Y, 2),
                Orientation = Math.Round(touchDeviceOrientation ?? 0.0, 2),

                Width  = Math.Round(touchDeviceRect.Width, 2),
                Height = Math.Round(touchDeviceRect.Height, 2)
            };

            if (touchDevice.GetTagData() != TagData.None)
            {
                message.TagSchema        = touchDevice.GetTagData().Schema.ToString("x8", CultureInfo.InvariantCulture);
                message.TagSeries        = touchDevice.GetTagData().Series.ToString("x16", CultureInfo.InvariantCulture);
                message.TagExtendedValue = touchDevice.GetTagData().ExtendedValue.ToString("x16", CultureInfo.InvariantCulture);
                message.TagValue         = touchDevice.GetTagData().Value.ToString("x16", CultureInfo.InvariantCulture);
            }

            MQTTClient.Instance.PublishMessage(message);
        }
        /// <summary>
        /// Update the bounding rectangle with the most recent touch device info. If a
        /// rectangle has not been created yet, create one.
        /// </summary>
        /// <param name="touchDevice">the touch device to diagram</param>
        /// <param name="showBoundingRectangle">Whether or not the rectangle should be shown</param>
        private void UpdateRectangle(TouchDevice touchDevice, bool showBoundingRectangle)
        {
            // Create an rectangle if one does not exist already.
            if (boundingRectangle == null)
            {
                // Make a new Rectangle
                boundingRectangle = new Rectangle();

                // Give the rectangle a fill.
                boundingRectangle.Fill = new SolidColorBrush(Color.FromArgb(0xFF, 0xE6, 0xE6, 0xE6));

                // Add the rectangle to the MainCanvas.
                MainCanvas.Children.Add(boundingRectangle);

                // Give the rectangle a lower ZIndex than everything else on the main canvas
                // so it is not drawn on top of anything else
                Canvas.SetZIndex(boundingRectangle, int.MinValue);
            }

            // Get the bounding rect for the touchDevice
            Rect touchDeviceRect = touchDevice.GetBounds(this);
            Rect bounds          = new Rect(touchDeviceRect.X, touchDeviceRect.Y, touchDeviceRect.Width, touchDeviceRect.Height);

            // Update the properties of boundingRectangle
            boundingRectangle.Height = bounds.Height;
            boundingRectangle.Width  = bounds.Width;
            Canvas.SetLeft(boundingRectangle, bounds.Left);
            Canvas.SetTop(boundingRectangle, bounds.Top);

            // Hide the rectangle if the user does not want to view bounding rectangles
            boundingRectangle.Visibility = showBoundingRectangle ? Visibility.Visible : Visibility.Hidden;
        }