Checks if the current code is executing in a ViewPortChanged event.
This is to help preventing "event looping" in complicated GUI designs in which multiple controls can update the viewport and indirectly update each others.
For example, suppose in a scrollable chart design, the x-axis can be scrolled by both a scroll bar control and a date/time picker control. That means both scroll bar and date/time picker events may update the viewport.
The following sequence of events may happen:
- User changes the start date on the x-axis using the date/time picker control.
- The viewport is updated, so WinChartViewer.updateViewPort is called, triggering a WinChartViewer.ViewPortChanged event.
- In the ViewPortChanged event handler, the scroll bar position needs to be updated to reflect that the viewport has moved.
- As the scroll bar has changed, a scroll bar event occurs. The scroll bar event handler may update the viewport and call WinChartViewer.updateViewPort again.
The above is potentially an infinite loop as the ViewPortChanged event will keep firing again and again. To avoid this,
WinChartViewer.updateViewPort will perform no action if it is called within ViewPortChanged event. So the last step above cannot actually trigger another ViewPortChanged event. This avoids the infinite loop.
Internally, WinChartViewer.updateViewPort use this property to checks if it is called within a ViewPortChanged event, and ignores the request if it is already in the event. This property allows external code to also change behaviour in a ViewPortChanged event.
© 2023 Advanced Software Engineering Limited. All rights reserved.