Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / CompMod / System / ComponentModel / Design / DesignerActionList.cs / 1 / DesignerActionList.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel.Design {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
///
///
/// DesignerActionList is the abstract base class which control authors inherit from to create a task sheet.
/// Typical usage is to add properties and methods and then implement the abstract
/// GetSortedActionItems method to return an array of DesignerActionItems in the order they are to be displayed.
///
public class DesignerActionList {
private bool _autoShow = false;
private IComponent _component;
///
///
/// takes the related component as a parameter
///
public DesignerActionList(IComponent component) {
_component = component;
}
///
///
/// [to be provvided]
///
public virtual bool AutoShow {
get {
return _autoShow;
}
set {
if(_autoShow != value) {
_autoShow = value;
}
}
}
///
///
/// this will be null for list created from upgraded verbs collection...
///
public IComponent Component {
get {
return _component;
}
}
///
///
/// [to be provvided]
///
public object GetService(Type serviceType) {
if (_component != null && _component.Site != null) {
return _component.Site.GetService(serviceType);
} else {
return null;
}
}
private object GetCustomAttribute(MemberInfo info, Type attributeType) {
object[] attributes = info.GetCustomAttributes(attributeType, true);
if (attributes.Length > 0) {
return attributes[0];
} else {
return null;
}
}
private void GetMemberDisplayProperties(MemberInfo info, out string displayName, out string description, out string category) {
displayName = description = category = "";
DescriptionAttribute descAttr = GetCustomAttribute(info, typeof(DescriptionAttribute)) as DescriptionAttribute;
if(descAttr != null) {
description = descAttr.Description;
}
DisplayNameAttribute dispNameAttr = GetCustomAttribute(info, typeof(DisplayNameAttribute)) as DisplayNameAttribute;
if(dispNameAttr != null) {
displayName = dispNameAttr.DisplayName;
}
CategoryAttribute catAttr = GetCustomAttribute(info, typeof(CategoryAttribute)) as CategoryAttribute;
if(dispNameAttr != null) {
category = catAttr.Category;
}
if (string.IsNullOrEmpty(displayName)) {
displayName = info.Name;
}
}
///
///
/// [to be provvided]
///
public virtual DesignerActionItemCollection GetSortedActionItems() {
string dispName, desc, cat;
SortedList items = new SortedList();
// we want to ignore the public methods and properties for THIS class (only take the inherited ones)
IList originalMethods = Array.AsReadOnly(typeof(DesignerActionList).GetMethods(BindingFlags.InvokeMethod |
BindingFlags.Instance |
BindingFlags.DeclaredOnly |
BindingFlags.Public));
IList originalProperties = Array.AsReadOnly(typeof(DesignerActionList).GetProperties(BindingFlags.InvokeMethod |
BindingFlags.Instance |
BindingFlags.DeclaredOnly |
BindingFlags.Public));
// Do methods
MethodInfo[] methods = this.GetType().GetMethods(BindingFlags.InvokeMethod |
BindingFlags.Instance |
BindingFlags.DeclaredOnly |
BindingFlags.Public);
foreach (MethodInfo info in methods) {
if(originalMethods.Contains(info))
continue;
// Make sure there are only methods that take no parameters
if (info.GetParameters().Length == 0 && !info.IsSpecialName ) {
GetMemberDisplayProperties(info, out dispName, out desc, out cat);
items.Add(info.Name, new DesignerActionMethodItem(this, info.Name, dispName, cat, desc));
}
}
// Do properties
PropertyInfo [] properties = this.GetType().GetProperties(BindingFlags.InvokeMethod |
BindingFlags.Instance |
BindingFlags.DeclaredOnly |
BindingFlags.Public);
foreach (PropertyInfo info in properties) {
if(originalProperties.Contains(info))
continue;
GetMemberDisplayProperties(info, out dispName, out desc, out cat);
items.Add(dispName, new DesignerActionPropertyItem(info.Name, dispName, cat, desc));
}
DesignerActionItemCollection returnValue = new DesignerActionItemCollection();
foreach (DesignerActionItem dai in items.Values) {
returnValue.Add(dai);
}
return returnValue;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientCultureInfo.cs
- ThrowHelper.cs
- EntityDataSourceUtil.cs
- Soap.cs
- DNS.cs
- TextSearch.cs
- GenericTypeParameterBuilder.cs
- CatalogPart.cs
- BoundPropertyEntry.cs
- StickyNote.cs
- SvcMapFileSerializer.cs
- LingerOption.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- RegularExpressionValidator.cs
- EntityConnectionStringBuilderItem.cs
- DependencyProperty.cs
- TextTreeTextBlock.cs
- CssClassPropertyAttribute.cs
- HttpDebugHandler.cs
- ListDictionary.cs
- Int64Animation.cs
- LifetimeMonitor.cs
- Hashtable.cs
- DetailsViewInsertedEventArgs.cs
- NativeMethodsOther.cs
- DocumentEventArgs.cs
- CapiHashAlgorithm.cs
- GlyphCache.cs
- NameValueSectionHandler.cs
- OlePropertyStructs.cs
- ElementNotAvailableException.cs
- WebBrowserHelper.cs
- SymLanguageVendor.cs
- coordinatorfactory.cs
- RayHitTestParameters.cs
- GotoExpression.cs
- InputScope.cs
- TrustSection.cs
- XmlTextReaderImpl.cs
- wgx_exports.cs
- UnauthorizedWebPart.cs
- BasePropertyDescriptor.cs
- VisualState.cs
- RandomNumberGenerator.cs
- SqlConnectionHelper.cs
- SizeKeyFrameCollection.cs
- TrustManagerMoreInformation.cs
- PostBackOptions.cs
- OdbcDataReader.cs
- ReflectionPermission.cs
- GridItemPattern.cs
- ListChunk.cs
- Freezable.cs
- Certificate.cs
- TypeForwardedToAttribute.cs
- ThicknessAnimationBase.cs
- ObjectStateManager.cs
- CommandField.cs
- SqlFunctionAttribute.cs
- WCFBuildProvider.cs
- PropertyOverridesDialog.cs
- SecurityContextCookieSerializer.cs
- AuthenticationService.cs
- ListDictionaryInternal.cs
- XmlDataImplementation.cs
- OleDbStruct.cs
- ObjectAnimationBase.cs
- WebBrowserProgressChangedEventHandler.cs
- HandoffBehavior.cs
- XmlMemberMapping.cs
- AttachedAnnotation.cs
- GregorianCalendarHelper.cs
- SQLBoolean.cs
- File.cs
- RefExpr.cs
- BuildResult.cs
- StreamMarshaler.cs
- Effect.cs
- RtfToXamlReader.cs
- ValidationHelper.cs
- LinkLabel.cs
- ProtocolsSection.cs
- SafeCryptContextHandle.cs
- Group.cs
- ECDiffieHellmanCng.cs
- MarkupWriter.cs
- EventMappingSettings.cs
- FontClient.cs
- VisualStyleRenderer.cs
- QueryAccessibilityHelpEvent.cs
- Root.cs
- WindowsBrush.cs
- EntityDataSourceContextCreatingEventArgs.cs
- PersonalizationEntry.cs
- CircleHotSpot.cs
- DataGridCaption.cs
- EnumValAlphaComparer.cs
- HashAlgorithm.cs
- ProxyAttribute.cs
- UserControl.cs