mirror of
				https://github.com/chylex/TweetDuck.git
				synced 2025-10-31 18:17:15 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			1c1aa5ea44
			...
			taskbar-ov
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9238410756 | 
| @@ -1,6 +1,7 @@ | |||||||
| using System; | using System; | ||||||
| using System.Drawing; | using System.Drawing; | ||||||
| using System.Windows.Forms; | using System.Windows.Forms; | ||||||
|  | using Microsoft.WindowsAPICodePack.Taskbar; | ||||||
| using TweetDuck.Configuration; | using TweetDuck.Configuration; | ||||||
| using TweetDuck.Core.Bridge; | using TweetDuck.Core.Bridge; | ||||||
| using TweetDuck.Core.Controls; | using TweetDuck.Core.Controls; | ||||||
| @@ -50,6 +51,7 @@ namespace TweetDuck.Core{ | |||||||
|         private readonly FormNotificationTweet notification; |         private readonly FormNotificationTweet notification; | ||||||
|         private readonly ContextMenu contextMenu; |         private readonly ContextMenu contextMenu; | ||||||
|         private readonly UpdateBridge updateBridge; |         private readonly UpdateBridge updateBridge; | ||||||
|  |         private readonly TaskbarIcon taskbarIcon; | ||||||
| 
 | 
 | ||||||
|         private bool isLoaded; |         private bool isLoaded; | ||||||
|         private FormWindowState prevState; |         private FormWindowState prevState; | ||||||
| @@ -84,6 +86,9 @@ namespace TweetDuck.Core{ | |||||||
| 
 | 
 | ||||||
|             Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update |             Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update | ||||||
| 
 | 
 | ||||||
|  |             this.taskbarIcon = new TaskbarIcon(); | ||||||
|  |             Shown += (sender, args) => taskbarIcon.UpdateIcon(); | ||||||
|  | 
 | ||||||
|             Disposed += (sender, args) => { |             Disposed += (sender, args) => { | ||||||
|                 Config.MuteToggled -= Config_MuteToggled; |                 Config.MuteToggled -= Config_MuteToggled; | ||||||
|                 Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; |                 Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; | ||||||
| @@ -91,6 +96,7 @@ namespace TweetDuck.Core{ | |||||||
|                 browser.Dispose(); |                 browser.Dispose(); | ||||||
|                 updates.Dispose(); |                 updates.Dispose(); | ||||||
|                 contextMenu.Dispose(); |                 contextMenu.Dispose(); | ||||||
|  |                 taskbarIcon.Dispose(); | ||||||
| 
 | 
 | ||||||
|                 notificationScreenshotManager?.Dispose(); |                 notificationScreenshotManager?.Dispose(); | ||||||
|                 videoPlayer?.Dispose(); |                 videoPlayer?.Dispose(); | ||||||
| @@ -105,10 +111,6 @@ namespace TweetDuck.Core{ | |||||||
| 
 | 
 | ||||||
|             UpdateTray(); |             UpdateTray(); | ||||||
| 
 | 
 | ||||||
|             if (Config.MuteNotifications){ |  | ||||||
|                 UpdateFormIcon(); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             if (Config.AllowDataCollection){ |             if (Config.AllowDataCollection){ | ||||||
|                 analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath); |                 analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath); | ||||||
|             } |             } | ||||||
| @@ -134,10 +136,6 @@ namespace TweetDuck.Core{ | |||||||
|             isLoaded = true; |             isLoaded = true; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private void UpdateFormIcon(){ // TODO fix to show icon in taskbar too |  | ||||||
|             Icon = Config.MuteNotifications ? Properties.Resources.icon_muted : Properties.Resources.icon; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         private void UpdateTray(){ |         private void UpdateTray(){ | ||||||
|             trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon(); |             trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon(); | ||||||
|         } |         } | ||||||
| @@ -152,6 +150,7 @@ namespace TweetDuck.Core{ | |||||||
|             if (!isLoaded)return; |             if (!isLoaded)return; | ||||||
| 
 | 
 | ||||||
|             trayIcon.HasNotifications = false; |             trayIcon.HasNotifications = false; | ||||||
|  |             taskbarIcon.HasNotifications = false; | ||||||
| 
 | 
 | ||||||
|             if (!browser.Enabled){      // when taking a screenshot, the window is unfocused and |             if (!browser.Enabled){      // when taking a screenshot, the window is unfocused and | ||||||
|                 browser.Enabled = true; // the browser is disabled; if the user clicks back into |                 browser.Enabled = true; // the browser is disabled; if the user clicks back into | ||||||
| @@ -213,7 +212,6 @@ namespace TweetDuck.Core{ | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private void Config_MuteToggled(object sender, EventArgs e){ |         private void Config_MuteToggled(object sender, EventArgs e){ | ||||||
|             UpdateFormIcon(); |  | ||||||
|             AnalyticsFile.NotificationMutes.Trigger(); |             AnalyticsFile.NotificationMutes.Trigger(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @@ -503,9 +501,13 @@ namespace TweetDuck.Core{ | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public void OnTweetNotification(){ // may be called multiple times, once for each type of notification |         public void OnTweetNotification(){ // may be called multiple times, once for each type of notification | ||||||
|             if (Config.EnableTrayHighlight && !ContainsFocus){ |             if (!ContainsFocus){ | ||||||
|  |                 if (Config.EnableTrayHighlight){ | ||||||
|                     trayIcon.HasNotifications = true; |                     trayIcon.HasNotifications = true; | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|  |                 taskbarIcon.HasNotifications = false; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public void OnTweetSound(){ |         public void OnTweetSound(){ | ||||||
|   | |||||||
							
								
								
									
										49
									
								
								Core/Other/TaskbarIcon.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								Core/Other/TaskbarIcon.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | |||||||
|  | using System; | ||||||
|  | using Microsoft.WindowsAPICodePack.Taskbar; | ||||||
|  | using TweetDuck.Configuration; | ||||||
|  | using Res = TweetDuck.Properties.Resources; | ||||||
|  | 
 | ||||||
|  | namespace TweetDuck.Core.Other{ | ||||||
|  |     sealed class TaskbarIcon : IDisposable{ | ||||||
|  |         private static UserConfig Config => Program.Config.User; | ||||||
|  | 
 | ||||||
|  |         public bool HasNotifications{ | ||||||
|  |             get{ | ||||||
|  |                 return hasNotifications; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             set{ | ||||||
|  |                 if (hasNotifications != value){ | ||||||
|  |                     hasNotifications = value; | ||||||
|  |                     UpdateIcon(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private bool hasNotifications; | ||||||
|  | 
 | ||||||
|  |         public TaskbarIcon(){ | ||||||
|  |             Config.MuteToggled += Config_MuteToggled; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void Dispose(){ | ||||||
|  |             Config.MuteToggled -= Config_MuteToggled; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void Config_MuteToggled(object sender, EventArgs e){ | ||||||
|  |             UpdateIcon(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void UpdateIcon(){ | ||||||
|  |             if (hasNotifications){ | ||||||
|  |                 TaskbarManager.Instance.SetOverlayIcon(Res.overlay_notification, "Unread Notifications"); | ||||||
|  |             } | ||||||
|  |             else if (Config.MuteNotifications){ | ||||||
|  |                 TaskbarManager.Instance.SetOverlayIcon(Res.overlay_muted, "Notifications Muted"); | ||||||
|  |             } | ||||||
|  |             else{ | ||||||
|  |                 TaskbarManager.Instance.SetOverlayIcon(null, string.Empty); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										22
									
								
								Properties/Resources.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										22
									
								
								Properties/Resources.Designer.cs
									
									
									
										generated
									
									
									
								
							| @@ -19,7 +19,7 @@ namespace TweetDuck.Properties { | |||||||
|     // class via a tool like ResGen or Visual Studio. |     // class via a tool like ResGen or Visual Studio. | ||||||
|     // To add or remove a member, edit your .ResX file then rerun ResGen |     // To add or remove a member, edit your .ResX file then rerun ResGen | ||||||
|     // with the /str option, or rebuild your VS project. |     // with the /str option, or rebuild your VS project. | ||||||
|     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] |     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] | ||||||
|     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | ||||||
|     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | ||||||
|     internal class Resources { |     internal class Resources { | ||||||
| @@ -120,6 +120,26 @@ namespace TweetDuck.Properties { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  |         /// <summary> | ||||||
|  |         ///   Looks up a localized resource of type System.Drawing.Icon similar to (Icon). | ||||||
|  |         /// </summary> | ||||||
|  |         internal static System.Drawing.Icon overlay_muted { | ||||||
|  |             get { | ||||||
|  |                 object obj = ResourceManager.GetObject("overlay_muted", 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 overlay_notification { | ||||||
|  |             get { | ||||||
|  |                 object obj = ResourceManager.GetObject("overlay_notification", resourceCulture); | ||||||
|  |                 return ((System.Drawing.Icon)(obj)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         ///   Looks up a localized resource of type System.Byte[]. |         ///   Looks up a localized resource of type System.Byte[]. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
| @@ -136,6 +136,12 @@ | |||||||
|   <data name="icon_tray_new" type="System.Resources.ResXFileRef, System.Windows.Forms"> |   <data name="icon_tray_new" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|     <value>..\Resources\Images\icon-tray-new.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> |     <value>..\Resources\Images\icon-tray-new.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||||||
|   </data> |   </data> | ||||||
|  |   <data name="overlay_muted" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|  |     <value>..\Resources\Images\overlay-muted.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||||||
|  |   </data> | ||||||
|  |   <data name="overlay_notification" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|  |     <value>..\Resources\Images\overlay-notification.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||||||
|  |   </data> | ||||||
|   <data name="spinner" type="System.Resources.ResXFileRef, System.Windows.Forms"> |   <data name="spinner" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|     <value>..\Resources\Images\spinner.apng;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |     <value>..\Resources\Images\spinner.apng;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||||||
|   </data> |   </data> | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ The program can be built using Visual Studio 2017 or newer. Before opening the s | |||||||
| After opening the solution, right-click the solution and select **Restore NuGet Packages**, or manually run this command in the **Package Manager Console**: | After opening the solution, right-click the solution and select **Restore NuGet Packages**, or manually run this command in the **Package Manager Console**: | ||||||
| ``` | ``` | ||||||
| PM> Install-Package CefSharp.WinForms -Version 67.0.0 | PM> Install-Package CefSharp.WinForms -Version 67.0.0 | ||||||
|  | PM> Install-Package WindowsAPICodePack-Shell -Version 1.1.1 | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ### Debug | ### Debug | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								Resources/Design/overlay_icons.afdesign
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Resources/Design/overlay_icons.afdesign
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Resources/Images/overlay-muted.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Resources/Images/overlay-muted.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 9.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Resources/Images/overlay-notification.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Resources/Images/overlay-notification.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 9.4 KiB | 
| @@ -46,6 +46,12 @@ | |||||||
|     <LangVersion>7</LangVersion> |     <LangVersion>7</LangVersion> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|  |     <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||||||
|  |       <HintPath>packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|  |     <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||||||
|  |       <HintPath>packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|     <Reference Include="System" /> |     <Reference Include="System" /> | ||||||
|     <Reference Include="System.Core" /> |     <Reference Include="System.Core" /> | ||||||
|     <Reference Include="System.Drawing" /> |     <Reference Include="System.Drawing" /> | ||||||
| @@ -393,6 +399,15 @@ | |||||||
|       <Name>TweetLib.Communication</Name> |       <Name>TweetLib.Communication</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <None Include="Resources\Images\overlay-muted.png" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <None Include="Resources\Images\overlay-muted.ico" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <None Include="Resources\Images\overlay-notification.ico" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <PostBuildEvent>rmdir "$(ProjectDir)bin\Debug" |     <PostBuildEvent>rmdir "$(ProjectDir)bin\Debug" | ||||||
|   | |||||||
| @@ -5,4 +5,6 @@ | |||||||
|   <package id="CefSharp.Common" version="67.0.0" targetFramework="net452" /> |   <package id="CefSharp.Common" version="67.0.0" targetFramework="net452" /> | ||||||
|   <package id="CefSharp.WinForms" version="67.0.0" targetFramework="net452" /> |   <package id="CefSharp.WinForms" version="67.0.0" targetFramework="net452" /> | ||||||
|   <package id="Microsoft.Net.Compilers" version="2.9.0" targetFramework="net452" developmentDependency="true" /> |   <package id="Microsoft.Net.Compilers" version="2.9.0" targetFramework="net452" developmentDependency="true" /> | ||||||
|  |   <package id="WindowsAPICodePack-Core" version="1.1.1" targetFramework="net452" /> | ||||||
|  |   <package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net452" /> | ||||||
| </packages> | </packages> | ||||||
		Reference in New Issue
	
	Block a user