So I need to procedurally generate a background image for a grid, it only takes .1sec.
So I can wire into the SizeChanged event, but then when you resize the chart, it goes and fires the event maybe 30 times a second, so the resize event lags out signifigantly.
Does anybody know a good way to wire into the resize event and test weather the use is done resizing, I tried simply checking for the mouse up/down state, but when the resize event fires the mouse is pretty much always down.
On resize, you could start a short lived timer (say 100 mSec), on each resize reset that timer to prevent it from elapsing. When the last resize happens, the timer will elapse, and you can draw your background image then.
Example:
Timer resizeTimer = new Timer(100) { Enabled = false };
public Window1()
{
InitializeComponent();
resizeTimer.Elapsed += new ElapsedEventHandler(ResizingDone);
}
void ResizingDone(object sender, ElapsedEventArgs e)
{
resizeTimer.Stop();
GenerateImage();
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
resizeTimer.Stop();
resizeTimer.Start();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With