MaterialSkin icon indicating copy to clipboard operation
MaterialSkin copied to clipboard

Slider needs a Direction property.

Open Release opened this issue 2 years ago • 5 comments

TrackBar control increases the value when the mouse wheel is moved up, while Slider decreases it. It needs a property that would change this behavior to the opposite.

Release avatar Oct 17 '23 10:10 Release

Solved. Now I hope leo to merge it 😁

valimaties avatar Oct 31 '23 06:10 valimaties

Thanks, it also lacks the property of adjusting the value change step. To be able to set the scrolling step different from the one set in the system. Something like that:

public enum Directions { Normal, Reverse }

protected override void OnMouseWheel(MouseEventArgs e)
{
	int scrollLines = SystemInformation.MouseWheelScrollLines;

	Value += e.Delta / 40 / scrollLines * StepChange * (ScrollDirection == Directions.Normal ? 1 : -1);
	Value = Math.Clamp(Value, RangeMin, RangeMax);

	onValueChanged?.Invoke(this, Value);
}

[DefaultValue(2)]
[Category("Material Skin")]
[Description("Define control step change value")]
public int StepChange
{
	get => stepChange;
	set => stepChange = Math.Clamp(value, 1, RangeMax);
}

[DefaultValue(Directions.Normal)]
[Category("Material Skin")]
[Description("Define control direction change value with mouse wheel")]
public Directions ScrollDirection { get; set; }

Release avatar Oct 31 '23 11:10 Release

Make a PR please and I will delete mine.

valimaties avatar Oct 31 '23 13:10 valimaties

@valimaties, judging by this post, the edits will probably never be accepted.

Release avatar Nov 01 '23 11:11 Release

@valimaties, judging by this post, the edits will probably never be accepted.

You can take a look at this project. I will add your changes as PR in a moment.

Taiizor avatar Jan 10 '24 12:01 Taiizor