⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outlookbarbandcollection.cs

📁 c#编写的仿OUTLOOK工具条的Winform菜单
💻 CS
字号:
using System;
using System.Collections;
using System.Windows.Forms;
using UtilityLibrary.WinControls;

namespace UtilityLibrary.Collections
{
	/// <summary>
	/// Summary description for OutlookBarBandCollection.
	/// </summary>
	public class OutlookBarBandCollection  : System.Collections.CollectionBase, IEnumerable
	{
		
		#region Events
        public event EventHandler Changed;
		#endregion

		#region Class Variables
		// Back reference to the parent control
		OutlookBar parentBar = null;
		#endregion

		#region Constructors
		public OutlookBarBandCollection(OutlookBar bar)
		{
			parentBar = bar;
		}
		#endregion

		#region Methods
        public int Add(OutlookBarBand band)
		{
			
			if (Contains(band)) return -1;
			int index = InnerList.Add(band);
			RaiseChanged();
			return index;
		}

		public bool Contains(OutlookBarBand band)
		{
			return InnerList.Contains(band);
		}
	
		public int IndexOf(OutlookBarBand band)
		{
			return InnerList.IndexOf(band);
		}
	
		public void Remove(OutlookBarBand band)
		{
			// Make sure currentBandIndex is always valid
			int currentBandIndex = parentBar.GetCurrentBand();
			bool updateCurrentIndex = currentBandIndex != -1 && currentBandIndex == Count - 1;
			InnerList.Remove(band);
			if ( updateCurrentIndex )
			{
                // Since we just removed the currently selected band,
                // set the new selected band to last band
				if ( Count > 0 )
					parentBar.SetCurrentBand(Count-1);
			}
			
			RaiseChanged();		
		}
		
		public OutlookBarBand this[int index]
		{
			get { 
				if ( index < 0 || index >= Count) 
					return null;
				return (OutlookBarBand) InnerList[index]; 
			}
		}
		#endregion
	
		#region Implementation
        void RaiseChanged()
		{
			if (Changed != null) Changed(this, null);
		}
		#endregion

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -