Skip to content

Commit

Permalink
Add flag to override OS build number
Browse files Browse the repository at this point in the history
Closes #474
  • Loading branch information
srwi committed Jan 7, 2024
1 parent 4d7f9fb commit a747a57
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 16 deletions.
3 changes: 3 additions & 0 deletions EverythingToolbar.Deskband/CSDeskBand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using CSDeskBand.ContextMenu;
using CSDeskBand.Interop;
using EverythingToolbar.Helpers;
using EverythingToolbar.Properties;
using Microsoft.Win32;
using NLog;
using MSG = CSDeskBand.Interop.MSG;
Expand Down Expand Up @@ -1018,6 +1019,8 @@ public CSDeskBandWpf()
{
ToolbarLogger.Initialize();
Logger.Info($"EverythingToolbar {Assembly.GetExecutingAssembly().GetName().Version} started. OS: {Environment.OSVersion}");
if (Settings.Default.OSBuildNumberOverride != 0)
Logger.Info($"OS build number override: {Settings.Default.OSBuildNumberOverride}");
AppDomain.CurrentDomain.FirstChanceException += (sender, e) =>
{
Logger.Debug(e.Exception, "Unhandled first chance exception");
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar.Deskband/WindowPlacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private double GetScalingFactor()

private int GetMargin()
{
if (Environment.OSVersion.Version >= Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows11)
return (int)(12 / GetScalingFactor());

return 0;
Expand Down
2 changes: 2 additions & 0 deletions EverythingToolbar.Launcher/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public LauncherWindow(NotifyIcon icon)
{
ToolbarLogger.Initialize();
Logger.Info($"EverythingToolbar Launcher {Assembly.GetExecutingAssembly().GetName().Version} started. OS: {Environment.OSVersion}");
if (Settings.Default.OSBuildNumberOverride != 0)
Logger.Info($"OS build number override: {Settings.Default.OSBuildNumberOverride}");

_searchWindowRecentlyClosedTimer = new Timer(500);
_searchWindowRecentlyClosedTimer.AutoReset = false;
Expand Down
4 changes: 1 addition & 3 deletions EverythingToolbar.Launcher/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public static string GetTaskbarShortcutPath()

public static bool IsTaskbarCenterAligned()
{
ToolbarLogger.GetLogger<Utils>().Debug($"Windows version: {Environment.OSVersion.Version}");

if (Settings.Default.isForceCenterAlignment)
return true;

if (Environment.OSVersion.Version < WindowsVersion.Windows11)
if (Helpers.Utils.GetWindowsVersion() < Helpers.Utils.WindowsVersion.Windows11)
return false;

using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"))
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar.Launcher/WindowPlacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private double GetScalingFactor()

private int GetMargin()
{
if (Environment.OSVersion.Version >= Helpers.Utils.WindowsVersion.Windows11)
if (Helpers.Utils.GetWindowsVersion() >= Helpers.Utils.WindowsVersion.Windows11)
return 12;
else
return 0;
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Behaviors/DpiScaling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override void OnDetaching()

private static double GetParentWindowDpi(Visual visual)
{
if (Environment.OSVersion.Version < Utils.WindowsVersion.Windows10Anniversary)
if (Utils.GetWindowsVersion() < Utils.WindowsVersion.Windows10Anniversary)
{
return 96.0;
}
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Behaviors/MicaWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override void OnAttached()
{
base.OnAttached();

if (Environment.OSVersion.Version < Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() < Utils.WindowsVersion.Windows11)
return;

if (AssociatedObject.IsLoaded)
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Behaviors/ThemeAwareness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void ApplyTheme(bool isLightTheme)
var assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

var themeLocation = assemblyLocation;
if (Environment.OSVersion.Version >= Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows11)
themeLocation = Path.Combine(themeLocation, "Themes", "Win11");
else
themeLocation = Path.Combine(themeLocation, "Themes", "Win10");
Expand Down
6 changes: 3 additions & 3 deletions EverythingToolbar/Helpers/FilterLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class FilterLoader : INotifyPropertyChanged
{
new Filter {
Name = Resources.DefaultFilterAll,
Icon = Environment.OSVersion.Version >= Utils.WindowsVersion.Windows10 ? "\xE71D " : "",
Icon = Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows10 ? "\xE71D " : "",
IsMatchCase = false,
IsMatchWholeWord = false,
IsMatchPath = false,
Expand All @@ -28,7 +28,7 @@ internal class FilterLoader : INotifyPropertyChanged
},
new Filter {
Name = Resources.DefaultFilterFile,
Icon = Environment.OSVersion.Version >= Utils.WindowsVersion.Windows10 ? "\xE7C3 " : "",
Icon = Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows10 ? "\xE7C3 " : "",
IsMatchCase = false,
IsMatchWholeWord = false,
IsMatchPath = false,
Expand All @@ -38,7 +38,7 @@ internal class FilterLoader : INotifyPropertyChanged
},
new Filter {
Name = Resources.DefaultFilterFolder,
Icon = Environment.OSVersion.Version >= Utils.WindowsVersion.Windows10 ? "\xE8B7 " : "",
Icon = Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows10 ? "\xE8B7 " : "",
IsMatchCase = false,
IsMatchWholeWord = false,
IsMatchPath = false,
Expand Down
9 changes: 9 additions & 0 deletions EverythingToolbar/Helpers/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using EverythingToolbar.Properties;

namespace EverythingToolbar.Helpers
{
Expand All @@ -11,6 +12,14 @@ public static string GetConfigDirectory()
"EverythingToolbar");
}

public static Version GetWindowsVersion()
{
if (Settings.Default.OSBuildNumberOverride != 0)
return new Version(10, 0, Settings.Default.OSBuildNumberOverride);

return Environment.OSVersion.Version;
}

public static class WindowsVersion
{
public static readonly Version Windows10 = new Version(10, 0, 10240);
Expand Down
15 changes: 13 additions & 2 deletions EverythingToolbar/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 EverythingToolbar/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@
<Setting Name="isDoubleClickToOpen" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="OSBuildNumberOverride" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
6 changes: 3 additions & 3 deletions EverythingToolbar/SearchWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private SearchWindow()
Settings.Default.isUpgradeRequired = false;
}

if (Environment.OSVersion.Version < Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() < Utils.WindowsVersion.Windows11)
{
AllowsTransparency = true;
Loaded += (s, e) =>
Expand Down Expand Up @@ -150,7 +150,7 @@ public void AnimateShow(double left, double top, double width, double height, Ed
};
animation.Completed += (s, e) =>
{
if (Environment.OSVersion.Version >= Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows11)
AnimateShowWin11(left, top, width, height, taskbarEdge);
else
AnimateShowWin10(left, top, width, height, taskbarEdge);
Expand Down Expand Up @@ -424,7 +424,7 @@ private void AnimateHideWin11(Edge taskbarEdge)

public void AnimateHide(Edge taskbarEdge)
{
if (Environment.OSVersion.Version >= Utils.WindowsVersion.Windows11)
if (Utils.GetWindowsVersion() >= Utils.WindowsVersion.Windows11)
AnimateHideWin11(taskbarEdge);
else
AnimateHideWin10(taskbarEdge);
Expand Down
3 changes: 3 additions & 0 deletions EverythingToolbar/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
<setting name="isDoubleClickToOpen" serializeAs="String">
<value>False</value>
</setting>
<setting name="OSBuildNumberOverride" serializeAs="String">
<value>0</value>
</setting>
</EverythingToolbar.Properties.Settings>
</userSettings>
<System.Windows.Forms.ApplicationConfigurationSection>
Expand Down

0 comments on commit a747a57

Please sign in to comment.