public void OnAddDevice(IDevice device) { var menuItem = new MenuItem(); menuItem.Text = device.GetFriendlyName(); menuItem.Click += device.OnClickDeviceButton; notifyIcon.ContextMenu.MenuItems.Add(notifyIcon.ContextMenu.MenuItems.Count - 1, menuItem); device.SetMenuItem(menuItem); mainForm.AddDevice(device); }
/// <summary> /// Callback for Devices, a new device is added. /// </summary> /// <param name="deviceIn">the new device</param> public void OnAddDevice(IDevice deviceIn) { if (deviceIn == null) { return; } var menuItem = new MenuItem { Text = deviceIn.GetFriendlyName() }; menuItem.Click += deviceIn.OnClickPlayPause; notifyIcon?.ContextMenu?.MenuItems?.Add(notifyIcon.ContextMenu.MenuItems.Count - 1, menuItem); deviceIn.SetMenuItem(menuItem); mainForm.AddDevice(deviceIn); }
/// <summary> /// Callback for Devices, a new device is added. /// </summary> /// <param name="deviceIn">the new device</param> public void OnAddDevice(IDevice deviceIn) { if (deviceIn == null || mainForm == null) { return; } try { var menuItem = new MenuItem { Text = deviceIn.GetFriendlyName() }; menuItem.Click += deviceIn.OnClickPlayPause; notifyIcon?.ContextMenu?.MenuItems?.Add(notifyIcon.ContextMenu.MenuItems.Count - 1, menuItem); deviceIn.SetMenuItem(menuItem); } catch (Exception ex) { logger.Log(ex, "ApplicationLogic.OnAddDevice"); } mainForm.AddDevice(deviceIn); }