private void CreateButton(string text, Action action) { Style style = new Style(); style.Font = new Font(FontFamily.GenericSansSerif, 18, FontStyle.Bold); BorderLabel showItemStatusButton = new BorderLabel(text, Color.BlueViolet, Color.Black, Color.White, 1, style); showItemStatusButton.Margin = new Padding(0); showItemStatusButton.Anchor = AnchorStyles.Top | AnchorStyles.Left; showItemStatusButton.Dock = DockStyle.Fill; showItemStatusButton.Click += (obj, e) => action(); _panel.Controls.Add(showItemStatusButton); }
private void SharedInit() { int topPanelHeight = 100; int offset = SystemInformation.CaptionHeight; Size newViewSize = new Size(_column * _width, topPanelHeight + offset); _view.BackColor = Color.White;; _view.FormBorderStyle = FormBorderStyle.FixedSingle; Panel topPanel = new Panel(); topPanel.Size = new Size(newViewSize.Width, topPanelHeight); topPanel.Dock = DockStyle.Top; topPanel.Margin = new Padding(0); topPanel.BackColor = Color.White; string msg = "Benvenuto " + _loginName; Style style = new Style(); style.Font = new Font(FontFamily.GenericSansSerif, 22, FontStyle.Bold); BorderLabel loginInfoLabel = new BorderLabel( msg, Color.DeepSkyBlue, Color.White, Color.White, 0, style); loginInfoLabel.Dock = DockStyle.Fill; topPanel.Controls.Add(loginInfoLabel); Panel tableContainer = new Panel(); tableContainer.AutoScroll = true; tableContainer.AutoSize = false; tableContainer.Margin = new Padding(0); tableContainer.Location = new Point(0, topPanelHeight); tableContainer.BackColor = Color.White; TableLayoutPanel tablePanel = new TableLayoutPanel(); tablePanel = new TableLayoutPanel(); tablePanel.AutoSize = false; tablePanel.BackColor = Color.White; tablePanel.Margin = new Padding(0); tablePanel.Padding = new Padding(0); tablePanel.BackColor = Color.White; tablePanel.RowCount = 0; tablePanel.RowStyles.Clear(); tablePanel.ControlAdded += delegate(Object o, ControlEventArgs e) { tablePanel.RowCount = (int)Math.Ceiling((double)tablePanel.Controls.Count / _column); if (tablePanel.RowCount > tablePanel.RowStyles.Count) { int tableRow = tablePanel.RowCount > _row ? _row : tablePanel.RowCount; tableContainer.Size = new Size(newViewSize.Width, tableRow * _height); tablePanel.Size = new Size(newViewSize.Width - SystemInformation.VerticalScrollBarWidth, tablePanel.RowCount * _height); tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, _height)); } _view.Size = new Size(_column * _width, topPanelHeight + offset + tableContainer.Height); }; loginInfoLabel.Click += (obj, e) => _view.Size += new Size(0, 1); tablePanel.ColumnStyles.Clear(); tablePanel.ColumnCount = _column; for (int i = 0; i < _column; i++) { tablePanel.ColumnStyles.Add( new ColumnStyle(SizeType.Absolute, (newViewSize.Width - SystemInformation.VerticalScrollBarWidth) / _column)); } _view.Size = newViewSize; _view.Controls.Add(topPanel); tableContainer.Controls.Add(tablePanel); _view.Controls.Add(tableContainer); _panel = tablePanel; }