1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-21 03:54:07 +02:00

Add second tray icon for unread tweets when notifications are muted

Closes 
This commit is contained in:
2016-05-12 15:46:39 +02:00
parent 7238e17b86
commit fd97c20d37
9 changed files with 53 additions and 5 deletions

@@ -68,7 +68,7 @@ namespace TweetDck.Core{
}
public FormNotification CreateNotificationForm(bool autoHide){
return new FormNotification(this,bridge,autoHide);
return new FormNotification(this,bridge,trayIcon,autoHide);
}
// window setup

@@ -14,6 +14,7 @@ namespace TweetDck.Core{
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 @@ namespace TweetDck.Core{
}
}
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 @@ namespace TweetDck.Core{
MoveToVisibleLocation();
LoadNextNotification();
}
trayIcon.HasNotifications = false;
}
}
@@ -124,6 +128,7 @@ namespace TweetDck.Core{
public void ShowNotification(TweetNotification notification){
if (Program.UserConfig.MuteNotifications){
tweetQueue.Enqueue(notification);
trayIcon.HasNotifications = true;
}
else{
MoveToVisibleLocation();

@@ -31,13 +31,13 @@
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,

@@ -21,6 +21,21 @@ namespace TweetDck.Core{
}
}
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;

@@ -69,5 +69,25 @@ namespace TweetDck.Properties {
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));
}
}
}
}

@@ -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>

BIN
Resources/icon-tray-new.ico Normal file

Binary file not shown.

After

(image error) Size: 9.4 KiB

BIN
Resources/icon-tray.ico Normal file

Binary file not shown.

After

(image error) Size: 9.4 KiB

@@ -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">