using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace HH.WMS.Client.CustomControl
|
{
|
public partial class CusTray : UserControl
|
{
|
|
|
public CusTray()
|
{
|
InitializeComponent();
|
}
|
public CusTray(int? row,int? col)
|
{
|
InitializeComponent();
|
|
RowCount = row.HasValue?row.Value:1;
|
|
ColCount = col.HasValue ? col.Value : 1;
|
}
|
|
public void SetNum(string grid, decimal current, decimal total)
|
{
|
int row =Convert.ToInt16(grid.Split('-')[0]);
|
int col = Convert.ToInt16(grid.Split('-')[1]);
|
|
CusTrayContent content = (CusTrayContent)tlpGrid.GetControlFromPosition(row, col);
|
content.Current = current;
|
content.Total = total;
|
}
|
|
public void SetNumByTrayGrid(int grid, decimal current, decimal total)
|
{
|
int row = grid / ColCount;
|
int col = grid % RowCount;
|
if (col == 0)
|
{
|
row -= 1;
|
col = ColCount - 1;
|
}
|
else
|
col -= 1;
|
|
CusTrayContent content = (CusTrayContent)tlpGrid.GetControlFromPosition(row, col);
|
content.Current = current;
|
content.Total = total;
|
//content.BackColor = Color.Blue;
|
//content.Refresh();
|
}
|
|
public int _row = 1;
|
public int RowCount {
|
get { return _row; }
|
set {
|
_row = value;
|
tlpGrid.RowCount = _row;
|
for (int i = 0; i < _row; i++)
|
{
|
this.tlpGrid.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
}
|
}
|
}
|
public int _col = 1;
|
public int ColCount
|
{
|
get { return _col; }
|
set
|
{
|
_col = value;
|
tlpGrid.ColumnCount = _col;
|
for (int i = 0; i < _col; i++)
|
{
|
this.tlpGrid.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
}
|
SetGridPanl();
|
}
|
}
|
|
private void SetGridPanl()
|
{
|
for (int i = 0; i < RowCount; i++)
|
{
|
for (int j = 0; j < ColCount; j++)
|
{
|
CusTrayContent c = new CusTrayContent(0, 0);
|
c.Dock = DockStyle.Fill;
|
|
if (null != tlpGrid.GetControlFromPosition(i, j))
|
{
|
tlpGrid.Controls.Remove(tlpGrid.GetControlFromPosition(i, j));
|
}
|
this.tlpGrid.Controls.Add(c, i, j);
|
}
|
}
|
}
|
}
|
}
|