1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-09-14 19:32:10 +02:00

Compare commits

...

4 Commits

13 changed files with 139 additions and 30 deletions

View File

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

View File

@@ -30,11 +30,19 @@ namespace TweetDuck.Core.Utils{
public sealed class Item : IComparable<Item>{
public string Code { get; }
public CultureInfo Info { get; }
private string Name => info?.NativeName ?? Code;
private readonly CultureInfo info;
public Item(string code, string alt = null){
this.Code = code;
this.Info = CultureInfo.GetCultureInfo(alt ?? code);
try{
this.info = CultureInfo.GetCultureInfo(alt ?? code);
}catch(CultureNotFoundException){
// ignore
}
}
public override bool Equals(object obj){
@@ -46,12 +54,16 @@ namespace TweetDuck.Core.Utils{
}
public override string ToString(){
string capitalizedName = Info.TextInfo.ToTitleCase(Info.NativeName);
return Info.DisplayName == Info.NativeName ? capitalizedName : $"{capitalizedName}, {Info.DisplayName}";
if (info == null){
return Code;
}
string capitalizedName = info.TextInfo.ToTitleCase(info.NativeName);
return info.DisplayName == info.NativeName ? capitalizedName : $"{capitalizedName}, {info.DisplayName}";
}
public int CompareTo(Item other){
return string.Compare(Info.NativeName, other.Info.NativeName, false, CultureInfo.InvariantCulture);
return string.Compare(Name, other.Name, false, CultureInfo.InvariantCulture);
}
}
}

View File

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

View File

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

View File

@@ -6,20 +6,20 @@
### Setup
The program was built using Visual Studio 2017. Before opening the solution, please make sure you have the following workloads and components installed (optional components that are not listed can be deselected to save space):
The program can be built using Visual Studio 2017 or newer. Before opening the solution, please make sure you have the following workloads and components installed (optional components that are not listed can be deselected to save space):
* **.NET desktop development**
* .NET Framework 4 4.6 development tools
* F# desktop language support
* **Desktop development with C++**
* VC++ 2017 latest v141 tools
* *(VS 2017)* VC++ 2017 version 15.9 v14.16 latest v141 tools
* *(VS 2019)* MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.20)
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-pre01
PM> Install-Package CefSharp.WinForms -Version 67.0.0
PM> Install-Package WindowsAPICodePack-Shell -Version 1.1.1
```
Note that some pre-release builds of CefSharp are not available on NuGet. To correctly restore packages in that case, open **Package Manager Settings**, and add `https://www.myget.org/F/cefsharp/api/v3/index.json` to the list of package sources.
### Debug
The `Debug` configuration uses a separate data folder by default (`%LOCALAPPDATA%\TweetDuckDebug`) to avoid affecting an existing installation of TweetDuck. You can modify this by opening **TweetDuck Properties** in Visual Studio, clicking the **Debug** tab, and changing the **Command line arguments** field.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -56,12 +56,6 @@ enabled(){
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
window.TDPF_injectMustache("compose/docked_compose.mustache", "append", '<div class="cf margin-t--12 margin-b--30">', buttonHTML);
let maybeDockedComposePanel = $(".js-docked-compose");
if (maybeDockedComposePanel.length){
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
}
this.getDrawerInput = () => {
return $(".js-compose-text", me.composeDrawer);
};
@@ -413,6 +407,15 @@ enabled(){
me.currentKeyboard.style.top = getKeyboardTop()+"px";
}
};
// re-enabling
let maybeDockedComposePanel = $(".js-docked-compose");
if (maybeDockedComposePanel.length){
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
this.drawerToggleEvent({}, { activeDrawer: "compose" });
}
}
ready(){

View File

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

View File

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