131 lines
5.3 KiB
C#
131 lines
5.3 KiB
C#
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;
|
|
|
|
namespace Lskj.Control.Model
|
|
{
|
|
public static class StaticBandedControl
|
|
{
|
|
public static void ReleaseModuleReferences(WinFormsControl moduleRoot, XtraTabPage modulePage, string moduleCode)
|
|
{
|
|
try
|
|
{
|
|
List<BandedGridView> bandedViews = CollectBandedGridViews(moduleRoot);
|
|
List<GridView> targetViews = CollectTargetGridViews(moduleRoot);
|
|
foreach (BandedGridView view in bandedViews)
|
|
BandedGridDragGrid.DisposeRegistrations(
|
|
BandedGridViewDragGridDic,
|
|
BandedTargetViewDragGridDic,
|
|
view,
|
|
null);
|
|
foreach (GridView view in targetViews)
|
|
BandedGridDragGrid.DisposeRegistrations(
|
|
BandedGridViewDragGridDic,
|
|
BandedTargetViewDragGridDic,
|
|
null,
|
|
view);
|
|
if (SourceDragBandedGridView != null &&
|
|
(bandedViews.Contains(SourceDragBandedGridView) ||
|
|
(SourceDragBandedGridView.GridControl != null && SourceDragBandedGridView.GridControl.IsDisposed)))
|
|
SourceDragBandedGridView = null;
|
|
RemoveConditionPanels(moduleCode);
|
|
while (modulePage != null && DogVerifyModuleForms.Remove(modulePage))
|
|
{
|
|
}
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("释放旧 Banded 模块引用失败:" + exception);
|
|
}
|
|
}
|
|
|
|
private static List<BandedGridView> CollectBandedGridViews(WinFormsControl root)
|
|
{
|
|
List<BandedGridView> result = new List<BandedGridView>();
|
|
if (root == null)
|
|
return result;
|
|
foreach (WinFormsControl control in EnumerateControls(root))
|
|
{
|
|
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
|
|
BandedGridView view = grid == null ? null : grid.MainView as BandedGridView;
|
|
if (view != null && !result.Contains(view))
|
|
result.Add(view);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private static List<GridView> CollectTargetGridViews(WinFormsControl root)
|
|
{
|
|
List<GridView> result = new List<GridView>();
|
|
if (root == null)
|
|
return result;
|
|
foreach (WinFormsControl control in EnumerateControls(root))
|
|
{
|
|
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
|
|
GridView view = grid == null ? null : grid.MainView as GridView;
|
|
if (view != null && !result.Contains(view))
|
|
result.Add(view);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
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)
|
|
{
|
|
foreach (string key in ConditionsPanelDic.Keys.ToList())
|
|
{
|
|
ModuleConditionsPanelEx panel;
|
|
if (string.Equals(key, moduleCode, StringComparison.OrdinalIgnoreCase) ||
|
|
!ConditionsPanelDic.TryGetValue(key, out panel) || panel == null || panel.IsDisposed)
|
|
ConditionsPanelDic.Remove(key);
|
|
}
|
|
}
|
|
/// <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>();
|
|
|
|
/// <summary>
|
|
/// 表格拖拽类,key值为源表,多表格
|
|
/// </summary>
|
|
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>>();
|
|
|
|
/// <summary>
|
|
/// 当前拖拽源表格
|
|
/// </summary>
|
|
public static BandedGridView SourceDragBandedGridView;
|
|
/// <summary>
|
|
/// 指纹识别模块
|
|
/// </summary>
|
|
public static FingerHelper fingerHelper;
|
|
/// <summary>
|
|
/// 进度条
|
|
/// </summary>
|
|
public static FrmProgressBar frmProgressBar;
|
|
}
|
|
}
|