mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:36:30 +00:00
rework throttle
reuse throttle mechanism for catching global keys
This commit is contained in:
@@ -150,16 +150,16 @@ public partial class MainWindow
|
||||
|
||||
Volume.ValueChanged += (_, newValue) => _mediator.Publish(new VolumeChangedEvent((int)newValue));
|
||||
|
||||
SizeChanged += (_, _) => SaveUserSettings();
|
||||
LocationChanged += (_, _) => SaveUserSettings();
|
||||
StateChanged += (_, _) => SaveUserSettings();
|
||||
SizeChanged += async (_, _) => await SaveUserSettings();
|
||||
LocationChanged += async (_, _) => await SaveUserSettings();
|
||||
StateChanged += async (_, _) => await SaveUserSettings();
|
||||
|
||||
Editor.FormState = _formState;
|
||||
Editor.Mediator = _mediator;
|
||||
DgAnnotations.ItemsSource = _formState.AnnotationResults;
|
||||
}
|
||||
|
||||
private void SaveUserSettings()
|
||||
private async Task SaveUserSettings()
|
||||
{
|
||||
if (_suspendLayout)
|
||||
return;
|
||||
@@ -169,8 +169,11 @@ public partial class MainWindow
|
||||
_config.WindowSize = new Size(Width, Height);
|
||||
_config.WindowLocation = new Point(Left, Top);
|
||||
_config.FullScreen = WindowState == WindowState.Maximized;
|
||||
var saveConfigFn = () => _configRepository.Save(_config);
|
||||
saveConfigFn.Debounce(TimeSpan.FromSeconds(5)).Invoke();
|
||||
await ThrottleExt.Throttle(() =>
|
||||
{
|
||||
_configRepository.Save(_config);
|
||||
return Task.CompletedTask;
|
||||
}, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
|
||||
public void ShowCurrentAnnotations() => ShowTimeAnnotations(TimeSpan.FromMilliseconds(_mediaPlayer.Time));
|
||||
|
||||
Reference in New Issue
Block a user