public static void SetLanguageForTrayMenuItems() { _menuOpen.Text = PBApp.ReturnResourceString(OpenKey); _menuManageDevices.Text = PBApp.ReturnResourceString(ManageDevicesKey); _menuCheckUpdates.Text = PBApp.ReturnResourceString(CheckUpdatesKey); _menuBackupNow.Text = PBApp.ReturnResourceString(BackupNowKey); _menuSetting.Text = PBApp.ReturnResourceString(SettingKey); _menuSupport.Text = PBApp.ReturnResourceString(SupportKey); _menuSysInfo.Text = PBApp.ReturnResourceString(SysInfoKey); _menuExit.Text = PBApp.ReturnResourceString(ExitKey); }
/// <summary> /// Sets the system tray icon with menus and events binded /// </summary> public void InitializeTrayProperties() { sync = resolver.GetInstanceOf <IPBSync>(); if (sync != null) { sync.OnSyncSuccess += syncSuccessed; } forceMessageShowing = true; if (_trayNotify != null) { return; } //Set up the system tray icon _trayNotify = new System.Windows.Forms.NotifyIcon { //BalloonTipTitle = PBApp.ReturnResourceString(AppTitleKey), //BalloonTipText = PBApp.ReturnResourceString(ToolTipKey), Text = PBApp.ReturnResourceString(AppTitleKey) }; _trayNotify.MouseClick += _trayNotify_MouseClick; _trayNotify.MouseDoubleClick += _trayNotify_MouseDoubleClick; _trayMenu.Renderer = new MyRenderer(); _trayMenu.Opening += _trayMenu_Opening; _menuOpen.MouseEnter += item_MouseEnter; _menuOpen.MouseLeave += item_MouseLeave; _menuOpen.Click += _menuOpen_Click; _menuOpen.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuOpen); _trayMenu.Items.Add(new System.Windows.Forms.ToolStripSeparator()); _menuManageDevices.MouseEnter += item_MouseEnter; _menuManageDevices.MouseLeave += item_MouseLeave; _menuManageDevices.Click += _menuManageDevices_Click; _menuManageDevices.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuManageDevices); _menuCheckUpdates.MouseEnter += item_MouseEnter; _menuCheckUpdates.MouseLeave += item_MouseLeave; _menuCheckUpdates.Click += _menuCheckUpdates_Click; _menuCheckUpdates.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuCheckUpdates); _menuBackupNow.MouseEnter += item_MouseEnter; _menuBackupNow.MouseLeave += item_MouseLeave; _menuBackupNow.Click += _menuBackupNow_Click; _menuBackupNow.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuBackupNow); _trayMenu.Items.Add(new System.Windows.Forms.ToolStripSeparator()); _menuSetting.MouseEnter += item_MouseEnter; _menuSetting.MouseLeave += item_MouseLeave; _menuSetting.Click += _menuSetting_Click; _menuSetting.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuSetting); _menuSupport.MouseEnter += item_MouseEnter; _menuSupport.MouseLeave += item_MouseLeave; _menuSupport.Click += _menuSupport_Click; _menuSupport.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuSupport); _menuSysInfo.MouseEnter += item_MouseEnter; _menuSysInfo.MouseLeave += item_MouseLeave; _menuSysInfo.Click += _menuSysInfo_Click; _menuSysInfo.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuSysInfo); #if DEBUG _trayMenu.Items.Add(new System.Windows.Forms.ToolStripSeparator()); _menuExit.MouseEnter += item_MouseEnter; _menuExit.MouseLeave += item_MouseLeave; _menuExit.Click += _menuExit_Click; _menuExit.BackColor = System.Drawing.Color.White; _trayMenu.Items.Add(_menuExit); #endif _trayNotify.ContextMenuStrip = _trayMenu; try { _trayNotify.Icon = new System.Drawing.Icon(TrayIconStream); if (_trayNotify != null) { // Show the icon _trayNotify.Visible = true; // Show the balloon tip // _trayNotify.ShowBalloonTip(2000); } } catch (Exception ex) { MessageBox.Show((string)System.Windows.Application.Current.FindResource("GeneralErrorText")); logger.Error(ex.Message); } }