How to detect scrollbar scrolled to the end?
Posted: Wed Apr 04, 2018 3:36 am
Hi, I have saw the ExampleThreadFedScrollBar example, but I want to resume realtime mode when scrollbar scrolled to the end.
So I must find a method to detect scrollbar scrolled to the end. Recently I havn't find any direct or convenient methods to do that.
But After several tests, I find a relationship between the scrollbar's Value, LargeChange, SmallChange and Maximum properties when scrolling, and I use it as the method to detect scrolled to the end.
Bellow is the detect code when scroll event fired:
Is this method correct? Is there any direct or convenient methods to do that?
Thanks!
So I must find a method to detect scrollbar scrolled to the end. Recently I havn't find any direct or convenient methods to do that.
But After several tests, I find a relationship between the scrollbar's Value, LargeChange, SmallChange and Maximum properties when scrolling, and I use it as the method to detect scrolled to the end.
Bellow is the detect code when scroll event fired:
Code: Select all
private void sb_Scroll(Object sender, Arction.Wpf.Charting.ScrollEventArgs e)
{
HorizontalScrollBar sb = sender as HorizontalScrollBar;
if (sb == null) return;
if (e.NewValue == (sb.Maximum - sb.LargeChange + sb.SmallChange))
{
buttonPauseResume.Content = "Pause";
_isRealtime = true;
_scrollPosition = e.NewValue;
_chart.BeginUpdate();
_chart.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
_chart.EndUpdate();
}
else
{
buttonPauseResume.Content = "Resume";
_isRealtime = false;
_scrollPosition = e.NewValue;
_chart.BeginUpdate();
//Set ScrollMode to None
_chart.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
// Call SetRange so that data is displayed correctly.
_chart.ViewXY.XAxes[0].SetRange(e.NewValue / _samplingFrequency, e.NewValue / _samplingFrequency + _xLength);
_chart.EndUpdate();
}
}
Thanks!