mirror of
				https://github.com/chylex/TweetDuck.git
				synced 2025-10-31 00:17:14 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			9953f06ab1
			...
			taskbar-ov
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9238410756 | 
| @@ -1,6 +1,7 @@ | ||||
| using System; | ||||
| using System.Drawing; | ||||
| using System.Windows.Forms; | ||||
| using Microsoft.WindowsAPICodePack.Taskbar; | ||||
| using TweetDuck.Configuration; | ||||
| using TweetDuck.Core.Bridge; | ||||
| using TweetDuck.Core.Controls; | ||||
| @@ -50,6 +51,7 @@ namespace TweetDuck.Core{ | ||||
|         private readonly FormNotificationTweet notification; | ||||
|         private readonly ContextMenu contextMenu; | ||||
|         private readonly UpdateBridge updateBridge; | ||||
|         private readonly TaskbarIcon taskbarIcon; | ||||
| 
 | ||||
|         private bool isLoaded; | ||||
|         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 | ||||
| 
 | ||||
|             this.taskbarIcon = new TaskbarIcon(); | ||||
|             Shown += (sender, args) => taskbarIcon.UpdateIcon(); | ||||
| 
 | ||||
|             Disposed += (sender, args) => { | ||||
|                 Config.MuteToggled -= Config_MuteToggled; | ||||
|                 Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; | ||||
| @@ -91,6 +96,7 @@ namespace TweetDuck.Core{ | ||||
|                 browser.Dispose(); | ||||
|                 updates.Dispose(); | ||||
|                 contextMenu.Dispose(); | ||||
|                 taskbarIcon.Dispose(); | ||||
| 
 | ||||
|                 notificationScreenshotManager?.Dispose(); | ||||
|                 videoPlayer?.Dispose(); | ||||
| @@ -105,10 +111,6 @@ namespace TweetDuck.Core{ | ||||
| 
 | ||||
|             UpdateTray(); | ||||
| 
 | ||||
|             if (Config.MuteNotifications){ | ||||
|                 UpdateFormIcon(); | ||||
|             } | ||||
| 
 | ||||
|             if (Config.AllowDataCollection){ | ||||
|                 analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath); | ||||
|             } | ||||
| @@ -134,10 +136,6 @@ namespace TweetDuck.Core{ | ||||
|             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(){ | ||||
|             trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon(); | ||||
|         } | ||||
| @@ -152,6 +150,7 @@ namespace TweetDuck.Core{ | ||||
|             if (!isLoaded)return; | ||||
| 
 | ||||
|             trayIcon.HasNotifications = false; | ||||
|             taskbarIcon.HasNotifications = false; | ||||
| 
 | ||||
|             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 | ||||
| @@ -213,7 +212,6 @@ namespace TweetDuck.Core{ | ||||
|         } | ||||
| 
 | ||||
|         private void Config_MuteToggled(object sender, EventArgs e){ | ||||
|             UpdateFormIcon(); | ||||
|             AnalyticsFile.NotificationMutes.Trigger(); | ||||
|         } | ||||
| 
 | ||||
| @@ -503,8 +501,12 @@ namespace TweetDuck.Core{ | ||||
|         } | ||||
| 
 | ||||
|         public void OnTweetNotification(){ // may be called multiple times, once for each type of notification | ||||
|             if (Config.EnableTrayHighlight && !ContainsFocus){ | ||||
|                 trayIcon.HasNotifications = true; | ||||
|             if (!ContainsFocus){ | ||||
|                 if (Config.EnableTrayHighlight){ | ||||
|                     trayIcon.HasNotifications = true; | ||||
|                 } | ||||
| 
 | ||||
|                 taskbarIcon.HasNotifications = false; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|   | ||||
							
								
								
									
										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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -51,7 +51,7 @@ namespace TweetDuck.Core.Other{ | ||||
|             this.contextMenu.MenuItems.Add("Mute notifications", menuItemMuteNotifications_Click); | ||||
|             this.contextMenu.MenuItems.Add("Close", menuItemClose_Click); | ||||
|             this.contextMenu.Popup += contextMenu_Popup; | ||||
|                  | ||||
|              | ||||
|             this.notifyIcon.ContextMenu = contextMenu; | ||||
|             this.notifyIcon.Text = Program.BrandName; | ||||
| 
 | ||||
|   | ||||
							
								
								
									
										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. | ||||
|     // To add or remove a member, edit your .ResX file then rerun ResGen | ||||
|     // 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.Runtime.CompilerServices.CompilerGeneratedAttribute()] | ||||
|     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> | ||||
|         ///   Looks up a localized resource of type System.Byte[]. | ||||
|         /// </summary> | ||||
|   | ||||
| @@ -136,6 +136,12 @@ | ||||
|   <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> | ||||
|   </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"> | ||||
|     <value>..\Resources\Images\spinner.apng;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||||
|   </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**: | ||||
| ``` | ||||
| PM> Install-Package CefSharp.WinForms -Version 67.0.0 | ||||
| PM> Install-Package WindowsAPICodePack-Shell -Version 1.1.1 | ||||
| ``` | ||||
|  | ||||
| ### 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> | ||||
|   </PropertyGroup> | ||||
|   <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.Core" /> | ||||
|     <Reference Include="System.Drawing" /> | ||||
| @@ -393,6 +399,15 @@ | ||||
|       <Name>TweetLib.Communication</Name> | ||||
|     </ProjectReference> | ||||
|   </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" /> | ||||
|   <PropertyGroup> | ||||
|     <PostBuildEvent>rmdir "$(ProjectDir)bin\Debug" | ||||
|   | ||||
| @@ -5,4 +5,6 @@ | ||||
|   <package id="CefSharp.Common" 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="WindowsAPICodePack-Core" version="1.1.1" targetFramework="net452" /> | ||||
|   <package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net452" /> | ||||
| </packages> | ||||
		Reference in New Issue
	
	Block a user