diff --git a/Rs.Controls/RsTray.cs b/Rs.Controls/RsTray.cs index 5435b7a..fe601b8 100644 --- a/Rs.Controls/RsTray.cs +++ b/Rs.Controls/RsTray.cs @@ -22,7 +22,9 @@ namespace Rs.Controls public enum ESortDir { LeftToRight, - RightToLeft + RightToLeft, + RightTopToBottom, + LeftBottomToTop } public enum ESlotStatus @@ -95,6 +97,27 @@ namespace Rs.Controls } } + private bool _ShowRowNumber; + /// + /// 是否显示行号 + /// + public bool ShowRowNumber + { + get { return _ShowRowNumber; } + set { _ShowRowNumber = value; } + } + + private bool _ShowColNumber; + /// + /// 是否显示列号 + /// + public bool ShowColNumber + { + get { return _ShowColNumber; } + set { _ShowColNumber = value; } + } + + public RsTray() { InitializeComponent(); @@ -184,7 +207,7 @@ namespace Rs.Controls set { _HeadText = value; this.label1.Text = value; } } - private int _RowNum = 26; + private int _RowNum = 16; /// /// 行数 @@ -195,7 +218,7 @@ namespace Rs.Controls set { _RowNum = value; InitSlot(InitSlotStatus); Invalidate(); } } - private int _ColumnNum = 10; + private int _ColumnNum = 16; /// /// 列数量 @@ -387,6 +410,48 @@ namespace Rs.Controls } } } + else if (sortDir == ESortDir.RightTopToBottom) + { + //从列开始画 + for (int r = RowNum; r > 0; r--) + { + for (int c = 0; c < ColumnNum; c++) + { + index++; + if (traySlotsDic.ContainsKey(index)) + { + float x = slotWidth * r; + float y = slotHeight * c; + traySlotsDic[index].Bound = new RectangleF(x, y, (int)slotWidth - ColSpace, (int)slotHeight - RowSpace); + } + } + } + } + else if (sortDir == ESortDir.LeftBottomToTop) + { + //从列开始画 + for (int r = 0; r < RowNum; r++) + { + for (int c = ColumnNum; c > 0; c--) + { + index++; + if (traySlotsDic.ContainsKey(index)) + { + float y = 0; + float x = LeftSpaceWidth + slotWidth * r; + if(!ShowColNumber) + { + y = slotHeight * c - TopSpaceHeight / 2; + } + else + { + y = slotHeight * c; + } + traySlotsDic[index].Bound = new RectangleF(x, y, (int)slotWidth - ColSpace, (int)slotHeight - RowSpace); + } + } + } + } panel2.Refresh(); } @@ -410,20 +475,31 @@ namespace Rs.Controls index++; if (r == 0) { - //画料盘的列号 - if (SortDir == ESortDir.LeftToRight) + if(ShowRowNumber) { - g2.DrawString((c+ 1).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(LeftSpaceWidth + (widthPer * c) + 5, 5)); - } - else if(SortDir== ESortDir.RightToLeft) - { - g2.DrawString((ColumnNum - c).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(LeftSpaceWidth + (widthPer * c) + 5, 5)); + //画料盘的列号 + if (SortDir == ESortDir.LeftToRight) + { + g2.DrawString((c + 1).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(LeftSpaceWidth + (widthPer * c) + 5, 5)); + } + else if (SortDir == ESortDir.RightToLeft) + { + g2.DrawString((ColumnNum - c).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(LeftSpaceWidth + (widthPer * c) + 5, 5)); + } + else if (SortDir == ESortDir.LeftBottomToTop) + { + //g2.DrawString((ColumnNum - c).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(LeftSpaceWidth + (widthPer * c) + 5, 5)); + } } + } if (c == 0) { - //画料盘的行号 - g2.DrawString((r + 1).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(5, TopSpaceHeight + (heightPer * r))); + if(ShowColNumber) + { + //画料盘的行号 + g2.DrawString((r + 1).ToString(), new Font("宋体", 7.0F), new SolidBrush(Color.White), new PointF(5, TopSpaceHeight + (heightPer * r))); + } } if (traySlotsDic.ContainsKey(index)) {