Пример #1
0
        private void DataGridView_Sorted(object sender, EventArgs e)
        {
            var dataGridValueRows = new List <FsEntriesDataGridRowMtbl>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                var  uuidCell = row.Cells[(int)FsEntriesGridColumn.Uuid];
                Guid uuid     = Guid.Parse((string)uuidCell.Value);

                var dataRow = EditableDataGridValueRows.Single(
                    entry => entry.Data.Uuid == uuid);

                dataGridValueRows.Add(dataRow);
            }

            EditableDataGridValueRows = dataGridValueRows;
        }
Пример #2
0
        public void SetFsEntries(ICollection <IFsItem> fsEntries)
        {
            dataGridView.Rows.Clear();

            EditableDataGridValueRows = fsEntries.Select(
                GetFsEntriesDataGridRowMtbl).ToList();

            var dataGridViewRows = EditableDataGridValueRows.Select(
                GetDataGridViewRow).ToArray();

            dataGridView.Rows.AddRange(dataGridViewRows);

            if (EditableDataGridValueRows.Any())
            {
                SetCurrentRow(0, 0, false);
            }
            else
            {
                ClearCurrentRow(false);
            }
        }
Пример #3
0
        private void DataGridView_KeyUp(object sender, KeyEventArgs e)
        {
            int newRowIndex;

            switch (e.KeyCode)
            {
            case Keys.R:
                if (e.Control)
                {
                    onReload?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                         CurrentCellIndex, CurrentRow));
                }
                break;

            case Keys.Enter:
                if (EditableDataGridValueRows.Any())
                {
                    onFsEntryOpen?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                              CurrentCellIndex, CurrentRow));
                }
                break;

            case Keys.Back:
                onGoToParent?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                         CurrentCellIndex, CurrentRow));
                break;

            case Keys.Space:
                if (CurrentRowIndex >= 0)
                {
                    SelectDataGridRow(CurrentRowIndex);
                }
                break;

            case Keys.Up:
                if (CurrentRowIndex > 0)
                {
                    SetCurrentRow(CurrentRowIndex - 1, CurrentCellIndex);
                }
                break;

            case Keys.Down:
                if (CurrentRowIndex < EditableDataGridValueRows.Count - 1)
                {
                    SetCurrentRow(CurrentRowIndex + 1, CurrentCellIndex);
                }
                break;

            case Keys.Home:
                if (e.Alt)
                {
                    onGoToRoot?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                           CurrentRowIndex, CurrentRow));
                }
                else if (e.Control && EditableDataGridValueRows.Any())
                {
                    SetCurrentRow(0, CurrentCellIndex);
                }
                break;

            case Keys.End:
                if (e.Control && EditableDataGridValueRows.Any())
                {
                    SetCurrentRow(EditableDataGridValueRows.Count - 1, CurrentCellIndex);
                }
                break;

            case Keys.PageDown:
                if (EditableDataGridValueRows.Any())
                {
                    newRowIndex = Math.Max(0, CurrentRowIndex - FS_ENTRIES_DATA_GRID_PAGE_SIZE);
                    SetCurrentRow(newRowIndex, CurrentCellIndex);
                }
                break;

            case Keys.PageUp:
                if (EditableDataGridValueRows.Any())
                {
                    newRowIndex = Math.Min(EditableDataGridValueRows.Count - 1, CurrentRowIndex + FS_ENTRIES_DATA_GRID_PAGE_SIZE);
                    SetCurrentRow(newRowIndex, CurrentCellIndex);
                }
                break;

            case Keys.OemMinus:
                if (e.Control)
                {
                    onGoBack?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                         CurrentCellIndex, CurrentRow));
                }
                break;

            case Keys.Oemplus:
                if (e.Control)
                {
                    onGoForward?.Invoke(new KeyValuePair <int, IFsEntriesDataGridRow>(
                                            CurrentCellIndex, CurrentRow));
                }
                break;
            }
        }