fix(control): 修复金额单元格关闭阶段异常

This commit is contained in:
2026-08-15 16:00:10 +08:00
parent 7d8ad77f5c
commit fc5faab65d
4 changed files with 125 additions and 20 deletions
+5
View File
@@ -637,6 +637,11 @@ namespace Lskj.Control
}
_gridResourcesDisposed = true;
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
StopColumnSourceTimer();
if (mTimer != null)
{
@@ -12,10 +12,15 @@ using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
// Token: 0x02000003 RID: 3
public class AmountCellRender
public class AmountCellRender : IDisposable
{
public AmountCellRender(GridView gridView_0)
{
if (gridView_0 == null)
{
throw new ArgumentNullException("gridView_0");
}
Class5.gBkiB4AzUqwkh();
this.colorGray = Color.FromArgb(189, 185, 185);
this.colorGreen = Color.Green;
@@ -25,23 +30,58 @@ public class AmountCellRender
this.dictionary_0 = new Dictionary<string, Class2>();
this.list_0 = new List<GridColumn>();
this.object_0 = gridView_0;
this.gridControl_0 = this.object_0.GridControl;
this.object_0.CustomDrawCell += this.object_0_CustomDrawCell;
this.object_0.CustomDrawColumnHeader += this.object_0_CustomDrawColumnHeader;
this.object_0.CustomDrawFooterCell += this.object_0_CustomDrawFooterCell;
this.object_0.GridControl.Paint += this.method_0;
if (this.gridControl_0 != null)
{
this.gridControl_0.Paint += this.method_0;
}
}
private void method_0(object sender, PaintEventArgs e)
{
BaseViewInfo viewInfo = ((sender as GridControl).FocusedView as GridView).GetViewInfo();
if (this.disposed || this.list_0.Count == 0)
{
return;
}
GridControl gridControl = sender as GridControl;
if (gridControl == null || gridControl.IsDisposed || gridControl.Disposing)
{
return;
}
GridView gridView = gridControl.FocusedView as GridView;
if (gridView == null)
{
return;
}
GridViewInfo gridViewInfo = gridView.GetViewInfo() as GridViewInfo;
if (gridViewInfo == null || gridViewInfo.ColumnsInfo == null)
{
return;
}
foreach (GridColumn gridColumn in this.list_0)
{
Class2 @class = this.dictionary_0[gridColumn.Name];
Class2 @class;
if (gridColumn == null ||
!this.dictionary_0.TryGetValue(gridColumn.Name, out @class) ||
@class == null)
{
continue;
}
if (@class.IsCountinuousCell())
{
GridViewInfo gridViewInfo = viewInfo as GridViewInfo;
GridColumnInfoArgs gridColumnInfoArgs = gridViewInfo.ColumnsInfo[gridColumn];
if (gridColumnInfoArgs == null) return;
if (gridColumnInfoArgs == null)
{
continue;
}
int num = 0;
int int_;
if (@class.method_4())
@@ -82,10 +122,16 @@ public class AmountCellRender
private void object_0_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
e.DisplayText = "";
Class2 @class = this.dictionary_0[e.Column.Name];
Rectangle bounds = e.Bounds;
Rectangle rectangle_ = bounds;
Graphics graphics = e.Graphics;
@@ -98,14 +144,20 @@ public class AmountCellRender
private void object_0_CustomDrawFooterCell(object sender, FooterCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_8())
{
e.Info.DisplayText = "";
Rectangle bounds = e.Bounds;
@class.method_17(bounds, e.Graphics, e.Appearance.Font, e.Info.Value.ToString());
@class.method_17(bounds, e.Graphics, e.Appearance.Font, Convert.ToString(e.Info.Value));
e.Handled = true;
}
}
@@ -113,13 +165,15 @@ public class AmountCellRender
private void object_0_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
{
if (e.Column == null)
if (this.disposed || e.Column == null)
{
return;
}
if (this.dictionary_0.ContainsKey(e.Column.Name))
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_6())
{
e.Column.Caption = "";
@@ -204,14 +258,44 @@ public class AmountCellRender
public void RemoveAmountColumn(GridColumn gridColumn_0)
{
if (this.dictionary_0.ContainsKey(gridColumn_0.Name))
if (gridColumn_0 != null && this.dictionary_0.ContainsKey(gridColumn_0.Name))
{
this.dictionary_0.Remove(gridColumn_0.Name);
this.list_0.Remove(gridColumn_0);
}
}
public void Dispose()
{
if (this.disposed)
{
return;
}
this.disposed = true;
GridView gridView = this.object_0;
GridControl gridControl = this.gridControl_0;
this.object_0 = null;
this.gridControl_0 = null;
if (gridView != null)
{
gridView.CustomDrawCell -= this.object_0_CustomDrawCell;
gridView.CustomDrawColumnHeader -= this.object_0_CustomDrawColumnHeader;
gridView.CustomDrawFooterCell -= this.object_0_CustomDrawFooterCell;
}
if (gridControl != null)
{
gridControl.Paint -= this.method_0;
}
this.dictionary_0.Clear();
this.list_0.Clear();
}
private GridView object_0;
private GridControl gridControl_0;
private bool disposed;
private Color colorGray;
private Color colorGreen;
+9 -3
View File
@@ -255,7 +255,10 @@ public class Class2
if (color != Color.Empty)
{
Rectangle rect = new Rectangle(rectangle_0.Left + i - 2, int_2, int_1, int_3);
graphics_0.FillRectangle(new SolidBrush(color), rect);
using (SolidBrush solidBrush = new SolidBrush(color))
{
graphics_0.FillRectangle(solidBrush, rect);
}
}
}
else
@@ -265,9 +268,12 @@ public class Class2
num++;
}
Rectangle rect2 = new Rectangle(rectangle_0.Left - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect2);
Rectangle rect3 = new Rectangle(rectangle_0.Left + rectangle_0.Width - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect3);
using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(161, 157, 157)))
{
graphics_0.FillRectangle(solidBrush, rect2);
graphics_0.FillRectangle(solidBrush, rect3);
}
}
// Token: 0x06000028 RID: 40 RVA: 0x00002CC8 File Offset: 0x00000EC8
+12 -2
View File
@@ -13,9 +13,19 @@
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
components.Dispose();
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
class2_0 = null;
class2_1 = null;
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}