Ejemplo n.º 1
0
        void showBTSettings()
        {
            var task = new ConnectionSettingsTask();
            task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
            task.Show();

        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Handles the network connection.
 /// </summary>
 private void HandleNetworkConnection()
 {
     NetworkDispatcher.IsConnected(connected =>
     {
         if (!connected)
         {
             Deployment.Current.Dispatcher.BeginInvoke(delegate
             {
                 var m = MessageBox.Show(AppResources.NetworkRequired, "", MessageBoxButton.OKCancel);
                 switch (m)
                 {
                     case MessageBoxResult.OK:
                     {
                         var cTask = new ConnectionSettingsTask
                         {
                             ConnectionSettingsType = ConnectionSettingsType.WiFi
                         };
                         cTask.Show();
                     }
                         break;
                     case MessageBoxResult.Cancel:
                         Application.Current.Terminate();
                         break;
                 }
             });
         }
     });
 }
Ejemplo n.º 3
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += MainPage_Loaded;
            connectionSettingsTask = new ConnectionSettingsTask();

            this.Tap += MainPage_Tap;
        }
 private void connectionSettings_Click(object sender, EventArgs e)
 {
     var task = new ConnectionSettingsTask
     {
         ConnectionSettingsType = ConnectionSettingsType.AirplaneMode,
     };
     task.Show();
 }
Ejemplo n.º 5
0
    public void showBluetoothSettings(string args)
    {
        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();

        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
        connectionSettingsTask.Show();
        DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
    }
Ejemplo n.º 6
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //if (NetworkInterface.GetIsNetworkAvailable())
            if (true)
            {
                await LoadData();
            }
            else
            {
                IAsyncResult result = Guide.BeginShowMessageBox(
                    AppResources.SplashScreen_OnNavigatedTo_No_Network,
                    AppResources.SplashScreen_OnNavigatedTo_No_network_details,
                    new string[] { "wifi", "3G/4G-LTE" },
                    0,
                    MessageBoxIcon.Error,
                    null,
                    null
                    );
                result.AsyncWaitHandle.WaitOne();

                int?choice = Guide.EndShowMessageBox(result);
                if (choice.HasValue)
                {
                    if (choice.Value == 0)
                    {
                        ConnectionSettingsTask con = new ConnectionSettingsTask();
                        con.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                        con.Show();
                    }
                    else
                    {
                        ConnectionSettingsTask con = new ConnectionSettingsTask();
                        con.ConnectionSettingsType = ConnectionSettingsType.Cellular;
                        con.Show();
                    }
                }
                else
                {
                    MessageBoxResult res = MessageBox.Show(AppResources.SplashScreen_OnNavigatedTo_OfflineModeQuestion,
                                                           AppResources.SplashScreen_OnNavigatedTo_Offline_Mode,
                                                           MessageBoxButton.OKCancel);
                    if (res == MessageBoxResult.Cancel)
                    {
                        StaticMethod.Quit();
                    }
                    else if (res == MessageBoxResult.OK)
                    {
                        StaticData.isOffline = true;
                        //Navigate to MainPage
                        MessageBox.Show("Voucher World required a working internet connection", "We are sorry",
                                        MessageBoxButton.OK);
                        StaticMethod.Quit();
                        //NavigationService.Navigate(new Uri("/PageGroups/KaraokeGroup/OfflinePage.xaml", UriKind.Relative));
                    }
                }
            }
            base.OnNavigatedTo(e);
        }
Ejemplo n.º 7
0
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            ConnectionSettingsTask cst = new ConnectionSettingsTask()
            {
                ConnectionSettingsType = ConnectionSettingsType.Bluetooth
            };

            cst.Show();
        }
Ejemplo n.º 8
0
        private void ShowBluetoothSettings()
        {
            ConnectionSettingsTask bluetoothSettingsTask = new ConnectionSettingsTask()
            {
                ConnectionSettingsType = ConnectionSettingsType.Bluetooth
            };

            bluetoothSettingsTask.Show();
        }
Ejemplo n.º 9
0
        private void connectionSettings_Click(object sender, EventArgs e)
        {
            var task = new ConnectionSettingsTask
            {
                ConnectionSettingsType = ConnectionSettingsType.AirplaneMode,
            };

            task.Show();
        }
Ejemplo n.º 10
0
        public MainPage()
        {
            InitializeComponent();

            MyPivot.SelectionChanged += MyPivot_SelectionChanged;

            abm.SetEvent(IconMenu.About, (sender, e) => { NavigationService.Navigate(new Uri("/Pages/AboutPage.xaml", UriKind.Relative)); });
            abm.SetEvent(IconMenu.WiFi, (sender, e) => { var task = new ConnectionSettingsTask { ConnectionSettingsType = ConnectionSettingsType.WiFi }; task.Show(); });
            abm.SetEvent(IconMenu.ControlPanel, (sender, e) => { ApplicationBar.IsVisible = false; cpm.Show(); });
        }
 public CountryDescription()
 {
     InitializeComponent();
     InitializeComponent();
     if (!DeviceNetworkInformation.IsNetworkAvailable)
     {
         ConnectionSettingsTask cst = new ConnectionSettingsTask();
         cst.ConnectionSettingsType = ConnectionSettingsType.WiFi;
         cst.Show();
     }
     client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
     client.OpenReadAsync(new Uri("http://localhost:23790/WebService/GetCountry?ID=1"), UriKind.Absolute);
 }
Ejemplo n.º 12
0
 private void leftButton_Click(object sender, RoutedEventArgs e)
 {
     if (wizard.SelectedItem == wizardItemWiFi)
     {
         ConnectionSettingsTask task = new ConnectionSettingsTask();
         task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
         task.Show();
     }
     else
     {
         Hide();
     }
 }
Ejemplo n.º 13
0
        private async void checkBluetooth()
        {
            SolidColorBrush statuscolor = new SolidColorBrush();

            try
            {
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
                var devices = await PeerFinder.FindAllPeersAsync();

                bluetoothStatus.Text       = "Online";
                statuscolor.Color          = Colors.Green;
                bluetoothStatus.Foreground = statuscolor;

                if (devices.Count == 0)
                {
                    MessageBox.Show("No paired bluetooth devices have been found, please pair with a bluetooth device!");
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));

                    var task = new ConnectionSettingsTask();
                    task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                    task.Show();
                }

                PeerInformation peerInfo = devices.FirstOrDefault(c => c.DisplayName.Contains(DeviceName.Text));
                DeviceName.Text = peerInfo.DisplayName;

                if (peerInfo == null)
                {
                    MessageBox.Show("No paired device please pair with a device!");
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                }


                await socket.ConnectAsync(peerInfo.HostName, "1");

                DeviceName.Text = peerInfo.ServiceName.ToString();

                await socket.ConnectAsync(peerInfo.HostName, peerInfo.ServiceName);
            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x8007048F)
                {
                    bluetoothStatus.Text       = "Offline";
                    statuscolor.Color          = Colors.Red;
                    bluetoothStatus.Foreground = statuscolor;
                }
            }
        }
Ejemplo n.º 14
0
        private async void checkBluetooth()
        {
            

            SolidColorBrush statuscolor = new SolidColorBrush();
            try
            {
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
                var devices = await PeerFinder.FindAllPeersAsync();
                bluetoothStatus.Text = "Online";
                statuscolor.Color = Colors.Green;
                bluetoothStatus.Foreground = statuscolor;

                if (devices.Count == 0)
                {
                    MessageBox.Show("No paired bluetooth devices have been found, please pair with a bluetooth device!");
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                    var task = new ConnectionSettingsTask();
            task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
            task.Show();
                }

                PeerInformation peerInfo = devices.FirstOrDefault(c => c.DisplayName.Contains(DeviceName.Text));
                DeviceName.Text = peerInfo.DisplayName;
                
                if (peerInfo == null)
                {
                    MessageBox.Show("No paired device please pair with a device!");
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                }

               
                await socket.ConnectAsync(peerInfo.HostName, "1");
                DeviceName.Text = peerInfo.ServiceName.ToString();

                await socket.ConnectAsync(peerInfo.HostName, peerInfo.ServiceName);


            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x8007048F)
                {
                    bluetoothStatus.Text = "Offline";
                    statuscolor.Color = Colors.Red;
                    bluetoothStatus.Foreground = statuscolor;
                }
            }
        }
        public AttractionsCities()
        {
            InitializeComponent(); if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask cst = new ConnectionSettingsTask();
                cst.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                cst.Show();
            }
            String countryName = PhoneApplicationService.Current.State["Country"].ToString();
            clientPlaces.OpenReadCompleted += new OpenReadCompletedEventHandler(clientCities_OpenReadCompleted);
            clientPlaces.OpenReadAsync(new Uri("http://pm.studentlive.pl/WebService/GetPlaces?country=" + countryName + "&start=0&count=20"), UriKind.Absolute);

            clientCountires.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            clientCountires.OpenReadAsync(new Uri("http://pm.studentlive.pl/WebService/GetCountries?start=0&count=20"), UriKind.Absolute);
        }
Ejemplo n.º 16
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask cst = new ConnectionSettingsTask();
                cst.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                cst.Show();
            }
            WebClient webclient = new WebClient();
            webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);

            webclient.DownloadStringAsync(new Uri("http://www.google.com/ig/api?weather=" + locationTextBox.Text)); // weather location

            CurrentWeather.Text = locationTextBox.Text + " weather forecast";
        }
Ejemplo n.º 17
0
        public AttractionsClass()
        {
            InitializeComponent();
            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask cst = new ConnectionSettingsTask();
                cst.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                cst.Show();
            }
            clientPlaces.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            clientPlaces.OpenReadAsync(new Uri("http://pm.studentlive.pl/WebService/GetCountries?start=0&count=20"), UriKind.Absolute);

            clientCountires.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            clientCountires.OpenReadAsync(new Uri("http://pm.studentlive.pl/WebService/GetCountries?start=0&count=20"), UriKind.Absolute);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Opens Bluetooth settings dialog.
        /// </summary>
        private void OpenBluetoothSettings()
        {
            try
            {
                PhoneApplicationService service = PhoneApplicationService.Current;
                service.Activated += this.OnResume;

                ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                connectionSettingsTask.Show();
                this.isBluetoothSettingsOpen = true;
            }
            catch (Exception)
            {
                this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unable to open Bluetooth settings"));
            }
        }
Ejemplo n.º 19
0
        private void ConnectivityProblem()
        {
            _dataContext.Communication.Stop();
            _dataContext.Communication.Start();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                MessageBoxResult r = MessageBox.Show("Would you like to make sure that Bluetooth has been turned on?", "Unable to connect", MessageBoxButton.OKCancel);

                if (r.HasFlag(MessageBoxResult.OK))
                {
                    ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                    connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                    connectionSettingsTask.Show();
                }
            });
        }
Ejemplo n.º 20
0
        public PanoramicMain()
        {
            InitializeComponent();
            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask cst = new ConnectionSettingsTask();
                cst.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                cst.Show();
            }
            WebClient client = new WebClient();
            if (watcher == null)
            {
                //---get the highest accuracy---
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                {
                    //---the minimum distance (in meters) to travel before the next
                    // location update---
                    MovementThreshold = 10
                };

                //---event to fire when a new position is obtained---
                watcher.PositionChanged += new
                EventHandler<GeoPositionChangedEventArgs
                <GeoCoordinate>>(watcher_PositionChanged);

                //---event to fire when there is a status change in the location
                // service API---
                watcher.StatusChanged += new
                EventHandler<GeoPositionStatusChangedEventArgs>
                (watcher_StatusChanged);
                watcher.Start();
            }

            map1.Center = new GeoCoordinate(51.10955, 17.037048);
            map1.ZoomBarVisibility = System.Windows.Visibility.Visible;
            String lat = map1.Center.Latitude.ToString();
            String lon = map1.Center.Longitude.ToString();
            lat = lat.Replace(",", ".");
            lon = lon.Replace(",", ".");

            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            client.OpenReadAsync(new Uri("http://pm.studentlive.pl/WebService/GetAttractionsByLatLng?lat=" + lat + "&lng=" + lon), UriKind.Absolute);

            map1.ZoomLevel = 12;
        }
Ejemplo n.º 21
0
        public void Show(string which)
        {
            var task = new ConnectionSettingsTask();

            switch (which)
            {
                case KnownSettings.Bluetooth:
                    task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                    break;
                case KnownSettings.Wifi:
                    task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                    break;
                default:
                    throw new NotSupportedException("Not supported " + which);
            }

            task.Show();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Asynchronous call to re-populate the ListBox of paired devices.
        /// </summary>
        private async void RefreshPairedDevicesList()
        {
            try {
                // Search for all paired devices
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
                var peers = await PeerFinder.FindAllPeersAsync();

                // By clearing the backing data, we are effectively clearing the ListBox
                _pairedDevices.Clear();

                if (peers.Count == 0)
                {
                    MessageBox.Show(AppResources.Msg_NoPairedDevices);
                }
                else
                {
                    // Found paired devices.
                    foreach (var peer in peers)
                    {
                        _pairedDevices.Add(new PairedDeviceInfo(peer));
                    }
                }
            } catch (Exception ex) {
                if ((uint)ex.HResult == 0x8007048F)
                {
                    var result = MessageBox.Show(AppResources.Msg_BluetoothOff, "Bluetooth Off", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        var connectionSettingsTask = new ConnectionSettingsTask {
                            ConnectionSettingsType = ConnectionSettingsType.Bluetooth
                        };
                        connectionSettingsTask.Show();
                    }
                }
                else if ((uint)ex.HResult == 0x80070005)
                {
                    MessageBox.Show(AppResources.Msg_MissingCaps);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 23
0
        private async void Settings_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
                var peers = await PeerFinder.FindAllPeersAsync();
                var displayNames = peers.Where(x => !string.IsNullOrEmpty(x.DisplayName)).Select(x => x.DisplayName).ToList();

                devices.ItemsSource = displayNames;

                // Need to handle the case when the device no longer is paired
                if (!displayNames.Contains(App.MainViewModel.SettingsViewModel.BluetoothDeviceName))
                {
                    App.MainViewModel.SettingsViewModel.BluetoothDeviceName = null;
                }
            }
            catch (Exception ex)
            {
                // Unable to connect to bluetooth, so just clear the value.
                App.MainViewModel.SettingsViewModel.BluetoothDeviceName = null;

                if ((uint)ex.HResult == ObdErrorCodes.ERR_BLUETOOTH_OFF)
                {
                    var result = MessageBox.Show("Bluetooth is turned off, would you like to see the current Bluetooth settings?", "Bluetooth Off", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                        connectionSettingsTask.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Unable to query for Bluetooth devices.\n" + ex.Message, "Error", MessageBoxButton.OK);
                }
            }
            finally
            {
                if (!App.RunningInEmulator)
                {
                    this.DataContext = App.MainViewModel;
                }
            }
        }
Ejemplo n.º 24
0
        private void leftButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = wizard.SelectedItem;

            if (selectedItem == wizardItemWiFi)
            {
                ConnectionSettingsTask task = new ConnectionSettingsTask();
                task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                task.Show();
            }
            else if (selectedItem == wizardItemHostnamePIN)
            {
                ConnectToServer();
            }
            else if (selectedItem == wizardItemConnecting)
            {
                // TODO: Cancel connection
            }
        }
Ejemplo n.º 25
0
        public override void OnClick()
        {
            string internalName = InternalName;

            if (internalName == "Bluetooth")
            {
                var task = new ConnectionSettingsTask();
                task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                task.Show();
            }
            else if (internalName == "Wifi")
            {
                var task = new ConnectionSettingsTask();
                task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                task.Show();
            }
            else if (internalName == "Phone")
            {
                //ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5602/Start");
                ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA561C/CallSettings");
            }
            else if (internalName == "Search")
            {
                ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5661/SearchHome?QuerySource=HardwareBtn");
            }
            else if (internalName == "BatterySaving")
            {
                ApplicationApi.LaunchSession("app://AFE91DD5-26FB-4ba6-A5A4-4BCEDE8FB3E6/_default");
            }
            else if (internalName == "DataConnection")
            {
                ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA561F/_default");
            }
            else if (internalName == "Accelerometer")
            {
                ApplicationApi.LaunchSession("app://126b3759-8034-4fff-b987-3c0c6f9136f3/_default");
            }
            else if (internalName == "InternetSharing")
            {
                ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5629/_default");
            }
        }
Ejemplo n.º 26
0
        public void Show(string which)
        {
            var task = new ConnectionSettingsTask();

            switch (which)
            {
            case KnownSettings.Bluetooth:
                task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                break;

            case KnownSettings.Wifi:
                task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                break;

            default:
                throw new NotSupportedException("Not supported " + which);
            }

            task.Show();
        }
Ejemplo n.º 27
0
        private void CheckNetwork()
        {
            IsSearchButtonEnabled = true;
            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                IsSearchButtonEnabled = false;

                var result = MessageBox.Show(
                    NetworkInterface.NetworkInterfaceType + AppResources.NetworkBlowUp,
                    AppResources.NoConnection,
                    MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.OK)
                {
                    var connectionSettingsTask = new ConnectionSettingsTask
                    {
                        ConnectionSettingsType = ConnectionSettingsType.WiFi
                    };
                    connectionSettingsTask.Show();
                }
            }
        }
Ejemplo n.º 28
0
 public override void OnClick()
 {
     string internalName = InternalName;
     if (internalName == "Bluetooth")
     {
         var task = new ConnectionSettingsTask();
         task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
         task.Show();
     }
     else if (internalName == "Wifi")
     {
         var task = new ConnectionSettingsTask();
         task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
         task.Show();
     }
     else if (internalName == "Phone")
     {
         //ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5602/Start");
         ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA561C/CallSettings");
     }
     else if (internalName == "Search")
     {
         ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5661/SearchHome?QuerySource=HardwareBtn");
     }
     else if (internalName == "BatterySaving")
     {
         ApplicationApi.LaunchSession("app://AFE91DD5-26FB-4ba6-A5A4-4BCEDE8FB3E6/_default");
     }
     else if (internalName == "DataConnection")
     {
         ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA561F/_default");
     }
     else if (internalName == "Accelerometer")
     {
         ApplicationApi.LaunchSession("app://126b3759-8034-4fff-b987-3c0c6f9136f3/_default");
     }
     else if (internalName == "InternetSharing")
     {
         ApplicationApi.LaunchSession("app://5B04B775-356B-4AA0-AAF8-6491FFEA5629/_default");
     }
 }
Ejemplo n.º 29
0
 private void WifiButton_OnClick(object sender, RoutedEventArgs e)
 {
     var connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 30
0
        public async void ConnectKreyosDevice(string p_device)
        {
            if (string.IsNullOrWhiteSpace(p_device))
            {
                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceDisconnected;
                info.Error   = "Error! Invalid device name!";
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceDisconnected, info);
                return;
            }

            var succ = await BluetoothAgent.Instance.Start(p_device);

            if (succ)
            {
                BluetoothAgent.Instance.InnerProtocol.OnElementParsed          += OnElementParsed;
                BluetoothAgent.Instance.InnerProtocol.OnFileReceived           += OnFileReceived;
                BluetoothAgent.Instance.InnerProtocol.OnDeviceIDRead           += OnDeviceIDRead;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataRead       += OnActivityDataRead;
                BluetoothAgent.Instance.InnerProtocol.OnSportsGridRead         += OnSportsGridRead;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataEnd        += OnActivityDataEnd;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataPrepared   += OnActivityDataPrepared;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataSync       += OnActivityDataSync;
                BluetoothAgent.Instance.InnerProtocol.OnFirmwareVersionRequest += OnFirmwareVersionRequest;

                BluetoothAgent.Instance.InnerProtocol.OnOverallActivitiesReceived += OnOverallActivitiesReceived;
                BluetoothAgent.Instance.InnerProtocol.OnTodayActivityReceived     += OnTodayActivityReceived;
                BluetoothAgent.Instance.InnerProtocol.OnSportsDataReceived        += OnSportsDataReceived;

                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceConnected;
                info.Device  = p_device;
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceConnected, info);
                return;
            }
            else
            {
                switch (BluetoothAgent.Instance.ConnectInfo)
                {
                case EBTConnect.BluetoothIsOff:
                {
                    var result = MessageBox.Show("Bluetooth is turned off. To see the current Bluetooth settings tap 'ok'", "Bluetooth Off", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        // TODO: Show the bluetooth control panel here
                        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                        connectionSettingsTask.Show();
                    }
                }
                break;

                case EBTConnect.CapPermission:
                {
                    MessageBox.Show("To run this app, you must have ID_CAP_PROXIMITY enabled in WMAppManifest.xaml");
                }
                break;
                }

                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceDisconnected;
                info.Error   = BluetoothAgent.Instance.ErrorMessage;
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceDisconnected, info);
            }
        }
Ejemplo n.º 31
0
 private void Toggle3G_Click(object sender, RoutedEventArgs e)
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Cellular;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 32
0
        public BingMaps()
        {
            InitializeComponent();
            if (!InternetIsAvailable())
            {
                //Service1Client objClient = new Service1Client();
                //objClient.WiFiCompleted += new EventHandler<WiFiCompletedEventArgs>(WIFiCall);
                //objClient.WiFiAsync();
                ConnectionSettingsTask task = new ConnectionSettingsTask();
                task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                task.Show();
            }
            if (watcher == null)
            {
                //---get the highest accuracy---
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                {
                    //---the minimum distance (in meters) to travel before the next
                    // location update---
                    MovementThreshold = 10
                };

                //---event to fire when a new position is obtained---
                watcher.PositionChanged += new
                EventHandler<GeoPositionChangedEventArgs
                <GeoCoordinate>>(watcher_PositionChanged);

                //---event to fire when there is a status change in the location
                // service API---
                watcher.StatusChanged += new
                EventHandler<GeoPositionStatusChangedEventArgs>
                (watcher_StatusChanged);
                watcher.Start();
            }
            map1.Center = new GeoCoordinate(47.676289396624654, -122.12096571922302);
            map1.ZoomBarVisibility = System.Windows.Visibility.Visible;

            map1.ZoomLevel = 15;
            for (int i = 0; i < 10; i++)
            {

                //---create a new pushpin---
                Pushpin pin = new Pushpin();

                //---set the location for the pushpin---
                pin.Location = new GeoCoordinate(47.676289396624654+i, -122.12096571922302+i);

                //---add the pushpin to the map---

                pin.Content = new Ellipse()
                {
                    Fill = image,

                    StrokeThickness = 10,
                    Height = 100,
                    Width = 100
                };
                pin.MouseLeftButtonUp += new MouseButtonEventHandler(Pushpin_MouseLeftButtonUp);

                //---add the pushpin to the map---
                map1.Children.Add(pin);
            }
        }
Ejemplo n.º 33
0
 public ConnectionSettingTaskPage()
 {
     InitializeComponent();
     //创建一个连接设置任务
     connectionSettingsTask = new ConnectionSettingsTask();
 }
 public static void ShowBluetoothControlPanel()
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 35
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ConnectionSettingsTask con = new ConnectionSettingsTask();

            con.Show();
        }
        private void OnOK()
        {
            bool bGoBack = true;

            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                connectionSettingsTask.Show();

                return;
            }

            if (m_AppInput != null)
            {
                string strRes = txSvrIP.Text;

                //NoEmpty...
                if (m_AppInput.GetFlag(1).Length > 0)
                {
                    strRes = strRes.Trim();

                    if (strRes.Length == 0)
                    {
                        MessageBox.Show("Value must not be empty!");
                        return;
                    }
                }

                /*
                 * //FileName...
                 * if( m_AppInput.GetFlag(1).Length > 0 )
                 * {
                 *      strRes = strRes.Trim();
                 *
                 *      string strChk = "\\/:*?\"<>|";
                 *      foreach( char cChk in strChk )
                 *      {
                 *              if( strRes.IndexOf( cChk ) >= 0 )
                 *              {
                 *                      MessageBox.Show("Value must not contain characters of '" + strChk + "'!");
                 *                      return;
                 *              }
                 *      }
                 * }
                 */

                bGoBack = false;

                if (RscUtils.IsIpAddress(strRes))
                {
                    /*
                     * MessageBox.Show("IP Address is not allowed here!");
                     * return;
                     */

                    DoOk();
                }
                else
                {
                    prsBar.Visibility = Rsc.Visible;

                    var endpoint = new DnsEndPoint(strRes, 0);
                    DeviceNetworkInformation.ResolveHostNameAsync(endpoint, OnHostResolved, null);
                }
            }

            if (bGoBack)
            {
                this.NavigationService.GoBack();
            }
        }
        private void ConnectivityProblem()
        {
            _dataContext.Communication.Stop();
            _dataContext.Communication.Start();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBoxResult r = MessageBox.Show("Would you like to make sure that Bluetooth has been turned on?", "Unable to connect", MessageBoxButton.OKCancel);

                    if (r.HasFlag(MessageBoxResult.OK))
                    {
                        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                        connectionSettingsTask.Show();
                    }
                });
        }
Ejemplo n.º 38
0
 private void ShowBluetoothcControlPanel()
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Opens Bluetooth settings dialog.
        /// </summary>
        private void OpenBluetoothSettings()
        {
            try
            {
                PhoneApplicationService service = PhoneApplicationService.Current;
                service.Activated += this.OnResume;

                ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                connectionSettingsTask.Show();
                this.isBluetoothSettingsOpen = true;
            }
            catch (Exception)
            {
                this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unable to open Bluetooth settings"));
            }
        }
Ejemplo n.º 40
0
        private void GetObdData()
        {
            if (App.RunningInEmulator &&
                this.progressIndicatorVisibility)
            {
                return;
            }

            Dispatcher.BeginInvoke(() =>
            {
                this.SetProgressIndicatorVisibility(true);
            });

            ThreadPool.QueueUserWorkItem(async (object state) =>
            {
                // If user changes the device name, null it out so that future calls will re-create the device.
                if (this.device != null &&
                    this.device.DisplayName != App.MainViewModel.SettingsViewModel.BluetoothDeviceName)
                {
                    this.device = null;
                }

                if (this.device == null)
                {
                    try
                    {
                        this.device = await this.service.GetObdDevice(App.MainViewModel.SettingsViewModel.BluetoothDeviceName);
                        if (this.device == null &&
                            this.RunningInForeground())
                        {
                            Dispatcher.BeginInvoke(() =>
                            {
                                MessageBox.Show("No OBD II devices found of name " + App.MainViewModel.SettingsViewModel.BluetoothDeviceName, "Error", MessageBoxButton.OK);
                                this.SetProgressIndicatorVisibility(false);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            this.SetProgressIndicatorVisibility(false);
                            if (this.RunningInForeground())
                            {
                                if ((uint)ex.HResult == ObdErrorCodes.ERR_BLUETOOTH_OFF)
                                {
                                    var result = MessageBox.Show("Bluetooth is turned off, would you like to see the current Bluetooth settings?", "Bluetooth Off", MessageBoxButton.OKCancel);
                                    if (result == MessageBoxResult.OK)
                                    {
                                        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                                        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                                        connectionSettingsTask.Show();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
                                }
                            }
                        });
                    }
                }

                if (this.device != null)
                {
                    try
                    {
                        ObdModel data = await this.service.GetObdData(this.device);
                        this.DisplayObdData(data);
                    }
                    catch (Exception ex)
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            this.SetProgressIndicatorVisibility(false);
                            if (this.RunningInForeground())
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
                            }
                        });
                    }
                }
            });
        }
Ejemplo n.º 41
0
        public bool networkCheck()
        {
            bool temp=DeviceNetworkInformation.IsNetworkAvailable;
            if (!temp)
            {
                MessageBoxResult r = MessageBox.Show("Internet Connectivity",
                    "Something isn't quite right here. I cant find the interwebs and this feature doesnt work without interwebs. Want me to take you to the WiFi's?",
                    MessageBoxButton.OKCancel);
                if (r == MessageBoxResult.OK)
                {
                    ConnectionSettingsTask launchWifi = new ConnectionSettingsTask();
                    launchWifi.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                    launchWifi.Show();
                    networkCheck();
                    temp = true;
                }
                else
                {
                    MessageBox.Show("If You Say So", "Whatever you say but this means the messaging feature will not enable", MessageBoxButton.OK);
                    temp = false;
                }
            }

            return temp;
        }
Ejemplo n.º 42
0
 /// <summary>
 /// 打开 WiFi / Bluetooth / Cellular / AirplaneMode 设置界面
 /// </summary>
 /// <param name="type">ConnectionSettingsType</param>
 public void OpenConnectionSetting(ConnectionSettingsType type)
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = type;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 43
0
 private void ToggleWifi_Click(object sender, RoutedEventArgs e)
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 44
0
        public static void OpenConnectionSettings()
        {
            var connection = new ConnectionSettingsTask();

            connection.Show();
        }
Ejemplo n.º 45
0
 private void ShowBluetoothControlPanel()
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
     connectionSettingsTask.Show();
 }
Ejemplo n.º 46
0
        private void m_AppFrame_OnNext(object sender, EventArgs e)
        {
            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                if (!DeviceNetworkInformation.IsCellularDataEnabled)
                {
                    ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                    connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                    connectionSettingsTask.Show();

                    return;
                }
                else
                {
                    MessageBox.Show("ATT: For security reasons and high amount of possible data FTP connection through the Internet and Public WiFi networks is not recommended!");
                }
            }

            m_AppFrame.ShowButtonNext(false);

            parPanel.Visibility = Rsc.Collapsed;

            if (chbAutoLogOn.IsChecked.Value)
            {
                btnLogUsr.Visibility = Rsc.Collapsed;
                btnLogPw.Visibility  = Rsc.Collapsed;
            }

            if (chbAutoPasv.IsChecked.Value)
            {
                btnPasv.Visibility = Rsc.Collapsed;
            }

            //lastFilePanel.Visibility = Rsc.Collapsed; //Rsc.Visible;
            SetLastFile("", false);

            pathPanel.Visibility    = Rsc.Visible;
            custCmdPanel.Visibility = Rsc.Visible;
            logPanel.Visibility     = Rsc.Visible;

            svrAddr.Text        = " ";
            svrTit.Text         = " ";
            svrPanel.Visibility = Rsc.Visible;

            //WP81 FIX
            //m_ftpc.SetFastConnection( chbFastConn.IsChecked.Value, chbFastConnEx.IsChecked.Value );

            NationalChrsToTestFileNames = "";
            if (chbNatFsNames.IsChecked.Value)
            {
                NationalChrsToTestFileNames = " (ÁáÉéÍíÓóÖöŐőÚúÜüŰű)";
            }

            sSAVE_Status = "";
            scSAVE       = StatusColoring.Normal;

            _Log("21", "Connecting...");

            SaveToReg();

            //unkLISTresLEN sign reset...
            m_AppFrame.TRACE = "";

            m_ftpc.CloseAllSockets();

            m_ftpc.IPAddress       = txSvrIP.Text.ToString();
            m_ftpc.Port            = Int32.Parse(txSvrPort.Text.ToString());
            m_ftpc.UserName        = txUsr.Text.ToString();
            m_ftpc.PassWord        = txPwd.Text.ToString();
            m_ftpc.AutoLogOn       = chbAutoLogOn.IsChecked.Value;
            m_ftpc.AutoPassiveMode = chbAutoPasv.IsChecked.Value;

            m_ftpc.Connect();
        }
Ejemplo n.º 47
0
 public void showBluetoothSettings(string args)
 {
     ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
     connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
     connectionSettingsTask.Show();
     DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
 }
Ejemplo n.º 48
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            if (!DeviceNetworkInformation.IsWiFiEnabled)
            {
                MessageBoxResult result = MessageBox.Show(AppResources.WIFI_OFF_MESSAGE, AppResources.WIFI_OFF, MessageBoxButton.OK);

                switch (result)
                {
                    case MessageBoxResult.OK:
                        ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                        connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                        connectionSettingsTask.Show();
                        return;
                }
            }
            else
            {
                bool found = false;
                NetworkInterfaceList netList = new NetworkInterfaceList();
                foreach (NetworkInterfaceInfo network in netList)
                {
                    if (network.InterfaceType == NetworkInterfaceType.Wireless80211
                        && network.InterfaceState == ConnectState.Connected
                        && network.InterfaceName.StartsWith("Rm3Wi-Fi"))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    MessageBox.Show(AppResources.WRONG_WIFI_MESSAGE, AppResources.WRONG_WIFI, MessageBoxButton.OK);
                    return;
                }
            }
            LoggedInText.Text = String.Empty;
            ProgressBar.Visibility = Visibility.Visible;
            webClient = new WebClient();
            webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            var uri = new Uri("https://authentication.uniroma3.it/login.pl", UriKind.Absolute);
            StringBuilder postData = new StringBuilder();
            postData.AppendFormat("{0}={1}", "bs_name", HttpUtility.UrlEncode(Username.Text));
            postData.AppendFormat("&{0}={1}", "bs_password", HttpUtility.UrlEncode(Password.Password));
            postData.AppendFormat("&{0}={1}", "_FORM_SUBMIT", HttpUtility.UrlEncode("1"));
            postData.AppendFormat("&{0}={1}", "which_form", HttpUtility.UrlEncode("reg"));
            //postData.AppendFormat("&{0}={1}", "source", HttpUtility.UrlEncode("10.8.1.199"));
            //postData.AppendFormat("&{0}={1}", "destination", HttpUtility.UrlEncode("www.uniroma3.it"));

            webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);

            try
            {
                webClient.UploadStringAsync(uri, "POST", postData.ToString());
            }
            catch (Exception)
            {
                webClient.UploadStringCompleted -= webClient_UploadStringCompleted;
                MessageBox.Show(AppResources.WEB_ERROR_MESSAGE, AppResources.WEB_ERROR, MessageBoxButton.OK);
            }
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Connect to the given host device.
        /// </summary>
        /// <param name="deviceHostName">The host device name.</param>
        public async Task Connect()
        {
            try
            {
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "{00001101-0000-1000-8000-00805f9b34fb}";
                var pairedDevices = await PeerFinder.FindAllPeersAsync();

                if (pairedDevices.Count == 0)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("No paired devices were found.");
                    });
                }
                else
                {
                    foreach (PeerInformation pairedDevice in pairedDevices)
                    {
                        if (pairedDevice.DisplayName == "HC-05")
                        {
                            if (socket != null)
                            {
                                await socket.ConnectAsync(pairedDevice.HostName, "1", SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);

                                dataReader = new DataReader(socket.InputStream);
                                dataReadWorker.RunWorkerAsync();
                                dataWriter = new DataWriter(socket.OutputStream);
                                await SendCommand("SYNC_DATA");
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x80070490)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (MessageBox.Show("Bluetooth device is not connected. Click OK to open Bluetooth settings.", "Alert!", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                            connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                            connectionSettingsTask.Show();
                        }
                    });
                }
                else if ((uint)ex.HResult == 0x80070103)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (MessageBox.Show("Bluetooth device is not available or turned off. Click OK to open Bluetooth settings.", "Alert!", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                            connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                            connectionSettingsTask.Show();
                        }
                    });
                }
                else if ((uint)ex.HResult == 0x8007048F)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (MessageBox.Show("Bluetooth is turned off. Click OK to open Bluetooth settings.", "Alert!", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                            connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                            connectionSettingsTask.Show();
                        }
                    });
                }
            }
        }
Ejemplo n.º 50
0
        public async void ConnectKreyosDevice (string p_device)
        {
            if (string.IsNullOrWhiteSpace(p_device))
            {
                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceDisconnected;
                info.Error = "Error! Invalid device name!";
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceDisconnected, info);
                return;
            }

            var succ = await BluetoothAgent.Instance.Start(p_device);

            if (succ)
            {
                BluetoothAgent.Instance.InnerProtocol.OnElementParsed               += OnElementParsed;
                BluetoothAgent.Instance.InnerProtocol.OnFileReceived                += OnFileReceived;
                BluetoothAgent.Instance.InnerProtocol.OnDeviceIDRead                += OnDeviceIDRead;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataRead            += OnActivityDataRead;
                BluetoothAgent.Instance.InnerProtocol.OnSportsGridRead              += OnSportsGridRead;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataEnd             += OnActivityDataEnd;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataPrepared        += OnActivityDataPrepared;
                BluetoothAgent.Instance.InnerProtocol.OnActivityDataSync            += OnActivityDataSync;
                BluetoothAgent.Instance.InnerProtocol.OnFirmwareVersionRequest      += OnFirmwareVersionRequest;

                BluetoothAgent.Instance.InnerProtocol.OnOverallActivitiesReceived   += OnOverallActivitiesReceived;
                BluetoothAgent.Instance.InnerProtocol.OnTodayActivityReceived       += OnTodayActivityReceived;
                BluetoothAgent.Instance.InnerProtocol.OnSportsDataReceived          += OnSportsDataReceived;

                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceConnected;
                info.Device = p_device;
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceConnected, info);
                return;
            }
            else
            {
                switch (BluetoothAgent.Instance.ConnectInfo)
                {
                    case EBTConnect.BluetoothIsOff:
                    {
                        var result = MessageBox.Show("Bluetooth is turned off. To see the current Bluetooth settings tap 'ok'", "Bluetooth Off", MessageBoxButton.OKCancel);
                        if (result == MessageBoxResult.OK)
                        {
                            // TODO: Show the bluetooth control panel here
                            ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                            connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
                            connectionSettingsTask.Show();
                        }
                    }
                    break;

                    case EBTConnect.CapPermission:
                    {
                        MessageBox.Show("To run this app, you must have ID_CAP_PROXIMITY enabled in WMAppManifest.xaml");
                    }
                    break;
                }

                ObserverInfo info = new ObserverInfo();
                info.Command = EBTEvent.BTE_OnDeviceDisconnected;
                info.Error = BluetoothAgent.Instance.ErrorMessage;
                BluetoothObserver.Instance.Trigger(EBTEvent.BTE_OnDeviceDisconnected, info);
            }
        }