Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / CompMod / System / ComponentModel / Design / DesignerActionUIService.cs / 1 / DesignerActionUIService.cs
//#define DEBUGDESIGNERTASKS //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel.Design { using System; using System.Collections; using System.ComponentModel; using System.Timers; using System.Diagnostics.CodeAnalysis; using System.Diagnostics; ////// /// public sealed class DesignerActionUIService : IDisposable { private DesignerActionUIStateChangeEventHandler designerActionUIStateChangedEventHandler; private IServiceProvider serviceProvider;//standard service provider private DesignerActionService designerActionService; internal DesignerActionUIService(IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; if (serviceProvider != null) { this.serviceProvider = serviceProvider; IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); host.AddService(typeof(DesignerActionUIService), this); designerActionService = serviceProvider.GetService(typeof(DesignerActionService)) as DesignerActionService; Debug.Assert(designerActionService != null, "we should have created and registered the DAService first"); } } ////// /// Disposes all resources and unhooks all events. /// [SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed")] public void Dispose() { if (serviceProvider != null) { IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); if (host != null) { host.RemoveService(typeof(DesignerActionUIService)); } } } ////// /// This event is thrown whenever a request is made to show/hide the ui /// public event DesignerActionUIStateChangeEventHandler DesignerActionUIStateChange { add { designerActionUIStateChangedEventHandler += value; } remove { designerActionUIStateChangedEventHandler -= value; } } public void HideUI(IComponent component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Hide)); } public void ShowUI(IComponent component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Show)); } ////// /// This is a new Helper Method that the service provides to refresh the DesignerActionGlyph as well as DesignerActionPanels. /// public void Refresh(IComponent component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Refresh)); } ////// This fires our DesignerActionsChanged event. /// private void OnDesignerActionUIStateChange(DesignerActionUIStateChangeEventArgs e) { if (designerActionUIStateChangedEventHandler != null) { designerActionUIStateChangedEventHandler(this, e); } } public bool ShouldAutoShow(IComponent component) { // Check the designer options... if (serviceProvider != null) { DesignerOptionService opts = serviceProvider.GetService(typeof(DesignerOptionService)) as DesignerOptionService; if (opts != null) { PropertyDescriptor p = opts.Options.Properties["ObjectBoundSmartTagAutoShow"]; if (p != null && p.PropertyType == typeof(bool) && !(bool)p.GetValue(null)) { return false; } } } if(designerActionService != null) { DesignerActionListCollection coll = designerActionService.GetComponentActions(component); if(coll != null && coll.Count > 0) { for(int i = 0;i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeNamespace.cs
- JoinTreeNode.cs
- ImageAutomationPeer.cs
- EllipseGeometry.cs
- HwndHost.cs
- DispatcherTimer.cs
- CodeChecksumPragma.cs
- CopyOfAction.cs
- OSFeature.cs
- EventRouteFactory.cs
- MenuCommand.cs
- WebServiceMethodData.cs
- MessageQueueCriteria.cs
- GZipObjectSerializer.cs
- MatrixAnimationUsingKeyFrames.cs
- WebPartEditorApplyVerb.cs
- XmlSchemaObjectCollection.cs
- ResourceReader.cs
- DictionaryContent.cs
- PropertyItem.cs
- TitleStyle.cs
- FixedSOMContainer.cs
- InheritedPropertyChangedEventArgs.cs
- BitmapSource.cs
- BrowserTree.cs
- XmlDataDocument.cs
- InputLangChangeRequestEvent.cs
- SerializationInfoEnumerator.cs
- ProtectedProviderSettings.cs
- PropertyOverridesTypeEditor.cs
- XmlAutoDetectWriter.cs
- FatalException.cs
- FixedSchema.cs
- MexServiceChannelBuilder.cs
- MailMessageEventArgs.cs
- Restrictions.cs
- BamlBinaryReader.cs
- DispatcherExceptionEventArgs.cs
- FlowNode.cs
- ThreadBehavior.cs
- SecurityResources.cs
- OleDbError.cs
- BaseCodePageEncoding.cs
- TemplateParser.cs
- SqlTypeSystemProvider.cs
- Image.cs
- ProcessHost.cs
- TrimSurroundingWhitespaceAttribute.cs
- FileDataSourceCache.cs
- WmlListAdapter.cs
- DataTableCollection.cs
- XmlNodeList.cs
- Single.cs
- OdbcError.cs
- WeakReferenceEnumerator.cs
- VisualProxy.cs
- _CookieModule.cs
- XmlObjectSerializer.cs
- GlobalEventManager.cs
- BigInt.cs
- DocumentPageViewAutomationPeer.cs
- XmlObjectSerializerReadContext.cs
- Rules.cs
- MexBindingBindingCollectionElement.cs
- ElasticEase.cs
- GlyphRunDrawing.cs
- ResourcePermissionBase.cs
- TableDetailsRow.cs
- HttpWebRequest.cs
- IsolatedStorageException.cs
- PreservationFileWriter.cs
- DirtyTextRange.cs
- Pointer.cs
- ILGen.cs
- ClientUrlResolverWrapper.cs
- PingOptions.cs
- WindowsImpersonationContext.cs
- FolderBrowserDialog.cs
- AddInPipelineAttributes.cs
- PrePostDescendentsWalker.cs
- PropertyMetadata.cs
- DashStyles.cs
- RenderCapability.cs
- DataGridViewRowsAddedEventArgs.cs
- HtmlInputImage.cs
- FixedSOMTableRow.cs
- CatalogPartChrome.cs
- PerformanceCounter.cs
- SqlStream.cs
- SqlBulkCopyColumnMappingCollection.cs
- DataBoundLiteralControl.cs
- ButtonAutomationPeer.cs
- TreeViewImageKeyConverter.cs
- ProfileProvider.cs
- Point3DCollectionConverter.cs
- Label.cs
- MatchingStyle.cs
- WsatConfiguration.cs
- PackUriHelper.cs
- WinEventQueueItem.cs