优化模块资源释放与异步预加载

This commit is contained in:
2026-09-03 14:16:48 +08:00
parent a263522b47
commit fddab16bd2
35 changed files with 1553 additions and 977 deletions
+3 -2
View File
@@ -32,14 +32,15 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label_tips = new DevExpress.XtraEditors.LabelControl();
this.label_date = new DevExpress.XtraEditors.LabelControl();
this.pl_bottom = new DevExpress.XtraEditors.PanelControl();
this.btnReverseSelection = new DevExpress.XtraEditors.SimpleButton();
this.btnSelectAll = new DevExpress.XtraEditors.SimpleButton();
this.dpb_Tools = new DevExpress.XtraEditors.DropDownButton();
this.p_menu = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.p_menu = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
+15 -3
View File
@@ -2747,10 +2747,17 @@ namespace Lskj.Control
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected virtual void Multifunction(object sender, EventArgs e)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
//DataTable newDt = this.SetDealWithValueTab();
FrmGridSift frmGridSift = new FrmGridSift();
string guid = Guid.NewGuid().ToString();
moduleScope = new StaticControl.ModuleResourceScope(guid);
FrmGridSift frmGridSift;
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift = new FrmGridSift();
}
frmGridSift.CustomColumKey = this.CustomColumKey;
//frmGridSift.source = newDt;
frmGridSift.ParentGridEx = this;
@@ -2762,7 +2769,6 @@ namespace Lskj.Control
BeforePage = ERPInfo.Instance.CurrentModulePage
};
module.ModuleForm = frmGridSift;
string guid = Guid.NewGuid().ToString();
DevExpress.XtraTab.XtraTabPage tp = new DevExpress.XtraTab.XtraTabPage();
tp.Tag = guid;
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
@@ -2776,13 +2782,19 @@ namespace Lskj.Control
tp.Controls.Add(frmGridSift);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
StaticControl.RegisterModulePage(module, tp, frmGridSift);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
ERPInfo.Instance.ModuleForms.Add(guid, module);
frmGridSift.Show();
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift.Show();
}
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
MessageUtil.Show(Message, ex.Message);
}
@@ -247,13 +247,25 @@ namespace Lskj.Control.BrowserSetting
/// <param name="args">The arguments.</param>
public static void AddModuleToTab(DllModule module, string[] args)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
string guid = Guid.NewGuid().ToString();
XtraTabPage tp = new XtraTabPage();
moduleScope = new StaticControl.ModuleResourceScope(guid);
StaticControl.AttachModuleScope(tp, moduleScope);
moduleScope.Register(tp, () =>
{
if (!tp.IsDisposed)
tp.Dispose();
});
ERPInfo.Instance.selectFormModleId = module.Id;
IForm iform = FormHelper.LoadDllForm(module.DllName, args);
IForm iform;
using (StaticControl.PushModuleScope(moduleScope))
{
iform = FormHelper.LoadDllForm(module.DllName, args);
}
// 菜单打开的模块默认最大化,界面FormState设置为Normal模式,否则会出现界面不是全屏,会显示默认阴影界面
//iform.SubForm.WindowState = _frmMain.WindowState;
iform.SubForm.WindowState = FormWindowState.Normal; ;
@@ -278,28 +290,26 @@ namespace Lskj.Control.BrowserSetting
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
//module.Tag = "1";
module.Tag = guid;
module.ModuleForm = form;
form.Show();
StaticControl.RegisterModulePage(module, tp, form);
// OnLoad may create additional non-visual helpers. Keep the
// module scope active until the form has finished loading so
// those helpers are registered with the same page lifetime.
using (StaticControl.PushModuleScope(moduleScope))
{
form.Show();
}
if (args != null && !string.IsNullOrEmpty(args[4] + ""))
{
ModuleModel moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(args[4] + ""));
if (!string.IsNullOrEmpty(moduleModel.SearchCondFormModuleCode))
{
ModuleConditionsPanelEx mcpex = new ModuleConditionsPanelEx();
mcpex.InitializeControl(new ModuleModel(MainImpl.GetSystemdllTab(moduleModel.SearchCondFormModuleCode)), null, null, true);
if (StaticControl.ConditionsPanelDic.ContainsKey(args[4] + ""))
using (ModuleConditionsPanelEx mcpex = new ModuleConditionsPanelEx())
{
StaticControl.ConditionsPanelDic[args[4] + ""].Dispose();
StaticControl.ConditionsPanelDic[args[4] + ""] = mcpex;
mcpex.InitializeControl(new ModuleModel(MainImpl.GetSystemdllTab(moduleModel.SearchCondFormModuleCode)), null, null, true);
StaticControl.RegisterConditionPanel(args[4] + "", mcpex);
DialogResult dialogResult = mcpex.ShowDialog();
}
else
{
StaticControl.ConditionsPanelDic.Add(args[4] + "", mcpex);
}
DialogResult dialogResult = mcpex.ShowDialog();
}
}
ERPInfo.Instance.AddModulePage(tp);
@@ -309,6 +319,8 @@ namespace Lskj.Control.BrowserSetting
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
LogHelper.Instance.WriteError(ex);
+2 -1
View File
@@ -102,7 +102,8 @@ namespace Lskj.Control
this.SizeChanged += OnFrmAutoSqlLoad_SizeChanged;
this.topSplitContainerControl.SplitterPositionChanged += OnTopSplitContainerControl_SplitterPositionChanged;
this.clearBtn.Click += OnClearBtn_Click;//清除按钮点击
popupMenu = new DevExpress.XtraBars.PopupMenu(barManager);//右键菜单
popupMenu = new DevExpress.XtraBars.PopupMenu(this.components);//右键菜单
popupMenu.Manager = barManager;
BarButtonItem barButtonItemFull = new DevExpress.XtraBars.BarButtonItem();
barButtonItemFull.Caption = "全连接";
barButtonItemFull.Name = "join";
+2 -1
View File
@@ -28,7 +28,8 @@
/// </summary>
private void InitializeComponent()
{
this.barManager = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.barManager = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
+5 -3
View File
@@ -1660,7 +1660,7 @@ namespace Lskj.Control
BarButtonItem itemExportDetail = new BarButtonItem();
itemExportDetail.Caption = "导出明细Excel";
itemExportDetail.ItemClick += new ItemClickEventHandler(OnItemExportDetail_ItemClick);
PopupMenu exportPopupMenu = new PopupMenu();
PopupMenu exportPopupMenu = new PopupMenu(this.components);
exportPopupMenu.Manager = this.barManager;
exportPopupMenu.AddItems(new BarItem[] { itemExportExcel, itemExportDetail });
this.exportDropBtn.DropDownControl = exportPopupMenu;
@@ -1682,7 +1682,8 @@ namespace Lskj.Control
#region
private void InitResultRightMenu()
{
popupMenu = new DevExpress.XtraBars.PopupMenu(barManager);
popupMenu = new DevExpress.XtraBars.PopupMenu(this.components);
popupMenu.Manager = barManager;
BarButtonItem barButtonItemSum = new DevExpress.XtraBars.BarButtonItem();
barButtonItemSum.Caption = "求和";
barButtonItemSum.Name = "Sum";
@@ -1704,7 +1705,8 @@ namespace Lskj.Control
popupMenu.ItemLinks[i].BeginGroup = true;//设置分割条
popupMenu.ItemLinks[i].Item.ItemClick += OnItem_ItemClick;
}
allpopupMenu = new DevExpress.XtraBars.PopupMenu(barManager);
allpopupMenu = new DevExpress.XtraBars.PopupMenu(this.components);
allpopupMenu.Manager = barManager;
BarButtonItem barButtonItemAllSum = new DevExpress.XtraBars.BarButtonItem();
barButtonItemAllSum.Caption = "一键求和";
barButtonItemAllSum.Name = "Sum";
+16 -3
View File
@@ -508,6 +508,7 @@ namespace Lskj.Control
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
this.Disposed += OnGridControlExDisposed;
// 自定义选中区域方式
@@ -3940,10 +3941,17 @@ namespace Lskj.Control
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected virtual void Multifunction(object sender, EventArgs e)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
//DataTable newDt = this.SetDealWithValueTab();
FrmGridSift frmGridSift = new FrmGridSift();
string guid = Guid.NewGuid().ToString();
moduleScope = new StaticControl.ModuleResourceScope(guid);
FrmGridSift frmGridSift;
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift = new FrmGridSift();
}
frmGridSift.CustomColumKey = this.CustomColumKey;
//frmGridSift.source = newDt;
frmGridSift.ParentGridEx = this;
@@ -3955,7 +3963,6 @@ namespace Lskj.Control
BeforePage = ERPInfo.Instance.CurrentModulePage
};
module.ModuleForm = frmGridSift;
string guid = Guid.NewGuid().ToString();
DevExpress.XtraTab.XtraTabPage tp = new DevExpress.XtraTab.XtraTabPage();
tp.Tag = guid;
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
@@ -3969,13 +3976,19 @@ namespace Lskj.Control
tp.Controls.Add(frmGridSift);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
StaticControl.RegisterModulePage(module, tp, frmGridSift);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
ERPInfo.Instance.ModuleForms.Add(guid, module);
frmGridSift.Show();
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift.Show();
}
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
MessageUtil.Show(Message, ex.Message);
}
@@ -1330,14 +1330,45 @@ namespace Lskj.Control.Model
SmartX1Api.SmartX1Close(keyHandle);
}
}
IForm form = FormHelper.LoadDllForm(dllName, str);
string guid = isAddPage ? Guid.NewGuid().ToString() : null;
StaticControl.ModuleResourceScope moduleScope = null;
XtraTabPage modulePage = null;
if (isAddPage)
{
modulePage = new XtraTabPage();
modulePage.Tag = guid;
moduleScope = new StaticControl.ModuleResourceScope(guid);
StaticControl.AttachModuleScope(modulePage, moduleScope);
moduleScope.Register(modulePage, () =>
{
if (!modulePage.IsDisposed)
modulePage.Dispose();
});
}
IForm form;
if (moduleScope == null)
{
form = FormHelper.LoadDllForm(dllName, str);
}
else
{
using (StaticControl.PushModuleScope(moduleScope))
{
form = FormHelper.LoadDllForm(dllName, str);
}
}
if (form == null)
{
if (moduleScope != null)
moduleScope.Dispose();
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
return false;
}
if (form.SubForm == null)
{
if (moduleScope != null)
moduleScope.Dispose();
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
return false;
}
@@ -1356,7 +1387,7 @@ namespace Lskj.Control.Model
form.SubForm.Text = model.MenuName;
if (isPrivateDll)
{
StaticControl.DogVerifyNoPageForms.Add(form);
StaticControl.RegisterProtectedForm(form);
}
if (form.SubForm is BaseForm)//dllName.Equals("Lskj.BaseAccraditation.dll", StringComparison.OrdinalIgnoreCase)
{
@@ -1384,8 +1415,7 @@ namespace Lskj.Control.Model
}
else
{
string guid = Guid.NewGuid().ToString();
XtraTabPage tp = new XtraTabPage();
XtraTabPage tp = modulePage;
tp.Text = model.MenuName;
if (!string.IsNullOrWhiteSpace(model.PageName))
@@ -1403,6 +1433,7 @@ namespace Lskj.Control.Model
tp.Controls.Add(form.SubForm);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
StaticControl.RegisterModulePage(module, tp, form.SubForm);
//配置了右键刷新的情况下,在当前页签关闭时触发刷新
if (model.Refresh && this.OnRightCallback != null)
{
@@ -1412,13 +1443,16 @@ namespace Lskj.Control.Model
ERPInfo.Instance.CurrentModulePage = tp;
if (isPrivateDll)
{
StaticControl.DogVerifyModuleForms.Add(tp);
StaticControl.RegisterProtectedPage(tp);
}
if (form.SubForm is BaseForm)
{
(form.SubForm as BaseForm).ParentView = this.BaseGridView;
}
form.SubForm.Show();
using (StaticControl.PushModuleScope(moduleScope))
{
form.SubForm.Show();
}
ERPInfo.Instance.ModuleForms.Add(guid, module);
//直接页签打开模块会直接向后面运行,默认返回false避免外面执行右键刷新
return false;
+43 -14
View File
@@ -15,6 +15,7 @@ using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
@@ -34,6 +35,13 @@ namespace Lskj.Control.Model
/// </summary>
public class MyControl : IDisposable
{
// Runtime menus and managers are owned by this model instance.
private readonly IContainer _components = new Container();
/// <summary>
/// Raised once when this non-visual control model releases its owned
/// resources. Static runtime references use it to clear exact owners.
/// </summary>
public event EventHandler Disposed;
private const long UserSearchCooldownTicks =
TimeSpan.TicksPerMillisecond * 350;
private string _searchSql;
@@ -54,6 +62,10 @@ namespace Lskj.Control.Model
private bool mUserSearchInProgress;
private long mLastUserSearchCompletedTicks;
private int mAcceptedUserSearchCount;
public bool IsDisposed
{
get { return mDisposed; }
}
/// <summary>
/// 计算字段
/// </summary>
@@ -112,7 +124,7 @@ namespace Lskj.Control.Model
/// </summary>
public string RefreshControl;
protected bool mLoading = false;
protected Timer mTimer = new Timer();
protected Timer mTimer;
/// <summary>
/// 查询按钮
/// </summary>
@@ -304,7 +316,8 @@ namespace Lskj.Control.Model
/// </summary>
public MyControl()
{
mTimer = new Timer(_components);
StaticControl.RegisterModuleResource(this, Dispose);
}
/// <summary>
/// Initializes a new instance of the <see cref="MyControl"/> class.
@@ -315,12 +328,14 @@ namespace Lskj.Control.Model
/// <param name="treeView">The tree view.</param>
public MyControl(string searchSql, GridControlEx mainGridEx, TreeViewEx treeView = null, GridControlEx gridLeft = null, MyControl leftSearch = null)
{
mTimer = new Timer(_components);
this._searchSql = searchSql;
this._mainGridEx = mainGridEx;
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
this._tvLeft = treeView;
this._gridLeft = gridLeft;
this._leftSearch = leftSearch;
StaticControl.RegisterModuleResource(this, mainGridEx, Dispose);
}
/// <summary>
/// <para>说明:设置GridControlEx</para>
@@ -336,6 +351,7 @@ namespace Lskj.Control.Model
{
this._mainGridEx = mainGridEx;
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
StaticControl.RegisterModuleResource(this, mainGridEx, Dispose);
}
/// <summary>
/// <para>说明:设置GridLeft</para>
@@ -1039,7 +1055,7 @@ namespace Lskj.Control.Model
{
if (_popupMenu == null)
{
_popupMenu = new PopupMenu();
_popupMenu = new PopupMenu(_components);
}
_dropDown = new DropDownButton();
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
@@ -1052,7 +1068,7 @@ namespace Lskj.Control.Model
_dropDown.Leave += new EventHandler(OnDropDownLeave);
width = _dropDown.Location.X + _dropDown.Width;
BarManager barManager1 = new BarManager();
BarManager barManager1 = new BarManager(_components);
_popupMenu.Manager = barManager1;
_popupMenu.Name = "pm_search";
CreateSearchScheme();
@@ -1234,7 +1250,7 @@ namespace Lskj.Control.Model
{
if (_popupMenu == null)
{
_popupMenu = new PopupMenu();
_popupMenu = new PopupMenu(_components);
}
_dropDown = new DropDownButton();
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
@@ -1247,7 +1263,7 @@ namespace Lskj.Control.Model
_dropDown.Leave += new EventHandler(OnDropDownLeave);
width = _dropDown.Location.X + _dropDown.Width;
BarManager barManager1 = new BarManager();
BarManager barManager1 = new BarManager(_components);
_popupMenu.Manager = barManager1;
_popupMenu.Name = "pm_search";
CreateSearchScheme();
@@ -1778,6 +1794,7 @@ namespace Lskj.Control.Model
{
timer.Tick -= mTimerTick;
timer.Stop();
_components.Remove(timer);
timer.Dispose();
}
}
@@ -3294,7 +3311,7 @@ namespace Lskj.Control.Model
//menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
//menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
//StaticControl.RightMenuGridView = MainGridEx.GridView;
StaticControl.RightMenuMyControl = this;
StaticControl.SetRightMenuMyControl(this);
menu.Apply(menuRow);
if (!menu.issuccess)
{
@@ -6833,6 +6850,20 @@ namespace Lskj.Control.Model
mDisposed = true;
mUserSearchInProgress = false;
EventHandler disposed = Disposed;
Disposed = null;
if (disposed != null)
{
try
{
disposed(this, EventArgs.Empty);
}
catch
{
// Reference cleanup must not interrupt disposal.
}
}
Timer timer = mTimer;
mTimer = null;
if (timer != null)
@@ -6841,6 +6872,7 @@ namespace Lskj.Control.Model
{
timer.Tick -= mTimerTick;
timer.Stop();
_components.Remove(timer);
timer.Dispose();
}
catch
@@ -6882,17 +6914,10 @@ namespace Lskj.Control.Model
}
}
BarManager searchSchemeManager =
_popupMenu == null ? null : _popupMenu.Manager;
if (_popupMenu != null)
{
_popupMenu.Manager = null;
_popupMenu.ItemLinks.Clear();
_popupMenu.Dispose();
}
if (searchSchemeManager != null)
{
searchSchemeManager.Dispose();
}
if (_mainGridEx != null &&
@@ -6937,6 +6962,10 @@ namespace Lskj.Control.Model
ModuleResultDic.Clear();
ParaContrlsDic.Clear();
// PopupMenu, BarManager and any future non-visual components are
// disposed together with this MyControl instance.
_components.Dispose();
_controls = null;
_schemes = null;
_fixField = null;
@@ -1,268 +1,55 @@
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraTab;
using Lskj.Control.ZKFinger;
using Lskj.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinFormsControl = System.Windows.Forms.Control;
using Lskj.Util;
using DevExpress.XtraTab;
namespace Lskj.Control.Model
{
/// <summary>
/// Static registries for banded-grid drag helpers. The helpers unregister
/// themselves from these dictionaries when their GridView is disposed;
/// module closing therefore does not need to scan a control tree.
/// </summary>
public static class StaticBandedControl
{
public static void ReleaseModuleReferences(WinFormsControl moduleRoot, XtraTabPage modulePage, string moduleCode)
{
List<WinFormsControl> moduleControls = CollectModuleControls(moduleRoot, modulePage);
ReleaseModuleReferences(moduleControls, modulePage, moduleCode);
}
internal static void ReleaseModuleReferences(
IEnumerable<WinFormsControl> moduleControls,
XtraTabPage modulePage,
string moduleCode)
{
try
{
List<WinFormsControl> controls = new List<WinFormsControl>();
if (moduleControls != null)
foreach (WinFormsControl control in moduleControls)
if (control != null && !ContainsControl(controls, control))
controls.Add(control);
List<BandedGridView> bandedViews = CollectBandedGridViews(controls);
List<GridView> targetViews = CollectTargetGridViews(controls);
foreach (BandedGridView view in bandedViews)
BandedGridDragGrid.DisposeRegistrations(
BandedGridViewDragGridDic,
BandedTargetViewDragGridDic,
view,
null);
foreach (GridView view in targetViews)
BandedGridDragGrid.DisposeRegistrations(
BandedGridViewDragGridDic,
BandedTargetViewDragGridDic,
null,
view);
if (ContainsBandedGridView(bandedViews, SourceDragBandedGridView))
SourceDragBandedGridView = null;
RemoveConditionPanels(moduleCode, controls);
RemoveProtectedReferences(controls, modulePage);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("释放旧 Banded 模块引用失败:" + exception);
}
}
private static List<WinFormsControl> CollectModuleControls(
WinFormsControl moduleRoot,
XtraTabPage modulePage)
{
List<WinFormsControl> result = new List<WinFormsControl>();
AddModuleControls(result, moduleRoot);
if (!ReferenceEquals(moduleRoot, modulePage))
AddModuleControls(result, modulePage);
return result;
}
private static void AddModuleControls(
List<WinFormsControl> target,
WinFormsControl root)
{
if (root == null)
return;
foreach (WinFormsControl control in EnumerateControls(root))
if (!ContainsControl(target, control))
target.Add(control);
}
private static List<BandedGridView> CollectBandedGridViews(
IEnumerable<WinFormsControl> controls)
{
List<BandedGridView> result = new List<BandedGridView>();
if (controls == null)
return result;
foreach (WinFormsControl control in controls)
{
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
if (grid == null)
continue;
try
{
AddBandedGridView(result, grid.MainView as BandedGridView);
foreach (DevExpress.XtraGrid.Views.Base.BaseView baseView in grid.ViewCollection)
AddBandedGridView(result, baseView as BandedGridView);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("读取旧 Banded 表格视图失败:" + exception);
}
}
return result;
}
private static void AddBandedGridView(
List<BandedGridView> target,
BandedGridView view)
{
if (view != null && !ContainsBandedGridView(target, view))
target.Add(view);
}
private static bool ContainsBandedGridView(
IEnumerable<BandedGridView> gridViews,
BandedGridView value)
{
if (gridViews == null || value == null)
return false;
foreach (BandedGridView gridView in gridViews)
if (ReferenceEquals(gridView, value))
return true;
return false;
}
private static List<GridView> CollectTargetGridViews(
IEnumerable<WinFormsControl> controls)
{
List<GridView> result = new List<GridView>();
if (controls == null)
return result;
foreach (WinFormsControl control in controls)
{
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
if (grid == null)
continue;
try
{
AddGridView(result, grid.MainView as GridView);
foreach (DevExpress.XtraGrid.Views.Base.BaseView baseView in grid.ViewCollection)
AddGridView(result, baseView as GridView);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("读取旧 Banded 目标表格视图失败:" + exception);
}
}
return result;
}
private static void AddGridView(List<GridView> target, GridView view)
{
if (view != null && !ContainsGridView(target, view))
target.Add(view);
}
private static bool ContainsGridView(
IEnumerable<GridView> gridViews,
GridView value)
{
if (gridViews == null || value == null)
return false;
foreach (GridView gridView in gridViews)
if (ReferenceEquals(gridView, value))
return true;
return false;
}
private static IEnumerable<WinFormsControl> EnumerateControls(WinFormsControl root)
{
yield return root;
foreach (WinFormsControl child in root.Controls)
foreach (WinFormsControl nested in EnumerateControls(child))
yield return nested;
}
private static void RemoveConditionPanels(
string moduleCode,
IEnumerable<WinFormsControl> moduleControls)
{
foreach (string key in ConditionsPanelDic.Keys.ToList())
{
ModuleConditionsPanelEx panel;
if (!ConditionsPanelDic.TryGetValue(key, out panel) || panel == null || panel.IsDisposed)
{
ConditionsPanelDic.Remove(key);
continue;
}
if (string.Equals(key, moduleCode, StringComparison.OrdinalIgnoreCase) &&
IsConditionPanelOwnedByModule(panel, moduleControls))
ConditionsPanelDic.Remove(key);
}
}
private static bool IsConditionPanelOwnedByModule(
ModuleConditionsPanelEx panel,
IEnumerable<WinFormsControl> moduleControls)
{
if (panel == null)
return false;
if (ContainsControl(moduleControls, panel) || ContainsControl(moduleControls, panel.Owner))
return true;
MyControl parentControl = panel.ParentControlObj;
return parentControl != null &&
parentControl.MainGridEx != null &&
ContainsControl(moduleControls, parentControl.MainGridEx);
}
private static void RemoveProtectedReferences(
IEnumerable<WinFormsControl> moduleControls,
XtraTabPage modulePage)
{
while (modulePage != null && DogVerifyModuleForms.Remove(modulePage))
{
}
foreach (XtraTabPage item in DogVerifyModuleForms.ToList())
if (item == null || item.IsDisposed || ContainsControl(moduleControls, item))
DogVerifyModuleForms.Remove(item);
foreach (IForm item in DogVerifyNoPageForms.ToList())
if (item == null || item.SubForm == null || item.SubForm.IsDisposed ||
ContainsControl(moduleControls, item.SubForm))
DogVerifyNoPageForms.Remove(item);
}
private static bool ContainsControl(
IEnumerable<WinFormsControl> moduleControls,
WinFormsControl value)
{
if (moduleControls == null || value == null)
return false;
foreach (WinFormsControl control in moduleControls)
if (ReferenceEquals(control, value))
return true;
return false;
}
/// <summary>
/// 记录当前U盾权限窗口
/// </summary>
public static List<XtraTabPage> DogVerifyModuleForms = new List<XtraTabPage>();
public static List<IForm> DogVerifyNoPageForms = new List<IForm>();
/// <summary>
///模块打开时的条件界面
/// </summary>
public static Dictionary<string, ModuleConditionsPanelEx> ConditionsPanelDic = new Dictionary<string, ModuleConditionsPanelEx>();
// Keep the old public fields as aliases so already deployed plug-ins
// loaded from lib do not fail with MissingFieldException.
[System.Obsolete("请使用 StaticControl.DogVerifyModuleForms")]
public static List<XtraTabPage> DogVerifyModuleForms =
StaticControl.DogVerifyModuleForms;
[System.Obsolete("请使用 StaticControl.DogVerifyNoPageForms")]
public static List<IForm> DogVerifyNoPageForms =
StaticControl.DogVerifyNoPageForms;
[System.Obsolete("请使用 StaticControl.ConditionsPanelDic")]
public static Dictionary<string, ModuleConditionsPanelEx> ConditionsPanelDic =
StaticControl.ConditionsPanelDic;
/// <summary>
/// 表格拖拽类,key值为源表,多表格
/// </summary>
public static Dictionary<BandedGridView, List<BandedGridDragGrid>> BandedGridViewDragGridDic = new Dictionary<BandedGridView, List<BandedGridDragGrid>>();
public static Dictionary<BandedGridView, List<BandedGridDragGrid>>
BandedGridViewDragGridDic =
new Dictionary<BandedGridView, List<BandedGridDragGrid>>();
/// <summary>
/// 表格拖拽类,key值为目标表
/// </summary>
public static Dictionary<GridView, List<BandedGridDragGrid>> BandedTargetViewDragGridDic = new Dictionary<GridView, List<BandedGridDragGrid>>();
public static Dictionary<GridView, List<BandedGridDragGrid>>
BandedTargetViewDragGridDic =
new Dictionary<GridView, List<BandedGridDragGrid>>();
/// <summary>
/// 当前拖拽源表格
/// </summary>
public static BandedGridView SourceDragBandedGridView;
/// <summary>
/// 指纹识别模块
/// </summary>
public static FingerHelper fingerHelper;
/// <summary>
/// 进度条
/// </summary>
File diff suppressed because it is too large Load Diff
+5 -3
View File
@@ -595,6 +595,7 @@ namespace Lskj.Control
out this.MrpClickMenus);
}
this.SearchObj = searchObj;
StaticControl.RegisterModuleSearchControl(this, searchObj);
// 搜索区域复用当前模块配置,MyControl 内部会校验模块号,不一致时仍按原逻辑查询。
this.SearchObj.SystemModel = this.SysModel;
this.SearchObj.MrpClickMenus = this.MrpClickMenus;
@@ -2410,7 +2411,7 @@ namespace Lskj.Control
/// </summary>
private void AddPanelViewRecord()
{
StaticControl.AddParentGrid = new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain);
StaticControl.SetAddParentGrid(new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain));
string mLeftFieldId = string.Empty;
string mLeftFieldName = string.Empty;
string mLeftTreeData = string.Empty;
@@ -3375,7 +3376,7 @@ namespace Lskj.Control
{
try
{
StaticControl.AddParentGrid = new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain);
StaticControl.SetAddParentGrid(new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain));
if (!string.IsNullOrWhiteSpace(this.SysModel.MenuAddName))
{
string modifyCond = this.SysModel.ModifyCond;
@@ -3786,6 +3787,7 @@ namespace Lskj.Control
public ModuleGridEx()
{
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
InitializeAltButtonShortcuts();
this.OperShortMode = true;
this.Disposed += OnModuleGridExDisposed;
@@ -3838,7 +3840,7 @@ namespace Lskj.Control
searchObj.OnDataSourceBindCallBack -= OnMainSearchDataSourceBindCallBack;
if (ReferenceEquals(StaticControl.RightMenuMyControl, searchObj))
{
StaticControl.RightMenuMyControl = null;
StaticControl.SetRightMenuMyControl(null);
}
searchObj.Dispose();
}
+1
View File
@@ -194,6 +194,7 @@ namespace Lskj.Control
public TabControlEx()
{
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
this.Disposed += OnTabControlExDisposed;
}
#region