Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DesignerContextDescriptor.cs / 1 / DesignerContextDescriptor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System; using System.Design; using System.ComponentModel; using System.Windows.Forms; using System.ComponentModel.Design; using System.Drawing; using System.Windows.Forms.Design.Behavior; using System.Drawing.Design; using System.Diagnostics; using System.Collections; using System.Runtime.InteropServices; using System.Diagnostics.CodeAnalysis; ////// // --------------------------------------------------------------------------------- // Class Implemented for opening the ImageEditor ... // // This class is replaces the ContextDescriptor in ToolStripItem designer. // // DesignerContextDescriptor implements the IWindowsFormsEditorService which is required // to open the ImageEditor .. Hence the need for this Implementation //----------------------------------------------------------------------------------- /// internal class DesignerContextDescriptor : IWindowsFormsEditorService, ITypeDescriptorContext { private Component _component; private PropertyDescriptor _propertyDescriptor; private IDesignerHost _host; // // Constructor // ///[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] public DesignerContextDescriptor(Component component, PropertyDescriptor imageProperty, IDesignerHost host) { _component = component; _propertyDescriptor = imageProperty; _host = host; } /// /// /// Gets called thru the TemplateNode to open the ImageEditor. /// ///// Called through reflection [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] public Image OpenImageCollection() { object propertyValue = _propertyDescriptor.GetValue(_component); if (_propertyDescriptor != null) { Image image = null; UITypeEditor itemsEditor = _propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; Debug.Assert(itemsEditor != null, "Didn't get a collection editor for type '" + _propertyDescriptor.PropertyType.FullName + "'"); if (itemsEditor != null) { image = (Image)itemsEditor.EditValue(this, (IServiceProvider)this, propertyValue); } if (image != null) { return image; } } // Always Return old Image if Image is not changed... return (Image)propertyValue; } IContainer ITypeDescriptorContext.Container { get { return null; } } object ITypeDescriptorContext.Instance { get { return _component; } } PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor { get { return _propertyDescriptor; } } void ITypeDescriptorContext.OnComponentChanged() { } bool ITypeDescriptorContext.OnComponentChanging() { return false; } /// /// Self-explanitory interface impl. /// object IServiceProvider.GetService(Type serviceType) { if (serviceType == typeof(IWindowsFormsEditorService)) { return this; } else { return _host.GetService(serviceType); } } ////// Self-explanitory interface impl. /// void IWindowsFormsEditorService.CloseDropDown() { // we'll never be called to do this. // Debug.Fail("NOTIMPL"); return; } ////// Self-explanitory interface impl. /// void IWindowsFormsEditorService.DropDownControl(Control control) { // nope, sorry // Debug.Fail("NOTIMPL"); return; } ////// Self-explanitory interface impl. /// System.Windows.Forms.DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) { IntPtr priorFocus = UnsafeNativeMethods.GetFocus(); DialogResult result; IUIService uiSvc = (IUIService)((IServiceProvider)this).GetService(typeof(IUIService)); if (uiSvc != null) { result = uiSvc.ShowDialog(dialog); } else { result = dialog.ShowDialog(_component as IWin32Window); } if (priorFocus != IntPtr.Zero) { UnsafeNativeMethods.SetFocus(new HandleRef(null, priorFocus)); } return result; } } } // 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
- WebScriptMetadataMessage.cs
- backend.cs
- SystemIPInterfaceStatistics.cs
- COM2IDispatchConverter.cs
- LinqDataSourceHelper.cs
- XmlDesigner.cs
- SmiEventSink_DeferedProcessing.cs
- XMLSyntaxException.cs
- HtmlInputHidden.cs
- RemoveStoryboard.cs
- DynamicDataResources.Designer.cs
- ValidatingPropertiesEventArgs.cs
- WindowsPrincipal.cs
- Control.cs
- SystemResources.cs
- XMLUtil.cs
- DelegatingHeader.cs
- Function.cs
- DbBuffer.cs
- SimpleBitVector32.cs
- DataGridItemEventArgs.cs
- SimpleHandlerFactory.cs
- TextRunProperties.cs
- xamlnodes.cs
- LocationUpdates.cs
- GlyphTypeface.cs
- AutomationIdentifierGuids.cs
- PathGeometry.cs
- TableAdapterManagerHelper.cs
- UriSchemeKeyedCollection.cs
- _SslState.cs
- wgx_commands.cs
- ListView.cs
- DataGridViewComboBoxEditingControl.cs
- GlobalizationAssembly.cs
- EventLogConfiguration.cs
- SqlInfoMessageEvent.cs
- BinaryFormatterWriter.cs
- MethodBody.cs
- TreeNodeCollectionEditor.cs
- XmlJsonWriter.cs
- MemoryStream.cs
- SoapDocumentServiceAttribute.cs
- ContentType.cs
- UITypeEditor.cs
- SiteMapNode.cs
- UriScheme.cs
- EventManager.cs
- parserscommon.cs
- CompilerState.cs
- Matrix.cs
- ShutDownListener.cs
- CornerRadius.cs
- XmlSerializerSection.cs
- LayoutEvent.cs
- XappLauncher.cs
- HierarchicalDataBoundControl.cs
- TaskDesigner.cs
- GroupBox.cs
- ConfigurationManagerInternalFactory.cs
- SchemaSetCompiler.cs
- DataListItem.cs
- HttpRawResponse.cs
- DataGridViewColumnCollectionEditor.cs
- SettingsBindableAttribute.cs
- SimpleType.cs
- IdentitySection.cs
- RegexInterpreter.cs
- SqlCachedBuffer.cs
- Scalars.cs
- SafePEFileHandle.cs
- WinEventTracker.cs
- FontWeights.cs
- HtmlControl.cs
- TextEmbeddedObject.cs
- CodePageEncoding.cs
- PropertyNames.cs
- CompilerGlobalScopeAttribute.cs
- MarginsConverter.cs
- DoubleLinkListEnumerator.cs
- CustomAttributeFormatException.cs
- DbDataReader.cs
- ByteArrayHelperWithString.cs
- EntityClassGenerator.cs
- BinaryFormatter.cs
- NullableDecimalSumAggregationOperator.cs
- XmlBindingWorker.cs
- DecimalConstantAttribute.cs
- HebrewCalendar.cs
- DataGridViewBand.cs
- RegistrySecurity.cs
- StrokeCollectionDefaultValueFactory.cs
- Buffer.cs
- DrawTreeNodeEventArgs.cs
- Int16.cs
- FormattedText.cs
- ListViewInsertedEventArgs.cs
- SafeEventHandle.cs
- LZCodec.cs
- MeshGeometry3D.cs