Skip to content

Commit

Permalink
0.10 Beta Bugfix (Win11 OSD & Lock keys) (#1205)
Browse files Browse the repository at this point in the history
* Updated the toolkit

Microsoft deprecated the old toolkit and released the same thing under a new name.

* Update ModernFlyouts.Package.wapproj

* Update README.md

* Adds Windows 11 Support for hiding the volume OSD

Changes the class that is being searched for depending on the build number.

* Revert "Update README.md"

This reverts commit 381e623.

* Reverting the name back to normal

I changed it to avoid interfering with normal builds.
  • Loading branch information
manstheram authored Jul 30, 2023
1 parent fc78d2d commit 60626f8
Show file tree
Hide file tree
Showing 26 changed files with 191 additions and 183 deletions.
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Display/BrightnessController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Management;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using ModernFlyouts.Core.Interop;

namespace ModernFlyouts.Core.Display
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Display/DisplayManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using ModernFlyouts.Core.Interop;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Display/DisplayMonitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Windows;

Expand Down
30 changes: 26 additions & 4 deletions ModernFlyouts.Core/Interop/NativeFlyoutHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Threading;
using static ModernFlyouts.Core.Interop.NativeMethods;

Expand Down Expand Up @@ -340,11 +342,31 @@ private static bool IsShellProcess(int id)

private bool GetAllInfos()
{
IntPtr hWndHost;
while ((hWndHost = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "NativeHWNDHost", "")) != IntPtr.Zero)
IntPtr hWndHost = IntPtr.Zero;
IntPtr hWndDUI = IntPtr.Zero;

String build = RuntimeInformation.OSDescription.Substring(RuntimeInformation.OSDescription.LastIndexOf('.') + 1);
int buildNumber = int.Parse(build);

String outerClass = "";
String outerName = "";
String innerClass = "";
String innerName = "";
if (buildNumber >= 22000)
{
outerClass = "XamlExplorerHostIslandWindow";
innerClass = "Windows.UI.Composition.DesktopWindowContentBridge";
innerName = "DesktopWindowXamlSource";
}
else
{
outerClass = "NativeHWNDHost";
innerClass = "DirectUIHWND";
}

while ((hWndHost = FindWindowEx(IntPtr.Zero, hWndHost, outerClass, outerName)) != IntPtr.Zero)
{
IntPtr hWndDUI;
if ((hWndDUI = FindWindowEx(hWndHost, IntPtr.Zero, "DirectUIHWND", "")) != IntPtr.Zero)
if ((hWndDUI = FindWindowEx(hWndHost, IntPtr.Zero, innerClass, innerName)) != IntPtr.Zero)
{
GetWindowThreadProcessId(hWndHost, out int pid);
if (Process.GetProcessById(pid).ProcessName.ToLower() == "explorer")
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Media/Control/GSMTCMediaSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Input;
using ModernFlyouts.Core.AppInformation;
using ModernFlyouts.Core.Helpers;
using System;
Expand Down
4 changes: 2 additions & 2 deletions ModernFlyouts.Core/Media/Control/MediaSession.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Windows;
using System.Windows.Input;
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Media/Control/MediaSessionManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.ObjectModel;

Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts.Core/Media/Control/NowPlayingMediaSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Input;
using ModernFlyouts.Core.AppInformation;
using ModernFlyouts.Core.Helpers;
using ModernFlyouts.Core.Threading;
Expand Down
3 changes: 2 additions & 1 deletion ModernFlyouts.Core/ModernFlyouts.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="NPSMLib" Version="0.9.14" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0-rc.2.21480.5" />
Expand Down
7 changes: 4 additions & 3 deletions ModernFlyouts.Package/ModernFlyouts.Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppInstallerUri>https://ModernFlyouts-community.github.io/package.github.io/ModernFlyouts.Package/ModernFlyouts.Package.appinstaller</AppInstallerUri>
<EntryPointProjectUniqueName>..\ModernFlyouts\ModernFlyouts.csproj</EntryPointProjectUniqueName>
Expand Down Expand Up @@ -110,7 +110,9 @@
<Content Include="Images\Wide310x150Logo.scale-150.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
<Content Include="Images\Wide310x150Logo.scale-400.png" />
<PRIResource Include="Strings\en-us\Resources.resw" />
<PRIResource Include="Strings\en-us\Resources.resw">
<SubType>Designer</SubType>
</PRIResource>
<None Include="ModernFlyouts.Package_TemporaryKey.pfx" />
<Content Include="Package.appinstaller" />
<Content Include="priconfig.default.xml" />
Expand All @@ -122,7 +124,6 @@
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
<ProjectReference Include="..\ModernFlyoutsBridge\ModernFlyoutsBridge.vcxproj" />
</ItemGroup>
<Target Name="FlattenPackage" BeforeTargets="_ConvertItems">
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts/Controls/DisplayMonitorPicker.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Input;
using ModernFlyouts.Core.Display;
using System.Windows;
using System.Windows.Controls;
Expand Down
8 changes: 3 additions & 5 deletions ModernFlyouts/Controls/LockKeysControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
Height="64" d:DesignWidth="354" DataContext="{x:Static root:FlyoutHandler.Instance}">

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<ui:FontIcon Glyph="{Binding LockKeysFlyoutHelper.StatusGlyph}"
d:Glyph="{x:Static utils:CommonGlyphs.Lock}" FontSize="24" />
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center"
<ui:FontIcon x:Name="LockGlyph" Glyph="{x:Static utils:CommonGlyphs.Lock}" FontSize="24" />
<TextBlock x:Name="txt" HorizontalAlignment="Left" VerticalAlignment="Center"
Style="{DynamicResource BaseTextBlockStyle}" FontSize="18"
Margin="20" Text="{Binding LockKeysFlyoutHelper.StatusText}"
d:Text="Lock key is on" />
Margin="20" Text="Lock key is on" />
</StackPanel>

</UserControl>
2 changes: 1 addition & 1 deletion ModernFlyouts/Flyout Helpers/FlyoutHelperBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Windows;

namespace ModernFlyouts
Expand Down
24 changes: 3 additions & 21 deletions ModernFlyouts/Flyout Helpers/LockKeysFlyoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ public class LockKeysFlyoutHelper : FlyoutHelperBase

#region Properties

private string statusGlyph = string.Empty;

public string StatusGlyph
{
get => statusGlyph;
private set => SetProperty(ref statusGlyph, value);
}

private string statusText = string.Empty;

public string StatusText
{
get => statusText;
private set => SetProperty(ref statusText, value);
}

private bool capsLockEnabled = DefaultValuesStore.LockKeysModule_CapsLockEnabled;

public bool CapsLockEnabled
Expand Down Expand Up @@ -151,7 +135,6 @@ private void KeyReleased(Key key, int virtualKey)
private void Prepare(LockKeys key, bool islock)
{
string msg;
string glyph;

if (key != LockKeys.Insert)
{
Expand All @@ -164,16 +147,15 @@ private void Prepare(LockKeys key, bool islock)
};

msg = string.Format(islock ? Properties.Strings.LockKeysFlyoutHelper_KeyIsOn : Properties.Strings.LockKeysFlyoutHelper_KeyIsOff, keyName);
glyph = islock ? CommonGlyphs.Lock : CommonGlyphs.Unlock;
lockKeysControl.LockGlyph.Glyph = islock ? CommonGlyphs.Lock : CommonGlyphs.Unlock;
}
else
{
msg = islock ? Properties.Strings.LockKeysFlyoutHelper_OvertypeMode : Properties.Strings.LockKeysFlyoutHelper_InsertMode;
glyph = string.Empty;
lockKeysControl.LockGlyph.Glyph = string.Empty;
}

StatusGlyph = glyph;
StatusText = msg;
lockKeysControl.txt.Text = msg;
}

private enum LockKeys
Expand Down
2 changes: 1 addition & 1 deletion ModernFlyouts/FlyoutHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using ModernFlyouts.AppLifecycle;
using ModernFlyouts.Core.Display;
using ModernFlyouts.Core.Interop;
Expand Down
1 change: 1 addition & 0 deletions ModernFlyouts/ModernFlyouts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="ModernWpf.Toolkit.UI.Controls" Version="0.1.0" />
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
Expand Down
58 changes: 8 additions & 50 deletions ModernFlyouts/Properties/Strings.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<value>Repetir: desactivado</value>
</data>
<data name="SessionControl.RepeatOne" xml:space="preserve">
<value>Repetir: una</value>
<value>Repetir: bucle</value>
</data>
<data name="SessionControl.ShuffleOff" xml:space="preserve">
<value>Aleatorio: desactivado</value>
Expand Down Expand Up @@ -147,7 +147,7 @@
<value>Teclas de bloqueo</value>
</data>
<data name="Settings.RunAtStartup" xml:space="preserve">
<value>Ejecutar al inicio</value>
<value>Iniciar con Windows</value>
</data>
<data name="SettingsItem" xml:space="preserve">
<value>Configuración</value>
Expand Down Expand Up @@ -216,7 +216,7 @@
<value>Mostrar controles de transporte de medios del sistema global (GSMTC) también conocidos como controles de medios en el control flotante de volumen</value>
</data>
<data name="AudioFlyoutHelper.ShowVolumeControlInGSMTCFlyout" xml:space="preserve">
<value>Mostrar control de volumen en global system Media Transport Controls (GSMTC) también conocido como control flotante de medios</value>
<value>Mostrar control de volumen en transporte de medios del sistema global (GSMTC) también conocido como control flotante de medios</value>
</data>
<data name="AudioFlyoutHelper.ThumbnailAlignment" xml:space="preserve">
<value>Alineación de miniaturas</value>
Expand Down Expand Up @@ -249,7 +249,7 @@
<value>Bloq Despl</value>
</data>
<data name="LockKeysFlyoutHelper.SelectKeyDescription" xml:space="preserve">
<value>Seleccione las teclas para las que desea mostrar el control flotante</value>
<value>Selecciona las teclas para las que desea mostrar el control flotante</value>
</data>
<data name="Settings.Appearance" xml:space="preserve">
<value>Apariencia</value>
Expand All @@ -258,13 +258,13 @@
<value>Activar el control flotante del modo avión</value>
</data>
<data name="Settings.EnableModule.Audio" xml:space="preserve">
<value>Activar el control flotante del audio</value>
<value>Activar control flotante para audio</value>
</data>
<data name="Settings.EnableModule.Brightness" xml:space="preserve">
<value>Activar el control flotante del brillo</value>
<value>Activar control flotante para brillo</value>
</data>
<data name="Settings.EnableModule.LockKeys" xml:space="preserve">
<value>Activar el control flotante del bloqueo de teclas</value>
<value>Activar control flotante para bloqueo de teclas</value>
</data>
<data name="Settings.FlyoutTheme" xml:space="preserve">
<value>Tema del control flotante</value>
Expand Down Expand Up @@ -312,56 +312,14 @@
<value>Alinear control flotante a esta posición</value>
</data>
<data name="Settings.RestartRequired" xml:space="preserve">
<value>Reinicio necesario para aplicar algunos cambios</value>
<value>Reinicia la aplicación para aplicar algunos cambios</value>
</data>
<data name="AudioFlyoutHelper.UseThumbnailAsBackground" xml:space="preserve">
<value>Usar la miniatura multimedia como fondo del control multimedia</value>
</data>
<data name="Enums.FlyoutWindowAlignments.Bottom" xml:space="preserve">
<value>Inferior</value>
</data>
<data name="Enums.FlyoutWindowAlignments.Center" xml:space="preserve">
<value>Centro</value>
</data>
<data name="Enums.FlyoutWindowAlignments.Left" xml:space="preserve">
<value>Izquierda</value>
</data>
<data name="Enums.FlyoutWindowAlignments.Right" xml:space="preserve">
<value>Derecha</value>
</data>
<data name="Enums.FlyoutWindowAlignments.Top" xml:space="preserve">
<value>Arriba</value>
</data>
<data name="Enums.FlyoutWindowExpandDirection.Auto" xml:space="preserve">
<value>Automático</value>
</data>
<data name="Enums.FlyoutWindowExpandDirection.Down" xml:space="preserve">
<value>Abajo</value>
</data>
<data name="Enums.FlyoutWindowExpandDirection.Left" xml:space="preserve">
<value>Izquierda</value>
</data>
<data name="Enums.FlyoutWindowExpandDirection.Right" xml:space="preserve">
<value>Derecha</value>
</data>
<data name="Enums.FlyoutWindowExpandDirection.Up" xml:space="preserve">
<value>Arriba</value>
</data>
<data name="Enums.FlyoutWindowPlacementMode.Auto" xml:space="preserve">
<value>Automático</value>
</data>
<data name="Enums.FlyoutWindowPlacementMode.Manual" xml:space="preserve">
<value>Manualmente</value>
</data>
<data name="Enums.StackingDirection.Ascending" xml:space="preserve">
<value>Ascendente</value>
</data>
<data name="Enums.StackingDirection.Descending" xml:space="preserve">
<value>Descendente</value>
</data>
<data name="Settings.Display" xml:space="preserve">
<value>Mostrar</value>
</data>
<data name="Settings.HorizontalAlignment" xml:space="preserve">
<value>Alineación horizontal</value>
</data>
Expand Down
Loading

0 comments on commit 60626f8

Please sign in to comment.