Skip to content

Commit

Permalink
Reduce taskbar display is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliviaophia committed Apr 18, 2022
1 parent 44f9a4c commit a907a2b
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 12 deletions.
23 changes: 13 additions & 10 deletions Sources/SmartTaskbar.Win10/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SmartTaskbar.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
Expand All @@ -17,12 +17,15 @@
</System.Windows.Forms.ApplicationConfigurationSection>
<userSettings>
<SmartTaskbar.Properties.Settings>
<setting name="AutoModeType" serializeAs="String">
<value>Display</value>
</setting>
<setting name="ShowTaskbarWhenExit" serializeAs="String">
<value>True</value>
</setting>
</SmartTaskbar.Properties.Settings>
<setting name="AutoModeType" serializeAs="String">
<value>Display</value>
</setting>
<setting name="ShowTaskbarWhenExit" serializeAs="String">
<value>True</value>
</setting>
<setting name="ReduceTaskbarDisplay" serializeAs="String">
<value>False</value>
</setting>
</SmartTaskbar.Properties.Settings>
</userSettings>
</configuration>
2 changes: 2 additions & 0 deletions Sources/SmartTaskbar.Win10/Languages/LangName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public static class LangName

public const string Animation = "tray_animation";

public const string ReduceTaskbarDisplay = "tray_reduceTaskbarDisplay";

public const string Auto = "tray_auto";

public const string ShowBarOnExit = "tray_showBarOnExit";
Expand Down
3 changes: 3 additions & 0 deletions Sources/SmartTaskbar.Win10/Languages/Resource.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="tray_exit" xml:space="preserve">
<value>Exit</value>
</data>
<data name="tray_reduceTaskbarDisplay" xml:space="preserve">
<value>Reduce taskbar display</value>
</data>
<data name="tray_showBarOnExit" xml:space="preserve">
<value>Show the taskbar after exit</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Sources/SmartTaskbar.Win10/Languages/Resource.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="tray_exit" xml:space="preserve">
<value>Выход</value>
</data>
<data name="tray_reduceTaskbarDisplay" xml:space="preserve">
<value>Reduce taskbar display</value>
</data>
<data name="tray_showBarOnExit" xml:space="preserve">
<value>Show the taskbar after exit</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Sources/SmartTaskbar.Win10/Languages/Resource.uk-UA.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="tray_exit" xml:space="preserve">
<value>Вихід</value>
</data>
<data name="tray_reduceTaskbarDisplay" xml:space="preserve">
<value>Reduce taskbar display</value>
</data>
<data name="tray_showBarOnExit" xml:space="preserve">
<value>Show the taskbar after exit</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Sources/SmartTaskbar.Win10/Languages/Resource.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="tray_exit" xml:space="preserve">
<value>退出</value>
</data>
<data name="tray_reduceTaskbarDisplay" xml:space="preserve">
<value>减少任务栏显示</value>
</data>
<data name="tray_showBarOnExit" xml:space="preserve">
<value>退出后显示任务栏</value>
</data>
Expand Down
5 changes: 5 additions & 0 deletions Sources/SmartTaskbar.Win10/Models/UserConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ internal struct UserConfiguration
/// Show taskbar when exiting
/// </summary>
public bool ShowTaskbarWhenExit { get; set; }

/// <summary>
/// Hide the taskbar when any windows intersect
/// </summary>
public bool ReduceTaskbarDisplay { get; set; }
}
}
17 changes: 16 additions & 1 deletion Sources/SmartTaskbar.Win10/Models/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ static UserSettings()
=> _userConfiguration = new UserConfiguration
{
AutoModeType = Settings.Default.AutoModeType.AsAutoModeType(),
ShowTaskbarWhenExit = Settings.Default.ShowTaskbarWhenExit
ShowTaskbarWhenExit = Settings.Default.ShowTaskbarWhenExit,
ReduceTaskbarDisplay = Settings.Default.ReduceTaskbarDisplay
};

public static AutoModeType AutoModeType
Expand All @@ -31,6 +32,20 @@ public static AutoModeType AutoModeType
}
}

public static bool ReduceTaskbarDisplay
{
get => _userConfiguration.ReduceTaskbarDisplay;
set
{
if (value == _userConfiguration.ReduceTaskbarDisplay)
return;

_userConfiguration.ReduceTaskbarDisplay = value;
Settings.Default.ReduceTaskbarDisplay = value;
Settings.Default.Save();
}
}

public static bool ShowTaskbarWhenExit
{
get => _userConfiguration.ShowTaskbarWhenExit;
Expand Down
12 changes: 12 additions & 0 deletions Sources/SmartTaskbar.Win10/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 Sources/SmartTaskbar.Win10/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<Setting Name="ShowTaskbarWhenExit" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ReduceTaskbarDisplay" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
14 changes: 14 additions & 0 deletions Sources/SmartTaskbar.Win10/Views/SystemTray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class SystemTray : ApplicationContext
private const int TrayTolerance = 4;
private readonly ToolStripMenuItem _about;
private readonly ToolStripMenuItem _animation;
private readonly ToolStripMenuItem _reduceTaskbarDisplay;
private readonly ToolStripMenuItem _autoMode;
private readonly Container _container = new Container();
private readonly ContextMenuStrip _contextMenuStrip;
Expand Down Expand Up @@ -40,6 +41,11 @@ public SystemTray()
Text = resource.GetString(LangName.Animation),
Font = font
};
_reduceTaskbarDisplay = new ToolStripMenuItem
{
Text = resource.GetString(LangName.ReduceTaskbarDisplay),
Font = font
};
_autoMode = new ToolStripMenuItem
{
Text = resource.GetString(LangName.Auto),
Expand All @@ -65,6 +71,7 @@ public SystemTray()
_about,
_animation,
new ToolStripSeparator(),
_reduceTaskbarDisplay,
_autoMode,
new ToolStripSeparator(),
_showTaskbarWhenExit,
Expand All @@ -86,6 +93,8 @@ public SystemTray()

_animation.Click += AnimationOnClick;

_reduceTaskbarDisplay.Click += ReduceTaskbarDisplayOnClick;

_autoMode.Click += AutoModeOnClick;

_showTaskbarWhenExit.Click += ShowTaskbarWhenExitOnClick;
Expand All @@ -101,6 +110,9 @@ public SystemTray()
#endregion
}

private void ReduceTaskbarDisplayOnClick(object sender, EventArgs e)
=> UserSettings.ReduceTaskbarDisplay = !_reduceTaskbarDisplay.Checked;


private void ShowTaskbarWhenExitOnClick(object sender, EventArgs e)
=> UserSettings.ShowTaskbarWhenExit = !_showTaskbarWhenExit.Checked;
Expand Down Expand Up @@ -133,6 +145,8 @@ private void NotifyIconOnMouseClick(object s, MouseEventArgs e)

_animation.Checked = Fun.IsEnableTaskbarAnimation();

_reduceTaskbarDisplay.Checked = UserSettings.ReduceTaskbarDisplay;

_showTaskbarWhenExit.Checked = UserSettings.ShowTaskbarWhenExit;

_autoMode.Checked = UserSettings.AutoModeType == AutoModeType.Auto;
Expand Down
49 changes: 48 additions & 1 deletion Sources/SmartTaskbar.Win10/Worker/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ private static void Timer_Tick(object sender, EventArgs e)
case TaskbarBehavior.DoNothing:
break;
case TaskbarBehavior.Pending:
CheckCurrentWindow();
if (UserSettings.ReduceTaskbarDisplay)
CheckCurrentWindowReduceShowBar();
else
CheckCurrentWindow();

break;
case TaskbarBehavior.Show:
Expand Down Expand Up @@ -104,6 +107,47 @@ private static void CheckCurrentWindow()
Debug.WriteLine("try SHOW because of Desktop Show.");
#endif

_taskbar.ShowTaskar();
}

break;
case TaskbarBehavior.Show:
// #if DEBUG
// Debug.WriteLine(
// $"try SHOW because of {info.Handle.ToString("x8")} Class Name: {info.Handle.GetClassName()}");
// #endif

_taskbar.ShowTaskar();
break;
case TaskbarBehavior.Hide:
if (info == _currentForegroundWindow) return;

_taskbar.HideTaskbar();
break;
}

_currentForegroundWindow = info;
}


private static void CheckCurrentWindowReduceShowBar()
{
var behavior =
_taskbar.CheckIfForegroundWindowIntersectTaskbar(DesktopHandleSet,
NonForegroundShowHandleSet,
out var info);

switch (behavior)
{
case TaskbarBehavior.DoNothing:
break;
case TaskbarBehavior.Pending:
if (_taskbar.CheckIfDesktopShow(DesktopHandleSet, NonDesktopShowHandleSet))
{
#if DEBUG
Debug.WriteLine("try SHOW because of Desktop Show.");
#endif

BeforeShowBar();
}

Expand All @@ -113,7 +157,9 @@ private static void CheckCurrentWindow()
// Debug.WriteLine(
// $"try SHOW because of {info.Handle.ToString("x8")} Class Name: {info.Handle.GetClassName()}");
// #endif

BeforeShowBar();

break;
case TaskbarBehavior.Hide:
if (info == _currentForegroundWindow) return;
Expand All @@ -130,6 +176,7 @@ private static void CheckCurrentWindow()
#endif

_taskbar.HideTaskbar();

break;
}

Expand Down

0 comments on commit a907a2b

Please sign in to comment.