public NetPanel(DressMatrix in_netType) : this() { _netType = in_netType; Graphics g = CreateGraphics(); // 1. Measure sizes. NetUtil.MeasureNet(_netType, g, c_fieldWidth, out int maxWidthCapX, out int maxWidthCapY, out _widthCapX, out _widthCapY); // 2. Render labels. NetUtil.RenderLabels(_netType, this, maxWidthCapX, maxWidthCapY, _widthCapX, _widthCapY, c_labelWidthThreshold, c_height, c_gap, out _totalWidth, out _totalHeight); // 3. Render text labels of size chart. int xPos = maxWidthCapY + c_labelWidthThreshold * 2; for (int i = 0; i < _netType.CellsX.Count; i++) { int yPos = c_height + c_gap; for (int j = 0; j < _netType.CellsY.Count; j++) { TextBox tbox = new TextBox() { Parent = this, Location = new Point(xPos, yPos), Size = new Size(c_fieldWidth, c_height), Tag = new NetUtil.Value() { X = i, Y = j, NameX = _netType.CellsX[i], NameY = _netType.CellsY[j] } }; tbox.TextChanged += (s, e) => CellTextChanged((TextBox)s); tbox.GotFocus += (s, e) => ActiveCellChanged((TextBox)s); yPos += (c_gap + c_height); } xPos += (c_gap + maxWidthCapX); } foreach (Control ctrl in Controls) { if (ctrl is TextBox) { _textBoxBackColor = ctrl.BackColor; break; } } g.Dispose(); }
public FRM_CellSelector(SkuInStock in_skuInStock) : this() { SuspendLayout(); _skuInStock = in_skuInStock; Graphics g = CreateGraphics(); NetUtil.MeasureNet(_skuInStock.Article.Matrix, g, c_fieldWidth, out int maxWidthCapX, out int maxWidthCapY, out int[] widthsCapX, out int[] widthsCapY); NetUtil.RenderLabels(_skuInStock.Article.Matrix, this, maxWidthCapX, maxWidthCapY, widthsCapX, widthsCapY, c_labelWidthThreshold, c_fieldHeight, c_fieldGap, out int totalWidth, out int totalHeight, out _labelsX, out _labelsY); // Drawing buttons. int xPos = maxWidthCapY + c_labelWidthThreshold * 2; int cellsXCount = _skuInStock.Article.Matrix.CellsX.Count, cellsYCount = _skuInStock.Article.Matrix.CellsY.Count; for (int i = 0; i < cellsXCount; i++) { int yPos = c_fieldHeight + c_fieldGap; for (int j = 0; j < cellsYCount; j++) { new NetButton(this, _skuInStock[i, j], i, j, xPos, yPos, c_fieldWidth, c_fieldHeight); yPos += (c_fieldGap + c_fieldHeight); } xPos += (c_fieldGap + maxWidthCapX); } Width = totalWidth; Height = totalHeight; g.Dispose(); ResumeLayout(); }