public frmMain() { InitializeComponent(); figures = new List <Figure>(); paper = pnlDraw.CreateGraphics(); // Data grid view setup dgvFigData.AllowUserToAddRows = false; dgvFigData.AllowUserToDeleteRows = false; dgvFigData.AllowUserToOrderColumns = false; dgvFigData.ColumnHeadersVisible = false; dgvFigData.RowHeadersVisible = false; dgvFigData.Columns.Add("Key", "Key"); dgvFigData.Columns.Add("Value", "Value"); dgvFigData.Columns[0].ReadOnly = true; dgvFigData.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvFigData.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvFigData.Columns[0].Resizable = DataGridViewTriState.False; dgvFigData.Columns[1].Resizable = DataGridViewTriState.False; //Change cell font foreach (DataGridViewColumn col in dgvFigData.Columns) { col.DefaultCellStyle.Font = lbFigures.Font; } // Figures ListBox Setup lbFigures.DataSource = FigureFab.InitFiguresData(); }
// Add new figure to figures collection and redraw window private void btdDraw_Click(object sender, EventArgs e) { var fig = FigureFab.Make(lbFigures.SelectedItem as FiguresData); if (fig != null) { var pen = new Pen(btnLineColour.BackColor, (int)edLineWidth.Value); fig.drawer = new WFDrawer(pen, paper); figures.Add(fig); } Redraw(); }