mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 23:46:30 +00:00
I like it move it move it
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Azaion.Annotator.Controls
|
||||
{
|
||||
public class UpdatableProgressBar : ProgressBar
|
||||
{
|
||||
public delegate void ValueChange(double oldValue, double newValue);
|
||||
|
||||
public event ValueChange? ValueChanged;
|
||||
|
||||
public UpdatableProgressBar() : base()
|
||||
{
|
||||
MouseDown += OnMouseDown;
|
||||
MouseMove += OnMouseMove;
|
||||
}
|
||||
|
||||
private double SetProgressBarValue(double mousePos)
|
||||
{
|
||||
Value = Minimum;
|
||||
var pbValue = mousePos / ActualWidth * Maximum;
|
||||
ValueChanged?.Invoke(Value, pbValue);
|
||||
return pbValue;
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Value = SetProgressBarValue(e.GetPosition(this).X);
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
Value = SetProgressBarValue(e.GetPosition(this).X);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user