polish autodetection

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-02 20:59:51 +02:00
parent 418a2116b7
commit addf7ccc11
6 changed files with 90 additions and 27 deletions
@@ -0,0 +1,54 @@
using System.Windows;
using System.Windows.Controls;
namespace Azaion.Annotator.Extensions;
public class ScrollViewerExtensions
{
public static readonly DependencyProperty AlwaysScrollToEndProperty =
DependencyProperty.RegisterAttached("AlwaysScrollToEnd", typeof(bool), typeof(ScrollViewerExtensions), new PropertyMetadata(false, AlwaysScrollToEndChanged));
private static bool _autoScroll;
private static void AlwaysScrollToEndChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (sender is not ScrollViewer scroll)
throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances.");
var alwaysScrollToEnd = e.NewValue != null && (bool)e.NewValue;
if (alwaysScrollToEnd)
{
scroll.ScrollToEnd();
scroll.ScrollChanged += ScrollChanged;
}
else
scroll.ScrollChanged -= ScrollChanged;
}
public static bool GetAlwaysScrollToEnd(ScrollViewer scroll)
{
if (scroll == null)
throw new ArgumentNullException("scroll");
return (bool)scroll.GetValue(AlwaysScrollToEndProperty);
}
public static void SetAlwaysScrollToEnd(ScrollViewer scroll, bool alwaysScrollToEnd)
{
if (scroll == null)
throw new ArgumentNullException("scroll");
scroll.SetValue(AlwaysScrollToEndProperty, alwaysScrollToEnd);
}
private static void ScrollChanged(object sender, ScrollChangedEventArgs e)
{
var scroll = sender as ScrollViewer;
if (scroll == null)
throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances.");
if (e.ExtentHeightChange == 0)
_autoScroll = scroll.VerticalOffset == scroll.ScrollableHeight;
if (_autoScroll && e.ExtentHeightChange != 0)
scroll.ScrollToVerticalOffset(scroll.ExtentHeight);
}
}
@@ -47,11 +47,6 @@ public class VLCFrameExtractor(LibVLC libVLC)
_width = videoTrack.Data.Video.Width;
_height = videoTrack.Data.Video.Height;
//rescaling to DEFAULT_WIDTH
//TODO: probably rescaling is not necessary, should be checked
//_width = DEFAULT_WIDTH;
//_height = (uint)(DEFAULT_WIDTH * _height / (double)_width);
_pitch = Align32(_width * RGBA_BYTES);
_lines = Align32(_height);
_mediaPlayer.SetRate(PLAYBACK_RATE);
@@ -81,7 +76,6 @@ public class VLCFrameExtractor(LibVLC libVLC)
yield return (frameInfo.Time, ms);
Console.WriteLine($"Queue size: {FramesQueue.Count}");
frameInfo.Bitmap?.Dispose();
}
else