zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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);
                }
            }
        }
    }
}