private async void RealTimeInkPage_Loaded(object sender, RoutedEventArgs e)
        {
            IDigitalInkDevice device = AppObjects.Instance.Device;

            if (device == null)
            {
                textBlockPrompt.Text = "Device not connected";
                return;
            }

            device.Disconnected              += OnDeviceDisconnected;
            device.DeviceStatusChanged       += OnDeviceStatusChanged;
            device.PairingModeEnabledCallback = OnPairingModeEnabledAsync;

            IRealTimeInkService service = device.GetService(InkDeviceService.RealTimeInk) as IRealTimeInkService;

            service.NewPage            += OnNewPage;
            service.HoverPointReceived += OnHoverPointReceived;
            //service.StrokeStarted += Service_StrokeStarted;
            //service.StrokeEnded += Service_StrokeEnded;
            //service.StrokeUpdated += Service_StrokeUpdated;

            if (service == null)
            {
                textBlockPrompt.Text = "The Real-time Ink service is not supported on this device";
                return;
            }

            textBlockPrompt.Text = AppObjects.GetStringForDeviceStatus(device.DeviceStatus);

            try
            {
                uint width = (uint)await device.GetPropertyAsync("Width", m_cts.Token);

                uint height = (uint)await device.GetPropertyAsync("Height", m_cts.Token);

                uint ptSize = (uint)await device.GetPropertyAsync("PointSize", m_cts.Token);

                service.Transform = AppObjects.CalculateTransform(width, height, ptSize);

                float scaleFactor = ptSize * AppObjects.micrometerToDip;

                InkCanvasDocument document = new InkCanvasDocument();
                document.Size = new Windows.Foundation.Size(height * scaleFactor, width * scaleFactor);
                document.InkCanvasLayers.Add(new InkCanvasLayer());

                inkCanvas.InkCanvasDocument  = document;
                inkCanvas.GesturesManager    = new GesturesManager();
                inkCanvas.StrokeDataProvider = service;

                if (!service.IsStarted)
                {
                    await service.StartAsync(false, m_cts.Token);
                }
            }
            catch (Exception)
            {
            }
        }
        private async void RealTimeInkPage_Loaded(object sender, RoutedEventArgs e)
        {
            IDigitalInkDevice device = AppObjects.Instance.Device;

            device.Disconnected += OnDeviceDisconnected;

            NavigationService.Navigating += NavigationService_Navigating;
            NavigationService.Navigated  += NavigationService_Navigated;

            IRealTimeInkService service = device.GetService(InkDeviceService.RealTimeInk) as IRealTimeInkService;

            service.NewPage     += OnNewPage; //Clear page on new page or layer
            service.NewLayer    += OnNewPage;
            m_Canvas.DataContext = this;
            try
            {
                uint width = (uint)await device.GetPropertyAsync("Width", m_cts.Token);

                uint height = (uint)await device.GetPropertyAsync("Height", m_cts.Token);

                uint ptSize = (uint)await device.GetPropertyAsync("PointSize", m_cts.Token);


                m_deviceSize.Width  = width;
                m_deviceSize.Height = height;

                SetCanvasScaling();

                service.StrokeStarted      += Service_StrokeStarted;
                service.StrokeUpdated      += Service_StrokeUpdated;
                service.StrokeEnded        += Service_StrokeEnded;
                service.HoverPointReceived += Service_HoverPointReceived;;

                if (!service.IsStarted)
                {
                    await service.StartAsync(true, m_cts.Token);
                }
            }
            catch (Exception)
            {
            }
        }