Exemplo n.º 1
0
        private void dgvLayout_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            PARAM64.Layout.Entry entry = (PARAM64.Layout.Entry)dgvLayout.Rows[e.RowIndex].DataBoundItem;

            // Type
            if (e.ColumnIndex == 0)
            {
            }
            // Default
            else if (e.ColumnIndex == 3)
            {
                try
                {
                    if (entry.Type != CellType.dummy8)
                    {
                        PARAM64.Layout.ParseParamValue(entry.Type, e.FormattedValue.ToString());
                    }
                }
                catch
                {
                    e.Cancel = true;
                    ShowError($"Invalid value for type \"{entry.Type}\".");
                }
            }
        }
Exemplo n.º 2
0
        private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var layout = (PARAM64.Layout)dgvLayout.DataSource;
            var entry  = new PARAM64.Layout.Entry(CellType.u8, "name", 0);

            if (dgvLayout.SelectedCells.Count == 0)
            {
                layout.Add(entry);
            }
            else
            {
                layout.Insert(dgvLayout.SelectedCells[dgvLayout.SelectedCells.Count - 1].RowIndex + 1, entry);
            }

            dgvLayout.DataSource = null;
            dgvLayout.DataSource = layout;
        }
Exemplo n.º 3
0
        private void dgvLayout_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            PARAM64.Layout.Entry entry = (PARAM64.Layout.Entry)dgvLayout.Rows[e.RowIndex].DataBoundItem;
            DataGridViewCell     cell  = dgvLayout.Rows[e.RowIndex].Cells[e.ColumnIndex];

            // Size
            if (e.ColumnIndex == 2)
            {
                cell.ReadOnly = !entry.IsVariableSize;
            }
            // Default
            else if (e.ColumnIndex == 3)
            {
                cell.ReadOnly = entry.Type == CellType.dummy8;
            }
        }