示例#1
0
 public IEnumerator <HashRow> GetEnumerator()
 {
     foreach (var row in Rows.Cast <HashRow>())
     {
         yield return(row);
     }
 }
示例#2
0
        public async Task PrimaryKeyFieldsMetadataSupport()
        {
            using (var conn = await OpenConnectionAsync())
            {
                await using var _ = await GetTempTableName(conn, out var table);

                await conn.ExecuteNonQueryAsync($@"
CREATE TABLE {table} (
    field_pk1 INT2 NOT NULL,
    field_pk2 INT2 NOT NULL,
    field_serial SERIAL,
    CONSTRAINT data2_pkey PRIMARY KEY (field_pk1, field_pk2)
)");

                using (var command = new NpgsqlCommand($"SELECT * FROM {table}", conn))
                    using (var dr = command.ExecuteReader(CommandBehavior.KeyInfo))
                    {
                        dr.Read();
                        DataRow[] keyColumns =
#pragma warning disable 8602 // Warning should be removable after rc2 (https://github.com/dotnet/runtime/pull/42215)
                            dr.GetSchemaTable() !.Rows.Cast <DataRow>().Where(r => (bool)r["IsKey"]).ToArray() !;
#pragma warning restore 8602
                        Assert.That(keyColumns, Has.Length.EqualTo(2));
                        Assert.That(keyColumns.Count(c => (string)c["ColumnName"] == "field_pk1"), Is.EqualTo(1));
                        Assert.That(keyColumns.Count(c => (string)c["ColumnName"] == "field_pk2"), Is.EqualTo(1));
                    }
            }
        }
示例#3
0
 public void AutoResizeToFitContent()
 {
     AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
     Width = Columns.Cast <DataGridViewColumn>().Sum(c => c.Width) +
             (RowHeadersVisible ? RowHeadersWidth : 0) + 3;
     Height = Rows.Cast <DataGridViewRow>().Sum(r => r.Height) +
              (ColumnHeadersVisible ? ColumnHeadersHeight : 0) + 3;
 }
示例#4
0
 public bool checkInfoCompleteness()
 {
     return(Rows.Count == Rows.Cast <DataGridViewRow>()
            .Where(x => x.Cells[trackobj.Name].Value != null)
            .Where(x => x.Cells[pieceobj.Name].Value != null &&
                   ((Piece)x.Cells[pieceobj.Name].Value).ID != 0)
            .Count());
 }
 public DataGridViewRow this[string key]
 {
     get
     {
         return(Rows.
                Cast <DataGridViewRow>().
                First(val => val.Cells["gridColKey"].Value.ToString().Equals(key)));
     }
 }
 public void SelectFirstVisible()
 {
     foreach (DataGridViewRow gridRow in Rows)
     {
         gridRow.Selected = false;
     }
     foreach (var gridRow in Rows.Cast <DataGridViewRow>().Where(gridRow => gridRow.Visible))
     {
         gridRow.Selected = true;
         break;
     }
 }
示例#7
0
 public List <Track> exportInfo()
 {
     foreach (DataGridViewRow row in Rows)
     {
         Track t = (Track)row.Cells[trackobj.Name].Value;
         t.Piece      = (Piece)row.Cells[pieceobj.Name].Value;
         t.Performers = (List <Artist>)row.Cells[performersobj.Name].Value;
         t.Name       = row.Cells[title.Name].Value.ToString();
         t.Year       = int.Parse(row.Cells[year.Name].Value.ToString());
     }
     return(Rows.Cast <DataGridViewRow>().
            Select(x => (Track)x.Cells[trackobj.Name].Value).ToList());
 }
        public async Task Primary_key()
        {
            using var conn = await OpenConnectionAsync();

            await using var _ = await CreateTempTable(conn, "id SERIAL PRIMARY KEY, serial SERIAL", out var table);

            using var command = new NpgsqlCommand($"SELECT * FROM {table}", conn);
            using var dr      = command.ExecuteReader(CommandBehavior.KeyInfo);
            dr.Read();
            var metadata = await GetSchemaTable(dr);

#pragma warning disable 8602 // Warning should be removable after rc2 (https://github.com/dotnet/runtime/pull/42215)
            var key = metadata !.Rows.Cast <DataRow>().Single(r => (bool)r["IsKey"]) !;
#pragma warning restore 8602
            Assert.That(key["ColumnName"], Is.EqualTo("id"));
        }
        public void SelectLastVisible()
        {
            DataGridViewRow theLast = null;

            foreach (DataGridViewRow gridRow in Rows)
            {
                gridRow.Selected = false;
            }
            foreach (var gridRow in Rows.Cast <DataGridViewRow>().Where(gridRow => gridRow.Visible))
            {
                theLast = gridRow;
            }
            if (theLast != null)
            {
                theLast.Selected = true;
            }
        }
        public async Task IsAutoIncrement()
        {
            using var conn = await OpenConnectionAsync();

            await using var _ = await CreateTempTable(conn, "id SERIAL PRIMARY KEY", out var table);

            var command = new NpgsqlCommand($"SELECT * FROM {table}", conn);

            using var dr = command.ExecuteReader(CommandBehavior.KeyInfo);
            var metadata = await GetSchemaTable(dr);

#pragma warning disable 8602 // Warning should be removable after rc2 (https://github.com/dotnet/runtime/pull/42215)
            Assert.That(metadata !.Rows.Cast <DataRow>()
                        .Where(r => ((string)r["ColumnName"]).Contains("serial"))
                        .All(r => (bool)r["IsAutoIncrement"]));
#pragma warning restore 8602
        }
示例#11
0
        public void Commit(SQLiteConnection conn, CommitMode mode = CommitMode.All)
        {
            using (var trans = conn.BeginTransaction())
            {
                var command = conn.CreateCommand();

                var parId               = command.Parameters.Add("@ID", DbType.Int32);
                var parDiskLetter       = command.Parameters.Add("@DiskLetter", DbType.StringFixedLength, 1);
                var parDiskSerialNumber = command.Parameters.Add("@DiskSerialNumber", DbType.Int64);
                var parFileFormat       = command.Parameters.Add("@FileFormat", DbType.Int32);
                var parFileSize         = command.Parameters.Add("@FileSize", DbType.Int64);
                var parFileName         = command.Parameters.Add("@FileName", DbType.String);
                var parBitrate          = command.Parameters.Add("@Bitrate", DbType.Int32);
                var parChannels         = command.Parameters.Add("@Channels", DbType.Int32);
                var parDuration         = command.Parameters.Add("@Duration", DbType.Double);
                var parSampleRate       = command.Parameters.Add("@SampleRate", DbType.Int32);
                var parTrackNumber      = command.Parameters.Add("@TrackNumber", DbType.String);
                var parDiskNumber       = command.Parameters.Add("@DiskNumber", DbType.String);
                var parTitle            = command.Parameters.Add("@Title", DbType.String);
                var parAlbumId          = command.Parameters.Add("@AlbumID", DbType.String);
                var parAlbumArtistId    = command.Parameters.Add("@AlbumArtistID", DbType.String);
                var parArtistId         = command.Parameters.Add("@ArtistID", DbType.String);
                var parComposerId       = command.Parameters.Add("@ComposerID", DbType.String);
                var parCopyrightsId     = command.Parameters.Add("@CopyrightsID", DbType.Int32);
                var parPublisherId      = command.Parameters.Add("@PublisherID", DbType.String);
                var parUrlid            = command.Parameters.Add("@URLID", DbType.Int32);
                var parGenreId          = command.Parameters.Add("@GenreID", DbType.String);
                var parYearId           = command.Parameters.Add("@YearID", DbType.Int32);
                var parBpm              = command.Parameters.Add("@BPM", DbType.Int32);
                var parLabelsId         = command.Parameters.Add("@LabelsID", DbType.String);
                var parUserMark         = command.Parameters.Add("@UserMark", DbType.Int32);
                var parAdded            = command.Parameters.Add("@Added", DbType.Double);
                var parPlaybackCount    = command.Parameters.Add("@PlaybackCount", DbType.Int32);
                var parRatingRawScore   = command.Parameters.Add("@RatingRawScore", DbType.Double);
                var parLastPlayback     = command.Parameters.Add("@LastPlayback", DbType.Double);
                var parLastModification = command.Parameters.Add("@LastModification", DbType.Double);


                if (mode == CommitMode.All || mode == CommitMode.Delete)
                {
                    var toDelete = Rows.Cast <FilesRow>().Where(row => row.RowState == DataRowState.Deleted);
                    if (toDelete.Any())
                    {
                        throw new NotImplementedException("Ayy deletes ain't happening");
                    }
                }

                if (mode == CommitMode.All || mode == CommitMode.Upsert || mode == CommitMode.Insert)
                {
                    var toInsert = Rows.Cast <FilesRow>().Where(row => row.RowState == DataRowState.Added);
                    if (toInsert.Any())
                    {
                        throw new NotImplementedException("Ayy inserts ain't happening");
                    }
                }

                if (mode == CommitMode.All || mode == CommitMode.Upsert || mode == CommitMode.Update)
                {
                    var toUpdate = Rows.Cast <FilesRow>().Where(row => row.RowState == DataRowState.Modified);
                    if (toUpdate.Any())
                    {
                        command.CommandText = @"UPDATE TableFiles
                                                SET DiskLetter = @DiskLetter,
                                                DiskSerialNumber = @DiskSerialNumber,
                                                FileFormat = @FileFormat,
                                                FileSize = @FileSize,
                                                FileName = @FileName,
                                                Bitrate = @Bitrate,
                                                Channels = @Channels,
                                                Duration = @Duration,
                                                SampleRate = @SampleRate,
                                                TrackNumber = @TrackNumber,
                                                DiskNumber = @DiskNumber,
                                                Title = @Title,
                                                AlbumID = @AlbumID,
                                                AlbumArtistID = @AlbumArtistID,
                                                ArtistID = @ArtistID,
                                                ComposerID = @ComposerID,
                                                CopyrightsID = @CopyrightsID,
                                                PublisherID = @PublisherID,
                                                URLID = @URLID,
                                                GenreID = @GenreID,
                                                YearID = @YearID,
                                                BPM = @BPM,
                                                LabelsID = @LabelsID,
                                                UserMark = @UserMark,
                                                Added = @Added,
                                                PlaybackCount = @PlaybackCount,
                                                RatingRawScore = @RatingRawScore,
                                                LastPlayback = @LastPlayback,
                                                LastModification = @LastModification
                                                WHERE ID = @ID;";
                        foreach (var row in toUpdate)
                        {
                            parId.Value               = row["ID"];
                            parDiskLetter.Value       = row["DiskLetter"];
                            parDiskSerialNumber.Value = row["DiskSerialNumber"];
                            parFileFormat.Value       = row["FileFormat"];
                            parFileSize.Value         = row["FileSize"];
                            parFileName.Value         = row["FileName"];
                            parBitrate.Value          = row["Bitrate"];
                            parChannels.Value         = row["Channels"];
                            parDuration.Value         = row["Duration"];
                            parSampleRate.Value       = row["SampleRate"];
                            parTrackNumber.Value      = row["TrackNumber"];
                            parDiskNumber.Value       = row["DiskNumber"];
                            parTitle.Value            = row["Title"];
                            parAlbumId.Value          = row["AlbumID"];
                            parAlbumArtistId.Value    = row["AlbumArtistID"];
                            parArtistId.Value         = row["ArtistID"];
                            parComposerId.Value       = row["ComposerID"];
                            parCopyrightsId.Value     = row["CopyrightsID"];
                            parPublisherId.Value      = row["PublisherID"];
                            parUrlid.Value            = row["URLID"];
                            parGenreId.Value          = row["GenreID"];
                            parYearId.Value           = row["YearID"];
                            parBpm.Value              = row["BPM"];
                            parLabelsId.Value         = row["LabelsID"];
                            parUserMark.Value         = row["UserMark"];
                            parAdded.Value            = row["Added"];
                            parPlaybackCount.Value    = row["PlaybackCount"];
                            parRatingRawScore.Value   = row["RatingRawScore"];
                            parLastPlayback.Value     = row["LastPlayback"];
                            parLastModification.Value = row["LastModification"];

                            command.ExecuteNonQuery();
                        }
                    }
                }
                trans.Commit();
            }
        }
示例#12
0
            /// <summary>
            /// Отображение значений
            /// </summary>
            /// <param name="source">таблица с даными</param>
            public void ShowValues(IEnumerable <HandlerDbTaskCalculate.VALUES> inValues
                                   , IEnumerable <HandlerDbTaskCalculate.VALUES> outValues)
            {
                int idAlg       = -1
                , idPut         = -1
                , iQuality      = -1
                , iCol          = 0;
                double dblVal   = -1F,
                       dbSumVal = 0;
                DataGridViewRow row;
                IEnumerable <HandlerDbTaskCalculate.VALUES> componentValues = null;

                //if ((int)HandlerDbTaskCalculate.ID_VIEW_VALUES.SOURCE == (int)typeValues)
                //    ;

                if (RowCount > 1)
                {
                    foreach (DataGridViewColumn col in Columns)
                    {
                        try {
                            componentValues = inValues.Where(value => { return(value.m_IdPut == ((HandlerDbTaskCalculate.PUT_PARAMETER)col.Tag).m_Id); });

                            idAlg = ((HandlerDbTaskCalculate.PUT_PARAMETER)col.Tag).m_idNAlg;
                            idPut = ((HandlerDbTaskCalculate.PUT_PARAMETER)col.Tag).m_Id;
                            iCol  = Columns.IndexOf(col);
                        } catch (Exception e) {
                            Logging.Logg().Exception(e, @"DataGridViewValuesReaktivka::ShowValues () - ...", Logging.INDEX_MESSAGE.NOT_SET);
                        }

                        if (!(componentValues == null))
                        {
                            dbSumVal = 0F;

                            foreach (HandlerDbTaskCalculate.VALUES value in componentValues)
                            {
                                dblVal   = value.value;
                                iQuality = value.m_iQuality;

                                dbSumVal += dblVal;

                                row = Rows.Cast <DataGridViewRow>().FirstOrDefault(r => { return((r.Tag is DateTime) ? value.stamp_value.Equals(((DateTime)(r.Tag))) == true : false); });

                                if (!(row == null))
                                {
                                    if ((row.Cells[iCol].ReadOnly = double.IsNaN(dblVal)) == false)
                                    {
                                        dblVal = GetValueCellAsRatio(idAlg, idPut, dblVal);
                                    }
                                    else
                                    {
                                        dblVal = 0F;
                                    }

                                    row.Cells[iCol].Value = dblVal.ToString(m_dictNAlgProperties[idAlg].FormatRound, CultureInfo.InvariantCulture);
                                }
                                else
                                {
                                    // не найдена строка для даты в наборе данных для отображения
                                    Logging.Logg().Warning(string.Format(@"DataGridViewValuesReaktivka::ShowValues () - не найдена строка для даты [DATETIME={0}] в наборе данных для отображения..."
                                                                         , value.stamp_value.Date)
                                                           , Logging.INDEX_MESSAGE.NOT_SET);
                                }
                            }

                            dbSumVal = GetValueCellAsRatio(idAlg, idPut, dbSumVal);
                            Rows[Rows.Count - 1].Cells[iCol].Value = dbSumVal.ToString(m_dictNAlgProperties[idAlg].FormatRound, CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            Logging.Logg().Error(string.Format(@"DataGridViewValuesReaktivka::ShowValues () - не найдено ни одного значения для [ID_PUT={0}] в наборе данных [COUNT={1}] для отображения..."
                                                               , ((HandlerDbTaskCalculate.PUT_PARAMETER)col.Tag).m_Id, inValues.Count())
                                                 , Logging.INDEX_MESSAGE.NOT_SET);
                        }
                    }
                }
                else
                {
                    Logging.Logg().Error(string.Format(@"DataGridViewValuesReaktivka::ShowValues () - нет строк для отображения..."), Logging.INDEX_MESSAGE.NOT_SET);
                }
            }
 public bool ValidateRows()
 {
     EndEdit();
     return(Rows.Cast <DataGridViewRow>().All(OnValidateRow));
 }
示例#14
0
        private void ProcessNewCtrlUp(bool shiftKey = false)
        {
            DataGridViewCell firstSelectedCell =
                SelectedCells.Cast <DataGridViewCell>().Where(p => p.OwningRow.Frozen == false).OrderBy(p => p.RowIndex).
                FirstOrDefault();

            if (firstSelectedCell == null)
            {
                return;
            }

            bool reverse = false;

            if (CurrentCell.RowIndex == firstSelectedCell.RowIndex && SelectedCells.Count > 1)
            {
                firstSelectedCell =
                    SelectedCells.Cast <DataGridViewCell>().Where(p => p.OwningRow.Frozen == false).OrderByDescending(
                        p => p.RowIndex).FirstOrDefault();
                if (firstSelectedCell == null)
                {
                    return;
                }
                reverse = true;
            }

            int currentColumnIndex = firstSelectedCell.ColumnIndex;
            int currentRowIndex    = firstSelectedCell.RowIndex;

            DataGridViewCell beforeCell = firstSelectedCell.RowIndex <= 0
                                                                                          ? null
                                                                                          : Rows[firstSelectedCell.RowIndex - 1].Cells[currentColumnIndex];

            if (beforeCell == null)
            {
                return;
            }

            DataGridViewCell targetCell;

            if ((firstSelectedCell.Value != null && beforeCell.Value != null) &&
                (firstSelectedCell.Value.ToString() == string.Empty ||
                 (firstSelectedCell.Value.ToString() != string.Empty && beforeCell.Value.ToString() == string.Empty)))
            {
                targetCell = beforeCell.Value.ToString() == string.Empty
                                                                 ? Rows.Cast <DataGridViewRow>().Reverse().Where(
                    p =>
                    p.Cells[currentColumnIndex].Value != null && p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex < currentRowIndex &&
                    p.Cells[currentColumnIndex].Value.ToString() != string.Empty).Select(
                    p => p.Cells[currentColumnIndex]).FirstOrDefault()
                                                                 : beforeCell;

                //no non blank exists, so goto the last cell in that column
                targetCell = targetCell ?? Rows[0].Cells[currentColumnIndex];
            }
            else
            {
                targetCell =
                    Rows.Cast <DataGridViewRow>().Reverse().Where(
                        p =>
                        p.Cells[currentColumnIndex].Value != null && p.Frozen == false &&
                        p.Cells[currentColumnIndex].RowIndex < currentRowIndex &&
                        p.Cells[currentColumnIndex].Value.ToString() == string.Empty).Select(
                        p => p.Cells[currentColumnIndex]).FirstOrDefault();

                //targetCell = targetCell == null ? Rows[0].Cells[currentColumnIndex] : Rows[targetCell.RowIndex + 1].Cells[currentColumnIndex];
                targetCell = targetCell == null
                                                                 ? Rows.Cast <DataGridViewRow>().Where(p => p.Frozen == false).Select(
                    p => p.Cells[currentColumnIndex]).FirstOrDefault()
                                                                 : Rows[targetCell.RowIndex + 1].Cells[currentColumnIndex];
            }


            if (targetCell == null)
            {
                return;
            }


            if (shiftKey)
            {
                int selectedRowIndex = reverse
                                           ? SelectedCells.Cast <DataGridViewCell>().OrderByDescending(p => p.RowIndex).
                                       First().RowIndex
                                           : SelectedCells.Cast <DataGridViewCell>().OrderBy(p => p.RowIndex).First().
                                       RowIndex;

                List <DataGridViewCell> toBeSelectedRows = reverse
                                                              ? Rows.Cast <DataGridViewRow>().Where(
                    p =>
                    p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex <=
                    selectedRowIndex &&
                    p.Cells[currentColumnIndex].RowIndex >=
                    targetCell.RowIndex).Select(
                    p => p.Cells[currentColumnIndex]).OrderBy(
                    p => p.RowIndex).ToList()
                                                              : Rows.Cast <DataGridViewRow>().Where(
                    p =>
                    p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex <=
                    selectedRowIndex &&
                    p.Cells[currentColumnIndex].RowIndex >=
                    targetCell.RowIndex).Select(
                    p => p.Cells[currentColumnIndex]).
                                                           OrderByDescending(p => p.RowIndex).ToList();

                toBeSelectedRows.ForEach(a => a.Selected = CurrentCell.RowIndex >= a.RowIndex);

                targetCell.Selected = true;

                if (FirstDisplayedScrollingRowIndex > targetCell.RowIndex)
                {
                    FirstDisplayedScrollingRowIndex = targetCell.RowIndex;
                }
            }
            else
            {
                CurrentCell = targetCell;
            }
        }
 IEnumerator <RelationshipDetailsRow> IEnumerable <RelationshipDetailsRow> .GetEnumerator()
 {
     return(Rows.Cast <RelationshipDetailsRow>().GetEnumerator());
 }
示例#16
0
 IEnumerator <TableDetailsRow> IEnumerable <TableDetailsRow> .GetEnumerator()
 {
     return(Rows.Cast <TableDetailsRow>().GetEnumerator());
 }
示例#17
0
        private void ProcessNewCtrlDown(bool shiftKey = false)
        {
            DataGridViewCell lastSelectedCell =
                SelectedCells.Cast <DataGridViewCell>().Where(p => p.OwningRow.Frozen == false).OrderByDescending(
                    p => p.RowIndex).FirstOrDefault();

            if (lastSelectedCell == null)
            {
                return;
            }
            bool reverse = false;

            if (CurrentCell.RowIndex == lastSelectedCell.RowIndex && SelectedCells.Count > 1)
            {
                lastSelectedCell = SelectedCells.Cast <DataGridViewCell>().OrderBy(p => p.RowIndex).FirstOrDefault();
                if (lastSelectedCell == null)
                {
                    return;
                }
                reverse = true;
            }

            int currentColumnIndex = lastSelectedCell.ColumnIndex;
            int currentRowIndex    = lastSelectedCell.RowIndex;


            DataGridViewCell nextCell = Rows.Count == lastSelectedCell.RowIndex + 1
                                                                                        ? null
                                                                                        : Rows[lastSelectedCell.RowIndex + 1].Cells[currentColumnIndex];

            if (nextCell == null)
            {
                return;
            }

            DataGridViewCell targetCell;

            if ((lastSelectedCell.Value != null && nextCell.Value != null) &&
                (lastSelectedCell.Value.ToString() == string.Empty ||
                 (lastSelectedCell.Value.ToString() != string.Empty && nextCell.Value.ToString() == string.Empty)))
            {
                targetCell = nextCell.Value.ToString() == string.Empty
                                                                 ? Rows.Cast <DataGridViewRow>().Where(
                    p =>
                    p.Cells[currentColumnIndex].Value != null && p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex > currentRowIndex &&
                    p.Cells[currentColumnIndex].Value.ToString() != string.Empty).Select(
                    p => p.Cells[currentColumnIndex]).FirstOrDefault()
                                                                 : nextCell;

                //no non blank exists, so goto the last cell in that column
                targetCell = targetCell ?? Rows[Rows.Count - 1].Cells[currentColumnIndex];

                targetCell = targetCell ??
                             Rows.Cast <DataGridViewRow>().OrderByDescending(p => p.Cells[currentColumnIndex].RowIndex).
                             First().Cells[currentColumnIndex];
            }

            else
            {
                targetCell =
                    Rows.Cast <DataGridViewRow>().Where(
                        p =>
                        p.Cells[currentColumnIndex].Value != null && p.Frozen == false &&
                        p.Cells[currentColumnIndex].RowIndex > currentRowIndex &&
                        p.Cells[currentColumnIndex].Value.ToString() == string.Empty).Select(
                        p => p.Cells[currentColumnIndex]).FirstOrDefault();

                targetCell = targetCell == null
                                                                 ? Rows[Rows.Count - 1].Cells[currentColumnIndex]
                                                                 : Rows[targetCell.RowIndex - 1].Cells[currentColumnIndex];
            }

            if (shiftKey)
            {
                int selectedRowIndex = reverse
                                           ? SelectedCells.Cast <DataGridViewCell>().OrderByDescending(p => p.RowIndex).
                                       First().RowIndex
                                           : SelectedCells.Cast <DataGridViewCell>().OrderBy(p => p.RowIndex).First().
                                       RowIndex;

                List <DataGridViewCell> toBeSelectedRows = reverse
                                                              ? Rows.Cast <DataGridViewRow>().Where(
                    p =>
                    p.Cells[currentColumnIndex].Value != null &&
                    p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex >=
                    selectedRowIndex &&
                    p.Cells[currentColumnIndex].RowIndex <=
                    targetCell.RowIndex).Select(
                    p => p.Cells[currentColumnIndex]).
                                                           OrderByDescending(p => p.RowIndex).ToList()
                                                              : Rows.Cast <DataGridViewRow>().Where(
                    p =>
                    p.Cells[currentColumnIndex].Value != null &&
                    p.Frozen == false &&
                    p.Cells[currentColumnIndex].RowIndex >=
                    selectedRowIndex &&
                    p.Cells[currentColumnIndex].RowIndex <=
                    targetCell.RowIndex).Select(
                    p => p.Cells[currentColumnIndex]).OrderBy(
                    p => p.RowIndex).ToList();

                SelectedCells.Cast <DataGridViewCell>().Where(p => p.RowIndex < targetCell.RowIndex).ForEach(
                    p => p.Selected = p.RowIndex > CurrentCell.RowIndex);
                toBeSelectedRows.ForEach(a => a.Selected = CurrentCell.RowIndex <= a.RowIndex);

                targetCell.Selected = true;

                if (FirstDisplayedScrollingRowIndex + DisplayedRowCount(false) <= targetCell.RowIndex)
                {
                    FirstDisplayedScrollingRowIndex = targetCell.RowIndex - DisplayedRowCount(false) + 1;
                }
            }
            else
            {
                CurrentCell = targetCell;
            }
        }
示例#18
0
            /// <summary>
            /// Обновить структуру таблицы (доступность(цвет)/видимость столбцов/строк)
            /// </summary>
            /// <param name="item">Аргумент события для обновления структуры представления</param>
            public /*override*/ void UpdateStructure(PanelManagementTaskTepValues.ItemCheckedParametersEventArgs item)
            {
                Color clrCell      = Color.Empty; //Цвет фона для ячеек, не участвующих в расчете
                int   indx         = -1;
                bool  bItemChecked = item.NewCheckState == CheckState.Checked ? true :
                                     item.NewCheckState == CheckState.Unchecked ? false :
                                     false;

                //Поиск индекса элемента отображения
                if (item.IsComponent == true)
                {
                    // найти индекс столбца (компонента) - по идентификатору
                    foreach (DataGridViewColumn c in Columns)
                    {
                        if (((TepCommon.HandlerDbTaskCalculate.TECComponent)c.Tag).m_Id == item.m_idComp)
                        {
                            indx = Columns.IndexOf(c);
                            break;
                        }
                        else
                        {
                            ;
                        }
                    }
                }
                else if (item.IsNAlg == true)
                {
                    // найти индекс строки (параметра) - по идентификатору
                    // вариант №1
                    indx = Rows.Cast <DataGridViewRow>().First(r => { return((int)r.Tag == item.m_idAlg); }).Index;
                    //// // вариант №2
                    //indx = (
                    //        from r in Rows.Cast<DataGridViewRow>()
                    //        where (int)r.Tag == item.m_idAlg
                    //        select new { r.Index }
                    //    ).Cast<int>().ElementAt<int>(0);
                    //// // вариант №3
                    //foreach (DataGridViewRow r in Rows)
                    //    if ((int)r.Tag == item.m_idAlg) {
                    //        indx = Rows.IndexOf(r);
                    //        break;
                    //    } else
                    //        ;
                }
                else
                {
                    ;
                }

                if (!(indx < 0))
                {
                    if (item.m_type == PanelManagementTaskTepValues.ItemCheckedParametersEventArgs.TYPE.ENABLE)
                    {
                        if (item.IsComponent == true)   // COMPONENT ENABLE
                        // для всех ячеек в столбце
                        {
                            foreach (DataGridViewRow r in Rows)
                            {
                                if (getColorCellToColumn(indx, r.Index, bItemChecked, out clrCell) == true)
                                {
                                    r.Cells[indx].Style.BackColor = clrCell;
                                }
                                else
                                {
                                    ;
                                }
                            }
                            ((TepCommon.HandlerDbTaskCalculate.TECComponent)Columns[indx].Tag).SetEnabled(bItemChecked);
                        }
                        else if (item.IsNAlg == true)     // NALG ENABLE
                        // для всех ячеек в строке
                        {
                            foreach (DataGridViewCell c in Rows[indx].Cells)
                            {
                                if (getColorCellToRow(c.ColumnIndex, indx, bItemChecked, out clrCell) == true)
                                {
                                    c.Style.BackColor = clrCell;
                                }
                                else
                                {
                                    ;
                                }

                                m_dictNAlgProperties.SetEnabled((int)Rows[indx].Tag, ((TepCommon.HandlerDbTaskCalculate.TECComponent)Columns[c.ColumnIndex].Tag).m_Id, bItemChecked);
                            }
                        }
                        else
                        {
                            ;
                        }
                    }
                    else if (item.m_type == PanelManagementTaskTepValues.ItemCheckedParametersEventArgs.TYPE.VISIBLE)
                    {
                        if (item.IsComponent == true)   // COMPONENT VISIBLE
                        // для всех ячеек в столбце
                        {
                            Columns[indx].Visible = bItemChecked;
                        }
                        else if (item.IsNAlg == true)      // NALG VISIBLE
                        // для всех ячеек в строке
                        {
                            Rows[indx].Visible = bItemChecked;
                        }
                        else
                        {
                            ;
                        }
                    }
                    else
                    {
                        ;
                    }
                }
                else
                {
                    // нет элемента для изменения стиля
                    ;
                }
            }
示例#19
0
 /// <summary>
 /// This property returns an enumerator of T for the TypedTable.  Note, this could
 /// execute the underlying Linq expression.
 /// </summary>
 /// <returns>IEnumerable of T.</returns>
 public IEnumerator <T> GetEnumerator()
 {
     return(Rows.Cast <T>().GetEnumerator());
 }
示例#20
0
 public IEnumerator <DataRow> GetEnumerator()
 {
     return(Rows.Cast <DataRow>().GetEnumerator());
 }