-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix bug of arrange for WrapPanel #1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use `int` as backing field of `U` and `V`, see #1085
|
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
|
|
||
| internal double V { get; set; } | ||
| private int u, v; | ||
| internal double U { get { return u / FACTOR; } set { u = (int)(value * FACTOR); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this getter/setter could be replaced with Math.Floor ? I didn't try my suggestion but it seems you convert to integer then divide to get rid of decimal point to get the floor of the number
| internal const double FACTOR = 10000; | ||
|
|
||
| internal double V { get; set; } | ||
| private int u, v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doubles are used for a reasons, you can't just drop the double and use int :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to double and Math.Floor, thanks for your advice.
|
|
||
| internal double V { get; set; } | ||
| private double u, v; | ||
| internal double U { get { return u / FACTOR; } set { u = Math.Floor(value * FACTOR); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you've done the floor you're no longer need the FACTOR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You means Math.Floor(value * FACTOR) / FACTOR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean
u=Math.Floor(value); directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Doing this will cut all fractions, which is used in some controls. We should keep several number of digits.
|
@OpportunityLiu, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
| U = 0.0; | ||
| V = 0.0; | ||
| } | ||
| internal double V { get { return v ; } set { v = Math.Floor(value * FACTOR) / FACTOR; } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the FACTOR in this case mate :) right ? just do Math.Floor(value) with no multiplication or division.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think ?
|
|
| internal double U { get; set; } | ||
|
|
||
| internal double V { get; set; } | ||
| private double u, v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Private variables must start with Underscore, _u, _v
|
|
||
| internal double V { get; set; } | ||
| private double u, v; | ||
| internal double U { get { return u; } set { u = Math.Floor(value); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a space between private double u, v; and the next line.
Internal double U .... need to be on multiple lines.
The toolkit already has StyleCop file that contains everything regarding the recommended practices which should be highlighted in the file by default.
| U = 0.0; | ||
| V = 0.0; | ||
| } | ||
| internal double V { get { return v; } set { v = Math.Floor(value); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
| } | ||
| internal double V { get { return v; } set { v = Math.Floor(value); } } | ||
|
|
||
| public UvMeasure(Orientation orientation, double width, double height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default constructor was used to reinitialize U and V values, the default constructor was used in the wrapPanel class multiple times. I know that you're using a struct which has no a default constructor so either you go back to class or create a function to reset the values to zeroes which should be used in the wrapPanel.cs class.
|
|
||
| public UvMeasure(Orientation orientation, double width, double height) | ||
| { | ||
| this.u = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"this.u" is useless you can remove it and use "u" directly
| public UvMeasure(Orientation orientation, double width, double height) | ||
| { | ||
| this.u = 0.0; | ||
| this.v = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
| totalMeasure.V += lineMeasure.V; | ||
|
|
||
| totalMeasure.U = Math.Ceiling(totalMeasure.U); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use Ceiling here once, all problem solved.
How did I come out with that complex idea...
Use
intas backing field ofUandV, see #1085