Exemplo n.º 1
0
        private void ModList_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            DataGridViewRow row = ModList.Rows[e.RowIndex];

            if (!(row.Cells[0] is DataGridViewCheckBoxCell))
            {
                return;
            }
            // Need to change the state here, because the user hasn't clicked on a checkbox
            row.Cells[0].Value = !(bool)row.Cells[0].Value;
            ModList.CommitEdit(DataGridViewDataErrorContexts.Commit);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called on key down when the mod list is focused.
        /// Makes the Home/End keys go to the top/bottom of the list respectively.
        /// </summary>
        private void ModList_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Home:
                // First row.
                ModList.CurrentCell = ModList.Rows[0].Cells[SelectableColumnIndex()];
                e.Handled           = true;
                break;

            case Keys.End:
                // Last row.
                ModList.CurrentCell = ModList.Rows[ModList.Rows.Count - 1].Cells[SelectableColumnIndex()];
                e.Handled           = true;
                break;

            case Keys.Space:
                // If they've focused one of the checkbox columns, don't intercept
                if (ModList.CurrentCell.ColumnIndex > 3)
                {
                    DataGridViewRow row = ModList.CurrentRow;
                    // Toggle Update column if enabled, otherwise Install
                    for (int colIndex = 2; colIndex >= 0; --colIndex)
                    {
                        if (row?.Cells[colIndex] is DataGridViewCheckBoxCell)
                        {
                            // Need to change the state here, because the user hasn't clicked on a checkbox
                            row.Cells[colIndex].Value = !(bool)row.Cells[colIndex].Value;
                            ModList.CommitEdit(DataGridViewDataErrorContexts.Commit);
                            e.Handled = true;
                            break;
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// I'm pretty sure this is what gets called when the user clicks on a ticky
 /// in the mod list.
 /// </summary>
 private void ModList_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     ModList.CommitEdit(DataGridViewDataErrorContexts.Commit);
 }