Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BluetoothSettingsPage"/> class.
        /// </summary>
        public BluetoothSettingsPage()
        {
            _oSelectedBluetoothCommand = null;
            InitializeComponent();

            App.ShowToast(AppResources.bluetooth);
            swEnableBluetooth.IsToggled = App.AppSettings.BluetoothEnabled;
            swEnableBluetooth.Toggled  += (sender, args) =>
            {
                App.AppSettings.BluetoothEnabled = swEnableBluetooth.IsToggled;
            };

            swEnableBluetoothNotifications.IsToggled = App.AppSettings.BluetoothNotificationsEnabled;
            swEnableBluetoothNotifications.Toggled  += (sender, args) =>
            {
                App.AppSettings.BluetoothNotificationsEnabled = swEnableBluetoothNotifications.IsToggled;
            };

            _oListSource = App.AppSettings.Bluetooths;
            if (_oListSource == null)
            {
                _oListSource = new List <BluetoothModel>();
            }
            listView.ItemsSource = _oListSource;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Connect device to Bluetooth Command
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/></param>
        /// <param name="e">The e<see cref="EventArgs"/></param>
        private async void btnConnect_Clicked(object sender, EventArgs e)
        {
            _oSelectedBluetoothCommand = (Models.BluetoothModel)((TintedCachedImage)sender).BindingContext;
            var oSwitchPopup = new SwitchPopup();

            oSwitchPopup.DeviceSelectedMethod += DelegateMethod;
            await Navigation.PushAsync(oSwitchPopup);
        }
Exemplo n.º 3
0
        /// <summary>
        /// On Bluetooth configed
        /// </summary>
        private void OnBluetoothConfigged(BluetoothModel newBluetooth)
        {
            if (newBluetooth == null)
            {
                return;
            }

            _oListSource.Add(newBluetooth);
            App.ShowToast(AppResources.noSwitchSelected_explanation_bluetooth);
            SaveAndRefresh();
        }
        private async Task TryGetNetworksAsync()
        {
            try
            {
                IsBusy = true;
                var bluetoothClient = new BluetoothModel();
                WiFiNetworksResponse wifiResponse = await bluetoothClient.GetNetworksAsync(_mMContext.Device);

                if (wifiResponse.IsSuccess)
                {
                    HasNetworks = wifiResponse.Networks.Any();
                    if (HasNetworks)
                    {
                        Networks = new ObservableCollection <string>(wifiResponse.Networks);
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Alert", "Not determine wifi networks. Please try again", "OK");

                        IsNotSuccessResult = true;
                    }
                }
                else
                {
                    _navigation.NextPage <WiFiSetupCredentialsPage>();

                    /*if (wifiResponse.ErrorCode == 2)
                     * {
                     *  //todo вручную вводить имя сети и пароль и потом перезапустить зеркало
                     *  IsNotSuccessResult = true;
                     * }
                     * else
                     * {
                     *  //display this error wifiResponse.ErrorInfo
                     *  await App.Current.MainPage.DisplayAlert("Alert", "Something went wrong, please reconnect", "OK");
                     *  await _bluetoothService.DisconnectAsync(_mMContext.Device);
                     *  _navigation.NextPage(typeof(SearchingDevicePage));
                     * }*/
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 5
0
    void Awake()
    {
        // This is a SingleTON of stuff
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);
        observerList = new List <IBtObserver>();

        macAddresses = new List <string>();
        messageQueue = new Queue <string>();
        rawMessage   = new StringBuilder(bufferSize);

        // Tell the GM we exist (safe to do in Awake w/ modified script execution order)
        GameManager.instance.SetBluetoothModel(this);
    }
Exemplo n.º 6
0
 // Trying a different approach for GM systems that require being a GameObject component eliminating .Find() -
 // let them contact US on Start (the rest of the systems are regular Objects instantiated in Awake)
 public void SetBluetoothModel(BluetoothModel bm)
 {
     btModel = bm;
 }