public void PopulateForm () { //for (int i = 0; i < comboboxDevices.Model.IterNChildren(); i++) // comboboxDevices.RemoveText(i); /* List<String> deviceNames = new List<string> (); foreach (LedController controller in Manager.Controllers) { deviceNames.Add (controller.DeviceVisibleName); } deviceNames.Sort (); */ string previousDeviceSerial = ""; if (comboboxDevices.Active >= 0) previousDeviceSerial = DeviceEntities[comboboxDevices.Active].Serial; ListStore store = new ListStore(typeof (string)); comboboxDevices.Model = store; DeviceEntities = Manager.GetOnlineDeviceList(); int previousDeviceIndex = -1; int index = -1; foreach (DeviceEntity entity in DeviceEntities) { store.AppendValues(entity.ToString()); index++; if (entity.ToString() == previousDeviceSerial) { previousDeviceIndex = index; } } SelectedController = null; if (store.IterNChildren() >= 1 && previousDeviceIndex == -1) { comboboxDevices.Active = 0; } else if (previousDeviceIndex >= 0) { comboboxDevices.Active = previousDeviceIndex; } else { UpdateFormComponents(); } }
protected void OnTreeviewDevicesCursorChanged (object sender, EventArgs e) { TreeModel model; TreeIter iter; TreeSelection selection = (sender as TreeView).Selection; if(selection.GetSelected(out model, out iter)){ SelectedController = (LedController)model.GetValue (iter, 0); } }
protected void OnComboboxDevicesChanged (object sender, EventArgs e) { SelectedController = Manager.FindControllerBySerialNumber(DeviceEntities[comboboxDevices.Active].Serial); UpdateFormComponents(); }
public static LedController[] AllControllers () { List<LedController> result = new List<LedController>(); foreach (AbstractBlinkstickHid hidDevice in BlinkstickDeviceFinder.FindDevices()) { LedController controller = new LedController(); controller.Device = hidDevice; controller.Device.OpenDevice(); result.Add (controller); } return result.ToArray(); }