المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : [SOLVED] "Negative" Rectangle (ControlPaint.DrawReversibleFrame) To "Positive"



C# Programming
09-03-2011, 07:30 AM
I am using ControlPaint.DrawReversibleFrame to draw a frame while the user clicks/drags on a control. All is well there. Once complete, I do some things with the information, including drawing to the control using rectangle used to draw the frame. However, if I drag backward OR upward, I end up with nothing because it has negative values. How can I correct this? Sorry if I did not explain well enough, I am busy with things at home. But I can elaborate later if necessary.

SOLUTION:

Basic math

if (finalRect.Width < 0){ finalRect.X = (finalRect.X + finalRect.Width); finalRect.Width = Math.Abs(finalRect.Width);}if (finalRect.Height < 0){ finalRect.Y = (finalRect.Y + finalRect.Height); finalRect.Height = Math.Abs(finalRect.Height);}djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
modified on Friday, September 2, 2011 8:54 PM