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

📄 wroxstylerconverter.cs

📁 ASP.NET服务器控件高级编程电子书
💻 CS
字号:
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;

namespace WroxDesign.Design
{
	public class WroxStylerConverter : TypeConverter
	{
		private ArrayList _stylers = new ArrayList();

		public WroxStylerConverter()
		{ 
		}

		public override bool GetStandardValuesSupported(
			ITypeDescriptorContext context) 
		{
			if (!_stylers.Contains(context.Instance))
				_stylers.Add(context.Instance);
			return true;
		}

		public override bool GetStandardValuesExclusive(
			ITypeDescriptorContext context) 
		{
			return true;
		}

		public override StandardValuesCollection GetStandardValues(
			ITypeDescriptorContext context) 
		{
			System.Collections.ArrayList list = new System.Collections.ArrayList();

			foreach (IComponent comp in context.Container.Components)
				if (comp is WroxButton) list.Add(((WroxButton)comp).ID);

			IComponentChangeService svc = context.GetService(
				typeof(IComponentChangeService)) as IComponentChangeService;			

			svc.ComponentRename += new ComponentRenameEventHandler(OnRename);
			svc.ComponentRemoved += new ComponentEventHandler(OnRemove);
			return new StandardValuesCollection(list);
		}

		private void OnRemove(object sender, ComponentEventArgs e)
		{
			if (_stylers.Contains(e.Component))
				_stylers.Remove(e.Component);
		}

		private void OnRename(object sender, ComponentRenameEventArgs e)
		{
			if (e.Component is WroxButton)
				foreach (WroxStyler st in _stylers)
					if (e.OldName == st.RelatedButtonID)
						TypeDescriptor.GetProperties(st)
							["RelatedButtonID"].SetValue(st, e.NewName);
		}
	}
}

⌨️ 快捷键说明

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