protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
        {
            base.OnCellPainting(e);

            if (e.RowIndex >= 0 && Rows[e.RowIndex].Tag is Host)
            {
                PoolHostDataGridViewOneCheckboxRow row = (PoolHostDataGridViewOneCheckboxRow)Rows[e.RowIndex];
                //Paintout checkbox - note: it's still there
                if (!row.CheckBoxVisible && e.ColumnIndex == 1)
                {
                    e.PaintBackground(e.ClipBounds, true);
                    e.Handled = true;
                }
                else if (row.HasPool && (e.ColumnIndex == 0 || e.ColumnIndex == 1))
                {
                    e.PaintBackground(e.ClipBounds, true);
                    e.Handled = true;
                }
                else if (!row.HasPool && e.ColumnIndex == 0)
                {
                    e.PaintBackground(e.ClipBounds, true);
                    e.Handled = true;
                }
            }
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj != null && obj.GetType() == GetType())
            {
                PoolHostDataGridViewOneCheckboxRow castRow = (PoolHostDataGridViewOneCheckboxRow)obj;
                return(_nameCell.Value.ToString().Equals(castRow._nameCell.Value.ToString()));
            }

            return(false);
        }
Exemplo n.º 3
0
            protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
            {
                PoolHostDataGridViewOneCheckboxRow row = (PoolHostDataGridViewOneCheckboxRow)this.OwningRow;

                if (value is Host || value is Pool)
                {
                    Image hostIcon   = Images.GetImage16For(value as IXenObject);
                    var   iconIndent = row.IsCheckable ? 0 : 16;
                    var   textIndent = iconIndent + 16;
                    base.Paint(graphics, clipBounds,
                               new Rectangle(cellBounds.X + textIndent, cellBounds.Y, cellBounds.Width - textIndent,
                                             cellBounds.Height), rowIndex, cellState, value, formattedValue,
                               errorText, cellStyle, advancedBorderStyle, paintParts);
                    if ((cellState & DataGridViewElementStates.Selected) != 0 && row.Enabled)
                    {
                        using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.SelectionBackColor))
                            graphics.FillRectangle(
                                brush, cellBounds.X, cellBounds.Y, hostIcon.Width + iconIndent, cellBounds.Height);
                    }
                    else
                    {
                        //Background behind the host icon
                        using (var brush = new SolidBrush(this.DataGridView.DefaultCellStyle.BackColor))
                            graphics.FillRectangle(brush,
                                                   cellBounds.X, cellBounds.Y, hostIcon.Width + iconIndent, cellBounds.Height);
                    }

                    if (row.Enabled)
                    {
                        graphics.DrawImage(hostIcon, cellBounds.X + iconIndent, cellBounds.Y + 3, hostIcon.Width, hostIcon.Height);
                    }
                    else
                    {
                        graphics.DrawImage(hostIcon,
                                           new Rectangle(cellBounds.X + iconIndent, cellBounds.Y + 3, hostIcon.Width, hostIcon.Height),
                                           0, 0, hostIcon.Width, hostIcon.Height, GraphicsUnit.Pixel,
                                           Drawing.GreyScaleAttributes);
                    }
                }
                else
                {
                    base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
                }
            }
        public void SetCheckStateOfHostRowsContaining(IEnumerable <Host> hostsToCheck, CheckState checkState)
        {
            foreach (PoolHostDataGridViewOneCheckboxRow row in Rows)
            {
                if (!row.IsCheckable)
                {
                    continue;
                }

                PoolHostDataGridViewOneCheckboxRow currentRow = row;
                bool canCheck = row.IsAPoolRow
                                    ? hostsToCheck.Any(
                    host => currentRow.UnderlyingPool.Equals(Helpers.GetPoolOfOne(host.Connection)))
                                    : row.IsAHostRow ? hostsToCheck.Contains(row.UnderlyingHost) : false;
                if (canCheck)
                {
                    row.Checked = checkState;
                }
            }
        }
        public override void CheckBoxChange(int rowIndex, int columnIndex)
        {
            if (columnIndex != 1 || !((DataGridViewExRow)Rows[rowIndex]).Enabled)
            {
                return;
            }

            Rows[rowIndex].Cells[columnIndex].Value = (int)(Rows[rowIndex].Cells[columnIndex].Value) == 0 ? 1 : 0;

            PoolHostDataGridViewOneCheckboxRow row = (PoolHostDataGridViewOneCheckboxRow)Rows[rowIndex];

            if (row.CheckBoxVisible && row.IsCheckable)
            {
                OnCheckBoxClicked();
            }
            else
            {
                //Make sure the invisible checked box is unclicked
                row.Checked = CheckState.Unchecked;
            }
        }