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
- AttachedPropertyDescriptor.cs
- EmptyEnumerator.cs
- X509SecurityTokenAuthenticator.cs
- Compiler.cs
- DateTimeUtil.cs
- ClientTarget.cs
- XmlElementAttributes.cs
- XmlWellformedWriter.cs
- AspCompat.cs
- BaseDataList.cs
- TraceEventCache.cs
- ProfilePropertyNameValidator.cs
- LayoutManager.cs
- SchemaNamespaceManager.cs
- BufferAllocator.cs
- ImageIndexEditor.cs
- AssemblyBuilder.cs
- ContentPresenter.cs
- TimeIntervalCollection.cs
- PartialCachingAttribute.cs
- SiteOfOriginPart.cs
- VirtualPath.cs
- XmlUtf8RawTextWriter.cs
- XPathExpr.cs
- WebServiceBindingAttribute.cs
- XamlReader.cs
- HtmlMeta.cs
- WebScriptEndpointElement.cs
- RequestQueryProcessor.cs
- SEHException.cs
- UInt32Storage.cs
- ListSortDescription.cs
- CredentialCache.cs
- HatchBrush.cs
- SQLStringStorage.cs
- EllipseGeometry.cs
- Nullable.cs
- SafePointer.cs
- DtcInterfaces.cs
- CharacterBufferReference.cs
- ValidatedControlConverter.cs
- DiscardableAttribute.cs
- HyperLinkStyle.cs
- TemplateField.cs
- ZipIOLocalFileHeader.cs
- DictionaryKeyPropertyAttribute.cs
- StyleTypedPropertyAttribute.cs
- StreamingContext.cs
- ConnectionsZoneAutoFormat.cs
- ResourcesBuildProvider.cs
- QueryContinueDragEventArgs.cs
- Overlapped.cs
- ToolStripContentPanel.cs
- TdsParserHelperClasses.cs
- ItemCheckedEvent.cs
- StaticContext.cs
- GenericUriParser.cs
- LayoutUtils.cs
- MexHttpBindingElement.cs
- DynamicFilterExpression.cs
- DPCustomTypeDescriptor.cs
- DesignerSerializerAttribute.cs
- TextContainer.cs
- PropertyDescriptorGridEntry.cs
- TreeChangeInfo.cs
- CompositeControl.cs
- SpecialNameAttribute.cs
- DesignerHost.cs
- EmissiveMaterial.cs
- ProxyGenerator.cs
- MarkedHighlightComponent.cs
- TreeView.cs
- ZoneIdentityPermission.cs
- DTCTransactionManager.cs
- SecurityVerifiedMessage.cs
- SmiEventStream.cs
- BeginGetFileNameFromUserRequest.cs
- DrawingContextWalker.cs
- ClientUtils.cs
- RecordManager.cs
- EmbossBitmapEffect.cs
- TypeSystem.cs
- SqlDataSourceConfigureFilterForm.cs
- InputLanguageProfileNotifySink.cs
- WebServiceErrorEvent.cs
- ControlUtil.cs
- CreateUserErrorEventArgs.cs
- RsaSecurityTokenAuthenticator.cs
- ContextStack.cs
- PackWebRequestFactory.cs
- TableColumnCollectionInternal.cs
- WebPartConnectionCollection.cs
- PageRanges.cs
- QilInvoke.cs
- ConfigurationManagerInternal.cs
- TrackBar.cs
- RelationshipConverter.cs
- TlsnegoTokenProvider.cs
- Accessible.cs
- MasterPageCodeDomTreeGenerator.cs