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
- Converter.cs
- HttpProfileGroupBase.cs
- EmptyWorkItem.cs
- DiscoveryClientDocuments.cs
- TableLayoutRowStyleCollection.cs
- SystemMulticastIPAddressInformation.cs
- ComboBoxRenderer.cs
- Error.cs
- HostedTcpTransportManager.cs
- OutputCacheModule.cs
- DocumentPageViewAutomationPeer.cs
- ExpressionBuilder.cs
- WindowPattern.cs
- StylusButtonEventArgs.cs
- FillErrorEventArgs.cs
- AssemblyResourceLoader.cs
- DiagnosticsConfiguration.cs
- BindStream.cs
- JournalEntryStack.cs
- XmlWrappingReader.cs
- MiniModule.cs
- PartDesigner.cs
- Rotation3D.cs
- BitmapCache.cs
- XmlBoundElement.cs
- FtpWebResponse.cs
- QueueProcessor.cs
- Nullable.cs
- UnescapedXmlDiagnosticData.cs
- DataConnectionHelper.cs
- Roles.cs
- DesignerAdRotatorAdapter.cs
- ExecutionTracker.cs
- ICspAsymmetricAlgorithm.cs
- EpmSyndicationContentSerializer.cs
- UnsignedPublishLicense.cs
- WebPartZoneDesigner.cs
- VSDExceptions.cs
- BulletedList.cs
- DiscoveryClientChannelFactory.cs
- ContextMenuAutomationPeer.cs
- COM2EnumConverter.cs
- UIElementParaClient.cs
- WindowClosedEventArgs.cs
- storepermissionattribute.cs
- SAPIEngineTypes.cs
- Evaluator.cs
- clipboard.cs
- OleDbPermission.cs
- GeneralTransform3DTo2DTo3D.cs
- SmtpDateTime.cs
- MetadataItemEmitter.cs
- MouseEventArgs.cs
- AccessControlEntry.cs
- ClientViaElement.cs
- ProjectionQueryOptionExpression.cs
- IPAddressCollection.cs
- Context.cs
- xmlsaver.cs
- SystemSounds.cs
- BaseProcessor.cs
- RequestStatusBarUpdateEventArgs.cs
- Empty.cs
- Transform3D.cs
- ElementUtil.cs
- StrongBox.cs
- SoapHeaderAttribute.cs
- ResourcePart.cs
- UrlPropertyAttribute.cs
- AbandonedMutexException.cs
- SchemaNames.cs
- Char.cs
- SchemaNamespaceManager.cs
- ProxyWebPartManager.cs
- DataServiceRequestOfT.cs
- WindowProviderWrapper.cs
- RecognizerInfo.cs
- QilFunction.cs
- PasswordRecovery.cs
- RecordsAffectedEventArgs.cs
- JsonFaultDetail.cs
- LogEntryHeaderDeserializer.cs
- DomNameTable.cs
- XmlSerializationReader.cs
- safemediahandle.cs
- Emitter.cs
- FormView.cs
- ProjectedSlot.cs
- FixedSOMTextRun.cs
- TextBoxLine.cs
- GroupBoxAutomationPeer.cs
- WebServiceData.cs
- UserControlBuildProvider.cs
- MsmqTransportSecurity.cs
- BamlResourceSerializer.cs
- RangeValidator.cs
- SimpleRecyclingCache.cs
- NamespaceDecl.cs
- HuffModule.cs
- StrokeNodeOperations2.cs