コード例 #1
0
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            IDigitalInkDevice device = sender as IDigitalInkDevice;

            if (device == null)
            {
                return;
            }

            TextBlock textBlock = null;

            switch (device.TransportProtocol)
            {
            case TransportProtocol.BLE:
                textBlock = tbBle;
                break;

            case TransportProtocol.USB:
                textBlock = tbUsb;
                break;

            case TransportProtocol.BTC:
                textBlock = tbBtc;
                break;
            }

            var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                textBlock.Text = AppObjects.GetStringForDeviceStatus(e.Status);
            });
        }
コード例 #2
0
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var ignore = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                switch (e.Status)
                {
                case DeviceStatus.Idle:
                    textBlockStatus.Text         = AppObjects.GetStringForDeviceStatus(e.Status);
                    buttonFileTransfer.IsEnabled = true;
                    buttonRealTime.IsEnabled     = true;
                    break;

                case DeviceStatus.ExpectingConnectionConfirmation:
                    textBlockStatus.Text         = AppObjects.GetStringForDeviceStatus(e.Status);
                    buttonFileTransfer.IsEnabled = false;
                    buttonRealTime.IsEnabled     = false;
                    break;

                case DeviceStatus.NotAuthorizedConnectionNotConfirmed:
                    await new MessageDialog(AppObjects.GetStringForDeviceStatus(e.Status)).ShowAsync();
                    Frame.Navigate(typeof(ScanAndConnectPage));
                    break;

                default:
                    textBlockStatus.Text = AppObjects.GetStringForDeviceStatus(e.Status);
                    break;
                }
            });
        }
 private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
 {
     var ignore = Task.Run(() =>
     {
         tbBle.Text = AppObjects.GetStringForDeviceStatus(e.Status); // FIX: make a switch on the transport protocol to switch the message for each text boxF
     });
 }
コード例 #4
0
        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)
            {
            }
        }
コード例 #5
0
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            buttonScan.IsEnabled         = false;
            buttonFileTransfer.IsEnabled = false;
            buttonRealTime.IsEnabled     = false;

            if (AppObjects.Instance.DeviceInfo == null)
            {
                AppObjects.Instance.DeviceInfo = await AppObjects.DeserializeDeviceInfoAsync();
            }

            if (AppObjects.Instance.DeviceInfo == null)
            {
                textBlockDeviceName.Text = "Not connected to a device, click the \"Scan for Devices\" button and follow the instructions.";
                buttonScan.IsEnabled     = true;
                return;
            }

            InkDeviceInfo inkDeviceInfo = AppObjects.Instance.DeviceInfo;

            textBlockDeviceName.Text = $"Reconnecting to device {inkDeviceInfo.DeviceName} ({inkDeviceInfo.TransportProtocol}) ...";

            try
            {
                if (AppObjects.Instance.Device == null)
                {
                    AppObjects.Instance.Device = await InkDeviceFactory.Instance.CreateDeviceAsync(inkDeviceInfo, AppObjects.Instance.AppId, false, false, OnDeviceStatusChanged);
                }

                AppObjects.Instance.Device.Disconnected              += OnDeviceDisconnected;
                AppObjects.Instance.Device.DeviceStatusChanged       += OnDeviceStatusChanged;
                AppObjects.Instance.Device.PairingModeEnabledCallback = OnPairingModeEnabledAsync;
            }
            catch (Exception ex)
            {
                textBlockDeviceName.Text = $"Cannot init device: {inkDeviceInfo.DeviceName} [{ex.Message}]";
                buttonScan.IsEnabled     = true;
                return;
            }

            textBlockDeviceName.Text     = $"Current device: {inkDeviceInfo.DeviceName}";
            buttonFileTransfer.IsEnabled = true;
            buttonRealTime.IsEnabled     = true;
            buttonScan.IsEnabled         = true;

            textBlockStatus.Text = AppObjects.GetStringForDeviceStatus(AppObjects.Instance.Device.DeviceStatus);

            await DisplayDevicePropertiesAsync();
        }
コード例 #6
0
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var ignore = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                switch (e.Status)
                {
                case DeviceStatus.NotAuthorizedConnectionNotConfirmed:
                    await new MessageDialog(AppObjects.GetStringForDeviceStatus(e.Status)).ShowAsync();
                    Frame.Navigate(typeof(ScanAndConnectPage));
                    break;

                default:
                    textBlockPrompt.Text = AppObjects.GetStringForDeviceStatus(e.Status);
                    break;
                }
            });
        }