diff --git a/LarkatorGUI/Converters.cs b/LarkatorGUI/Converters.cs
index 798d007..ce2745e 100644
--- a/LarkatorGUI/Converters.cs
+++ b/LarkatorGUI/Converters.cs
@@ -10,8 +10,9 @@ public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- var v = (bool)value;
- return v ? Visibility.Visible : Visibility.Collapsed;
+ if (value is bool asBool) return asBool ? Visibility.Visible : Visibility.Collapsed;
+ if (value is int asInt) return asInt != 0 ? Visibility.Visible : Visibility.Collapsed;
+ return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/LarkatorGUI/DebounceDispatcher.cs b/LarkatorGUI/DebounceDispatcher.cs
new file mode 100644
index 0000000..e3a1c3e
--- /dev/null
+++ b/LarkatorGUI/DebounceDispatcher.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Windows.Threading;
+
+namespace LarkatorGUI
+{
+ ///
+ /// Provides Debounce() and Throttle() methods.
+ /// Use these methods to ensure that events aren't handled too frequently.
+ ///
+ /// Throttle() ensures that events are throttled by the interval specified.
+ /// Only the last event in the interval sequence of events fires.
+ ///
+ /// Debounce() fires an event only after the specified interval has passed
+ /// in which no other pending event has fired. Only the last event in the
+ /// sequence is fired.
+ ///
+ /// From https://weblog.west-wind.com/posts/2017/Jul/02/Debouncing-and-Throttling-Dispatcher-Events.
+ ///
+ public class DebounceDispatcher
+ {
+ private DispatcherTimer timer;
+ private DateTime timerStarted { get; set; } = DateTime.UtcNow.AddYears(-1);
+
+ ///
+ /// Debounce an event by resetting the event timeout every time the event is
+ /// fired. The behavior is that the Action passed is fired only after events
+ /// stop firing for the given timeout period.
+ ///
+ /// Use Debounce when you want events to fire only after events stop firing
+ /// after the given interval timeout period.
+ ///
+ /// Wrap the logic you would normally use in your event code into
+ /// the Action you pass to this method to debounce the event.
+ /// Example: https://gist.github.com/RickStrahl/0519b678f3294e27891f4d4f0608519a
+ ///
+ /// Timeout in Milliseconds
+ /// Action
+ /// optional parameter
+ /// optional priorty for the dispatcher
+ /// optional dispatcher. If not passed or null CurrentDispatcher is used.
+ public void Debounce(int interval, Action