コード例 #1
0
        private void dgvLayout_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            PARAM.Layout.Entry entry = (PARAM.Layout.Entry)dgvLayout.Rows[e.RowIndex].DataBoundItem;

            // Type
            if (e.ColumnIndex == 0)
            {
            }
            // Default
            else if (e.ColumnIndex == 3)
            {
                try
                {
                    if (entry.Type != CellType.dummy8)
                    {
                        PARAM.Layout.ParseParamValue(entry.Type, e.FormattedValue.ToString());
                    }
                }
                catch
                {
                    e.Cancel = true;
                    ShowError($"Invalid value for type \"{entry.Type}\".");
                }
            }
        }
コード例 #2
0
        private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var layout = (PARAM.Layout)dgvLayout.DataSource;
            var entry  = new PARAM.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;
        }
コード例 #3
0
        private void dgvLayout_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            PARAM.Layout.Entry entry = (PARAM.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;
            }
        }