/// <summary> /// The devices filter has changed. /// </summary> /// <param name="value">new filter value</param> public void SetFilterDevices(FilterDevicesEnum value) { if (deviceList == null) { return; } foreach (var device in deviceList) { device.GetDeviceControl().Visible = FilterDevices.ShowFilterDevices(device, value); } }
public void AddDevice(IDevice device) { if (device == null || pnlDevices == null) { return; } if (InvokeRequired) { Invoke(new Action <Device>(AddDevice), new object[] { device }); return; } if (IsDisposed) { return; } var deviceControl = new DeviceControl(device); deviceControl.SetDeviceName(device.GetFriendlyName()); deviceControl.SetStatus(device.GetDeviceState(), null); pnlDevices.Controls.Add(deviceControl); device.SetDeviceControl(deviceControl); var filter = GetFilterDevices(); if (filter != null) { deviceControl.Visible = FilterDevices.ShowFilterDevices(device, filter.Value); } // Sort alphabetically. var deviceName = device.GetFriendlyName(); for (int i = 0; i < pnlDevices.Controls.Count - 1; i++) { if (pnlDevices.Controls[i] is DeviceControl) { var name = ((DeviceControl)pnlDevices.Controls[i]).GetDeviceName(); if (string.CompareOrdinal(deviceName, name) < 0) { pnlDevices.Controls.SetChildIndex(deviceControl, i); return; } } } }
/// <summary> /// The devices filter has changed. /// </summary> /// <param name="value">new filter value</param> public void SetFilterDevices(FilterDevicesEnum value) { if (deviceList == null) { return; } foreach (var device in deviceList) { if (device == null || device.GetDeviceControl() == null || device.GetDeviceControl().IsDisposed) { continue; } device.GetDeviceControl().Visible = FilterDevices.ShowFilterDevices(device, value); } }