|
@@ -21,23 +21,29 @@ public partial class DutyPreviewWindow : Window
|
|
|
{
|
|
|
if (Records.Count == 0) { return; }
|
|
|
|
|
|
- // 获取前10位人员
|
|
|
- var top8 = Records.Take(8).ToArray();
|
|
|
- for (var index = 0; index < top8.Length; index++)
|
|
|
+ // 获取前一半位人员
|
|
|
+ var odd = Records.Count % 2;
|
|
|
+ var middle = Records.Count / 2;
|
|
|
+ var media = odd == 0 ? middle : middle + 1;
|
|
|
+ var top = Records.Take(media).ToArray();
|
|
|
+
|
|
|
+ for (var index = 0; index < top.Length; index++)
|
|
|
{
|
|
|
- var record = top8[index];
|
|
|
+ var record = top[index];
|
|
|
var dailDuty = new DailyDuty()
|
|
|
{
|
|
|
Record = record
|
|
|
};
|
|
|
|
|
|
+ FirstGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
|
|
FirstGrid.Children.Add(dailDuty);
|
|
|
Grid.SetColumn(dailDuty, index);
|
|
|
}
|
|
|
|
|
|
- // 获取后10位人员
|
|
|
- var top7 = Records.Skip(8).Take(7).ToArray();
|
|
|
- foreach (var record in top7)
|
|
|
+ // 获取剩余人员
|
|
|
+ var rest = Records.Count - media;
|
|
|
+ var next = Records.Skip(media).Take(rest).ToArray();
|
|
|
+ foreach (var record in next)
|
|
|
{
|
|
|
var dailDuty = new DailyDuty()
|
|
|
{
|
|
@@ -69,6 +75,11 @@ public partial class DutyPreviewWindow : Window
|
|
|
child.Width = firstOrDefault.ActualWidth;
|
|
|
}
|
|
|
|
|
|
- panel.Spacing = firstOrDefault.ActualWidth / 6;
|
|
|
+ var firstGridChildren = FirstGrid.Children.Count;
|
|
|
+ var secondGridChildren = SecondGrid.Children.Count;
|
|
|
+ if (secondGridChildren < firstGridChildren)
|
|
|
+ {
|
|
|
+ panel.Spacing = firstOrDefault.ActualWidth / (secondGridChildren - 1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|