xchellx Posted January 19, 2022 Share Posted January 19, 2022 How exactly do I use ProgressEventHandler? There is only a progress value for ProgressEventArgs. There is no way to get and set the max progress... Quote Link to comment Share on other sites More sharing options...
otuncelli Posted January 19, 2022 Share Posted January 19, 2022 Its range is from 0 to 100 (percentage). AFAIK, There is no max value setter. You need to do the calculations. Quote Link to comment Share on other sites More sharing options...
xchellx Posted January 19, 2022 Author Share Posted January 19, 2022 @otuncelli How do I set the max size that way? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted January 19, 2022 Share Posted January 19, 2022 You don't set the max size. You report progress from 0 to 100. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
otuncelli Posted January 19, 2022 Share Posted January 19, 2022 (edited) ProgressEventArgs should have taken integer parameter, not double. The precision doesn't get used. Paint.NET UI doesn't show decimal places when saving. 1. progress = (current_index / maximum) * 100 2 Then round this value to nearest integer 3. Check the value if it equals to the previous calls' progress value. 4. If it's not equal, call the event handler, otherwise don't call it. Because you wouldn't want to call the event handler too frequently with the same values. This would just make UI thread busy and slows down the process. I don't know if Paint.NET prevents unnecessary calls here. Edited January 19, 2022 by otuncelli 2 Quote Link to comment Share on other sites More sharing options...
xchellx Posted January 19, 2022 Author Share Posted January 19, 2022 @otuncelli Thank you 👍 Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted January 20, 2022 Share Posted January 20, 2022 2 hours ago, otuncelli said: 2 Then round this value to nearest integer 3. Check the value if it equals to the previous calls' progress value. 4. If it's not equal, call the event handler, otherwise don't call it. Because you wouldn't want to call the event handler too frequently with the same values. This would just make UI thread busy and slows down the process. I don't know if Paint.NET prevents unnecessary calls here. Don't worry about these. Paint.NET already does the right thing here. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
midora Posted January 20, 2022 Share Posted January 20, 2022 The progress handler allows paint.net to throw the OperationCanceledException (if SupportsCancellation is set). This may be important to allow a fluid change of parameters by the user if the save operation is slow and/or the image is quite large. So you should not suppress progress calls. I'm happy that the progress parameter is not an int. This allows to show a higher granulation without an interface change. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.