public static async Task <SpheroConnection> CreateConnection(SpheroInformation spheroInformations)
        {
            try
            {
                SpheroConnection connection = new SpheroConnection(spheroInformations);

                if (await connection.Connect())
                {
                    return(connection);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147023729)
                {
                    throw new BluetoothDeactivatedException(ex);
                }

                throw new NoSpheroFoundException(ex);
            }
        }
        public JediSphero(SpheroConnection connection)
            : base(connection)
        {
            double frequency = 15.0;
            _msDelay = (int)(1000.0 / frequency);

            _connection = connection;
            _currentX = 0.0;
            _currentY = 0.0;

            _speedScale = 0.5;
            _spheroSpeed = 255.0 * _speedScale;
            _timer = new Timer(_msDelay);
            _timer.Elapsed += IterationHandler;
            _timer.Start();
        }
        public static async Task<SpheroConnection> CreateConnection(SpheroInformation spheroInformations)
        {
            try
            {
                SpheroConnection connection = new SpheroConnection(spheroInformations);

                if (await connection.Connect())
                    return connection;
                else
                    return null;
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147023729)
                {
                    throw new BluetoothDeactivatedException(ex);
                }

                throw new NoSpheroFoundException(ex);
            }
        }
示例#4
0
        /// Les méthodes fournies dans cette section sont utilisées simplement pour permettre
        /// NavigationHelper pour répondre aux méthodes de navigation de la page.
        /// 
        /// La logique spécifique à la page doit être placée dans les gestionnaires d'événements pour  
        /// <see cref="GridCS.Common.NavigationHelper.LoadState"/>
        /// et <see cref="GridCS.Common.NavigationHelper.SaveState"/>.
        /// Le paramètre de navigation est disponible dans la méthode LoadState 
        /// en plus de l'état de page conservé durant une session antérieure.

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
             if(e.Parameter != null && e.Parameter is SpheroConnection)
                 _connection = (SpheroConnection)e.Parameter;

            navigationHelper.OnNavigatedTo(e);
        }
示例#5
0
 protected override async void OnNavigatedFrom(NavigationEventArgs e)
 {
     navigationHelper.OnNavigatedFrom(e);
     if(_connection != null)
     {
        await _connection.Disconnect();
         _connection = null;
     }
 }
示例#6
0
 public CoreDevice(SpheroConnection connection)
 {
     this._connection = connection;
     this._connection.SetCore(this);
 }
示例#7
0
 /// <summary>
 /// Create an new sphero with a connection
 /// </summary>
 /// <param name="connection">Current connection to the sphero</param>
 public SpheroDevice(SpheroConnection connection)
 {
     this._connection = connection;
     this._connection.SetSphero(this);
 }