예제 #1
0
        private void FinalizeClient()
        {
            if (_client != null && _client.Alive)
            {
                _client.Disconnect();
            }

            _controller = null;
            _client     = null;
        }
예제 #2
0
        public MainPage()
        {
            this.InitializeComponent();

            ApplicationView.PreferredLaunchViewSize      = new Size(1024, 768);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            // create PenController instance.
            _controller = new PenController();

            // Create BluetoothPenClient instance. and bind PenController.
            // BluetoothPenClient is implementation of bluetooth function.
            _client = new BluetoothPenClient(_controller);

            // bluetooth watcher event
            _client.onAddPenController    += MClient_onAddPenController;
            _client.onRemovePenController += MClient_onRemovePenController;
            _client.onStopSearch          += MClient_onStopSearch;
            _client.onUpdatePenController += MClient_onUpdatePenController;

            // pen controller event
            _controller.PenStatusReceived       += MController_PenStatusReceived;
            _controller.Connected               += MController_Connected;
            _controller.Disconnected            += MController_Disconnected;
            _controller.Authenticated           += MController_Authenticated;
            _controller.DotReceived             += MController_DotReceived;
            _controller.PasswordRequested       += MController_PasswordRequested;
            _controller.OfflineDataListReceived += MController_OfflineDataListReceived;

            _controller.AutoPowerOffTimeChanged += MController_AutoPowerOffTimeChanged;
            _controller.AutoPowerOnChanged      += MController_AutoPowerOnChanged;
            _controller.BatteryAlarmReceived    += MController_BatteryAlarmReceived;
            _controller.RtcTimeChanged          += MController_RtcTimeChanged;
            _controller.SensitivityChanged      += MController_SensitivityChanged;
            _controller.PasswordChanged         += MController_PasswordChanged;
            _controller.BeepSoundChanged        += MController_BeepSoundChanged;
            _controller.PenColorChanged         += MController_PenColorChanged;

            _controller.OfflineDataDownloadStarted += MController_OfflineDataDownloadStarted;
            _controller.OfflineStrokeReceived      += MController_OfflineStrokeReceived;
            _controller.OfflineDownloadFinished    += MController_OfflineDownloadFinished;

            _controller.FirmwareInstallationStarted       += MController_FirmwareInstallationStarted;
            _controller.FirmwareInstallationStatusUpdated += MController_FirmwareInstallationStatusUpdated;
            _controller.FirmwareInstallationFinished      += MController_FirmwareInstallationFinished;

            InitColor();
            InitRenderer();
        }
예제 #3
0
 private async void MClient_onUpdatePenController(BluetoothPenClient sender, PenUpdateInformation args)
 {
     await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         var item = lvDevices.Items.Where(p => (p as PenInformation)?.Id == args.Id);
         if (item != null)
         {
             PenInformation penInformation = item as PenInformation;
             if (penInformation != null)
             {
                 penInformation.Update(args);
             }
         }
     });
 }
예제 #4
0
        private void InitPenClient()
        {
            // create PenController instance.
            _controller = new PenController();

            // Create BluetoothPenClient instance. and bind PenController.
            // BluetoothPenClient is implementation of bluetooth function.
            _client = new BluetoothPenClient(_controller);

            // bluetooth watcher event
            _client.onAddPenController    += MClient_onAddPenController;
            _client.onRemovePenController += MClient_onRemovePenController;
            _client.onStopSearch          += MClient_onStopSearch;
            _client.onUpdatePenController += MClient_onUpdatePenController;

            // pen controller event
            _controller.PenStatusReceived       += MController_PenStatusReceived;
            _controller.Connected               += MController_Connected;
            _controller.Disconnected            += MController_Disconnected;
            _controller.Authenticated           += MController_Authenticated;
            _controller.DotReceived             += MController_DotReceived;
            _controller.PasswordRequested       += MController_PasswordRequested;
            _controller.OfflineDataListReceived += MController_OfflineDataListReceived;

            _controller.AutoPowerOffTimeChanged += MController_AutoPowerOffTimeChanged;
            _controller.AutoPowerOnChanged      += MController_AutoPowerOnChanged;

            _controller.BatteryAlarmReceived += MController_BatteryAlarmReceived;
            _controller.RtcTimeChanged       += MController_RtcTimeChanged;
            _controller.SensitivityChanged   += MController_SensitivityChanged;
            _controller.PasswordChanged      += MController_PasswordChanged;
            _controller.BeepSoundChanged     += MController_BeepSoundChanged;
            _controller.PenColorChanged      += MController_PenColorChanged;

            _controller.OfflineDataDownloadStarted += MController_OfflineDataDownloadStarted;
            _controller.OfflineStrokeReceived      += MController_OfflineStrokeReceived;
            _controller.OfflineDownloadFinished    += MController_OfflineDownloadFinished;

            _controller.FirmwareInstallationStarted       += MController_FirmwareInstallationStarted;
            _controller.FirmwareInstallationStatusUpdated += MController_FirmwareInstallationStatusUpdated;
            _controller.FirmwareInstallationFinished      += MController_FirmwareInstallationFinished;

            _controller.PenProfileReceived += Mcontroller_PenProfileReceived;
        }
예제 #5
0
        public async Task SetUp()
        {
            FinalizeClient();

            await Task.Delay(1000);

            _controller = new PenController();

            _client = new BluetoothPenClient(_controller);

            TypedEventHandler <IPenClient, object> authenticated = new TypedEventHandler <IPenClient, object>((IPenClient sender, object obj) =>
            {
                _autoResetEvent.Set();
            });

            _controller.Authenticated += authenticated;

            TypedEventHandler <IPenClient, PasswordRequestedEventArgs> passwordRequested = new TypedEventHandler <IPenClient, PasswordRequestedEventArgs>((IPenClient sender, PasswordRequestedEventArgs args) =>
            {
                _controller.InputPassword(PASSWORD);
            });

            _controller.PasswordRequested += passwordRequested;

            _client.Connect(MAC).Wait();

            if (!_client.Alive)
            {
                Assert.Fail("connection failed");
                return;
            }

            _autoResetEvent.WaitOne();

            _controller.Authenticated     -= authenticated;
            _controller.PasswordRequested -= passwordRequested;
        }
예제 #6
0
 private async void MClient_onStopSearch(BluetoothPenClient sender, Windows.Devices.Bluetooth.BluetoothError args)
 {
     Debug.WriteLine("Watcher finidhed");
     await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => IsSearching = false);
 }
예제 #7
0
 private async void MClient_onAddPenController(BluetoothPenClient sender, PenInformation args)
 {
     await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => lvDevices.Items.Add(args));
 }