Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DesignBindingValueUIHandler.cs / 1 / DesignBindingValueUIHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System; using System.Collections; using System.Windows.Forms; using Microsoft.Win32; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing.Design; using System.Drawing; ////// /// /// internal class DesignBindingValueUIHandler : IDisposable { private Bitmap dataBitmap; internal Bitmap DataBitmap { get { if (dataBitmap == null) { dataBitmap = new Bitmap(typeof(DesignBindingValueUIHandler), "BoundProperty.bmp"); dataBitmap.MakeTransparent(); } return dataBitmap; } } internal void OnGetUIValueItem(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList){ if (context.Instance is Control) { Control control = (Control) context.Instance; foreach (Binding binding in control.DataBindings) { // Only add the binding if it is one of the data source types we recognize. Otherwise, our drop-down list won't show it as // an option, which is confusing. if ((binding.DataSource is IListSource || binding.DataSource is IList || binding.DataSource is Array) && binding.PropertyName.Equals(propDesc.Name)) { valueUIItemList.Add(new LocalUIItem(this, binding)); } } } } class LocalUIItem : PropertyValueUIItem { Binding binding; internal LocalUIItem(DesignBindingValueUIHandler handler, Binding binding) : base(handler.DataBitmap, new PropertyValueUIItemInvokeHandler(handler.OnPropertyValueUIItemInvoke), GetToolTip(binding)) { this.binding = binding; } internal Binding Binding { get { return binding; } } static string GetToolTip(Binding binding) { string name = ""; if (binding.DataSource is IComponent) { IComponent comp = (IComponent) binding.DataSource; if (comp.Site != null) { name = comp.Site.Name; } } if (name.Length == 0) { name = "(List)"; } name += " - " + binding.BindingMemberInfo.BindingMember; return name; } } private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem) { LocalUIItem localItem = (LocalUIItem) invokedItem; IServiceProvider sop = null; Control control = localItem.Binding.Control; if (control.Site != null) { sop = ( IServiceProvider ) control.Site.GetService(typeof( IServiceProvider )); } if (sop != null) { AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, control.DataBindings); } } public void Dispose() { if (dataBitmap != null) { dataBitmap.Dispose(); } } } } // 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
- HtmlInputHidden.cs
- SqlDataSourceCache.cs
- ControlUtil.cs
- SiteMapSection.cs
- CollectionViewSource.cs
- BitmapCodecInfoInternal.cs
- HitTestDrawingContextWalker.cs
- Annotation.cs
- UInt16Storage.cs
- UrlMappingCollection.cs
- EntityCommandExecutionException.cs
- DetailsViewRow.cs
- EdgeProfileValidation.cs
- Subset.cs
- _Win32.cs
- BamlCollectionHolder.cs
- WeakReadOnlyCollection.cs
- ClonableStack.cs
- Utils.cs
- NeedSkipTokenVisitor.cs
- DataGridViewImageColumn.cs
- ConfigsHelper.cs
- ConvertersCollection.cs
- CodeChecksumPragma.cs
- IFlowDocumentViewer.cs
- WebPartEditorOkVerb.cs
- XomlCompilerResults.cs
- IssuanceLicense.cs
- DataGridRowEventArgs.cs
- SerializationObjectManager.cs
- FilteredSchemaElementLookUpTable.cs
- PagesSection.cs
- InstanceOwnerQueryResult.cs
- SafeUserTokenHandle.cs
- PopOutPanel.cs
- KnownIds.cs
- XmlSerializerVersionAttribute.cs
- VoiceChangeEventArgs.cs
- AdornerPresentationContext.cs
- FormsAuthenticationUser.cs
- SQLDecimalStorage.cs
- IdentityValidationException.cs
- StateItem.cs
- ConfigXmlSignificantWhitespace.cs
- GridSplitter.cs
- Collection.cs
- SynchronizedDispatch.cs
- SqlMethodCallConverter.cs
- XmlSchemaValidator.cs
- Size3DConverter.cs
- PackUriHelper.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- MSAAWinEventWrap.cs
- EditorPart.cs
- ColumnTypeConverter.cs
- ComplexTypeEmitter.cs
- PageCanvasSize.cs
- ConnectionProviderAttribute.cs
- PartBasedPackageProperties.cs
- SpotLight.cs
- Pen.cs
- RuntimeIdentifierPropertyAttribute.cs
- BlobPersonalizationState.cs
- DropDownList.cs
- AuthenticationConfig.cs
- CorePropertiesFilter.cs
- RowUpdatedEventArgs.cs
- NumberFormatter.cs
- UrlPath.cs
- _BufferOffsetSize.cs
- WorkflowShape.cs
- SQLInt64Storage.cs
- BasicAsyncResult.cs
- NullRuntimeConfig.cs
- ReaderWriterLockWrapper.cs
- graph.cs
- RayMeshGeometry3DHitTestResult.cs
- StaticSiteMapProvider.cs
- AsymmetricSignatureFormatter.cs
- CodeSnippetExpression.cs
- ForeignKeyConstraint.cs
- HttpListenerResponse.cs
- SortDescriptionCollection.cs
- AdapterDictionary.cs
- DesignerWebPartChrome.cs
- PrivateFontCollection.cs
- SettingsSection.cs
- SoapProcessingBehavior.cs
- PropertyEntry.cs
- IPHostEntry.cs
- UnconditionalPolicy.cs
- Configuration.cs
- QilXmlWriter.cs
- shaperfactoryquerycachekey.cs
- EventListenerClientSide.cs
- EmbeddedMailObject.cs
- XsdDataContractExporter.cs
- Sentence.cs
- SettingsPropertyNotFoundException.cs
- ToolStripItemImageRenderEventArgs.cs