private void btnAddDevice_Click(object sender, EventArgs e) { try { if (DeviceManager.Devices.Count >= 8) { return; } string devName = txtDeviceName.Text; if (string.IsNullOrEmpty(devName)) { return; } if (!DeviceManager.CanAdd(devName)) { MessageBox.Show("Urządzenie o podanej nazwie już istnieje", "Niepoprawna nazwa", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } DeviceType type = (DeviceType)ddDeviceType.SelectedIndex; eCalendarColor color; int slot = Convert.ToInt32(ddDeviceSlot.Text); if (DeviceManager.HasColor(type)) { color = CalendarUtils.CalendarColorFromString(cddDeviceColor.SelectedItem.ToString()); } else { color = DeviceManager.GetDefaultColor(type); } DeviceManager.AddDevice(devName, type, slot, color); devName += getSlotFormat(slot); TimelineAddNewRow(devName, color); txtDeviceName.Text = ""; } catch (Exception ex) { Console.WriteLine(ex); } }