mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[OOBE] Out of box experience window (#9973)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using interop;
|
||||
|
||||
namespace ColorPicker.Helpers
|
||||
{
|
||||
[Export(typeof(NativeEventWaiter))]
|
||||
public class NativeEventWaiter
|
||||
{
|
||||
private AppStateHandler _appStateHandler;
|
||||
|
||||
[ImportingConstructor]
|
||||
public NativeEventWaiter(AppStateHandler appStateHandler)
|
||||
{
|
||||
_appStateHandler = appStateHandler;
|
||||
WaitForEventLoop(Constants.ShowColorPickerSharedEvent(), _appStateHandler.ShowColorPicker);
|
||||
}
|
||||
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
{
|
||||
if (eventHandle.WaitOne())
|
||||
{
|
||||
Logger.LogInfo("Successfully waited for SHOW_COLOR_PICKER_EVENT");
|
||||
Application.Current.Dispatcher.Invoke(callback);
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace ColorPicker.ViewModels
|
||||
private readonly ZoomWindowHelper _zoomWindowHelper;
|
||||
private readonly AppStateHandler _appStateHandler;
|
||||
private readonly IUserSettings _userSettings;
|
||||
private readonly NativeEventWaiter _nativeEventWaiter;
|
||||
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="OtherColor"/>
|
||||
@@ -48,11 +49,13 @@ namespace ColorPicker.ViewModels
|
||||
ZoomWindowHelper zoomWindowHelper,
|
||||
AppStateHandler appStateHandler,
|
||||
KeyboardMonitor keyboardMonitor,
|
||||
NativeEventWaiter nativeEventWaiter,
|
||||
IUserSettings userSettings)
|
||||
{
|
||||
_zoomWindowHelper = zoomWindowHelper;
|
||||
_appStateHandler = appStateHandler;
|
||||
_userSettings = userSettings;
|
||||
_nativeEventWaiter = nativeEventWaiter;
|
||||
|
||||
if (mouseInfoProvider != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user