Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebControls / ErrorStyle.cs / 1 / ErrorStyle.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; // A derived Style class with the default ForeColor set to Color.Red instead of Color.Empty internal sealed class ErrorStyle : Style, ICustomTypeDescriptor { public ErrorStyle() : base() { ForeColor = Color.Red; } #region ICustomTypeDesciptor implementation AttributeCollection ICustomTypeDescriptor.GetAttributes() { return TypeDescriptor.GetAttributes(this, true); } string ICustomTypeDescriptor.GetClassName() { return TypeDescriptor.GetClassName(this, true); } string ICustomTypeDescriptor.GetComponentName() { return TypeDescriptor.GetComponentName(this, true); } TypeConverter ICustomTypeDescriptor.GetConverter() { return TypeDescriptor.GetConverter(this, true); } EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return TypeDescriptor.GetDefaultEvent(this, true); } PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() { return TypeDescriptor.GetDefaultProperty(this, true); } object ICustomTypeDescriptor.GetEditor(Type editorBaseType) { return TypeDescriptor.GetEditor(this, editorBaseType, true); } EventDescriptorCollection ICustomTypeDescriptor.GetEvents() { return TypeDescriptor.GetEvents(this, true); } EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) { return TypeDescriptor.GetEvents(this, attributes, true); } PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() { return ((ICustomTypeDescriptor)this).GetProperties(null); } PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { PropertyDescriptorCollection oldProperties = TypeDescriptor.GetProperties(GetType(), attributes); PropertyDescriptor[] newProperties = new PropertyDescriptor[oldProperties.Count]; PropertyDescriptor foreColor = oldProperties["ForeColor"]; for (int i=0; i < oldProperties.Count; i++) { PropertyDescriptor property = oldProperties[i]; if (property == foreColor) { newProperties[i] = TypeDescriptor.CreateProperty( GetType(), property, new DefaultValueAttribute(typeof(Color), "Red")); } else { newProperties[i] = property; } } return new PropertyDescriptorCollection(newProperties, true); } object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) { return this; } #endregion //ICustomTypeDescriptor implementation } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; // A derived Style class with the default ForeColor set to Color.Red instead of Color.Empty internal sealed class ErrorStyle : Style, ICustomTypeDescriptor { public ErrorStyle() : base() { ForeColor = Color.Red; } #region ICustomTypeDesciptor implementation AttributeCollection ICustomTypeDescriptor.GetAttributes() { return TypeDescriptor.GetAttributes(this, true); } string ICustomTypeDescriptor.GetClassName() { return TypeDescriptor.GetClassName(this, true); } string ICustomTypeDescriptor.GetComponentName() { return TypeDescriptor.GetComponentName(this, true); } TypeConverter ICustomTypeDescriptor.GetConverter() { return TypeDescriptor.GetConverter(this, true); } EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return TypeDescriptor.GetDefaultEvent(this, true); } PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() { return TypeDescriptor.GetDefaultProperty(this, true); } object ICustomTypeDescriptor.GetEditor(Type editorBaseType) { return TypeDescriptor.GetEditor(this, editorBaseType, true); } EventDescriptorCollection ICustomTypeDescriptor.GetEvents() { return TypeDescriptor.GetEvents(this, true); } EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) { return TypeDescriptor.GetEvents(this, attributes, true); } PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() { return ((ICustomTypeDescriptor)this).GetProperties(null); } PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { PropertyDescriptorCollection oldProperties = TypeDescriptor.GetProperties(GetType(), attributes); PropertyDescriptor[] newProperties = new PropertyDescriptor[oldProperties.Count]; PropertyDescriptor foreColor = oldProperties["ForeColor"]; for (int i=0; i < oldProperties.Count; i++) { PropertyDescriptor property = oldProperties[i]; if (property == foreColor) { newProperties[i] = TypeDescriptor.CreateProperty( GetType(), property, new DefaultValueAttribute(typeof(Color), "Red")); } else { newProperties[i] = property; } } return new PropertyDescriptorCollection(newProperties, true); } object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) { return this; } #endregion //ICustomTypeDescriptor implementation } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeViewItemAutomationPeer.cs
- DataListItem.cs
- QilDataSource.cs
- DataServiceResponse.cs
- TaskExceptionHolder.cs
- MimeBasePart.cs
- NameHandler.cs
- ComponentEditorForm.cs
- TextBreakpoint.cs
- HttpCacheVaryByContentEncodings.cs
- RIPEMD160.cs
- IncrementalHitTester.cs
- SubMenuStyle.cs
- QualifierSet.cs
- SchemaNamespaceManager.cs
- PatternMatcher.cs
- SiteMap.cs
- Parser.cs
- IPipelineRuntime.cs
- RbTree.cs
- FindSimilarActivitiesVerb.cs
- FileDialog.cs
- NativeMethods.cs
- SiteMapNodeItem.cs
- DocumentSequenceHighlightLayer.cs
- OleDbInfoMessageEvent.cs
- ListViewItemEventArgs.cs
- PlacementWorkspace.cs
- MemoryPressure.cs
- FontUnit.cs
- oledbmetadatacollectionnames.cs
- HtmlTable.cs
- CalendarDataBindingHandler.cs
- SafeRightsManagementHandle.cs
- InternalSafeNativeMethods.cs
- TimerElapsedEvenArgs.cs
- Console.cs
- SqlTriggerContext.cs
- CfgParser.cs
- NavigationCommands.cs
- EnumBuilder.cs
- Duration.cs
- FloaterBaseParagraph.cs
- TableItemPatternIdentifiers.cs
- SystemDropShadowChrome.cs
- GroupBoxRenderer.cs
- XmlSchemaCollection.cs
- XmlnsDefinitionAttribute.cs
- HMACMD5.cs
- SqlCommandBuilder.cs
- NameTable.cs
- DbModificationClause.cs
- HttpsTransportBindingElement.cs
- SiteMapHierarchicalDataSourceView.cs
- ClickablePoint.cs
- SymbolType.cs
- Metafile.cs
- ResourceProperty.cs
- TextStore.cs
- RectAnimation.cs
- SmiSettersStream.cs
- EntityDataSourceMemberPath.cs
- SafeNativeMemoryHandle.cs
- HighContrastHelper.cs
- ByteStreamBufferedMessageData.cs
- DesignerLoader.cs
- remotingproxy.cs
- ConstructorNeedsTagAttribute.cs
- EditBehavior.cs
- DefaultHttpHandler.cs
- KeyPullup.cs
- AddInController.cs
- SocketElement.cs
- SmiRequestExecutor.cs
- ConfigurationPropertyAttribute.cs
- AutoFocusStyle.xaml.cs
- PasswordDeriveBytes.cs
- CustomErrorsSectionWrapper.cs
- ConnectionManagementSection.cs
- ClientConfigPaths.cs
- CacheForPrimitiveTypes.cs
- ReadOnlyDataSource.cs
- HyperLinkStyle.cs
- BitArray.cs
- DataGridClipboardHelper.cs
- TraceHandlerErrorFormatter.cs
- SerializationSectionGroup.cs
- UrlMappingCollection.cs
- DynamicDataManager.cs
- OleDbStruct.cs
- IndexedString.cs
- DataGridTextBoxColumn.cs
- IndependentAnimationStorage.cs
- UserNamePasswordClientCredential.cs
- DesignerCategoryAttribute.cs
- ApplicationSecurityInfo.cs
- ProjectionCamera.cs
- AnnotationService.cs
- Int64KeyFrameCollection.cs
- CheckableControlBaseAdapter.cs