fix: 收敛旧控件资源与后台线程生命周期
This commit is contained in:
@@ -111,15 +111,17 @@ namespace Lskj.Control.SiftColControl
|
||||
/// <returns></returns>
|
||||
static int CalcIndicatorBestWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
||||
{
|
||||
Graphics graphics = new System.Windows.Forms.Control().CreateGraphics();
|
||||
SizeF sizeF = new SizeF();
|
||||
int count = view.TopRowIndex + ((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo)view.GetViewInfo()).RowsInfo.Count;
|
||||
if (count == 0)
|
||||
{
|
||||
count = 30;
|
||||
}
|
||||
sizeF = graphics.MeasureString(count.ToString(), view.Appearance.Row.Font);
|
||||
return Convert.ToInt32(sizeF.Width) + 20;
|
||||
int textWidth = TextRenderer.MeasureText(
|
||||
count.ToString(),
|
||||
view.Appearance.Row.Font,
|
||||
Size.Empty,
|
||||
TextFormatFlags.NoPadding | TextFormatFlags.SingleLine).Width;
|
||||
return textWidth + 20;
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算默认的宽度
|
||||
@@ -129,16 +131,18 @@ namespace Lskj.Control.SiftColControl
|
||||
static int CalcIndicatorDefaultWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
||||
{
|
||||
var grid = view.GridControl;
|
||||
Graphics graphics = new System.Windows.Forms.Control().CreateGraphics();
|
||||
SizeF sizeF = new SizeF();
|
||||
int rowHeight = 22;//22是Row的估计高度
|
||||
if (view.RowHeight > 0)
|
||||
{
|
||||
rowHeight = view.RowHeight;
|
||||
}
|
||||
int count = grid != null ? grid.Height / rowHeight : 30;
|
||||
sizeF = graphics.MeasureString(count.ToString(), view.Appearance.Row.Font);
|
||||
return Convert.ToInt32(sizeF.Width) + 20;
|
||||
int textWidth = TextRenderer.MeasureText(
|
||||
count.ToString(),
|
||||
view.Appearance.Row.Font,
|
||||
Size.Empty,
|
||||
TextFormatFlags.NoPadding | TextFormatFlags.SingleLine).Width;
|
||||
return textWidth + 20;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user