Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (Items.Count == 0)
            {
                return;
            }
            if (Items.Count != boxes.Count)
            {
                ClearBoxes();

                for (int i = 0; i < Items.Count; i++)
                {
                    UICheckBox box = new UICheckBox
                    {
                        Font   = Font,
                        Parent = this,
                        Tag    = i,
                        Style  = Style
                    };

                    box.ValueChanged += Box_ValueChanged;
                    boxes.Add(box);
                }
            }

            int startX = StartPos.X;
            int startY = TitleTop + StartPos.Y;

            for (int i = 0; i < Items.Count; i++)
            {
                boxes[i].Text = Items[i].ToString();

                int rowIndex    = i / ColumnCount;
                int columnIndex = i % ColumnCount;

                boxes[i].Left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex;
                boxes[i].Top  = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex;
                boxes[i].Show();
            }
        }
Beispiel #2
0
        private void Box_ValueChanged(object sender, bool value)
        {
            UICheckBox checkBox = (UICheckBox)sender;

            ValueChanged?.Invoke(this, checkBox.Tag.ToString().ToInt(), checkBox.Text, checkBox.Checked);
        }