/// <summary>
/// 互斥工具类
/// </summary>
public class MutexTools
{
private Control mPanel;
private MMBPanel mCurrent;
private Action<MMBPanel> mCallBack;
public MutexTools(Control panel)
{
this.mPanel = panel;
this.mCallBack = null;
this.BindingEvent();
}
public MutexTools(Control panel, Action<MMBPanel> callback)
{
this.mPanel = panel;
this.mCallBack = callback;
this.BindingEvent();
}
private void BindingEvent()
{
foreach (Control item in this.mPanel.Controls)
{
if (item is MMBPanel)
(item as MMBPanel).StateChanged += MutexTools_StateChanged;
}
}
private void MutexTools_StateChanged(object sender, EventArgs e)
{
MMBPanel wouldPress = sender as MMBPanel;
if (wouldPress.State != EGUIState.Pressed)
return;
if (mCurrent != null)
mCurrent.State = EGUIState.Normal;
this.mCurrent = wouldPress;
if (this.mCallBack != null)
{
this.mCallBack(this.mCurrent);
}
}
}
互斥工具类【MutexTools】
最新推荐文章于 2024-01-13 16:26:26 发布