Code:
/ FX-1434 / FX-1434 / 1.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
- coordinatorscratchpad.cs
- CriticalHandle.cs
- ProfilePropertySettings.cs
- NativeDirectoryServicesQueryAPIs.cs
- XamlPoint3DCollectionSerializer.cs
- OTFRasterizer.cs
- ObjectParameter.cs
- RectAnimationClockResource.cs
- VirtualPathUtility.cs
- DbParameterCollectionHelper.cs
- HuffModule.cs
- CommandDevice.cs
- Triplet.cs
- TagNameToTypeMapper.cs
- FrameDimension.cs
- DataGridViewCellEventArgs.cs
- ScalarType.cs
- PriorityChain.cs
- ConnectionManagementElementCollection.cs
- EmbeddedMailObject.cs
- HandleRef.cs
- DataChangedEventManager.cs
- SimpleApplicationHost.cs
- SafeRightsManagementEnvironmentHandle.cs
- PointLight.cs
- ActivityDefaults.cs
- EntityDataSourceDataSelectionPanel.cs
- RepeaterItemEventArgs.cs
- SqlDataSourceView.cs
- SiteIdentityPermission.cs
- ItemChangedEventArgs.cs
- RemoteWebConfigurationHost.cs
- HttpCapabilitiesBase.cs
- PathFigureCollection.cs
- DynamicMetaObject.cs
- MemoryFailPoint.cs
- SingleConverter.cs
- SystemThemeKey.cs
- Propagator.Evaluator.cs
- PageSetupDialog.cs
- DataServiceBuildProvider.cs
- OdbcParameterCollection.cs
- RegistryExceptionHelper.cs
- ContainerUIElement3D.cs
- WhitespaceRuleReader.cs
- TextSelection.cs
- HtmlAnchor.cs
- BCryptNative.cs
- ReverseInheritProperty.cs
- KeyGestureValueSerializer.cs
- FontStretch.cs
- HttpListenerRequest.cs
- OptimisticConcurrencyException.cs
- MDIClient.cs
- TextDecoration.cs
- DataRowView.cs
- LocalizableResourceBuilder.cs
- ExceptionHelpers.cs
- ConcurrencyBehavior.cs
- CompositeTypefaceMetrics.cs
- SourceFilter.cs
- TextProperties.cs
- GetWinFXPath.cs
- UdpAnnouncementEndpoint.cs
- ExpressionVisitor.cs
- OneToOneMappingSerializer.cs
- DbProviderSpecificTypePropertyAttribute.cs
- Vars.cs
- Bold.cs
- GetTokenRequest.cs
- Configuration.cs
- XamlSerializerUtil.cs
- ColorAnimation.cs
- TemplateControlParser.cs
- CollectionBase.cs
- RequestResizeEvent.cs
- ExternalFile.cs
- BuildResult.cs
- DaylightTime.cs
- GridToolTip.cs
- WebPartAddingEventArgs.cs
- BlobPersonalizationState.cs
- SmiXetterAccessMap.cs
- MatrixAnimationUsingPath.cs
- WebPermission.cs
- TraceContextEventArgs.cs
- TableColumnCollection.cs
- ConfigXmlElement.cs
- FormsAuthenticationCredentials.cs
- NavigationWindow.cs
- RSAPKCS1SignatureDeformatter.cs
- TrustManagerMoreInformation.cs
- GeometryConverter.cs
- EditorPartChrome.cs
- XmlNamespaceMappingCollection.cs
- AssertFilter.cs
- HtmlSelect.cs
- ObjectConverter.cs
- DeleteHelper.cs
- SapiGrammar.cs