diff --git a/Rs.Controls/RsTray.cs b/Rs.Controls/RsTray.cs index 6e36976..6f3a27a 100644 --- a/Rs.Controls/RsTray.cs +++ b/Rs.Controls/RsTray.cs @@ -398,6 +398,9 @@ namespace Rs.Controls } else if (SortDir == ESortDir.RightToLeft) { + ShowColNumber = ShowRowNumber = false; + slotWidth = (this.panel2.Width) / ColumnNum; + slotHeight = (this.panel2.Height) / RowNum; for (int r = 0; r < RowNum; r++) { for (int c = 0; c < ColumnNum; c++) @@ -412,6 +415,9 @@ namespace Rs.Controls } else if (sortDir == ESortDir.RightTopToBottom) { + ShowColNumber = ShowRowNumber = false; + slotWidth = (this.panel2.Width) / ColumnNum; + slotHeight = (this.panel2.Height) / RowNum; //从列开始画 for (int c = ColumnNum; c > 0; c--) { @@ -429,26 +435,38 @@ namespace Rs.Controls } else if (sortDir == ESortDir.LeftBottomToTop) { + ShowColNumber = ShowRowNumber = false; + slotWidth = (this.panel2.Width ) / ColumnNum; + slotHeight = (this.panel2.Height ) / RowNum; //从列开始画 - for (int r = 0; r < RowNum; r++) + for (int c = 0; c < ColumnNum; c++) { - for (int c = ColumnNum; c > 0; c--) + for (int r = RowNum; r > 0; r--) { index++; if (traySlotsDic.ContainsKey(index)) { - float y = 0; - float x = LeftSpaceWidth + slotWidth * r; - if(!ShowColNumber) - { - y = slotHeight * c - TopSpaceHeight / 2; - } - else - { - y = slotHeight * c; - } + float x = slotWidth * c; + float y = slotHeight * (r-1); traySlotsDic[index].Bound = new RectangleF(x, y, (int)slotWidth - ColSpace, (int)slotHeight - RowSpace); } + + + //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); + //} } } } @@ -458,6 +476,7 @@ namespace Rs.Controls private void panel2_Paint(object sender, PaintEventArgs e) { + if(this.panel2.Width<=0 || this.panel2.Height<=0) { return; } this.DoubleBuffered = true; Graphics g = this.panel2.CreateGraphics(); drawImage = new Bitmap(this.panel2.Width, this.panel2.Height);