105 lines
2.8 KiB
C#
105 lines
2.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using DevExpress.XtraNavBar;
|
|||
|
|
|
|||
|
|
namespace WMS.Ctrl
|
|||
|
|
{
|
|||
|
|
public partial class MyNavBarGroup : NavBarGroup
|
|||
|
|
{
|
|||
|
|
public MyNavBarGroup()
|
|||
|
|
: base()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public MyNavBarGroup(string caption)
|
|||
|
|
: base(caption)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//重写展开折叠属性,在set中触发自己定义的事件
|
|||
|
|
private bool _Expanded = false;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 展开折叠属性
|
|||
|
|
/// </summary>
|
|||
|
|
public override bool Expanded
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return _Expanded;
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
//触发改变之前的事件
|
|||
|
|
CancelEventArgs args = new CancelEventArgs() { Cancel = false };
|
|||
|
|
OnExpandChanging(args);
|
|||
|
|
|
|||
|
|
//是否可以展开,是否取消,是否与上次一值想等
|
|||
|
|
if (CanExpand && !args.Cancel && _Expanded != value)
|
|||
|
|
{
|
|||
|
|
base.Expanded = _Expanded = value;
|
|||
|
|
//触发修改之后的事件
|
|||
|
|
OnExpandChanged(new ExpandedEventArgs(value));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//自己加了一个属性,是否能够折叠或者展开,有的时候我们需要这个功能
|
|||
|
|
private bool _CanExpand = true;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否能够展开折叠(为false时,则不能展开或者折叠)
|
|||
|
|
/// </summary>
|
|||
|
|
public virtual bool CanExpand
|
|||
|
|
{
|
|||
|
|
get { return _CanExpand; }
|
|||
|
|
set { _CanExpand = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 展开或者折叠之后
|
|||
|
|
/// </summary>
|
|||
|
|
public event EventHandler<ExpandedEventArgs> ExpandChanged;
|
|||
|
|
protected virtual void OnExpandChanged(ExpandedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (ExpandChanged != null)
|
|||
|
|
{
|
|||
|
|
ExpandChanged(this, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 展开或者折叠之前
|
|||
|
|
/// </summary>
|
|||
|
|
public event EventHandler<CancelEventArgs> ExpandChanging;
|
|||
|
|
protected virtual void OnExpandChanging(CancelEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (ExpandChanging != null)
|
|||
|
|
{
|
|||
|
|
ExpandChanging(this, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class ExpandedEventArgs : EventArgs
|
|||
|
|
{
|
|||
|
|
public ExpandedEventArgs()
|
|||
|
|
{
|
|||
|
|
Expanded = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ExpandedEventArgs(bool expanded)
|
|||
|
|
{
|
|||
|
|
Expanded = expanded;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 展开或者折叠
|
|||
|
|
/// </summary>
|
|||
|
|
public bool Expanded { get; set; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|