/// <summary>
 /// Sets the device.
 /// </summary>
 /// <param name="deviceManager">The device manager.</param>
 /// <param name="uid">The uid.</param>
 public void SetDevice(BaseManager deviceManager, string uid)
 {
     _deviceManager = deviceManager;
     Device device = _deviceManager.Nodes.Find(d => d.UID == uid) as Device;
     if (device != null)
         this.SetDevice(device);
     _tmpDeviceUID = uid;
 }
 /// <summary>
 /// Sets the device.
 /// </summary>
 /// <param name="deviceManager">The device manager.</param>
 /// <param name="device">The device.</param>
 public void SetDevice(BaseManager deviceManager, Device device)
 {
     _deviceManager = deviceManager;
     this.SetDevice(device);
 }
        /// <summary>
        /// Adds the device list.
        /// </summary>
        /// <param name="devicePlugins">The device plugins.</param>
        /// <param name="deviceManager">The device manager.</param>
        public void AddDeviceList(List<Node> devicePlugins, BaseManager deviceManager)
        {
            _deviceManager = deviceManager;

            if (_devicePlugins != null) _devicePlugins.Clear();

            List<Node> _matchingDevices = new List<Node>();
            if(_filterType == null)
                _devicePlugins = devicePlugins;
            else {
                _devicePlugins = new List<Node>();

                foreach (Node device in devicePlugins) {
                    if (device.GetType().IsAssignableFrom(FilterType) || device.GetType().IsSubclassOf(FilterType)) {
                        _devicePlugins.Add(device);
                    }
                }
            }

            if (this.Device == null || this.Device.GetType() == typeof(Device)) {
                Device selectedDevice = null;
                if ((selectedDevice = (_devicePlugins.Find(d => d.UID == this.DeviceUID)) as Device) != null) {
                    this.Value = selectedDevice;
                    this.SetDevice(selectedDevice);
                } else if((selectedDevice = (_deviceManager.Nodes.Find(d => d.UID == this.DeviceUID)) as Device) != null) {
                    this.Value = selectedDevice;
                    this.SetDevice(selectedDevice);

                    _devicePlugins.Insert(0, selectedDevice);
                } else if (_devicePlugins.Count > 0) {
                    this.Value = _devicePlugins[0];
                    this.SetDevice(_devicePlugins[0]);
                }
            }
        }