Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ImageCollectionEditor.cs / 1 / ImageCollectionEditor.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.ImageCollectionEditor..ctor(System.Type)")]
namespace System.Windows.Forms.Design {
using System.Runtime.InteropServices;
using System.Diagnostics;
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Design;
using System.Design;
using System.Windows.Forms.ComponentModel;
///
///
///
/// Provides an editor for an image collection.
///
internal class ImageCollectionEditor : CollectionEditor {
///
///
/// Initializes a new instance of the class.
///
public ImageCollectionEditor(Type type) : base(type){
}
///
///
/// Retrieves the display text for the given list item.
///
protected override string GetDisplayText(object value) {
string text;
if (value == null) {
return string.Empty;
}
PropertyDescriptor prop = TypeDescriptor.GetProperties(value)["Name"];
if (prop != null) {
text = (string) prop.GetValue( value );
if (text != null && text.Length > 0) {
return text;
}
}
// If we want to show any type information - pretend we're an image.
if (value is ImageListImage) {
value = ((ImageListImage)value).Image;
}
text = TypeDescriptor.GetConverter(value).ConvertToString(value);
if (text == null || text.Length == 0) {
text = value.GetType().Name;
}
return text;
}
///
///
/// Creates an instance of the specified type in the collection.
///
protected override object CreateInstance(Type type) {
UITypeEditor editor = (UITypeEditor) TypeDescriptor.GetEditor(typeof(ImageListImage), typeof(UITypeEditor));
return editor.EditValue(this.Context, null);
}
///
///
/// Creates a
/// new form to show the current collection.
///
protected override CollectionForm CreateCollectionForm() {
CollectionForm form = base.CreateCollectionForm();
// We want to switch the title to ImageCollection Editor instead of ImageListImage Editor.
// The collection editor is actually using ImageListImages, while the collection we're actually editing is the Image collection.
form.Text = SR.GetString(SR.ImageCollectionEditorFormText);
return form;
}
///
///
///
/// This Function gets the images from the givem object. The input is an ArrayList as an object.
/// The output is a arraylist which contains the individual images that need to be created.
///
///
protected override IList GetObjectsFromInstance(object instance) {
ArrayList value = instance as ArrayList;
if (value != null) {
return value;
}
else return null;
}
}
}
// 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
- PropertyPathWorker.cs
- MediaSystem.cs
- WorkflowNamespace.cs
- ObjectContext.cs
- HorizontalAlignConverter.cs
- ManipulationStartingEventArgs.cs
- DataMember.cs
- parserscommon.cs
- UrlMappingCollection.cs
- LoginCancelEventArgs.cs
- DesignBinding.cs
- AssemblyBuilder.cs
- Int32AnimationUsingKeyFrames.cs
- ResourceManager.cs
- LightweightCodeGenerator.cs
- PageParser.cs
- BamlTreeNode.cs
- Function.cs
- VoiceObjectToken.cs
- RC2CryptoServiceProvider.cs
- SchemaImporterExtensionsSection.cs
- BaseValidatorDesigner.cs
- XmlUTF8TextWriter.cs
- ExpressionNormalizer.cs
- ReachNamespaceInfo.cs
- X509CertificateInitiatorClientCredential.cs
- ClonableStack.cs
- TemplatedAdorner.cs
- InputChannel.cs
- CompiledQueryCacheKey.cs
- SecurityAlgorithmSuite.cs
- DirectoryObjectSecurity.cs
- FileUpload.cs
- TabletCollection.cs
- FormatConvertedBitmap.cs
- IssuedTokenParametersEndpointAddressElement.cs
- QueryCreatedEventArgs.cs
- CallbackException.cs
- DesignerForm.cs
- WindowsListViewGroupSubsetLink.cs
- ValueUtilsSmi.cs
- ProcessStartInfo.cs
- ApplicationHost.cs
- DataSourceControl.cs
- SettingsSection.cs
- PersonalizablePropertyEntry.cs
- DrawingServices.cs
- DbConnectionPoolGroup.cs
- AuthenticationSection.cs
- ToolStripOverflow.cs
- WorkItem.cs
- figurelengthconverter.cs
- LogLogRecord.cs
- StylusCaptureWithinProperty.cs
- Highlights.cs
- PaperSize.cs
- XmlSchemaValidator.cs
- SerializationObjectManager.cs
- ConnectionDemuxer.cs
- SmtpAuthenticationManager.cs
- PropertyFilter.cs
- CurrentTimeZone.cs
- CustomCredentialPolicy.cs
- AutomationPropertyInfo.cs
- _IPv6Address.cs
- OSEnvironmentHelper.cs
- DbProviderFactories.cs
- IteratorFilter.cs
- DataSysAttribute.cs
- AnonymousIdentificationModule.cs
- DropSource.cs
- CustomError.cs
- IdentityHolder.cs
- rsa.cs
- AttachedAnnotation.cs
- NavigatorInput.cs
- LinkClickEvent.cs
- ProgressiveCrcCalculatingStream.cs
- EditingCommands.cs
- ColorConverter.cs
- Native.cs
- SoapSchemaImporter.cs
- HTMLTagNameToTypeMapper.cs
- SqlNodeAnnotations.cs
- AddInControllerImpl.cs
- CommandManager.cs
- TextServicesCompartment.cs
- Effect.cs
- ResumeStoryboard.cs
- SqlCommand.cs
- NavigationPropertyEmitter.cs
- DurableDispatcherAddressingFault.cs
- OperationFormatUse.cs
- HtmlControlPersistable.cs
- NumberSubstitution.cs
- WSFederationHttpBindingElement.cs
- UnauthorizedAccessException.cs
- _CookieModule.cs
- PreviewKeyDownEventArgs.cs
- GB18030Encoding.cs