mirror of
https://gitee.com/AntdUI/AntdUI.git
synced 2026-03-19 12:10:44 +08:00
👾 Table 新增 SortColumns、修复 Table EnterEditMode 滚动条位置不正确、修复 Preview 不显示按钮
This commit is contained in:
@@ -33,7 +33,17 @@ namespace AntdUI
|
||||
if (inEditMode)
|
||||
{
|
||||
ScrollBar.OnInvalidate = null;
|
||||
Focus();
|
||||
if (!Focused)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
Focus();
|
||||
}));
|
||||
}
|
||||
else Focus();
|
||||
}
|
||||
inEditMode = false;
|
||||
}
|
||||
}
|
||||
@@ -63,11 +73,11 @@ namespace AntdUI
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
for (int i = 0; i < rows.Length; i++) rows[i].hover = i == i_row;
|
||||
int height = Helper.GDI(g =>
|
||||
int gap = (int)(Math.Max(_gap, 8) * Config.Dpi), height_real = Helper.GDI(g =>
|
||||
{
|
||||
if (multiline) return (int)Math.Ceiling(g.MeasureString(value?.ToString(), Font, cell.RECT_REAL.Width).Height * 1.4F);
|
||||
return (int)Math.Ceiling(g.MeasureString(Config.NullText, Font).Height * 1.66F);
|
||||
});
|
||||
return g.MeasureString(value?.ToString(), Font, cell.RECT_REAL.Width).Height + gap;
|
||||
}), height2 = cell.RECT_REAL.Height + gap;
|
||||
int height = multiline ? cell.RECT.Height : (height_real > height2 ? height_real : height2);
|
||||
var edit_input = ShowInput(cell, sx, sy, height, multiline, value, _value =>
|
||||
{
|
||||
bool isok_end = true;
|
||||
@@ -107,15 +117,13 @@ namespace AntdUI
|
||||
ScrollBar.OnInvalidate = () => EditModeClose();
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
for (int i = 0; i < rows.Length; i++) rows[i].hover = i == i_row;
|
||||
|
||||
int gap = (int)(Math.Max(_gap,8) * Config.Dpi), height_real = Helper.GDI(g =>
|
||||
{
|
||||
rows[i].hover = i == i_row;
|
||||
}
|
||||
int height = Helper.GDI(g =>
|
||||
{
|
||||
if (multiline) return (int)Math.Ceiling(g.MeasureString(value?.ToString(), Font, cell.RECT_REAL.Width).Height * 1.4F);
|
||||
return (int)Math.Ceiling(g.MeasureString(Config.NullText, Font).Height * 1.66F);
|
||||
});
|
||||
return g.MeasureString(value?.ToString(), Font, cell.RECT_REAL.Width).Height + gap;
|
||||
}), height2 = cell.RECT_REAL.Height + gap;
|
||||
int height = multiline ? cell.RECT.Height : (height_real > height2 ? height_real : height2);
|
||||
var edit_input = ShowInput(cell, sx, sy, height, multiline, value, _value =>
|
||||
{
|
||||
bool isok_end = true;
|
||||
|
||||
@@ -37,9 +37,7 @@ namespace AntdUI
|
||||
else if (selectedIndex < rows.Length - 1)
|
||||
{
|
||||
SelectedIndex++;
|
||||
var selectRow = rows[selectedIndex];
|
||||
int sy = ScrollBar.ValueY;
|
||||
if (selectRow.RECT.Y < sy || selectRow.RECT.Bottom > sy + rect_read.Height) ScrollLine(selectedIndex, rows);
|
||||
ScrollLine(selectedIndex, rows);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -50,9 +48,7 @@ namespace AntdUI
|
||||
else if (selectedIndex > 1)
|
||||
{
|
||||
SelectedIndex--;
|
||||
var selectRow = rows[selectedIndex];
|
||||
int sy = ScrollBar.ValueY;
|
||||
if (selectRow.RECT.Y < sy || selectRow.RECT.Bottom > sy + rect_read.Height) ScrollLine(selectedIndex, rows);
|
||||
ScrollLine(selectedIndex, rows);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -250,18 +250,15 @@ namespace AntdUI
|
||||
else if (radioCell.AutoCheck) isok = true;
|
||||
if (isok)
|
||||
{
|
||||
if (rows != null)
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
if (i != i_r)
|
||||
{
|
||||
if (i != i_r)
|
||||
var cell_selno = rows[i].cells[i_c];
|
||||
if (cell_selno is TCellRadio radioCell2 && radioCell2.Checked)
|
||||
{
|
||||
var cell_selno = rows[i].cells[i_c];
|
||||
if (cell_selno is TCellRadio radioCell2 && radioCell2.Checked)
|
||||
{
|
||||
radioCell2.Checked = false;
|
||||
SetValue(cell_selno, false);
|
||||
}
|
||||
radioCell2.Checked = false;
|
||||
SetValue(cell_selno, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,24 +353,21 @@ namespace AntdUI
|
||||
cell.MouseDown = 0;
|
||||
CellClick?.Invoke(this, new TableClickEventArgs(it.RECORD, i_row, i_cel, new Rectangle(cel_sel.RECT.X - offset_x, cel_sel.RECT.Y - offset_y, cel_sel.RECT.Width, cel_sel.RECT.Height), e));
|
||||
|
||||
bool enterEdit = false;
|
||||
if (doubleClick)
|
||||
{
|
||||
CellDoubleClick?.Invoke(this, new TableClickEventArgs(it.RECORD, i_row, i_cel, new Rectangle(cel_sel.RECT.X - offset_x, cel_sel.RECT.Y - offset_y, cel_sel.RECT.Width, cel_sel.RECT.Height), e));
|
||||
if (e.Button == MouseButtons.Left && editmode == TEditMode.DoubleClick)
|
||||
{
|
||||
//进入编辑模式
|
||||
EditModeClose();
|
||||
OnEditMode(it, cel_sel, i_row, i_cel, offset_xi, offset_y);
|
||||
}
|
||||
if (e.Button == MouseButtons.Left && editmode == TEditMode.DoubleClick) enterEdit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.Button == MouseButtons.Left && editmode == TEditMode.Click)
|
||||
{
|
||||
//进入编辑模式
|
||||
EditModeClose();
|
||||
OnEditMode(it, cell, i_r, i_c, offset_xi, offset_y);
|
||||
}
|
||||
if (e.Button == MouseButtons.Left && editmode == TEditMode.Click) enterEdit = true;
|
||||
}
|
||||
if (enterEdit)
|
||||
{
|
||||
EditModeClose();
|
||||
int val = ScrollLine(i_row, rows);
|
||||
OnEditMode(it, cel_sel, i_row, i_cel, offset_xi, offset_y - val);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -516,19 +516,45 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 滚动到指定行
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
public void ScrollLine(int i)
|
||||
/// <param name="i">行</param>
|
||||
/// <param name="force">是否强制滚动</param>
|
||||
/// <returns>返回滚动量</returns>
|
||||
public int ScrollLine(int i, bool force = false)
|
||||
{
|
||||
if (rows == null || !ScrollBar.ShowY) return;
|
||||
if (fixedHeader) ScrollBar.ValueY = rows[i].RECT.Y - rows[0].RECT.Height;
|
||||
else ScrollBar.ValueY = rows[i].RECT.Y;
|
||||
if (rows == null || !ScrollBar.ShowY) return 0;
|
||||
return ScrollLine(i, rows, force);
|
||||
}
|
||||
|
||||
void ScrollLine(int i, RowTemplate[] rows)
|
||||
int ScrollLine(int i, RowTemplate[] rows, bool force = false)
|
||||
{
|
||||
if (!ScrollBar.ShowY) return;
|
||||
if (fixedHeader) ScrollBar.ValueY = rows[i].RECT.Y - rows[0].RECT.Height;
|
||||
else ScrollBar.ValueY = rows[i].RECT.Y;
|
||||
if (!ScrollBar.ShowY) return 0;
|
||||
var selectRow = rows[i];
|
||||
int sy = ScrollBar.ValueY;
|
||||
if (force)
|
||||
{
|
||||
if (fixedHeader) ScrollBar.ValueY = rows[i].RECT.Y - rows[0].RECT.Height;
|
||||
else ScrollBar.ValueY = rows[i].RECT.Y;
|
||||
return sy - ScrollBar.ValueY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (visibleHeader && fixedHeader)
|
||||
{
|
||||
if (selectRow.RECT.Y - rows[0].RECT.Height < sy || selectRow.RECT.Bottom > sy + rect_read.Height)
|
||||
{
|
||||
if (fixedHeader) ScrollBar.ValueY = rows[i].RECT.Y - rows[0].RECT.Height;
|
||||
else ScrollBar.ValueY = rows[i].RECT.Y;
|
||||
return sy - ScrollBar.ValueY;
|
||||
}
|
||||
}
|
||||
else if (selectRow.RECT.Y < sy || selectRow.RECT.Bottom > sy + rect_read.Height)
|
||||
{
|
||||
if (fixedHeader) ScrollBar.ValueY = rows[i].RECT.Y - rows[0].RECT.Height;
|
||||
else ScrollBar.ValueY = rows[i].RECT.Y;
|
||||
return sy - ScrollBar.ValueY;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -588,6 +614,7 @@ namespace AntdUI
|
||||
var _row = rows[row];
|
||||
var item = _row.cells[column];
|
||||
EditModeClose();
|
||||
ScrollLine(row, rows);
|
||||
if (showFixedColumnL && fixedColumnL != null && fixedColumnL.Contains(column)) OnEditMode(_row, item, row, column, 0, ScrollBar.ValueY);
|
||||
else if (showFixedColumnR && fixedColumnR != null && fixedColumnR.Contains(column)) OnEditMode(_row, item, row, column, sFixedR, ScrollBar.ValueY);
|
||||
else OnEditMode(_row, item, row, column, ScrollBar.ValueX, ScrollBar.ValueY);
|
||||
@@ -633,6 +660,41 @@ namespace AntdUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表头排序序号
|
||||
/// </summary>
|
||||
public int[] SortColumnsIndex()
|
||||
{
|
||||
if (SortHeader == null)
|
||||
{
|
||||
if (columns == null || columns.Count == 0) return new int[0];
|
||||
var list = new int[columns.Count];
|
||||
for (int i = 0; i < columns.Count; i++) list[i] = i;
|
||||
return list;
|
||||
}
|
||||
else return SortHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表头排序数据
|
||||
/// </summary>
|
||||
public Column[] SortColumnsList()
|
||||
{
|
||||
if (columns == null || columns.Count == 0) return new Column[0];
|
||||
if (SortHeader == null)
|
||||
{
|
||||
var list = new Column[columns.Count];
|
||||
for (int i = 0; i < columns.Count; i++) list[i] = columns[i];
|
||||
return list;
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<Column>(columns.Count);
|
||||
foreach (var i in SortHeader) list.Add(columns[i]);
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace AntdUI
|
||||
{
|
||||
|
||||
@@ -363,28 +363,28 @@ namespace AntdUI
|
||||
rect_loading.Offset(0, loading_size);
|
||||
g.String(LoadingProgressStr, Font, Style.Db.ErrorColor, rect_loading, s_f);
|
||||
}
|
||||
using (var path = rect_panel.RoundPath(rect_panel.Height))
|
||||
}
|
||||
using (var path = rect_panel.RoundPath(rect_panel.Height))
|
||||
{
|
||||
using (var brush = new SolidBrush(Color.FromArgb(26, 0, 0, 0)))
|
||||
{
|
||||
using (var brush = new SolidBrush(Color.FromArgb(26, 0, 0, 0)))
|
||||
g.Fill(brush, path);
|
||||
PaintBtn(g, brush, rect_close, rect_close_icon, SvgDb.IcoClose, hoverClose, true);
|
||||
if (PageSize > 1)
|
||||
{
|
||||
g.Fill(brush, path);
|
||||
PaintBtn(g, brush, rect_close, rect_close_icon, SvgDb.IcoClose, hoverClose, true);
|
||||
if (PageSize > 1)
|
||||
{
|
||||
PaintBtn(g, brush, rect_left, rect_left_icon, SvgDb.IcoLeft, hoverLeft, enabledLeft);
|
||||
PaintBtn(g, brush, rect_right, rect_right_icon, SvgDb.IcoRight, hoverRight, enabledRight);
|
||||
}
|
||||
PaintBtn(g, brush, rect_left, rect_left_icon, SvgDb.IcoLeft, hoverLeft, enabledLeft);
|
||||
PaintBtn(g, brush, rect_right, rect_right_icon, SvgDb.IcoRight, hoverRight, enabledRight);
|
||||
}
|
||||
}
|
||||
foreach (var it in btns)
|
||||
}
|
||||
foreach (var it in btns)
|
||||
{
|
||||
using (var bmp = SvgExtend.GetImgExtend(it.svg, it.rect, it.hover ? colorHover : colorDefault))
|
||||
{
|
||||
using (var bmp = SvgExtend.GetImgExtend(it.svg, it.rect, it.hover ? colorHover : colorDefault))
|
||||
if (bmp != null)
|
||||
{
|
||||
if (bmp != null)
|
||||
{
|
||||
if (it.enabled) g.Image(bmp, it.rect);
|
||||
else g.Image(bmp, it.rect, 0.3F);
|
||||
}
|
||||
if (it.enabled) g.Image(bmp, it.rect);
|
||||
else g.Image(bmp, it.rect, 0.3F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user