按重量计算的动态大小的盒子? (C#)

时间:2016-06-15 21:06:00

标签: c# .net user-interface dynamic resize

我正在尝试根据特定对象的权重变量创建动态大小的UI地图。

我想要绘制的区域将始终相同,例如400x400格式。

我想要绘制的对象数量是动态的,但通常为1-10(超出范围的小例外)。

每个对象都有一个很长的值" weight"和一个浮点MinDrawPercent变量,它接受0到1之间的值。

举个例子,我有3个具有以下属性的对象,我想在我的表单上绘制。

DrawnObject a = new DrawnObject(Weight:=100,MinDrawPercent:=0.1);
DrawnObject b = new DrawnObject(Weight:=5000,MinDrawPercent:=0.1);
DrawnObject c = new DrawnObject(Weight:=25000,MinDrawPercent:=0.1);

绘制到表单的对象的总权重为30001.因此,每个控件都将绘制为占据屏幕的以下百分比的矩形

"a" would display as 10% of the total area (because its weight is < its MinDrawPercent)
"b" would want to display as 16.6% of the total area but cant due to the increase in "a" so would display as 11.6% of the form
"c" would want to display as 83.3% of the total area but cant due to the increase in "a" so would display as 78.3% of the form

重要的是它们尽可能正方形......我认为它会画出这样的东西:

example

我通常非常擅长UI设计和调整控件大小,但是我一直在努力完成这项任务。

有人能帮助我吗?

0 个答案:

没有答案