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-03-16 15:51:31 +01:00
|
|
|
|
using System;
|
2023-01-31 00:00:11 +01:00
|
|
|
|
using System.Timers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
|
|
|
|
|
{
|
2025-02-25 02:48:54 +08:00
|
|
|
|
public partial class FlyoutViewModel : IDisposable
|
2023-01-31 00:00:11 +01:00
|
|
|
|
{
|
2023-03-16 15:51:31 +01:00
|
|
|
|
private Timer _hideTimer;
|
|
|
|
|
|
private bool _disposed;
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
public bool CanHide { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public FlyoutViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = true;
|
2023-03-16 15:51:31 +01:00
|
|
|
|
_hideTimer = new Timer();
|
|
|
|
|
|
_hideTimer.Elapsed += HideTimer_Elapsed;
|
|
|
|
|
|
_hideTimer.Interval = 1000;
|
|
|
|
|
|
_hideTimer.Enabled = false;
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = true;
|
2023-03-16 15:51:31 +01:00
|
|
|
|
_hideTimer.Stop();
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void DisableHiding()
|
|
|
|
|
|
{
|
|
|
|
|
|
CanHide = false;
|
2023-03-16 15:51:31 +01:00
|
|
|
|
_hideTimer.Stop();
|
|
|
|
|
|
_hideTimer.Start();
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
2023-02-13 19:46:06 +01:00
|
|
|
|
|
2023-03-16 15:51:31 +01:00
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dispose(true);
|
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_disposed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
_hideTimer?.Dispose();
|
|
|
|
|
|
_disposed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|