2023-01-31 00:00:11 +01:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
2023-02-13 19:46:06 +01:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
2023-01-31 00:00:11 +01:00
|
|
|
|
using System.Timers;
|
2023-02-13 19:46:06 +01:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FlyoutViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool CanHide { get; set; }
|
|
|
|
|
|
|
2023-02-13 19:46:06 +01:00
|
|
|
|
private bool _windows10;
|
|
|
|
|
|
|
|
|
|
|
|
public bool Windows10
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _windows10;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_windows10 != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_windows10 = value;
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
private Timer hideTimer;
|
|
|
|
|
|
|
|
|
|
|
|
public FlyoutViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = true;
|
|
|
|
|
|
hideTimer = new Timer();
|
|
|
|
|
|
hideTimer.Elapsed += HideTimer_Elapsed;
|
|
|
|
|
|
hideTimer.Interval = 1000;
|
|
|
|
|
|
hideTimer.Enabled = false;
|
2023-02-13 19:46:06 +01:00
|
|
|
|
_windows10 = !Helper.Windows11();
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = true;
|
|
|
|
|
|
hideTimer.Stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void DisableHiding()
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = false;
|
|
|
|
|
|
hideTimer.Stop();
|
|
|
|
|
|
hideTimer.Start();
|
|
|
|
|
|
}
|
2023-02-13 19:46:06 +01:00
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|