Skip to content

Commit

Permalink
Merge pull request #637 from dremin/invert-icon-mode
Browse files Browse the repository at this point in the history
Add settings to control icon invert
  • Loading branch information
dremin authored Jul 25, 2023
2 parents a53bbb5 + 9e6b4b9 commit ce53546
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RetroBar is based on the [ManagedShell](https://github.com/cairoshell/ManagedShe
- Quick launch toolbar
- Start button opens modern start menu
- Ability to show or hide the clock
- Ability to auto-hide the taskbar
- Locked and unlocked taskbar appearances
- Display taskbar on any side of the screen (even on Windows 11)
- Option to display the taskbar, notification area, and clock on multiple monitors
- Ability to show Vista-style window thumbnails
Expand Down Expand Up @@ -74,6 +76,7 @@ RetroBar is based on the [ManagedShell](https://github.com/cairoshell/ManagedShe
- Russian (русский)
- Serbian (Cyrillic) (српски)
- Serbian (Latin) (srpski)
- Slovak (slovenčina)
- Spanish (español)
- Swedish (svenska)
- Turkish (Türkçe)
Expand Down
3 changes: 3 additions & 0 deletions RetroBar/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<setting name="LockTaskbar" serializeAs="String">
<value>False</value>
</setting>
<setting name="InvertIconsMode" serializeAs="String">
<value>0</value>
</setting>
</RetroBar.Properties.Settings>
</userSettings>
</configuration>
7 changes: 4 additions & 3 deletions RetroBar/Controls/NotifyIcon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public NotifyIcon()

private void applyEffects()
{
if (!EnvironmentHelper.IsWindows10OrBetter || TrayIcon == null)
if ((!EnvironmentHelper.IsWindows10OrBetter && Settings.Instance.InvertIconsMode == 0) || TrayIcon == null || Settings.Instance.InvertIconsMode == 2)
{
return;
}
Expand All @@ -53,13 +53,14 @@ private void applyEffects()
}

bool invertByTheme = Application.Current.FindResource("InvertSystemNotifyIcons") as bool? ?? false;
bool performInvert = invertByTheme || Settings.Instance.InvertIconsMode == 1;

if (NotifyIconImage.Effect == null != invertByTheme)
if (NotifyIconImage.Effect == null != performInvert)
{
return;
}

if (invertByTheme)
if (performInvert)
{
NotifyIconImage.Effect = new InvertEffect();
}
Expand Down
14 changes: 14 additions & 0 deletions RetroBar/Controls/NotifyIconList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
NotifyIcons.ItemsSource = allNotifyIconsSource.View;
}
}
else if (e.PropertyName == "InvertIconsMode")
{
// Reload icons
NotifyIcons.ItemsSource = null;

if (Settings.Instance.CollapseNotifyIcons)
{
NotifyIcons.ItemsSource = pinnedNotifyIconsSource.View;
}
else
{
NotifyIcons.ItemsSource = allNotifyIconsSource.View;
}
}
}

private void NotifyIconList_OnLoaded(object sender, RoutedEventArgs e)
Expand Down
6 changes: 6 additions & 0 deletions RetroBar/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<s:String>Same taskbar as window</s:String>
<s:String>Same taskbar as window and primary taskbar</s:String>
</x:Array>
<s:String x:Key="invert_system_icons">_Invert system icons:</s:String>
<x:Array x:Key="invert_system_icons_values" Type="s:String">
<s:String>When needed by theme</s:String>
<s:String>Always</s:String>
<s:String>Never</s:String>
</x:Array>
<s:String x:Key="version">Version {0}</s:String>
<s:String x:Key="visit_on_github">Visit RetroBar on GitHub</s:String>
<s:String x:Key="taskbar_scale">Taskbar scale</s:String>
Expand Down
12 changes: 12 additions & 0 deletions RetroBar/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions RetroBar/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
<Setting Name="LockTaskbar" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="InvertIconsMode" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
10 changes: 10 additions & 0 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=DebugLogging, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource debug_logging}" />
</CheckBox>
<DockPanel>
<Label VerticalAlignment="Center"
Target="{Binding ElementName=cboInvertIconsMode}">
<AccessText Text="{DynamicResource invert_system_icons}" />
</Label>
<ComboBox Name="cboInvertIconsMode"
ItemsSource="{DynamicResource invert_system_icons_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=InvertIconsMode, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="cboInvertIconsMode_SelectionChanged" />
</DockPanel>
</StackPanel>
<GroupBox Header="{DynamicResource multiple_displays}"
Margin="0,0,0,10">
Expand Down
8 changes: 8 additions & 0 deletions RetroBar/PropertiesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ private void cboMultiMonMode_SelectionChanged(object sender, System.Windows.Cont
}
}

private void cboInvertIconsMode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (cboInvertIconsMode.SelectedItem == null)
{
cboInvertIconsMode.SelectedValue = cboInvertIconsMode.Items[Settings.Instance.InvertIconsMode];
}
}

private void CustomizeNotifications_OnClick(object sender, RoutedEventArgs e)
{
OpenCustomizeNotifications();
Expand Down
36 changes: 36 additions & 0 deletions RetroBar/Utilities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public bool MiddleMouseToClose
}
}

/// <summary>
/// 0 = Left
/// 1 = Top
/// 2 = Right
/// 3 = Bottom
/// </summary>
public int Edge
{
get
Expand Down Expand Up @@ -348,6 +354,11 @@ public bool ShowTaskThumbnails
}
}

/// <summary>
/// 0 = All taskbars
/// 1 = Same taskbar as window
/// 2 = Same taskbar as window and primary taskbar
/// </summary>
public int MultiMonMode
{
get
Expand Down Expand Up @@ -427,6 +438,31 @@ public bool LockTaskbar
}
}
}

/// <summary>
/// 0 = When needed by theme
/// 1 = Always
/// 2 = Never
/// </summary>
public int InvertIconsMode
{
get
{
if (settings.InvertIconsMode >= 0 && settings.InvertIconsMode <= 2)
{
return settings.InvertIconsMode;
}

return 0;
}
set
{
if (settings.InvertIconsMode != value && value >= 0 && value <= 2)
{
settings.InvertIconsMode = value;
}
}
}
#endregion

#region Helpers
Expand Down

0 comments on commit ce53546

Please sign in to comment.