* Creating a control for the overlay * using Interactivity * trying to bind by reference * fix bindings * remove unused packages * Move getter/setter to show method * Convert to AutoProperty * Make text copied notification configurable * cache settings, removed unused file
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using FluentTerminal.App.Services;
|
|
using GalaSoft.MvvmLight;
|
|
using System;
|
|
|
|
namespace FluentTerminal.App.ViewModels
|
|
{
|
|
public class OverlayViewModel : ViewModelBase
|
|
{
|
|
private readonly IDispatcherTimer _overlayTimer;
|
|
private bool _showOverlay;
|
|
private string _overlayContent;
|
|
|
|
public OverlayViewModel(IDispatcherTimer dispatcherTimer)
|
|
{
|
|
_overlayTimer = dispatcherTimer;
|
|
_overlayTimer.Interval = new TimeSpan(0, 0, 2);
|
|
_overlayTimer.Tick += OnResizeOverlayTimerFinished;
|
|
}
|
|
|
|
public bool ShowOverlay
|
|
{
|
|
get => _showOverlay;
|
|
set => Set(ref _showOverlay, value);
|
|
}
|
|
|
|
public string OverlayContent
|
|
{
|
|
get => _overlayContent;
|
|
set => Set(ref _overlayContent, value);
|
|
}
|
|
|
|
public void Show(string message)
|
|
{
|
|
OverlayContent = message;
|
|
ShowOverlay = true;
|
|
|
|
if (_overlayTimer.IsEnabled)
|
|
{
|
|
_overlayTimer.Stop();
|
|
}
|
|
_overlayTimer.Start();
|
|
}
|
|
|
|
private void OnResizeOverlayTimerFinished(object sender, object e)
|
|
{
|
|
_overlayTimer.Stop();
|
|
ShowOverlay = false;
|
|
}
|
|
|
|
}
|
|
}
|