TurtleZenTaoLib.IssuesForm.getCheckBoxImage C# (CSharp) Method

getCheckBoxImage() private method

获取复选框的图像
private getCheckBoxImage ( bool isChecked ) : Image
isChecked bool true为选中的样式,false为未选中的样式
return Image
        private Image getCheckBoxImage(bool isChecked)
        {
            if (isChecked && this.checkedCheckBoxImage != null)
            {
                return checkedCheckBoxImage;
            }
            else if (!isChecked && this.uncheckedCheckBoxImage != null)
            {
                return uncheckedCheckBoxImage;
            }

            CheckBox chk = new CheckBox();
            chk.Checked = isChecked;
            chk.Text = "";
            chk.Margin = new Padding(3, 3, 3, 3);
            chk.Width = 14;
            chk.Height = 14;
            chk.BackColor = Color.Transparent;

            Bitmap bitmap = new Bitmap(chk.Width, chk.Height);

            Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);

            chk.DrawToBitmap(bitmap, rect);

            if (isChecked)
            {
                checkedCheckBoxImage = bitmap;
            }
            else
            {
                uncheckedCheckBoxImage = bitmap;
            }

            return bitmap;
        }