Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / StatusCommandUI.cs / 1 / StatusCommandUI.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System.Design; using System.Runtime.InteropServices; using System.ComponentModel; using System.Diagnostics; using System; using System.Collections; using Microsoft.Win32; using System.ComponentModel.Design; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.ComponentModel; using System.Windows.Forms.Design; using System.Windows.Forms.Design.Behavior; ////// /// This class provides a single entrypoint used by the Behaviors, KeySize and KeyMoves (in CommandSets) and SelectionService to update /// the StatusBar Information. /// internal class StatusCommandUI { MenuCommand statusRectCommand = null; IMenuCommandService menuService = null; IServiceProvider serviceProvider; public StatusCommandUI(IServiceProvider provider) { this.serviceProvider = provider; } ////// /// Retrieves the menu editor service, which we cache for speed. /// private IMenuCommandService MenuService { get { if (menuService == null) { menuService = (IMenuCommandService)serviceProvider.GetService(typeof(IMenuCommandService)); } return menuService; } } ////// /// Retrieves the actual StatusRectCommand, which we cache for speed. /// private MenuCommand StatusRectCommand { get { if (statusRectCommand == null) { if (MenuService != null) { statusRectCommand = MenuService.FindCommand(MenuCommands.SetStatusRectangle); } } return statusRectCommand; } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Component selectedComponent, Point location) { if (selectedComponent == null) { return; } Rectangle bounds = Rectangle.Empty; Control c = selectedComponent as Control; if (c != null) { bounds = c.Bounds; } else{ PropertyDescriptor BoundsProp = TypeDescriptor.GetProperties(selectedComponent)["Bounds"]; if (BoundsProp != null && typeof(Rectangle).IsAssignableFrom(BoundsProp.PropertyType)) { bounds = (Rectangle)BoundsProp.GetValue(selectedComponent); } } if (location != Point.Empty) { bounds.X = location.X; bounds.Y = location.Y; } if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Component selectedComponent) { if (selectedComponent == null) { return; } Rectangle bounds = Rectangle.Empty; Control c = selectedComponent as Control; if (c != null) { bounds = c.Bounds; } else{ PropertyDescriptor BoundsProp = TypeDescriptor.GetProperties(selectedComponent)["Bounds"]; if (BoundsProp != null && typeof(Rectangle).IsAssignableFrom(BoundsProp.PropertyType)) { bounds = (Rectangle)BoundsProp.GetValue(selectedComponent); } } if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Rectangle bounds) { if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } } } // 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
- InvalidBodyAccessException.cs
- XmlEntity.cs
- WindowsListViewGroup.cs
- UiaCoreProviderApi.cs
- RegexMatchCollection.cs
- TitleStyle.cs
- TextParaClient.cs
- DatePickerDateValidationErrorEventArgs.cs
- BrowserDefinition.cs
- TemplateBamlRecordReader.cs
- DataStreams.cs
- PageHandlerFactory.cs
- IPCCacheManager.cs
- CatalogPart.cs
- ActiveDesignSurfaceEvent.cs
- AccessControlEntry.cs
- ContractMapping.cs
- ClientScriptManager.cs
- IndicFontClient.cs
- PrimitiveList.cs
- GatewayDefinition.cs
- LifetimeServices.cs
- ModelTreeEnumerator.cs
- CalendarTable.cs
- PrivilegeNotHeldException.cs
- TextTreeFixupNode.cs
- InkCanvasInnerCanvas.cs
- BamlCollectionHolder.cs
- StaticSiteMapProvider.cs
- EditorAttribute.cs
- SeparatorAutomationPeer.cs
- WebPartDescriptionCollection.cs
- ParallelTimeline.cs
- DetailsViewPageEventArgs.cs
- CdpEqualityComparer.cs
- Utils.cs
- ReadWriteObjectLock.cs
- ScrollItemPattern.cs
- WinEventTracker.cs
- InternalRelationshipCollection.cs
- StringFreezingAttribute.cs
- MetadataCacheItem.cs
- WebPartConnectionsEventArgs.cs
- LinqDataSourceValidationException.cs
- webclient.cs
- ContentElementAutomationPeer.cs
- EntityDataSource.cs
- DecoderFallbackWithFailureFlag.cs
- SqlDuplicator.cs
- Base64Stream.cs
- JsonDeserializer.cs
- UrlAuthFailedErrorFormatter.cs
- TypeSystem.cs
- DbCommandTree.cs
- HighlightComponent.cs
- EllipseGeometry.cs
- CompilationUnit.cs
- MultilineStringConverter.cs
- FileReader.cs
- DataRecord.cs
- TextContainerChangeEventArgs.cs
- SafeFileHandle.cs
- BufferedOutputStream.cs
- BulletedList.cs
- TablePattern.cs
- ThrowOnMultipleAssignment.cs
- PageContentCollection.cs
- OutOfProcStateClientManager.cs
- BookmarkResumptionRecord.cs
- Drawing.cs
- CellPartitioner.cs
- SerializationObjectManager.cs
- TraceSection.cs
- ExpressionPrefixAttribute.cs
- ScriptRegistrationManager.cs
- ellipse.cs
- RelationshipWrapper.cs
- IncrementalCompileAnalyzer.cs
- SafeRightsManagementSessionHandle.cs
- PartialCachingAttribute.cs
- ScaleTransform3D.cs
- DataServiceProviderMethods.cs
- BinaryNode.cs
- DataBoundLiteralControl.cs
- AbstractSvcMapFileLoader.cs
- SynthesizerStateChangedEventArgs.cs
- _IPv4Address.cs
- KeyedCollection.cs
- ToolBarOverflowPanel.cs
- ValidatedControlConverter.cs
- X509SubjectKeyIdentifierClause.cs
- IfAction.cs
- UndirectedGraph.cs
- XPathChildIterator.cs
- RunClient.cs
- GroupStyle.cs
- RuntimeEnvironment.cs
- HotSpotCollectionEditor.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DebugView.cs