部分样式调整 ai生图逻辑调整
This commit is contained in:
1 parent
f04c74fa32
commit
f9572ea046
11 files changed
+162
-75
No files matched your search
@@ -9,6 +9,9 @@ using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace TemuKJD.UserComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 带表头全选的选择框列
|
||||
/// </summary>
|
||||
public class DataGridViewCheckBoxColumnSelectAll : DataGridViewCheckBoxColumn
|
||||
{
|
||||
private DatagridViewCheckBoxHeaderCell headerCell;
|
||||
@@ -100,7 +103,6 @@ namespace TemuKJD.UserComponent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 头被选中时触发OnCheckBoxClicked事件.
|
||||
/// </summary>
|
||||
@@ -113,7 +115,6 @@ namespace TemuKJD.UserComponent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public delegate void CheckBoxClickedHandler(bool state);
|
||||
|
||||
internal class DatagridViewCheckBoxHeaderCell : DataGridViewColumnHeaderCell
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace TemuKJD.UserComponent
|
||||
ControlStyles.AllPaintingInWmPaint,
|
||||
true);
|
||||
|
||||
this.CellPainting += DataGridViewEx_CellPainting;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
for (int i = 0; i < 50; i++)
|
||||
@@ -190,6 +192,44 @@ namespace TemuKJD.UserComponent
|
||||
e.Graphics.DrawRectangle(new Pen(this.BorderColor), new Rectangle(0, 0, this.Width - 1, this.Height - 1));
|
||||
}
|
||||
|
||||
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
|
||||
{
|
||||
//if (e.ColumnIndex == yourCheckBoxColumnIndex && e.RowIndex >= 0)
|
||||
//{
|
||||
// bool isChecked = (bool)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
// Rectangle checkBoxBounds = new Rectangle(e.CellBounds.Location.X + 10, e.CellBounds.Location.Y + (e.CellBounds.Height - 20) / 2, 20, 20); // 自定义大小和位置
|
||||
// ControlPaint.DrawCheckBox(e.Graphics, checkBoxBounds, DataGridViewState.Default, isChecked); // 绘制复选框
|
||||
// e.Handled = true; // 阻止默认绘制
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
private int checkBoxSize = 12;
|
||||
public Color CheckBoxColor = Color.White;
|
||||
public Color CheckBoxRowBoxCheckColor = Color.Blue;
|
||||
public Color CheckBoxRowBoxBorderColor = Color.Blue;
|
||||
|
||||
private void DataGridViewEx_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
|
||||
{
|
||||
var cellTmp = this.Rows[e.RowIndex].Cells[e.ColumnIndex];
|
||||
if (cellTmp is DataGridViewCheckBoxCell)
|
||||
{
|
||||
e.PaintBackground(e.CellBounds, true);
|
||||
|
||||
bool isChecked = (bool)cellTmp.Value;
|
||||
var locationX = e.CellBounds.Location.X + e.CellBounds.Width / 2 - checkBoxSize / 2 - 1;
|
||||
var locationY = e.CellBounds.Location.Y + e.CellBounds.Height / 2 - checkBoxSize / 2;
|
||||
Rectangle checkBoxBounds = new Rectangle(locationX, locationY, checkBoxSize, checkBoxSize); // 自定义大小和位置
|
||||
//ControlPaint.DrawCheckBox(e.Graphics, checkBoxBounds, isChecked ? ButtonState.Checked : ButtonState.Normal); // 绘制复选框
|
||||
UcCheckBox.DrawCheckBoxIcon(e.Graphics, checkBoxBounds, isChecked, CheckBoxColor, CheckBoxRowBoxCheckColor, CheckBoxRowBoxBorderColor);
|
||||
|
||||
e.Handled = true; // 阻止默认绘制
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool multiSelectCheckBox = true;
|
||||
/// <summary>
|
||||
/// 选择框批量选中(使用Shift按键)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AllBase.Helper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
@@ -16,38 +17,45 @@ namespace TemuKJD.UserComponent
|
||||
public UcCheckBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.CheckBoxCheckColor = GlobalConfig.MainColor;
|
||||
this.CheckBoxBorderColor = GlobalConfig.BorderColor;
|
||||
}
|
||||
|
||||
public UcCheckBox(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
this.CheckBoxCheckColor = GlobalConfig.MainColor;
|
||||
this.CheckBoxBorderColor = GlobalConfig.BorderColor;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private int checkBoxSize = 12;
|
||||
public Color CheckBoxColor = Color.White;
|
||||
public Color CheckBoxCheckColor = Color.Blue;
|
||||
public Color CheckBoxBorderColor = Color.Blue;
|
||||
public Color CheckBoxCheckColor = GlobalConfig.DefaultMainColor;
|
||||
public Color CheckBoxBorderColor = GlobalConfig.DefaultBorderColor;
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
//base.OnPaint(e); // 禁用系统绘制
|
||||
//base.OnPaint(e); // 禁用系统绘制全部
|
||||
base.OnPaintBackground(e); // 使用系统绘制背景
|
||||
|
||||
//if (e.ClipRectangle.X != 0 || e.ClipRectangle.Y != 0)
|
||||
// return;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
g.Clear(this.BackColor);
|
||||
//g.Clear(this.CheckBoxColor);
|
||||
|
||||
//填充背景色
|
||||
//g.FillRectangle(new SolidBrush(this.BackColor), e.ClipRectangle);
|
||||
g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);
|
||||
|
||||
|
||||
//绘制圆形(注释此句,以备后用)
|
||||
//Brush brush = new SolidBrush(this.Checked ? checkBoxCheckColor : checkBoxColor);
|
||||
//g.FillEllipse(brush, 0, (Height - checkBoxSize) / 2, checkBoxSize, checkBoxSize); // 绘制圆形按钮
|
||||
Size size = TextRenderer.MeasureText(this.Text, Font);
|
||||
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; // 或者 AntiAliasGridFit // 平滑字体
|
||||
//e.Graphics.DrawString(this.Text, Font, new SolidBrush(this.ForeColor),
|
||||
// new PointF(e.ClipRectangle.X + checkBoxSize + 2 + Padding.Left, e.ClipRectangle.Y + (Height - size.Height) / 2));
|
||||
e.Graphics.DrawString(this.Text, Font, new SolidBrush(this.ForeColor),
|
||||
new PointF(this.ClientRectangle.X + checkBoxSize + 2 + Padding.Left, this.ClientRectangle.Y + (Height - size.Height) / 2));
|
||||
|
||||
Rectangle rt = new Rectangle();
|
||||
rt.X = 0;
|
||||
@@ -55,28 +63,41 @@ namespace TemuKJD.UserComponent
|
||||
rt.Width = checkBoxSize;
|
||||
rt.Height = checkBoxSize;
|
||||
|
||||
Color color = this.Checked ? CheckBoxCheckColor : CheckBoxColor;
|
||||
DrawRoundedRectangle(g, rt, 2, color, true);
|
||||
DrawRoundedRectangle(g, rt, 2, CheckBoxBorderColor);
|
||||
|
||||
if (this.Checked)
|
||||
{
|
||||
// 绘制勾号
|
||||
Pen p = new Pen(Color.FromArgb(180, 255, 255, 255));
|
||||
//g.DrawLine(Pens.SkyBlue, rt.X + 3, rt.Y + 6, rt.X + 5, rt.Y + 8);
|
||||
//g.DrawLine(Pens.SkyBlue, rt.X + 5, rt.Y + 8, rt.X + 9, rt.Y + 4);
|
||||
g.DrawLine(p, rt.X + 3, rt.Y + 6, rt.X + 5, rt.Y + 8);
|
||||
g.DrawLine(p, rt.X + 5, rt.Y + 8, rt.X + 9, rt.Y + 4);
|
||||
}
|
||||
Size size = TextRenderer.MeasureText(this.Text, Font);
|
||||
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; // 或者 AntiAliasGridFit // 平滑字体
|
||||
//e.Graphics.DrawString(this.Text, Font, new SolidBrush(this.ForeColor),
|
||||
// new PointF(e.ClipRectangle.X + checkBoxSize + 2 + Padding.Left, e.ClipRectangle.Y + (Height - size.Height) / 2));
|
||||
e.Graphics.DrawString(this.Text, Font, new SolidBrush(this.ForeColor),
|
||||
new PointF(this.ClientRectangle.X + checkBoxSize + 2 + Padding.Left, this.ClientRectangle.Y + (Height - size.Height) / 2));
|
||||
DrawCheckBoxIcon(g, rt, this.Checked, this.CheckBoxColor, this.CheckBoxCheckColor, this.CheckBoxBorderColor);
|
||||
}
|
||||
|
||||
private void DrawRoundedRectangle(Graphics g, Rectangle rect, int radius, Color color, bool isFill = false)
|
||||
public static void DrawCheckBoxIcon(Graphics g, Rectangle rt, bool isChecked, Color checkBoxColor, Color checkBoxCheckColor, Color checkBoxBorderColor)
|
||||
{
|
||||
//绘制圆形(注释此句,以备后用)
|
||||
//Brush brush = new SolidBrush(this.Checked ? checkBoxCheckColor : checkBoxColor);
|
||||
//g.FillEllipse(brush, 0, (Height - checkBoxSize) / 2, checkBoxSize, checkBoxSize); // 绘制圆形按钮
|
||||
|
||||
Color color = isChecked ? checkBoxCheckColor : checkBoxColor;
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
DrawRoundedRectangle(g, rt, 2, color, true);
|
||||
DrawRoundedRectangle(g, rt, 2, checkBoxBorderColor);
|
||||
|
||||
// 绘制勾号
|
||||
Pen p = new Pen(Color.FromArgb(220, 255, 255, 255), 1);
|
||||
//g.DrawLine(Pens.SkyBlue, rt.X + 3, rt.Y + 6, rt.X + 5, rt.Y + 8);
|
||||
//g.DrawLine(Pens.SkyBlue, rt.X + 5, rt.Y + 8, rt.X + 9, rt.Y + 4);
|
||||
g.DrawLine(p, rt.X + 3, rt.Y + 5, rt.X + 5, rt.Y + 7);
|
||||
g.DrawLine(p, rt.X + 5, rt.Y + 7, rt.X + 9, rt.Y + 3);
|
||||
g.DrawLine(p, rt.X + 3, rt.Y + 6, rt.X + 5, rt.Y + 8);
|
||||
g.DrawLine(p, rt.X + 5, rt.Y + 8, rt.X + 9, rt.Y + 4);
|
||||
g.DrawLine(p, rt.X + 3, rt.Y + 7, rt.X + 5, rt.Y + 9);
|
||||
g.DrawLine(p, rt.X + 5, rt.Y + 9, rt.X + 9, rt.Y + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawRoundedRectangle(g, rt, 3, color, true);
|
||||
DrawRoundedRectangle(g, rt, 3, checkBoxBorderColor);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawRoundedRectangle(Graphics g, Rectangle rect, int radius, Color color, bool isFill = false)
|
||||
{
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user