1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-19 00:15:50 +02:00

Add second tray icon for unread tweets when notifications are muted

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

View File

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

View File

@ -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();

View File

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

View File

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

View File

@ -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));
}
}
}
}

View File

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

View File

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