fix(legacy): remove WPF splitter width workaround

This commit is contained in:
SugarChes
2026-09-01 16:06:03 +08:00
parent efc281c188
commit 4bb5434385
+11 -105
View File
@@ -91,9 +91,6 @@ namespace Lskj.PubBill
private DataTable _detailColumns;
private bool IsCopying = false;
private bool _moduleResourcesReleased;
private int _preferredSourcePanelWidth;
private bool _sourcePanelWidthRestorePending;
private bool _restoringSourcePanelWidth;
protected DataRow BillRowItem;
@@ -269,7 +266,6 @@ namespace Lskj.PubBill
public BillModule()
{
InitializeComponent();
this.ssc_main_top.SizeChanged += OnTopSplitterSizeChanged;
}
/// <summary>
@@ -354,7 +350,6 @@ namespace Lskj.PubBill
splitContainer.SplitterMoved -= OnDetailsSplitterMoved;
splitContainer.SplitterMoved -= OnSpecialMainSplitterMoved;
splitContainer.SplitterMoved -= OnSpecialLeftSplitterMoved;
splitContainer.SizeChanged -= OnTopSplitterSizeChanged;
}
SimpleButton commonButton = control as SimpleButton;
@@ -1197,24 +1192,14 @@ namespace Lskj.PubBill
// 设置单据来源左侧宽度
if (this.BillModel.PanelWidth == 0)
{
this._preferredSourcePanelWidth = 0;
this._sourcePanelWidthRestorePending = false;
// 隐藏来源
this.ssc_main_top.PanelVisibility = SplitPanelVisibility.Panel2;
}
else
{
string width = IniHelper.Read(string.Format("bill_width_{0}", this.SysModel.ModuleCode));
int savedWidth;
this._preferredSourcePanelWidth =
!string.IsNullOrEmpty(width) &&
int.TryParse(width, out savedWidth) &&
savedWidth > 0
? savedWidth
: this.BillModel.PanelWidth;
this._sourcePanelWidthRestorePending =
this._preferredSourcePanelWidth > 0;
TryRestoreSourcePanelWidth();
if (!string.IsNullOrEmpty(width))
this.ssc_main_top.SplitterPosition = Convert.ToInt32(width);
}
// 设置单据来源底部高度
@@ -1236,82 +1221,6 @@ namespace Lskj.PubBill
}
}
private void OnTopSplitterSizeChanged(object sender, EventArgs e)
{
if (!ReferenceEquals(sender, this.ssc_main_top) ||
this._moduleResourcesReleased ||
this.BillModel == null ||
this.BillModel.PanelWidth <= 0)
{
return;
}
if (this.ssc_main_top.ClientSize.Width <= 1)
{
if (this._preferredSourcePanelWidth > 0)
{
// WindowsFormsHost temporarily measures a projected page at
// zero while moving it between WPF content presenters. Keep
// the last valid position and restore it after reattachment.
this._sourcePanelWidthRestorePending = true;
}
return;
}
if (this._isInitFinish &&
this._sourcePanelWidthRestorePending &&
!this.ssc_main_top.Collapsed)
{
TryRestoreSourcePanelWidth();
}
}
private void TryRestoreSourcePanelWidth()
{
if (this._restoringSourcePanelWidth ||
this._preferredSourcePanelWidth <= 0 ||
this.ssc_main_top == null ||
this.ssc_main_top.IsDisposed ||
this.ssc_main_top.Collapsed)
{
return;
}
int availableWidth = this.ssc_main_top.ClientSize.Width;
if (availableWidth <= 1)
{
this._sourcePanelWidthRestorePending = true;
return;
}
int targetWidth = Math.Min(
this._preferredSourcePanelWidth,
availableWidth - 1);
if (targetWidth <= 0)
{
this._sourcePanelWidthRestorePending = true;
return;
}
this._restoringSourcePanelWidth = true;
try
{
this.ssc_main_top.SplitterPosition = targetWidth;
this._sourcePanelWidthRestorePending =
targetWidth < this._preferredSourcePanelWidth;
}
catch (ArgumentOutOfRangeException)
{
// The DevExpress panels may not have completed their minimum-size
// layout yet. The next SizeChanged event retries this instance.
this._sourcePanelWidthRestorePending = true;
}
finally
{
this._restoringSourcePanelWidth = false;
}
}
/// <summary>
/// <para>说明:初始化系统配置</para>
/// <para>创建人:龚宇超</para>
@@ -4613,6 +4522,14 @@ namespace Lskj.PubBill
UpdateDynamicColumns();
UpdateSummaryData();
// ✅ 新增:开启横向滚动(避免列宽自适应吃掉滚动条)
var gv = gcMain.GridView as DevExpress.XtraGrid.Views.Grid.GridView;
if (gv != null)
{
gv.OptionsView.ColumnAutoWidth = false;
gv.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always;
}
// 你原来的手动刷新——保持
OnGcMainDataSourceChanged(gcMain.GridView, null);
}
@@ -8463,19 +8380,8 @@ namespace Lskj.PubBill
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnTopSplitterMoved(object sender, EventArgs e)
{
if (this._restoringSourcePanelWidth)
if (this._isInitFinish)// 是否为初始化创建
{
return;
}
if (this._isInitFinish &&
this.SysModel != null &&
this.ssc_main_top.ClientSize.Width > 1 &&
this.ssc_main_top.SplitterPosition > 0)// 是否为初始化创建
{
this._preferredSourcePanelWidth =
this.ssc_main_top.SplitterPosition;
this._sourcePanelWidthRestorePending = false;
IniHelper.Write(string.Format("bill_width_{0}", this.SysModel.ModuleCode), this.ssc_main_top.SplitterPosition + "");
}
if (this.gcMain != null && this.gcMain.gridControl != null)