mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-18 13:31:41 +02:00
Configuration
Core
Controls
Handling
Other
Utils
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
FormNotification.Designer.cs
FormNotification.cs
TrayIcon.Designer.cs
TrayIcon.cs
Libraries
Migration
Properties
Resources
.gitignore
LICENSE.md
Program.cs
README.md
TweetDck.csproj
TweetDck.sln
_postbuild.bat
79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
|
|
namespace TweetDck.Core{
|
|
partial class TrayIcon : Component{
|
|
public enum Behavior{ // keep order
|
|
Disabled, DisplayOnly, MinimizeToTray, CloseToTray
|
|
}
|
|
|
|
public event EventHandler ClickRestore;
|
|
public event EventHandler ClickClose;
|
|
|
|
public bool Visible{
|
|
get{
|
|
return notifyIcon.Visible;
|
|
}
|
|
|
|
set{
|
|
notifyIcon.Visible = value;
|
|
}
|
|
}
|
|
|
|
public bool HasNotifications{
|
|
get{
|
|
return hasNotifications;
|
|
}
|
|
|
|
set{
|
|
if (hasNotifications != value){
|
|
notifyIcon.Icon = value ? Properties.Resources.icon_tray_new : Properties.Resources.icon_tray;
|
|
hasNotifications = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool hasNotifications;
|
|
|
|
public TrayIcon(){
|
|
InitializeComponent();
|
|
notifyIcon.Text = Program.BrandName;
|
|
}
|
|
|
|
// event handlers
|
|
|
|
private void trayIcon_MouseClick(object sender, MouseEventArgs e){
|
|
if (e.Button == MouseButtons.Left){
|
|
restoreToolStripMenuItem_Click(sender,e);
|
|
}
|
|
}
|
|
|
|
private void contextMenuTray_Opening(object sender, CancelEventArgs e){
|
|
muteNotificationsToolStripMenuItem.CheckedChanged -= muteNotificationsToolStripMenuItem_CheckedChanged;
|
|
muteNotificationsToolStripMenuItem.Checked = Program.UserConfig.MuteNotifications;
|
|
}
|
|
|
|
private void contextMenuTray_Opened(object sender, EventArgs e){
|
|
muteNotificationsToolStripMenuItem.CheckedChanged += muteNotificationsToolStripMenuItem_CheckedChanged;
|
|
}
|
|
|
|
private void restoreToolStripMenuItem_Click(object sender, EventArgs e){
|
|
if (ClickRestore != null){
|
|
ClickRestore(this,e);
|
|
}
|
|
}
|
|
|
|
private void muteNotificationsToolStripMenuItem_CheckedChanged(object sender, EventArgs e){
|
|
Program.UserConfig.MuteNotifications = muteNotificationsToolStripMenuItem.Checked;
|
|
Program.UserConfig.Save();
|
|
}
|
|
|
|
private void closeToolStripMenuItem_Click(object sender, EventArgs e){
|
|
if (ClickClose != null){
|
|
ClickClose(this,e);
|
|
}
|
|
}
|
|
}
|
|
}
|