-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #812 from dremin/invert-custom-icons
Ability to configure which tray icons get inverted
- Loading branch information
Showing
11 changed files
with
167 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using ManagedShell.WindowsTray; | ||
using RetroBar.Extensions; | ||
using System; | ||
using System.Windows.Data; | ||
|
||
namespace RetroBar.Converters | ||
{ | ||
[ValueConversion(typeof(NotifyIcon), typeof(bool))] | ||
public class NotifyIconCanInvertConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
if (value is NotifyIcon icon) | ||
{ | ||
return icon.CanInvert(); | ||
} | ||
|
||
return Binding.DoNothing; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return Binding.DoNothing; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using ManagedShell.WindowsTray; | ||
using RetroBar.Utilities; | ||
using System.Collections.Generic; | ||
|
||
namespace RetroBar.Extensions | ||
{ | ||
public static class NotifyIconExtensions | ||
{ | ||
public static string GetInvertIdentifier(this NotifyIcon icon) | ||
{ | ||
if (icon.GUID != default) return icon.GUID.ToString(); | ||
else return icon.Path + ":" + icon.UID.ToString(); | ||
} | ||
|
||
public static bool CanInvert(this NotifyIcon icon) { | ||
return Settings.Instance.InvertNotifyIcons.Contains(icon.GetInvertIdentifier()); | ||
} | ||
|
||
public static void SetCanInvert(this NotifyIcon icon, bool canInvert) | ||
{ | ||
var identifier = icon.GetInvertIdentifier(); | ||
var settings = new List<string>(Settings.Instance.InvertNotifyIcons); | ||
var changed = false; | ||
|
||
if (!canInvert) | ||
{ | ||
changed = settings.Remove(identifier); | ||
} | ||
else if (!settings.Contains(identifier)) | ||
{ | ||
settings.Add(identifier); | ||
changed = true; | ||
} | ||
|
||
if (changed) | ||
{ | ||
Settings.Instance.InvertNotifyIcons = settings; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters