Skip to content

Conversation

@OpportunityLiu
Copy link
Contributor

Use int as backing field of U and V, see #1085

Use `int` as backing field of `U` and `V`, see #1085
@dnfclas
Copy link

dnfclas commented Jun 13, 2017

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.
Thanks,
.NET Foundation Pull Request Bot

@OpportunityLiu OpportunityLiu changed the title Fix bug of arrange Fix bug of arrange for WrapPanel Jun 13, 2017

internal double V { get; set; }
private int u, v;
internal double U { get { return u / FACTOR; } set { u = (int)(value * FACTOR); } }
Copy link
Member

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;
Copy link
Member

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 :)

Copy link
Contributor Author

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); } }
Copy link
Member

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 :)

Copy link
Contributor Author

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 ?

Copy link
Member

@IbraheemOsama IbraheemOsama Jun 13, 2017

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

Copy link
Contributor Author

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.

@dnfclas
Copy link

dnfclas commented Jun 13, 2017

@OpportunityLiu, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, .NET Foundation Pull Request Bot

U = 0.0;
V = 0.0;
}
internal double V { get { return v ; } set { v = Math.Floor(value * FACTOR) / FACTOR; } }
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think ?

@OpportunityLiu
Copy link
Contributor Author

OpportunityLiu commented Jun 13, 2017

FACTOR removed

internal double U { get; set; }

internal double V { get; set; }
private double u, v;
Copy link
Member

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); } }
Copy link
Member

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); } }
Copy link
Member

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)
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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);

Copy link
Contributor Author

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...

@IbraheemOsama IbraheemOsama added bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ labels Jun 14, 2017
@nmetulev nmetulev merged commit d0b1426 into CommunityToolkit:dev Jun 19, 2017
@OpportunityLiu OpportunityLiu deleted the patch-1 branch June 27, 2017 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants