mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-13 18:15:48 +02:00
Add new program and tray icons to show when notifications are muted
This commit is contained in:
parent
ca67f2fe0a
commit
f60d5f650f
@ -95,7 +95,11 @@ public FormBrowser(){
|
||||
this.trayIcon.ClickClose += trayIcon_ClickClose;
|
||||
Config.TrayBehaviorChanged += Config_TrayBehaviorChanged;
|
||||
|
||||
UpdateTrayIcon();
|
||||
UpdateTray();
|
||||
|
||||
if (Config.MuteNotifications){
|
||||
UpdateFormIcon();
|
||||
}
|
||||
|
||||
this.updates = new UpdateHandler(browser, Program.InstallerPath);
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
@ -127,7 +131,11 @@ private void RestoreWindow(){
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
private void UpdateTrayIcon(){
|
||||
private void UpdateFormIcon(){ // TODO fix to show icon in taskbar too
|
||||
Icon = Config.MuteNotifications ? Properties.Resources.icon_muted : Properties.Resources.icon;
|
||||
}
|
||||
|
||||
private void UpdateTray(){
|
||||
trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon();
|
||||
}
|
||||
|
||||
@ -202,18 +210,19 @@ private void FormBrowser_FormClosed(object sender, FormClosedEventArgs e){
|
||||
}
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateFormIcon();
|
||||
AnalyticsFile.NotificationMutes.Trigger();
|
||||
}
|
||||
|
||||
private void Config_TrayBehaviorChanged(object sender, EventArgs e){
|
||||
UpdateTrayIcon();
|
||||
UpdateTray();
|
||||
}
|
||||
|
||||
private void trayIcon_ClickRestore(object sender, EventArgs e){
|
||||
Show();
|
||||
RestoreWindow();
|
||||
Activate();
|
||||
UpdateTrayIcon();
|
||||
UpdateTray();
|
||||
}
|
||||
|
||||
private void trayIcon_ClickClose(object sender, EventArgs e){
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using Res = TweetDuck.Properties.Resources;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
sealed partial class TrayIcon : Component{
|
||||
@ -8,6 +10,8 @@ public enum Behavior{ // keep order
|
||||
Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined
|
||||
}
|
||||
|
||||
private static UserConfig Config => Program.UserConfig;
|
||||
|
||||
public event EventHandler ClickRestore;
|
||||
public event EventHandler ClickClose;
|
||||
|
||||
@ -17,12 +21,9 @@ public bool Visible{
|
||||
}
|
||||
|
||||
set{
|
||||
if (value){
|
||||
notifyIcon.Icon = Properties.Resources.icon_tray;
|
||||
}
|
||||
|
||||
notifyIcon.Visible = value;
|
||||
hasNotifications = false;
|
||||
UpdateIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +33,9 @@ public bool HasNotifications{
|
||||
}
|
||||
|
||||
set{
|
||||
if (hasNotifications != value && Visible){
|
||||
notifyIcon.Icon = value ? Properties.Resources.icon_tray_new : Properties.Resources.icon_tray;
|
||||
if (hasNotifications != value){
|
||||
hasNotifications = value;
|
||||
UpdateIcon();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,14 +54,26 @@ public TrayIcon(){
|
||||
|
||||
this.notifyIcon.ContextMenu = contextMenu;
|
||||
this.notifyIcon.Text = Program.BrandName;
|
||||
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
}
|
||||
|
||||
public TrayIcon(IContainer container) : this(){
|
||||
container.Add(this);
|
||||
}
|
||||
|
||||
private void UpdateIcon(){
|
||||
if (Visible){
|
||||
notifyIcon.Icon = hasNotifications ? Res.icon_tray_new : Config.MuteNotifications ? Res.icon_tray_muted : Res.icon_tray;
|
||||
}
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateIcon();
|
||||
}
|
||||
|
||||
private void trayIcon_MouseClick(object sender, MouseEventArgs e){
|
||||
if (e.Button == MouseButtons.Left){
|
||||
menuItemRestore_Click(sender, e);
|
||||
@ -68,7 +81,7 @@ private void trayIcon_MouseClick(object sender, MouseEventArgs e){
|
||||
}
|
||||
|
||||
private void contextMenu_Popup(object sender, EventArgs e){
|
||||
contextMenu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
|
||||
contextMenu.MenuItems[1].Checked = Config.MuteNotifications;
|
||||
}
|
||||
|
||||
private void menuItemRestore_Click(object sender, EventArgs e){
|
||||
@ -76,8 +89,8 @@ private void menuItemRestore_Click(object sender, EventArgs e){
|
||||
}
|
||||
|
||||
private void menuItemMuteNotifications_Click(object sender, EventArgs e){
|
||||
Program.UserConfig.MuteNotifications = !contextMenu.MenuItems[1].Checked;
|
||||
Program.UserConfig.Save();
|
||||
Config.MuteNotifications = !contextMenu.MenuItems[1].Checked;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
private void menuItemClose_Click(object sender, EventArgs e){
|
||||
|
20
Properties/Resources.Designer.cs
generated
20
Properties/Resources.Designer.cs
generated
@ -80,6 +80,16 @@ internal static System.Drawing.Icon icon {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon icon_muted {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon_muted", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
@ -90,6 +100,16 @@ internal static System.Drawing.Icon icon_tray {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon icon_tray_muted {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon_tray_muted", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
|
@ -124,9 +124,15 @@
|
||||
<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_muted" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-muted.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_muted" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-tray-muted.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>
|
||||
|
BIN
Resources/icon-muted.ico
Normal file
BIN
Resources/icon-muted.ico
Normal file
Binary file not shown.
After (image error) Size: 17 KiB |
BIN
Resources/icon-tray-muted.ico
Normal file
BIN
Resources/icon-tray-muted.ico
Normal file
Binary file not shown.
After (image error) Size: 9.4 KiB |
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\CefSharp.WinForms.66.0.0-CI2629\build\CefSharp.WinForms.props" Condition="Exists('packages\CefSharp.WinForms.66.0.0-CI2629\build\CefSharp.WinForms.props')" />
|
||||
<Import Project="packages\CefSharp.Common.66.0.0-CI2629\build\CefSharp.Common.props" Condition="Exists('packages\CefSharp.Common.66.0.0-CI2629\build\CefSharp.Common.props')" />
|
||||
@ -334,6 +334,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\avatar.png" />
|
||||
<None Include="Resources\icon-tray-muted.ico" />
|
||||
<None Include="Resources\icon-muted.ico" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\icon-small.ico" />
|
||||
<None Include="Resources\icon-tray-new.ico" />
|
||||
|
Loading…
Reference in New Issue
Block a user