优化RsTray左下到左上画盘

master
lhiven 5 months ago
parent 8b46723040
commit a0aa68371f

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

Loading…
Cancel
Save