diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 18851a6c..9567e637 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -68,7 +68,7 @@ private void ShowChildForm(Form form){ } public FormNotification CreateNotificationForm(bool autoHide){ - return new FormNotification(this,bridge,autoHide); + return new FormNotification(this,bridge,trayIcon,autoHide); } // window setup diff --git a/Core/FormNotification.cs b/Core/FormNotification.cs index 83e52503..37f39fc5 100644 --- a/Core/FormNotification.cs +++ b/Core/FormNotification.cs @@ -14,6 +14,7 @@ sealed partial class FormNotification : Form{ public Func<bool> CanMoveWindow = () => true; private readonly Form owner; + private readonly TrayIcon trayIcon; private readonly ChromiumWebBrowser browser; private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4); @@ -46,12 +47,13 @@ private static int BaseClientHeight{ } } - public FormNotification(Form owner, TweetDeckBridge bridge, bool autoHide){ + public FormNotification(Form owner, TweetDeckBridge bridge, TrayIcon trayIcon, bool autoHide){ InitializeComponent(); Text = Program.BrandName; this.owner = owner; + this.trayIcon = trayIcon; this.autoHide = autoHide; owner.FormClosed += (sender, args) => Close(); @@ -102,6 +104,8 @@ private void Config_MuteToggled(object sender, EventArgs e){ MoveToVisibleLocation(); LoadNextNotification(); } + + trayIcon.HasNotifications = false; } } @@ -124,6 +128,7 @@ private void FormNotification_FormClosing(object sender, FormClosingEventArgs e) public void ShowNotification(TweetNotification notification){ if (Program.UserConfig.MuteNotifications){ tweetQueue.Enqueue(notification); + trayIcon.HasNotifications = true; } else{ MoveToVisibleLocation(); diff --git a/Core/TrayIcon.Designer.cs b/Core/TrayIcon.Designer.cs index 29a1fbf3..9e75dc32 100644 --- a/Core/TrayIcon.Designer.cs +++ b/Core/TrayIcon.Designer.cs @@ -31,13 +31,13 @@ private void InitializeComponent() { this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenu.SuspendLayout(); // - // trayIcon + // notifyIcon // this.notifyIcon.ContextMenuStrip = this.contextMenu; - this.notifyIcon.Icon = global::TweetDck.Properties.Resources.icon; + this.notifyIcon.Icon = global::TweetDck.Properties.Resources.icon_tray; this.notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayIcon_MouseClick); // - // contextMenuTray + // contextMenu // this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.restoreToolStripMenuItem, diff --git a/Core/TrayIcon.cs b/Core/TrayIcon.cs index 1b734961..863fed31 100644 --- a/Core/TrayIcon.cs +++ b/Core/TrayIcon.cs @@ -21,6 +21,21 @@ public bool Visible{ } } + 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; diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 39a1017c..9e9b61ab 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -69,5 +69,25 @@ internal static System.Drawing.Icon icon { return ((System.Drawing.Icon)(obj)); } } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// </summary> + internal static System.Drawing.Icon icon_tray { + get { + object obj = ResourceManager.GetObject("icon_tray", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// </summary> + internal static System.Drawing.Icon icon_tray_new { + get { + object obj = ResourceManager.GetObject("icon_tray_new", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } } } diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 95ac60c0..d6afc110 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -121,4 +121,10 @@ <data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> + <data name="icon_tray" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\icon-tray.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="icon_tray_new" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\icon-tray-new.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> </root> \ No newline at end of file diff --git a/Resources/icon-tray-new.ico b/Resources/icon-tray-new.ico new file mode 100644 index 00000000..5d5b0fc8 Binary files /dev/null and b/Resources/icon-tray-new.ico differ diff --git a/Resources/icon-tray.ico b/Resources/icon-tray.ico new file mode 100644 index 00000000..41dcaf82 Binary files /dev/null and b/Resources/icon-tray.ico differ diff --git a/TweetDck.csproj b/TweetDck.csproj index 0cd55f2f..12817e55 100644 --- a/TweetDck.csproj +++ b/TweetDck.csproj @@ -240,6 +240,8 @@ </ItemGroup> <ItemGroup> <Content Include="Resources\icon-small.ico" /> + <None Include="Resources\icon-tray-new.ico" /> + <None Include="Resources\icon-tray.ico" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">