Esempio n. 1
0
        static internal void RenderCheckBox(
            Graphics g, GridFilter gf, GridColumn column, Rectangle bounds)
        {
            object value = column.FilterValue;

            if (_sizeCheckBox == null)
            {
                _sizeCheckBox = new MyCheckBoxX();

                _sizeCheckBox.Text = "";
                _sizeCheckBox.BackColor = Color.Transparent;
            }

            _sizeCheckBox.Enabled = false;
            _sizeCheckBox.Size = new Size(20, 20);
            _sizeCheckBox.BackColor = GetSimpleColor(gf.GetEffectiveStyle(column));

            if (value is CheckState)
                _sizeCheckBox.CheckState = (CheckState)value;
            else
                _sizeCheckBox.CheckState = CheckState.Indeterminate;

            Rectangle r = new Rectangle(0, 0, 20, 20);

            using (Bitmap bm = new Bitmap(20, 20))
            {
                _sizeCheckBox.DrawToBitmap(bm, r);

                Rectangle t = bounds;

                if (bounds.Width > r.Width)
                {
                    t.X += (t.Width - r.Width - 1) / 2;
                    t.Width = r.Width;
                }

                if (bounds.Height > r.Height)
                {
                    t.Y += (t.Height - r.Height) / 2;
                    t.Height = r.Height;
                }

                g.DrawImage(bm, t);
            }
        }
Esempio n. 2
0
        static internal Size GetPreferredSize(
            GridFilter gridFilter, GridColumn gridColumn)
        {
            Size size = Size.Empty;

            FilterEditType type = gridColumn.GetFilterPanelType();

            switch (type)
            {
                case FilterEditType.ComboBox:
                    if (_sizeComboBox == null)
                        _sizeComboBox = new ComboBoxEx();

                    _sizeComboBox.Font = gridFilter.GetEffectiveStyle(gridColumn).Font;

                    size = _sizeComboBox.GetPreferredSize(Size.Empty);
                    break;

                case FilterEditType.TextBox:
                case FilterEditType.DateTime:
                    if (_sizeTextBox == null)
                        _sizeTextBox = new TextBoxX();

                    _sizeTextBox.BorderStyle = BorderStyle.None;
                    _sizeTextBox.Font = gridFilter.GetEffectiveStyle(gridColumn).Font;

                    size = _sizeTextBox.GetPreferredSize(Size.Empty);
                    break;

                case FilterEditType.CheckBox:
                    if (_sizeCheckBox == null)
                        _sizeCheckBox = new MyCheckBoxX();

                    size = new Size(20, 20);
                    break;
            }

            return (size);
        }