Ejemplo n.º 1
0
        private void DeviceTypeChanged(object o, EventArgs e)
        {
            FeatherBoard f = (FeatherBoard)o;

            Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ServerConnectDevicesObservableCollection.Remove(f)));
            Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ClientConnectDevicesObservableCollection.Remove(f)));
            Application.Current.Dispatcher.BeginInvoke(new Action(() => this.UnknownConnectDevicesObservableCollection.Remove(f)));
            AddArduino(f);
        }
Ejemplo n.º 2
0
        private void SetupDevicesAndCollectionsAsync(ArduinoManager am)
        {
            foreach (Arduino a in am.ConnectedDevices)
            {
                FeatherBoard f = new FeatherBoard(a);
                f.TypeChanged += DeviceTypeChanged;
                AddArduino(f);
            }

            am.DeviceAdded += DeviceAdded;

            am.DeviceRemoved += DeviceRemoved;
        }
Ejemplo n.º 3
0
 private void AddArduino(FeatherBoard f)
 {
     f.TypeChanged += DeviceTypeChanged;
     if (f.DeviceType == Values.DeviceTypes.Unknown)
     {
         Application.Current.Dispatcher.BeginInvoke(new Action(() => this.UnknownConnectDevicesObservableCollection.Add(f)));
     }
     else if (f.DeviceType == Values.DeviceTypes.Server)
     {
         f.ClientsCollection = MoteObservableCollection;
         Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ServerConnectDevicesObservableCollection.Add(f)));
     }
     else
     {
         Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ClientConnectDevicesObservableCollection.Add(f)));
     }
 }
Ejemplo n.º 4
0
        private FeatherBoard FindFeatheBoard(Arduino a)
        {
            FeatherBoard f = null;
            var          s = ServerConnectDevicesObservableCollection.Where(x => x.Arduino == a).ToList();
            var          c = ClientConnectDevicesObservableCollection.Where(x => x.Arduino == a).ToList();
            var          u = UnknownConnectDevicesObservableCollection.Where(x => x.Arduino == a).ToList();

            if (s.Count != 0)
            {
                f = s[0];
            }
            else if (c.Count != 0)
            {
                f = c[0];
            }
            else if (u.Count != 0)
            {
                f = u[0];
            }

            return(f);
        }
Ejemplo n.º 5
0
        private void DeviceRemoved(object o, EventArgs e)
        {
            FeatherBoard f = FindFeatheBoard((Arduino)o);

            if (f == null)
            {
                return;
            }

            if (f.DeviceType == Values.DeviceTypes.Unknown)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.UnknownConnectDevicesObservableCollection.Remove(f)));
            }
            else if (f.DeviceType == Values.DeviceTypes.Server)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ServerConnectDevicesObservableCollection.Remove(f)));
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ClientConnectDevicesObservableCollection.Remove(f)));
            }
        }
Ejemplo n.º 6
0
        private void DeviceAdded(object o, EventArgs e)
        {
            FeatherBoard f = new FeatherBoard((Arduino)o);

            AddArduino(f);
        }