public TrayIcon() { UpdateIcon(); _tooltipInfoManager = new TooltipInfoManager(NotifyIcon); _updateMenuItem = new ToolStripMenuItem(AppConfigs.Configuration.UpdateMode == UpdateMode.Never ? TrayIconStrings.updateDisabled : TrayIconStrings.noUpdate, RessourceUpdateBitmap, OnUpdateClick) { Enabled = false }; NotifyIcon.ContextMenuStrip = _settingsMenu; PopulateSettingsMenu(); _selectionMenu.Items.Add(TrayIconStrings.noDevicesSelected, RessourceSettingsSmallBitmap, (sender, e) => ShowSettings()); NotifyIcon.MouseDoubleClick += (sender, args) => { AppModel.Instance.CycleActiveDevice(DataFlow.Render); }; NotifyIcon.MouseClick += (sender, e) => { if (e.Button != MouseButtons.Left) { return; } if (_updateMenuItem.Tag != null) { OnUpdateClick(sender, e); return; } UpdateDeviceSelectionList(); NotifyIcon.ContextMenuStrip = _selectionMenu; var mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(NotifyIcon, null); NotifyIcon.ContextMenuStrip = _settingsMenu; }; NotifyIcon.MouseMove += (sender, args) => { if (!NotifyIcon.Visible) { return; } _tooltipInfoManager.ShowTooltipInfo(); }; _selectionMenu.Closed += (sender, args) => _tooltipInfoManager.IsBallontipVisible = false; _settingsMenu.Closed += (sender, args) => _tooltipInfoManager.IsBallontipVisible = false; SetEventHandlers(); _updateDownloadForm = new UpdateDownloadForm(); }
public TrayIcon() { UpdateIcon(); _tooltipInfoManager = new TooltipInfoManager(NotifyIcon); _updateMenuItem = new ToolStripMenuItem(TrayIconStrings.NoUpdate, Resources.Update, OnUpdateClick) { Enabled = false }; NotifyIcon.ContextMenuStrip = _settingsMenu; PopulateSettingsMenu(); _selectionMenu.Items.Add(TrayIconStrings.NoDevSel, Resources.SettingsSmall, (sender, e) => ShowSettings()); NotifyIcon.MouseDoubleClick += (sender, args) => { AppModel.Instance.CycleActiveDevice(AudioDeviceType.Playback); }; NotifyIcon.MouseClick += (sender, e) => { if (e.Button != MouseButtons.Left) { return; } UpdateDeviceSelectionList(); NotifyIcon.ContextMenuStrip = _selectionMenu; var mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(NotifyIcon, null); NotifyIcon.ContextMenuStrip = _settingsMenu; }; NotifyIcon.MouseMove += (sender, args) => { if (!NotifyIcon.Visible) { return; } _tooltipInfoManager.ShowTooltipInfo(); }; _selectionMenu.Closed += (sender, args) => _tooltipInfoManager.IsBallontipVisible = false; _settingsMenu.Closed += (sender, args) => _tooltipInfoManager.IsBallontipVisible = false; SetEventHandlers(); }