增加查询不同的状态的穴位时采用反向查找

master
lhiven 1 year ago
parent 480d1f6b24
commit 50385e3803

@ -98,16 +98,30 @@ namespace Rs.Controls
set { _InitSlotStatus = value; InitSlot(InitSlotStatus); Invalidate(); } set { _InitSlotStatus = value; InitSlot(InitSlotStatus); Invalidate(); }
} }
public TraySlot GetSlot(ESlotStatus status) public TraySlot GetSlot(ESlotStatus status,bool reverse=false)
{
if(reverse)
{
for (int row = 0; row < RowNum; row++)
{
for (int col = ColumnNum; col > 0; col--)
{
int index = row * (ColumnNum) + col;
if (traySlotsDic[index].SlotStatus == status)
return traySlotsDic[index];
}
}
}
else
{ {
foreach (KeyValuePair<int, TraySlot> kv in traySlotsDic) foreach (KeyValuePair<int, TraySlot> kv in traySlotsDic)
{ {
if (kv.Value.SlotStatus == status) if (kv.Value.SlotStatus == status)
return kv.Value; return kv.Value;
} }
}
return null; return null;
} }
/// <summary> /// <summary>
/// 通过穴位的索引获取穴位 /// 通过穴位的索引获取穴位
/// </summary> /// </summary>

Loading…
Cancel
Save