private void DoSelectionBG(PaintEventArgs e, List <RollColumn> visibleColumns)
        {
            // SuuperW: This allows user to see other colors in selected frames.
            Color rowColor        = Color.White;
            int   _lastVisibleRow = LastVisibleRow;
            int   lastRow         = -1;

            foreach (Cell cell in SelectedItems)
            {
                if (cell.RowIndex > _lastVisibleRow || cell.RowIndex < FirstVisibleRow ||
                    !VisibleColumns.Contains(cell.Column))
                {
                    continue;
                }

                Cell relativeCell = new Cell
                {
                    RowIndex = cell.RowIndex - FirstVisibleRow,
                    Column   = cell.Column,
                };
                relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value);

                if (QueryRowBkColor != null && lastRow != cell.RowIndex.Value)
                {
                    QueryRowBkColor(cell.RowIndex.Value, ref rowColor);
                    lastRow = cell.RowIndex.Value;
                }

                Color cellColor = rowColor;
                QueryItemBkColor(cell.RowIndex.Value, cell.Column, ref cellColor);
                // Alpha layering for cell before selection
                float alpha = (float)cellColor.A / 255;
                if (cellColor.A != 255 && cellColor.A != 0)
                {
                    cellColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - cellColor.R) * alpha),
                                               rowColor.G - (int)((rowColor.G - cellColor.G) * alpha),
                                               rowColor.B - (int)((rowColor.B - cellColor.B) * alpha));
                }
                // Alpha layering for selection
                alpha     = 0.33f;
                cellColor = Color.FromArgb(cellColor.R - (int)((cellColor.R - SystemColors.Highlight.R) * alpha),
                                           cellColor.G - (int)((cellColor.G - SystemColors.Highlight.G) * alpha),
                                           cellColor.B - (int)((cellColor.B - SystemColors.Highlight.B) * alpha));
                DrawCellBG(cellColor, relativeCell, visibleColumns);
            }
        }
Exemple #2
0
		private void DoSelectionBG(List<RollColumn> visibleColumns, Rectangle rect)
		{
			Color rowColor = Color.White;
			var visibleRows = FirstVisibleRow.RangeTo(LastVisibleRow);
			int lastRow = -1;
			foreach (Cell cell in _selectedItems)
			{
				if (!cell.RowIndex.HasValue || !visibleRows.Contains(cell.RowIndex.Value) || !VisibleColumns.Contains(cell.Column))
				{
					continue;
				}

				Cell relativeCell = new Cell
				{
					RowIndex = cell.RowIndex - visibleRows.Start,
					Column = cell.Column,
				};
				relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value);

				if (QueryRowBkColor != null && lastRow != cell.RowIndex.Value)
				{
					QueryRowBkColor(cell.RowIndex.Value, ref rowColor);
					lastRow = cell.RowIndex.Value;
				}

				Color cellColor = rowColor;
				QueryItemBkColor?.Invoke(cell.RowIndex.Value, cell.Column, ref cellColor);

				// Alpha layering for cell before selection
				float alpha = (float)cellColor.A / 255;
				if (cellColor.A != 255 && cellColor.A != 0)
				{
					cellColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - cellColor.R) * alpha),
						rowColor.G - (int)((rowColor.G - cellColor.G) * alpha),
						rowColor.B - (int)((rowColor.B - cellColor.B) * alpha));
				}

				// Alpha layering for selection
				alpha = 0.33f;
				cellColor = Color.FromArgb(cellColor.R - (int)((cellColor.R - SystemColors.Highlight.R) * alpha),
					cellColor.G - (int)((cellColor.G - SystemColors.Highlight.G) * alpha),
					cellColor.B - (int)((cellColor.B - SystemColors.Highlight.B) * alpha));
				DrawCellBG(cellColor, relativeCell, visibleColumns, rect);
			}
		}
Exemple #3
0
        protected string PutQuery(NameValueCollection queryString)
        {
            string result = "UPDATE ";

            if (!string.IsNullOrEmpty(CatalogName))
            {
                result += CatalogName + ".";
            }
            result += Name + " SET";
            string predicat = " WHERE 1=1";

            foreach (string name in queryString)
            {
                if (!FilterableColumns.Any() || FilterableColumns.Contains(name))
                {
                    if (Criteria.TryParse(queryString[name], out Criteria criteria))
                    {
                        predicat += " AND " + criteria.toSqlWhereClause(name);
                    }
                    else
                    {
                        predicat += " AND " + name;
                        if (queryString[name].Contains("%"))
                        {
                            predicat += " LIKE '" + queryString[name] + "'";
                        }
                        else
                        {
                            predicat += "=" + queryString[name].ToSqlValue();
                        }
                    }
                }
                else
                {
                    if (!VisibleColumns.Any() || VisibleColumns.Contains(name))
                    {
                        result += name + "=" + queryString[name].ToSqlValue() + ", ";
                    }
                }
            }

            result += string.Join(", ", DefaultColumns.Select(c => c.Key + "=" + c.Value.ToSqlValue())) + predicat;
            return(result);
        }
Exemple #4
0
        protected string PostQuery(NameValueCollection queryString)
        {
            string result = "INSERT INTO ";

            if (!string.IsNullOrEmpty(CatalogName))
            {
                result += CatalogName + ".";
            }
            result += Name + " (";
            string values = " VALUES (";

            foreach (string name in queryString)
            {
                if (!VisibleColumns.Any() || VisibleColumns.Contains(name))
                {
                    result += name + ", ";
                    values += queryString[name].ToSqlValue() + ", ";
                }
            }

            result += string.Join(", ", DefaultColumns.Keys) + ")" + values + string.Join(", ", DefaultColumns.Select(c => c.Value.ToSqlValue())) + ")";
            return(result);
        }
        public List <DataTableColumnInfo> GetColumnInfos()
        {
            if (_columnInfos == null)
            {
                _columnInfos = new List <DataTableColumnInfo>();

                var keyColumns   = GetKeyColumns();
                var columnsInfos = GetColumns().Select((c, index) =>
                {
                    var info = new DataTableColumnInfo(index)
                    {
                        IsDatabound = c.IsDataBound(),
                        IsVisible   = !keyColumns.Select(k => k.Name).Contains(c.Name) && (!VisibleColumns.Any() || VisibleColumns.Contains(c.Name)),
                        DataType    = c.PropertyType.ToString().ToLower()
                    };
                    info.UpdateData(c.Name);
                    info.UpdateName(c.GetDisplayName());
                    return(info);
                }).ToList();

                _columnInfos.AddRange(columnsInfos);
            }
            return(_columnInfos);
        }