Skip to content

Commit dd5de42

Browse files
committed
Init
1 parent 762ba7a commit dd5de42

File tree

4 files changed

+37
-62
lines changed

4 files changed

+37
-62
lines changed

Diff for: .github/NOTICE.md

-30
Original file line numberDiff line numberDiff line change
@@ -645,36 +645,6 @@ A "contributor" is any person that distributes its contribution under this licen
645645
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
646646
```
647647

648-
## Vanara
649-
650-
**Source**: [https://github.com/dahall/Vanara](https://github.com/dahall/Vanara)
651-
652-
### License
653-
654-
```
655-
MIT License
656-
657-
Copyright (c) 2017 David Hall
658-
659-
Permission is hereby granted, free of charge, to any person obtaining a copy
660-
of this software and associated documentation files (the "Software"), to deal
661-
in the Software without restriction, including without limitation the rights
662-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
663-
copies of the Software, and to permit persons to whom the Software is
664-
furnished to do so, subject to the following conditions:
665-
666-
The above copyright notice and this permission notice shall be included in all
667-
copies or substantial portions of the Software.
668-
669-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
670-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
671-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
672-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
673-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
674-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
675-
SOFTWARE.
676-
```
677-
678648
## WinUIEx
679649

680650
**Source**: [https://github.com/dotMorten/WinUIEx](https://github.com/dotMorten/WinUIEx)

Diff for: src/Files.App/NativeMethods.txt

+4
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@ DesktopWallpaper
9494
SHCreateShellItemArrayFromIDLists
9595
ILCreateFromPath
9696
CLSIDFromString
97+
FindWindow
98+
SendMessage
99+
IsWindowVisible
100+
COPYDATASTRUCT

Diff for: src/Files.App/Services/PreviewPopupProviders/SeerProProvider.cs

+33-31
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,47 @@
44
using Microsoft.Win32;
55
using System.IO;
66
using System.Runtime.InteropServices;
7-
using Vanara.PInvoke;
7+
using Windows.Win32;
8+
using Windows.Win32.Foundation;
9+
using Windows.Win32.System.DataExchange;
10+
using static Vanara.PInvoke.AdvApi32.INSTALLSPEC;
811

912
namespace Files.App.Services.PreviewPopupProviders
1013
{
11-
public struct COPYDATASTRUCT
12-
{
13-
public IntPtr dwData;
14-
public int cbData;
15-
public IntPtr lpData;
16-
}
17-
1814
public sealed class SeerProProvider : IPreviewPopupProvider
1915
{
2016
public static SeerProProvider Instance { get; } = new();
2117

2218
private string? CurrentPath;
2319

24-
public async Task TogglePreviewPopupAsync(string path)
20+
private bool? _IsTrackSelectionSettingEnabledCache;
21+
private bool IsTrackSelectionSettingEnabled
2522
{
26-
HWND Window = User32.FindWindow("SeerWindowClass", null);
27-
COPYDATASTRUCT data = new COPYDATASTRUCT();
28-
data.dwData = 5000;
29-
data.cbData = (path.Length + 1) * 2;
30-
data.lpData = Marshal.StringToHGlobalUni(path);
31-
User32.SendMessage(Window, (uint)User32.WindowMessage.WM_COPYDATA, 0, ref data);
32-
33-
CurrentPath = User32.IsWindowVisible(Window) ? path : null;
23+
get
24+
{
25+
_IsTrackSelectionSettingEnabledCache ??= DetectTrackSelectionSetting().Result;
26+
27+
return _IsTrackSelectionSettingEnabledCache.Value;
28+
}
29+
}
30+
31+
public unsafe async Task TogglePreviewPopupAsync(string path)
32+
{
33+
COPYDATASTRUCT data = default;
34+
data.dwData = 5000u;
35+
data.cbData = (uint)(path.Length + 1) * 2;
36+
data.lpData = (void*)Marshal.StringToHGlobalUni(path);
37+
38+
var pData = Marshal.AllocHGlobal(Marshal.SizeOf(data));
39+
Marshal.StructureToPtr(data, pData, false);
40+
41+
HWND hWnd = PInvoke.FindWindow("SeerWindowClass", null);
42+
var result = PInvoke.SendMessage(hWnd, 0x004A /*WM_COPYDATA*/, 0, pData);
43+
44+
CurrentPath = PInvoke.IsWindowVisible(hWnd) ? path : null;
45+
46+
Marshal.FreeHGlobal((nint)data.lpData);
47+
Marshal.FreeHGlobal(pData);
3448
}
3549

3650
public async Task SwitchPreviewAsync(string path)
@@ -49,20 +63,8 @@ public async Task SwitchPreviewAsync(string path)
4963

5064
public async Task<bool> DetectAvailability()
5165
{
52-
var handle = User32.FindWindow("SeerWindowClass", null).DangerousGetHandle();
53-
return handle != IntPtr.Zero && handle.ToInt64() != -1;
54-
}
55-
56-
private bool? _IsTrackSelectionSettingEnabledCache;
57-
private bool IsTrackSelectionSettingEnabled
58-
{
59-
get
60-
{
61-
if (_IsTrackSelectionSettingEnabledCache is null)
62-
_IsTrackSelectionSettingEnabledCache = DetectTrackSelectionSetting().Result;
63-
64-
return _IsTrackSelectionSettingEnabledCache.Value;
65-
}
66+
var hWnd = PInvoke.FindWindow("SeerWindowClass", null).Value;
67+
return hWnd != nint.Zero && hWnd.ToInt64() != -1;
6668
}
6769

6870
private Task<bool> DetectTrackSelectionSetting()

Diff for: src/Files.App/ViewModels/Settings/AboutViewModel.cs

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public AboutViewModel()
7070
new ("https://github.com/mono/taglib-sharp", "TagLibSharp"),
7171
new ("https://github.com/Tulpep/Active-Directory-Object-Picker", "ActiveDirectoryObjectPicker"),
7272
new ("https://github.com/dotMorten/WinUIEx", "WinUIEx"),
73-
new ("https://github.com/dahall/Vanara", "Vanara"),
7473
new ("https://github.com/PowerShell/MMI", "MMI"),
7574
new ("https://github.com/microsoft/CsWin32", "CsWin32"),
7675
new ("https://github.com/microsoft/CsWinRT", "CsWinRT"),

0 commit comments

Comments
 (0)