Ejemplo n.º 1
0
        private void AddNewFlic()
        {
            var scanWizard = new ScanWizard();

            scanWizard.FoundPrivateButton += ScanWizard_FoundPrivateButton;
            scanWizard.FoundPublicButton  += ScanWizard_FoundPublicButton;
            scanWizard.ButtonConnected    += ScanWizard_ButtonConnected;
            scanWizard.Completed          += ScanWizard_Completed;
            _flicClient.AddScanWizard(scanWizard);
        }
Ejemplo n.º 2
0
        private void btnAddNewFlic_Click(object sender, EventArgs e)
        {
            if (_currentScanWizard == null)
            {
                lblScanWizardStatus.Text = "Press your Flic button";

                var scanWizard = new ScanWizard();
                scanWizard.FoundPrivateButton += (o, args) => Invoke((MethodInvoker) delegate
                {
                    lblScanWizardStatus.Text = "Hold down your Flic button for 7 seconds";
                });
                scanWizard.FoundPublicButton += (o, args) => Invoke((MethodInvoker) delegate
                {
                    lblScanWizardStatus.Text = "Found button " + args.BdAddr.ToString() + ", now connecting...";
                });
                scanWizard.ButtonConnected += (o, args) => Invoke((MethodInvoker) delegate
                {
                    lblScanWizardStatus.Text = "Connected to " + args.BdAddr.ToString() + ", now pairing...";
                });
                scanWizard.Completed += (o, args) => Invoke((MethodInvoker) delegate
                {
                    lblScanWizardStatus.Text = "Result: " + args.Result;
                    _currentScanWizard       = null;
                    btnAddNewFlic.Text       = "Add new Flic";
                });

                _flicClient.AddScanWizard(scanWizard);

                _currentScanWizard = scanWizard;
                btnAddNewFlic.Text = "Cancel";
            }
            else
            {
                _flicClient.CancelScanWizard(_currentScanWizard);
            }
        }