/// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="bluetooth">Communication instance</param>
 /// <param name="target"> Target</param>
 public ObjectTracker(BluetoothDevice bluetooth, Indicator target)
 {
     Target = target;
     Bluetooth = bluetooth;
     Worker = new BackgroundWorker();
     Worker.DoWork += Tracking;
 }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="collection">Moves Collection</param>
 /// <param name="bluetooth">Communicate Object</param>
 public Player(MoveItemsCollection collection, BluetoothDevice bluetooth)
 {
     Collection = collection;
     Bluetooth = bluetooth;
     // register worker
     Worker = new BackgroundWorker();
     Worker.DoWork+= worker_DoWork;
 }
        public ObjectTracker(BluetoothDevice bluetooth, Indicator target, System.Windows.Controls.CheckBox activator)
        {
            Target = target;
            Bluetooth = bluetooth;
            Activator = activator;
            TimerClock = new Timer();
            TimerClock.Interval = 5000;
            TimerClock.Tick += TimerClockTick;

            Found = false;
        }
 /// <summary>
 /// Check for configuration
 /// </summary>
 /// <returns></returns>
 public bool CheckConfig() 
 {
     if (Configuration.Initiated) return true;
     MessageBoxResult result = MessageBox.Show("No Configuration was made. \nDo you want to config now?", "Configuration required", MessageBoxButton.YesNo,
                     MessageBoxImage.Question);
     if (result == MessageBoxResult.Yes)
     {
         Configuration config = new Configuration();
         if (config.ShowDialog() == true)
         {
             Bluetooth = new BluetoothDevice(Configuration.OutgoingPort, Configuration.OutgoingBaudrate);
             if (Bluetooth.Open() == 1)
             {
                 return true;
             }
             MessageBox.Show("Bluetooth connetion fail.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             Configuration.Initiated = false;
         }
     }
     return false;
 }
 /// <summary>
 /// Enable/Set focus on Config tab
 /// </summary>
 /// <param name="sender">Event source</param>
 /// <param name="e">Event arguments</param>
 private void menuConfig_Click(object sender, RoutedEventArgs e)
 {
     Configuration config = new Configuration();
     if (config.ShowDialog() == true)
     {
         if (Bluetooth != null)
         {
             Bluetooth.Close();
         }
         Bluetooth = new BluetoothDevice(Configuration.OutgoingPort, Configuration.OutgoingBaudrate);
         if (Bluetooth.Open() == 0)
         {
             MessageBox.Show("Bluetooth connetion fail.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 } 
 /// <summary>
 /// Check for configuration
 /// </summary>
 /// <returns></returns>
 public bool CheckConfig() 
 {
     if (Configuration.Initiated) return true;
     MessageBoxResult result = MessageBox.Show("No Configuration was made. \nDo you want to config now?", "Configuration required", MessageBoxButton.YesNo,
                     MessageBoxImage.Question);
     if (result == MessageBoxResult.Yes)
     {
         Configuration config = new Configuration();
         if (config.ShowDialog() == true)
         {
             Bluetooth = new BluetoothDevice(Configuration.OutgoingPort, Configuration.OutgoingBaudrate);
             //Bluetooth.ComPort.DataReceived += (sender,args) =>
             //{
             //    MessageBox.Show(Bluetooth.ComPort.ReadByte().ToString());
             //};
             if (Bluetooth.Open() == 1)
             {
                 return true;
             }
             MessageBox.Show("Bluetooth connetion fail.");
             Configuration.Initiated = false;
         }
     }
     return false;
 }